/usr/share/pyshared/gdata/calendar/__init__.py is in python-gdata 2.0.14-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 | #
# Copyright (C) 2006 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Contains extensions to ElementWrapper objects used with Google Calendar."""
__author__ = 'api.vli (Vivian Li), api.rboyd (Ryan Boyd)'
try:
from xml.etree import cElementTree as ElementTree
except ImportError:
try:
import cElementTree as ElementTree
except ImportError:
try:
from xml.etree import ElementTree
except ImportError:
from elementtree import ElementTree
import atom
import gdata
# XML namespaces which are often used in Google Calendar entities.
GCAL_NAMESPACE = 'http://schemas.google.com/gCal/2005'
GCAL_TEMPLATE = '{http://schemas.google.com/gCal/2005}%s'
WEB_CONTENT_LINK_REL = '%s/%s' % (GCAL_NAMESPACE, 'webContent')
GACL_NAMESPACE = gdata.GACL_NAMESPACE
GACL_TEMPLATE = gdata.GACL_TEMPLATE
class ValueAttributeContainer(atom.AtomBase):
"""A parent class for all Calendar classes which have a value attribute.
Children include Color, AccessLevel, Hidden
"""
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
def __init__(self, value=None, extension_elements=None,
extension_attributes=None, text=None):
self.value = value
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class Color(ValueAttributeContainer):
"""The Google Calendar color element"""
_tag = 'color'
_namespace = GCAL_NAMESPACE
_children = ValueAttributeContainer._children.copy()
_attributes = ValueAttributeContainer._attributes.copy()
class AccessLevel(ValueAttributeContainer):
"""The Google Calendar accesslevel element"""
_tag = 'accesslevel'
_namespace = GCAL_NAMESPACE
_children = ValueAttributeContainer._children.copy()
_attributes = ValueAttributeContainer._attributes.copy()
class Hidden(ValueAttributeContainer):
"""The Google Calendar hidden element"""
_tag = 'hidden'
_namespace = GCAL_NAMESPACE
_children = ValueAttributeContainer._children.copy()
_attributes = ValueAttributeContainer._attributes.copy()
class Selected(ValueAttributeContainer):
"""The Google Calendar selected element"""
_tag = 'selected'
_namespace = GCAL_NAMESPACE
_children = ValueAttributeContainer._children.copy()
_attributes = ValueAttributeContainer._attributes.copy()
class Timezone(ValueAttributeContainer):
"""The Google Calendar timezone element"""
_tag = 'timezone'
_namespace = GCAL_NAMESPACE
_children = ValueAttributeContainer._children.copy()
_attributes = ValueAttributeContainer._attributes.copy()
class Where(atom.AtomBase):
"""The Google Calendar Where element"""
_tag = 'where'
_namespace = gdata.GDATA_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['valueString'] = 'value_string'
def __init__(self, value_string=None, extension_elements=None,
extension_attributes=None, text=None):
self.value_string = value_string
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class CalendarListEntry(gdata.GDataEntry, gdata.LinkFinder):
"""A Google Calendar meta Entry flavor of an Atom Entry """
_tag = gdata.GDataEntry._tag
_namespace = gdata.GDataEntry._namespace
_children = gdata.GDataEntry._children.copy()
_attributes = gdata.GDataEntry._attributes.copy()
_children['{%s}color' % GCAL_NAMESPACE] = ('color', Color)
_children['{%s}accesslevel' % GCAL_NAMESPACE] = ('access_level',
AccessLevel)
_children['{%s}hidden' % GCAL_NAMESPACE] = ('hidden', Hidden)
_children['{%s}selected' % GCAL_NAMESPACE] = ('selected', Selected)
_children['{%s}timezone' % GCAL_NAMESPACE] = ('timezone', Timezone)
_children['{%s}where' % gdata.GDATA_NAMESPACE] = ('where', Where)
def __init__(self, author=None, category=None, content=None,
atom_id=None, link=None, published=None,
title=None, updated=None,
color=None, access_level=None, hidden=None, timezone=None,
selected=None,
where=None,
extension_elements=None, extension_attributes=None, text=None):
gdata.GDataEntry.__init__(self, author=author, category=category,
content=content, atom_id=atom_id, link=link,
published=published, title=title,
updated=updated, text=None)
self.color = color
self.access_level = access_level
self.hidden = hidden
self.selected = selected
self.timezone = timezone
self.where = where
class CalendarListFeed(gdata.GDataFeed, gdata.LinkFinder):
"""A Google Calendar meta feed flavor of an Atom Feed"""
_tag = gdata.GDataFeed._tag
_namespace = gdata.GDataFeed._namespace
_children = gdata.GDataFeed._children.copy()
_attributes = gdata.GDataFeed._attributes.copy()
_children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [CalendarListEntry])
class Scope(atom.AtomBase):
"""The Google ACL scope element"""
_tag = 'scope'
_namespace = GACL_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
_attributes['type'] = 'type'
def __init__(self, extension_elements=None, value=None, scope_type=None,
extension_attributes=None, text=None):
self.value = value
self.type = scope_type
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class Role(ValueAttributeContainer):
"""The Google Calendar timezone element"""
_tag = 'role'
_namespace = GACL_NAMESPACE
_children = ValueAttributeContainer._children.copy()
_attributes = ValueAttributeContainer._attributes.copy()
class CalendarAclEntry(gdata.GDataEntry, gdata.LinkFinder):
"""A Google Calendar ACL Entry flavor of an Atom Entry """
_tag = gdata.GDataEntry._tag
_namespace = gdata.GDataEntry._namespace
_children = gdata.GDataEntry._children.copy()
_attributes = gdata.GDataEntry._attributes.copy()
_children['{%s}scope' % GACL_NAMESPACE] = ('scope', Scope)
_children['{%s}role' % GACL_NAMESPACE] = ('role', Role)
def __init__(self, author=None, category=None, content=None,
atom_id=None, link=None, published=None,
title=None, updated=None,
scope=None, role=None,
extension_elements=None, extension_attributes=None, text=None):
gdata.GDataEntry.__init__(self, author=author, category=category,
content=content, atom_id=atom_id, link=link,
published=published, title=title,
updated=updated, text=None)
self.scope = scope
self.role = role
class CalendarAclFeed(gdata.GDataFeed, gdata.LinkFinder):
"""A Google Calendar ACL feed flavor of an Atom Feed"""
_tag = gdata.GDataFeed._tag
_namespace = gdata.GDataFeed._namespace
_children = gdata.GDataFeed._children.copy()
_attributes = gdata.GDataFeed._attributes.copy()
_children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [CalendarAclEntry])
class CalendarEventCommentEntry(gdata.GDataEntry, gdata.LinkFinder):
"""A Google Calendar event comments entry flavor of an Atom Entry"""
_tag = gdata.GDataEntry._tag
_namespace = gdata.GDataEntry._namespace
_children = gdata.GDataEntry._children.copy()
_attributes = gdata.GDataEntry._attributes.copy()
class CalendarEventCommentFeed(gdata.GDataFeed, gdata.LinkFinder):
"""A Google Calendar event comments feed flavor of an Atom Feed"""
_tag = gdata.GDataFeed._tag
_namespace = gdata.GDataFeed._namespace
_children = gdata.GDataFeed._children.copy()
_attributes = gdata.GDataFeed._attributes.copy()
_children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry',
[CalendarEventCommentEntry])
class ExtendedProperty(gdata.ExtendedProperty):
"""A transparent subclass of gdata.ExtendedProperty added to this module
for backwards compatibility."""
class Reminder(atom.AtomBase):
"""The Google Calendar reminder element"""
_tag = 'reminder'
_namespace = gdata.GDATA_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['absoluteTime'] = 'absolute_time'
_attributes['days'] = 'days'
_attributes['hours'] = 'hours'
_attributes['minutes'] = 'minutes'
_attributes['method'] = 'method'
def __init__(self, absolute_time=None,
days=None, hours=None, minutes=None, method=None,
extension_elements=None,
extension_attributes=None, text=None):
self.absolute_time = absolute_time
if days is not None:
self.days = str(days)
else:
self.days = None
if hours is not None:
self.hours = str(hours)
else:
self.hours = None
if minutes is not None:
self.minutes = str(minutes)
else:
self.minutes = None
self.method = method
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class When(atom.AtomBase):
"""The Google Calendar When element"""
_tag = 'when'
_namespace = gdata.GDATA_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_children['{%s}reminder' % gdata.GDATA_NAMESPACE] = ('reminder', [Reminder])
_attributes['startTime'] = 'start_time'
_attributes['endTime'] = 'end_time'
def __init__(self, start_time=None, end_time=None, reminder=None,
extension_elements=None, extension_attributes=None, text=None):
self.start_time = start_time
self.end_time = end_time
self.reminder = reminder or []
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class Recurrence(atom.AtomBase):
"""The Google Calendar Recurrence element"""
_tag = 'recurrence'
_namespace = gdata.GDATA_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
class UriEnumElement(atom.AtomBase):
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
def __init__(self, tag, enum_map, attrib_name='value',
extension_elements=None, extension_attributes=None, text=None):
self.tag=tag
self.enum_map=enum_map
self.attrib_name=attrib_name
self.value=None
self.text=text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
def findKey(self, value):
res=[item[0] for item in self.enum_map.items() if item[1] == value]
if res is None or len(res) == 0:
return None
return res[0]
def _ConvertElementAttributeToMember(self, attribute, value):
# Special logic to use the enum_map to set the value of the object's value member.
if attribute == self.attrib_name and value != '':
self.value = self.enum_map[value]
return
# Find the attribute in this class's list of attributes.
if self.__class__._attributes.has_key(attribute):
# Find the member of this class which corresponds to the XML attribute
# (lookup in current_class._attributes) and set this member to the
# desired value (using self.__dict__).
setattr(self, self.__class__._attributes[attribute], value)
else:
# The current class doesn't map this attribute, so try to parent class.
atom.ExtensionContainer._ConvertElementAttributeToMember(self,
attribute,
value)
def _AddMembersToElementTree(self, tree):
# Convert the members of this class which are XML child nodes.
# This uses the class's _children dictionary to find the members which
# should become XML child nodes.
member_node_names = [values[0] for tag, values in
self.__class__._children.iteritems()]
for member_name in member_node_names:
member = getattr(self, member_name)
if member is None:
pass
elif isinstance(member, list):
for instance in member:
instance._BecomeChildElement(tree)
else:
member._BecomeChildElement(tree)
# Special logic to set the desired XML attribute.
key = self.findKey(self.value)
if key is not None:
tree.attrib[self.attrib_name]=key
# Convert the members of this class which are XML attributes.
for xml_attribute, member_name in self.__class__._attributes.iteritems():
member = getattr(self, member_name)
if member is not None:
tree.attrib[xml_attribute] = member
# Lastly, call the parent's _AddMembersToElementTree to get any
# extension elements.
atom.ExtensionContainer._AddMembersToElementTree(self, tree)
class AttendeeStatus(UriEnumElement):
"""The Google Calendar attendeeStatus element"""
_tag = 'attendeeStatus'
_namespace = gdata.GDATA_NAMESPACE
_children = UriEnumElement._children.copy()
_attributes = UriEnumElement._attributes.copy()
attendee_enum = {
'http://schemas.google.com/g/2005#event.accepted' : 'ACCEPTED',
'http://schemas.google.com/g/2005#event.declined' : 'DECLINED',
'http://schemas.google.com/g/2005#event.invited' : 'INVITED',
'http://schemas.google.com/g/2005#event.tentative' : 'TENTATIVE'}
def __init__(self, extension_elements=None,
extension_attributes=None, text=None):
UriEnumElement.__init__(self, 'attendeeStatus', AttendeeStatus.attendee_enum,
extension_elements=extension_elements,
extension_attributes=extension_attributes,
text=text)
class AttendeeType(UriEnumElement):
"""The Google Calendar attendeeType element"""
_tag = 'attendeeType'
_namespace = gdata.GDATA_NAMESPACE
_children = UriEnumElement._children.copy()
_attributes = UriEnumElement._attributes.copy()
attendee_type_enum = {
'http://schemas.google.com/g/2005#event.optional' : 'OPTIONAL',
'http://schemas.google.com/g/2005#event.required' : 'REQUIRED' }
def __init__(self, extension_elements=None,
extension_attributes=None, text=None):
UriEnumElement.__init__(self, 'attendeeType',
AttendeeType.attendee_type_enum,
extension_elements=extension_elements,
extension_attributes=extension_attributes,text=text)
class Visibility(UriEnumElement):
"""The Google Calendar Visibility element"""
_tag = 'visibility'
_namespace = gdata.GDATA_NAMESPACE
_children = UriEnumElement._children.copy()
_attributes = UriEnumElement._attributes.copy()
visibility_enum = {
'http://schemas.google.com/g/2005#event.confidential' : 'CONFIDENTIAL',
'http://schemas.google.com/g/2005#event.default' : 'DEFAULT',
'http://schemas.google.com/g/2005#event.private' : 'PRIVATE',
'http://schemas.google.com/g/2005#event.public' : 'PUBLIC' }
def __init__(self, extension_elements=None,
extension_attributes=None, text=None):
UriEnumElement.__init__(self, 'visibility', Visibility.visibility_enum,
extension_elements=extension_elements,
extension_attributes=extension_attributes,
text=text)
class Transparency(UriEnumElement):
"""The Google Calendar Transparency element"""
_tag = 'transparency'
_namespace = gdata.GDATA_NAMESPACE
_children = UriEnumElement._children.copy()
_attributes = UriEnumElement._attributes.copy()
transparency_enum = {
'http://schemas.google.com/g/2005#event.opaque' : 'OPAQUE',
'http://schemas.google.com/g/2005#event.transparent' : 'TRANSPARENT' }
def __init__(self, extension_elements=None,
extension_attributes=None, text=None):
UriEnumElement.__init__(self, tag='transparency',
enum_map=Transparency.transparency_enum,
extension_elements=extension_elements,
extension_attributes=extension_attributes,
text=text)
class Comments(atom.AtomBase):
"""The Google Calendar comments element"""
_tag = 'comments'
_namespace = gdata.GDATA_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_children['{%s}feedLink' % gdata.GDATA_NAMESPACE] = ('feed_link',
gdata.FeedLink)
_attributes['rel'] = 'rel'
def __init__(self, rel=None, feed_link=None, extension_elements=None,
extension_attributes=None, text=None):
self.rel = rel
self.feed_link = feed_link
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class EventStatus(UriEnumElement):
"""The Google Calendar eventStatus element"""
_tag = 'eventStatus'
_namespace = gdata.GDATA_NAMESPACE
_children = UriEnumElement._children.copy()
_attributes = UriEnumElement._attributes.copy()
status_enum = { 'http://schemas.google.com/g/2005#event.canceled' : 'CANCELED',
'http://schemas.google.com/g/2005#event.confirmed' : 'CONFIRMED',
'http://schemas.google.com/g/2005#event.tentative' : 'TENTATIVE'}
def __init__(self, extension_elements=None,
extension_attributes=None, text=None):
UriEnumElement.__init__(self, tag='eventStatus',
enum_map=EventStatus.status_enum,
extension_elements=extension_elements,
extension_attributes=extension_attributes,
text=text)
class Who(UriEnumElement):
"""The Google Calendar Who element"""
_tag = 'who'
_namespace = gdata.GDATA_NAMESPACE
_children = UriEnumElement._children.copy()
_attributes = UriEnumElement._attributes.copy()
_children['{%s}attendeeStatus' % gdata.GDATA_NAMESPACE] = (
'attendee_status', AttendeeStatus)
_children['{%s}attendeeType' % gdata.GDATA_NAMESPACE] = ('attendee_type',
AttendeeType)
_attributes['valueString'] = 'name'
_attributes['email'] = 'email'
relEnum = { 'http://schemas.google.com/g/2005#event.attendee' : 'ATTENDEE',
'http://schemas.google.com/g/2005#event.organizer' : 'ORGANIZER',
'http://schemas.google.com/g/2005#event.performer' : 'PERFORMER',
'http://schemas.google.com/g/2005#event.speaker' : 'SPEAKER',
'http://schemas.google.com/g/2005#message.bcc' : 'BCC',
'http://schemas.google.com/g/2005#message.cc' : 'CC',
'http://schemas.google.com/g/2005#message.from' : 'FROM',
'http://schemas.google.com/g/2005#message.reply-to' : 'REPLY_TO',
'http://schemas.google.com/g/2005#message.to' : 'TO' }
def __init__(self, name=None, email=None, attendee_status=None,
attendee_type=None, rel=None, extension_elements=None,
extension_attributes=None, text=None):
UriEnumElement.__init__(self, 'who', Who.relEnum, attrib_name='rel',
extension_elements=extension_elements,
extension_attributes=extension_attributes,
text=text)
self.name = name
self.email = email
self.attendee_status = attendee_status
self.attendee_type = attendee_type
self.rel = rel
class OriginalEvent(atom.AtomBase):
"""The Google Calendar OriginalEvent element"""
_tag = 'originalEvent'
_namespace = gdata.GDATA_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
# TODO: The when tag used to map to a EntryLink, make sure it should really be a When.
_children['{%s}when' % gdata.GDATA_NAMESPACE] = ('when', When)
_attributes['id'] = 'id'
_attributes['href'] = 'href'
def __init__(self, id=None, href=None, when=None,
extension_elements=None, extension_attributes=None, text=None):
self.id = id
self.href = href
self.when = when
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
def GetCalendarEventEntryClass():
return CalendarEventEntry
# This class is not completely defined here, because of a circular reference
# in which CalendarEventEntryLink and CalendarEventEntry refer to one another.
class CalendarEventEntryLink(gdata.EntryLink):
"""An entryLink which contains a calendar event entry
Within an event's recurranceExceptions, an entry link
points to a calendar event entry. This class exists
to capture the calendar specific extensions in the entry.
"""
_tag = 'entryLink'
_namespace = gdata.GDATA_NAMESPACE
_children = gdata.EntryLink._children.copy()
_attributes = gdata.EntryLink._attributes.copy()
# The CalendarEventEntryLink should like CalendarEventEntry as a child but
# that class hasn't been defined yet, so we will wait until after defining
# CalendarEventEntry to list it in _children.
class RecurrenceException(atom.AtomBase):
"""The Google Calendar RecurrenceException element"""
_tag = 'recurrenceException'
_namespace = gdata.GDATA_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_children['{%s}entryLink' % gdata.GDATA_NAMESPACE] = ('entry_link',
CalendarEventEntryLink)
_children['{%s}originalEvent' % gdata.GDATA_NAMESPACE] = ('original_event',
OriginalEvent)
_attributes['specialized'] = 'specialized'
def __init__(self, specialized=None, entry_link=None,
original_event=None, extension_elements=None,
extension_attributes=None, text=None):
self.specialized = specialized
self.entry_link = entry_link
self.original_event = original_event
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class SendEventNotifications(atom.AtomBase):
"""The Google Calendar sendEventNotifications element"""
_tag = 'sendEventNotifications'
_namespace = GCAL_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
def __init__(self, extension_elements=None,
value=None, extension_attributes=None, text=None):
self.value = value
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class QuickAdd(atom.AtomBase):
"""The Google Calendar quickadd element"""
_tag = 'quickadd'
_namespace = GCAL_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
def __init__(self, extension_elements=None,
value=None, extension_attributes=None, text=None):
self.value = value
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
def _TransferToElementTree(self, element_tree):
if self.value:
element_tree.attrib['value'] = self.value
element_tree.tag = GCAL_TEMPLATE % 'quickadd'
atom.AtomBase._TransferToElementTree(self, element_tree)
return element_tree
def _TakeAttributeFromElementTree(self, attribute, element_tree):
if attribute == 'value':
self.value = element_tree.attrib[attribute]
del element_tree.attrib[attribute]
else:
atom.AtomBase._TakeAttributeFromElementTree(self, attribute,
element_tree)
class SyncEvent(atom.AtomBase):
_tag = 'syncEvent'
_namespace = GCAL_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
def __init__(self, value='false', extension_elements=None,
extension_attributes=None, text=None):
self.value = value
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class UID(atom.AtomBase):
_tag = 'uid'
_namespace = GCAL_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
def __init__(self, value=None, extension_elements=None,
extension_attributes=None, text=None):
self.value = value
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class Sequence(atom.AtomBase):
_tag = 'sequence'
_namespace = GCAL_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
def __init__(self, value=None, extension_elements=None,
extension_attributes=None, text=None):
self.value = value
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class WebContentGadgetPref(atom.AtomBase):
_tag = 'webContentGadgetPref'
_namespace = GCAL_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_attributes['name'] = 'name'
_attributes['value'] = 'value'
"""The Google Calendar Web Content Gadget Preferences element"""
def __init__(self, name=None, value=None, extension_elements=None,
extension_attributes=None, text=None):
self.name = name
self.value = value
self.text = text
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class WebContent(atom.AtomBase):
_tag = 'webContent'
_namespace = GCAL_NAMESPACE
_children = atom.AtomBase._children.copy()
_attributes = atom.AtomBase._attributes.copy()
_children['{%s}webContentGadgetPref' % GCAL_NAMESPACE] = ('gadget_pref',
[WebContentGadgetPref])
_attributes['url'] = 'url'
_attributes['width'] = 'width'
_attributes['height'] = 'height'
def __init__(self, url=None, width=None, height=None, text=None,
gadget_pref=None, extension_elements=None, extension_attributes=None):
self.url = url
self.width = width
self.height = height
self.text = text
self.gadget_pref = gadget_pref or []
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
class WebContentLink(atom.Link):
_tag = 'link'
_namespace = atom.ATOM_NAMESPACE
_children = atom.Link._children.copy()
_attributes = atom.Link._attributes.copy()
_children['{%s}webContent' % GCAL_NAMESPACE] = ('web_content', WebContent)
def __init__(self, title=None, href=None, link_type=None,
web_content=None):
atom.Link.__init__(self, rel=WEB_CONTENT_LINK_REL, title=title, href=href,
link_type=link_type)
self.web_content = web_content
class GuestsCanInviteOthers(atom.AtomBase):
"""Indicates whether event attendees may invite others to the event.
This element may only be changed by the organizer of the event. If not
included as part of the event entry, this element will default to true
during a POST request, and will inherit its previous value during a PUT
request.
"""
_tag = 'guestsCanInviteOthers'
_namespace = GCAL_NAMESPACE
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
def __init__(self, value='true', *args, **kwargs):
atom.AtomBase.__init__(self, *args, **kwargs)
self.value = value
class GuestsCanSeeGuests(atom.AtomBase):
"""Indicates whether attendees can see other people invited to the event.
The organizer always sees all attendees. Guests always see themselves. This
property affects what attendees see in the event's guest list via both the
Calendar UI and API feeds.
This element may only be changed by the organizer of the event.
If not included as part of the event entry, this element will default to
true during a POST request, and will inherit its previous value during a
PUT request.
"""
_tag = 'guestsCanSeeGuests'
_namespace = GCAL_NAMESPACE
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
def __init__(self, value='true', *args, **kwargs):
atom.AtomBase.__init__(self, *args, **kwargs)
self.value = value
class GuestsCanModify(atom.AtomBase):
"""Indicates whether event attendees may modify the original event.
If yes, changes are visible to organizer and other attendees. Otherwise,
any changes made by attendees will be restricted to that attendee's
calendar.
This element may only be changed by the organizer of the event, and may
be set to 'true' only if both gCal:guestsCanInviteOthers and
gCal:guestsCanSeeGuests are set to true in the same PUT/POST request.
Otherwise, request fails with HTTP error code 400 (Bad Request).
If not included as part of the event entry, this element will default to
false during a POST request, and will inherit its previous value during a
PUT request."""
_tag = 'guestsCanModify'
_namespace = GCAL_NAMESPACE
_attributes = atom.AtomBase._attributes.copy()
_attributes['value'] = 'value'
def __init__(self, value='false', *args, **kwargs):
atom.AtomBase.__init__(self, *args, **kwargs)
self.value = value
class CalendarEventEntry(gdata.BatchEntry):
"""A Google Calendar flavor of an Atom Entry """
_tag = gdata.BatchEntry._tag
_namespace = gdata.BatchEntry._namespace
_children = gdata.BatchEntry._children.copy()
_attributes = gdata.BatchEntry._attributes.copy()
# This class also contains WebContentLinks but converting those members
# is handled in a special version of _ConvertElementTreeToMember.
_children['{%s}where' % gdata.GDATA_NAMESPACE] = ('where', [Where])
_children['{%s}when' % gdata.GDATA_NAMESPACE] = ('when', [When])
_children['{%s}who' % gdata.GDATA_NAMESPACE] = ('who', [Who])
_children['{%s}extendedProperty' % gdata.GDATA_NAMESPACE] = (
'extended_property', [ExtendedProperty])
_children['{%s}visibility' % gdata.GDATA_NAMESPACE] = ('visibility',
Visibility)
_children['{%s}transparency' % gdata.GDATA_NAMESPACE] = ('transparency',
Transparency)
_children['{%s}eventStatus' % gdata.GDATA_NAMESPACE] = ('event_status',
EventStatus)
_children['{%s}recurrence' % gdata.GDATA_NAMESPACE] = ('recurrence',
Recurrence)
_children['{%s}recurrenceException' % gdata.GDATA_NAMESPACE] = (
'recurrence_exception', [RecurrenceException])
_children['{%s}sendEventNotifications' % GCAL_NAMESPACE] = (
'send_event_notifications', SendEventNotifications)
_children['{%s}quickadd' % GCAL_NAMESPACE] = ('quick_add', QuickAdd)
_children['{%s}comments' % gdata.GDATA_NAMESPACE] = ('comments', Comments)
_children['{%s}originalEvent' % gdata.GDATA_NAMESPACE] = ('original_event',
OriginalEvent)
_children['{%s}sequence' % GCAL_NAMESPACE] = ('sequence', Sequence)
_children['{%s}reminder' % gdata.GDATA_NAMESPACE] = ('reminder', [Reminder])
_children['{%s}syncEvent' % GCAL_NAMESPACE] = ('sync_event', SyncEvent)
_children['{%s}uid' % GCAL_NAMESPACE] = ('uid', UID)
_children['{%s}guestsCanInviteOthers' % GCAL_NAMESPACE] = (
'guests_can_invite_others', GuestsCanInviteOthers)
_children['{%s}guestsCanModify' % GCAL_NAMESPACE] = (
'guests_can_modify', GuestsCanModify)
_children['{%s}guestsCanSeeGuests' % GCAL_NAMESPACE] = (
'guests_can_see_guests', GuestsCanSeeGuests)
def __init__(self, author=None, category=None, content=None,
atom_id=None, link=None, published=None,
title=None, updated=None,
transparency=None, comments=None, event_status=None,
send_event_notifications=None, visibility=None,
recurrence=None, recurrence_exception=None,
where=None, when=None, who=None, quick_add=None,
extended_property=None, original_event=None,
batch_operation=None, batch_id=None, batch_status=None,
sequence=None, reminder=None, sync_event=None, uid=None,
guests_can_invite_others=None, guests_can_modify=None,
guests_can_see_guests=None,
extension_elements=None, extension_attributes=None, text=None):
gdata.BatchEntry.__init__(self, author=author, category=category,
content=content,
atom_id=atom_id, link=link, published=published,
batch_operation=batch_operation, batch_id=batch_id,
batch_status=batch_status,
title=title, updated=updated)
self.transparency = transparency
self.comments = comments
self.event_status = event_status
self.send_event_notifications = send_event_notifications
self.visibility = visibility
self.recurrence = recurrence
self.recurrence_exception = recurrence_exception or []
self.where = where or []
self.when = when or []
self.who = who or []
self.quick_add = quick_add
self.extended_property = extended_property or []
self.original_event = original_event
self.sequence = sequence
self.reminder = reminder or []
self.sync_event = sync_event
self.uid = uid
self.text = text
self.guests_can_invite_others = guests_can_invite_others
self.guests_can_modify = guests_can_modify
self.guests_can_see_guests = guests_can_see_guests
self.extension_elements = extension_elements or []
self.extension_attributes = extension_attributes or {}
# We needed to add special logic to _ConvertElementTreeToMember because we
# want to make links with a rel of WEB_CONTENT_LINK_REL into a
# WebContentLink
def _ConvertElementTreeToMember(self, child_tree):
# Special logic to handle Web Content links
if (child_tree.tag == '{%s}link' % atom.ATOM_NAMESPACE and
child_tree.attrib['rel'] == WEB_CONTENT_LINK_REL):
if self.link is None:
self.link = []
self.link.append(atom._CreateClassFromElementTree(WebContentLink,
child_tree))
return
# Find the element's tag in this class's list of child members
if self.__class__._children.has_key(child_tree.tag):
member_name = self.__class__._children[child_tree.tag][0]
member_class = self.__class__._children[child_tree.tag][1]
# If the class member is supposed to contain a list, make sure the
# matching member is set to a list, then append the new member
# instance to the list.
if isinstance(member_class, list):
if getattr(self, member_name) is None:
setattr(self, member_name, [])
getattr(self, member_name).append(atom._CreateClassFromElementTree(
member_class[0], child_tree))
else:
setattr(self, member_name,
atom._CreateClassFromElementTree(member_class, child_tree))
else:
atom.ExtensionContainer._ConvertElementTreeToMember(self, child_tree)
def GetWebContentLink(self):
"""Finds the first link with rel set to WEB_CONTENT_REL
Returns:
A gdata.calendar.WebContentLink or none if none of the links had rel
equal to WEB_CONTENT_REL
"""
for a_link in self.link:
if a_link.rel == WEB_CONTENT_LINK_REL:
return a_link
return None
def CalendarEventEntryFromString(xml_string):
return atom.CreateClassFromXMLString(CalendarEventEntry, xml_string)
def CalendarEventCommentEntryFromString(xml_string):
return atom.CreateClassFromXMLString(CalendarEventCommentEntry, xml_string)
CalendarEventEntryLink._children = {'{%s}entry' % atom.ATOM_NAMESPACE:
('entry', CalendarEventEntry)}
def CalendarEventEntryLinkFromString(xml_string):
return atom.CreateClassFromXMLString(CalendarEventEntryLink, xml_string)
class CalendarEventFeed(gdata.BatchFeed, gdata.LinkFinder):
"""A Google Calendar event feed flavor of an Atom Feed"""
_tag = gdata.BatchFeed._tag
_namespace = gdata.BatchFeed._namespace
_children = gdata.BatchFeed._children.copy()
_attributes = gdata.BatchFeed._attributes.copy()
_children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry',
[CalendarEventEntry])
_children['{%s}timezone' % GCAL_NAMESPACE] = ('timezone', Timezone)
def __init__(self, author=None, category=None, contributor=None,
generator=None, icon=None, atom_id=None, link=None, logo=None,
rights=None, subtitle=None, title=None, updated=None, entry=None,
total_results=None, start_index=None, items_per_page=None,
interrupted=None, timezone=None,
extension_elements=None, extension_attributes=None, text=None):
gdata.BatchFeed.__init__(self, author=author, category=category,
contributor=contributor, generator=generator,
icon=icon, atom_id=atom_id, link=link,
logo=logo, rights=rights, subtitle=subtitle,
title=title, updated=updated, entry=entry,
total_results=total_results,
start_index=start_index,
items_per_page=items_per_page,
interrupted=interrupted,
extension_elements=extension_elements,
extension_attributes=extension_attributes,
text=text)
self.timezone = timezone
def CalendarListEntryFromString(xml_string):
return atom.CreateClassFromXMLString(CalendarListEntry, xml_string)
def CalendarAclEntryFromString(xml_string):
return atom.CreateClassFromXMLString(CalendarAclEntry, xml_string)
def CalendarListFeedFromString(xml_string):
return atom.CreateClassFromXMLString(CalendarListFeed, xml_string)
def CalendarAclFeedFromString(xml_string):
return atom.CreateClassFromXMLString(CalendarAclFeed, xml_string)
def CalendarEventFeedFromString(xml_string):
return atom.CreateClassFromXMLString(CalendarEventFeed, xml_string)
def CalendarEventCommentFeedFromString(xml_string):
return atom.CreateClassFromXMLString(CalendarEventCommentFeed, xml_string)
|