File: __init__.py

package info (click to toggle)
python-gdata 2.0.18%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 8,460 kB
  • ctags: 17,143
  • sloc: python: 70,779; ansic: 150; makefile: 27; sh: 3
file content (525 lines) | stat: -rw-r--r-- 21,126 bytes parent folder | download | duplicates (2)
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
#
# Copyright (C) 2007 SIOS Technology, 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 objects used with Google Apps."""

__author__ = 'tmatsuo@sios.com (Takashi MATSUO)'


import atom
import gdata


# XML namespaces which are often used in Google Apps entity.
APPS_NAMESPACE = 'http://schemas.google.com/apps/2006'
APPS_TEMPLATE = '{http://schemas.google.com/apps/2006}%s'


class EmailList(atom.AtomBase):
  """The Google Apps EmailList element"""
  
  _tag = 'emailList'
  _namespace = APPS_NAMESPACE
  _children = atom.AtomBase._children.copy()
  _attributes = atom.AtomBase._attributes.copy()
  _attributes['name'] = 'name'

  def __init__(self, name=None, extension_elements=None,
               extension_attributes=None, text=None):
    self.name = name
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}

def EmailListFromString(xml_string):
  return atom.CreateClassFromXMLString(EmailList, xml_string)
  

class Who(atom.AtomBase):
  """The Google Apps Who element"""
  
  _tag = 'who'
  _namespace = gdata.GDATA_NAMESPACE
  _children = atom.AtomBase._children.copy()
  _attributes = atom.AtomBase._attributes.copy()
  _attributes['rel'] = 'rel'
  _attributes['email'] = 'email'

  def __init__(self, rel=None, email=None, extension_elements=None,
               extension_attributes=None, text=None):
    self.rel = rel
    self.email = email
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}

def WhoFromString(xml_string):
  return atom.CreateClassFromXMLString(Who, xml_string)
  

class Login(atom.AtomBase):
  """The Google Apps Login element"""
  
  _tag = 'login'
  _namespace = APPS_NAMESPACE
  _children = atom.AtomBase._children.copy()
  _attributes = atom.AtomBase._attributes.copy()
  _attributes['userName'] = 'user_name'
  _attributes['password'] = 'password'
  _attributes['suspended'] = 'suspended'
  _attributes['admin'] = 'admin'
  _attributes['changePasswordAtNextLogin'] = 'change_password'
  _attributes['agreedToTerms'] = 'agreed_to_terms'
  _attributes['ipWhitelisted'] = 'ip_whitelisted'
  _attributes['hashFunctionName'] = 'hash_function_name'

  def __init__(self, user_name=None, password=None, suspended=None,
               ip_whitelisted=None, hash_function_name=None, 
               admin=None, change_password=None, agreed_to_terms=None, 
               extension_elements=None, extension_attributes=None, 
               text=None):
    self.user_name = user_name
    self.password = password
    self.suspended = suspended
    self.admin = admin
    self.change_password = change_password
    self.agreed_to_terms = agreed_to_terms
    self.ip_whitelisted = ip_whitelisted
    self.hash_function_name = hash_function_name
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}

    
def LoginFromString(xml_string):
    return atom.CreateClassFromXMLString(Login, xml_string)
    

class Quota(atom.AtomBase):
  """The Google Apps Quota element"""
  
  _tag = 'quota'
  _namespace = APPS_NAMESPACE
  _children = atom.AtomBase._children.copy()
  _attributes = atom.AtomBase._attributes.copy()
  _attributes['limit'] = 'limit'

  def __init__(self, limit=None, extension_elements=None,
               extension_attributes=None, text=None):
    self.limit = limit
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}

    
def QuotaFromString(xml_string):
    return atom.CreateClassFromXMLString(Quota, xml_string)

    
class Name(atom.AtomBase):
  """The Google Apps Name element"""

  _tag = 'name'
  _namespace = APPS_NAMESPACE
  _children = atom.AtomBase._children.copy()
  _attributes = atom.AtomBase._attributes.copy()  
  _attributes['familyName'] = 'family_name'
  _attributes['givenName'] = 'given_name'
  
  def __init__(self, family_name=None, given_name=None,
               extension_elements=None, extension_attributes=None, text=None):
    self.family_name = family_name
    self.given_name = given_name
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}


def NameFromString(xml_string):
    return atom.CreateClassFromXMLString(Name, xml_string)


class Nickname(atom.AtomBase):
  """The Google Apps Nickname element"""
  
  _tag = 'nickname'
  _namespace = APPS_NAMESPACE
  _children = atom.AtomBase._children.copy()
  _attributes = atom.AtomBase._attributes.copy() 
  _attributes['name'] = 'name'

  def __init__(self, name=None,
               extension_elements=None, extension_attributes=None, text=None):
    self.name = name
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}


def NicknameFromString(xml_string):
    return atom.CreateClassFromXMLString(Nickname, xml_string)
  

class NicknameEntry(gdata.GDataEntry):
  """A Google Apps flavor of an Atom Entry for Nickname"""
  
  _tag = 'entry'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataEntry._children.copy()
  _attributes = gdata.GDataEntry._attributes.copy()
  _children['{%s}login' % APPS_NAMESPACE] = ('login', Login)
  _children['{%s}nickname' % APPS_NAMESPACE] = ('nickname', Nickname)

  def __init__(self, author=None, category=None, content=None,
               atom_id=None, link=None, published=None, 
               title=None, updated=None,
               login=None, nickname=None,
               extended_property=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)
    self.login = login
    self.nickname = nickname
    self.extended_property = extended_property or []
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}


def NicknameEntryFromString(xml_string):
  return atom.CreateClassFromXMLString(NicknameEntry, xml_string)


class NicknameFeed(gdata.GDataFeed, gdata.LinkFinder):
  """A Google Apps Nickname feed flavor of an Atom Feed"""
  
  _tag = 'feed'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataFeed._children.copy()
  _attributes = gdata.GDataFeed._attributes.copy()
  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [NicknameEntry])

  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, extension_elements=None,
               extension_attributes=None, text=None):
    gdata.GDataFeed.__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,
                             extension_elements=extension_elements,
                             extension_attributes=extension_attributes,
                             text=text)


def NicknameFeedFromString(xml_string):
  return atom.CreateClassFromXMLString(NicknameFeed, xml_string)


class UserEntry(gdata.GDataEntry):
  """A Google Apps flavor of an Atom Entry"""
  
  _tag = 'entry'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataEntry._children.copy()
  _attributes = gdata.GDataEntry._attributes.copy()
  _children['{%s}login' % APPS_NAMESPACE] = ('login', Login)
  _children['{%s}name' % APPS_NAMESPACE] = ('name', Name)
  _children['{%s}quota' % APPS_NAMESPACE] = ('quota', Quota)
  # This child may already be defined in GDataEntry, confirm before removing.
  _children['{%s}feedLink' % gdata.GDATA_NAMESPACE] = ('feed_link', 
                                                       [gdata.FeedLink])
  _children['{%s}who' % gdata.GDATA_NAMESPACE] = ('who', Who)

  def __init__(self, author=None, category=None, content=None,
               atom_id=None, link=None, published=None, 
               title=None, updated=None,
               login=None, name=None, quota=None, who=None, feed_link=None,
               extended_property=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)
    self.login = login
    self.name = name
    self.quota = quota
    self.who = who
    self.feed_link = feed_link or []
    self.extended_property = extended_property or []
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}
    

def UserEntryFromString(xml_string):
  return atom.CreateClassFromXMLString(UserEntry, xml_string)

  
class UserFeed(gdata.GDataFeed, gdata.LinkFinder):
  """A Google Apps User feed flavor of an Atom Feed"""
  
  _tag = 'feed'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataFeed._children.copy()
  _attributes = gdata.GDataFeed._attributes.copy()
  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [UserEntry])

  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, extension_elements=None,
               extension_attributes=None, text=None):
    gdata.GDataFeed.__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,
                             extension_elements=extension_elements,
                             extension_attributes=extension_attributes,
                             text=text)


def UserFeedFromString(xml_string):
  return atom.CreateClassFromXMLString(UserFeed, xml_string)


class EmailListEntry(gdata.GDataEntry):
  """A Google Apps EmailList flavor of an Atom Entry"""
  
  _tag = 'entry'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataEntry._children.copy()
  _attributes = gdata.GDataEntry._attributes.copy()
  _children['{%s}emailList' % APPS_NAMESPACE] = ('email_list', EmailList)
  # Might be able to remove this _children entry.
  _children['{%s}feedLink' % gdata.GDATA_NAMESPACE] = ('feed_link', 
                                                       [gdata.FeedLink])

  def __init__(self, author=None, category=None, content=None,
               atom_id=None, link=None, published=None, 
               title=None, updated=None,
               email_list=None, feed_link=None,
               extended_property=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)
    self.email_list = email_list
    self.feed_link = feed_link or []
    self.extended_property = extended_property or []
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}


def EmailListEntryFromString(xml_string):
  return atom.CreateClassFromXMLString(EmailListEntry, xml_string)
  

class EmailListFeed(gdata.GDataFeed, gdata.LinkFinder):
  """A Google Apps EmailList feed flavor of an Atom Feed"""
  
  _tag = 'feed'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataFeed._children.copy()
  _attributes = gdata.GDataFeed._attributes.copy()
  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [EmailListEntry])

  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, extension_elements=None,
               extension_attributes=None, text=None):
    gdata.GDataFeed.__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,
                             extension_elements=extension_elements,
                             extension_attributes=extension_attributes,
                             text=text)
                             

def EmailListFeedFromString(xml_string):
  return atom.CreateClassFromXMLString(EmailListFeed, xml_string)


class EmailListRecipientEntry(gdata.GDataEntry):
  """A Google Apps EmailListRecipient flavor of an Atom Entry"""
  
  _tag = 'entry'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataEntry._children.copy()
  _attributes = gdata.GDataEntry._attributes.copy()
  _children['{%s}who' % gdata.GDATA_NAMESPACE] = ('who', Who)

  def __init__(self, author=None, category=None, content=None,
               atom_id=None, link=None, published=None, 
               title=None, updated=None,
               who=None,
               extended_property=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)
    self.who = who
    self.extended_property = extended_property or []
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}


def EmailListRecipientEntryFromString(xml_string):
  return atom.CreateClassFromXMLString(EmailListRecipientEntry, xml_string)


class EmailListRecipientFeed(gdata.GDataFeed, gdata.LinkFinder):
  """A Google Apps EmailListRecipient feed flavor of an Atom Feed"""
  
  _tag = 'feed'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataFeed._children.copy()
  _attributes = gdata.GDataFeed._attributes.copy()
  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', 
                                                  [EmailListRecipientEntry])

  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, extension_elements=None,
               extension_attributes=None, text=None):
    gdata.GDataFeed.__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,
                             extension_elements=extension_elements,
                             extension_attributes=extension_attributes,
                             text=text)


def EmailListRecipientFeedFromString(xml_string):
  return atom.CreateClassFromXMLString(EmailListRecipientFeed, xml_string)


class Property(atom.AtomBase):
  """The Google Apps Property element"""

  _tag = 'property'
  _namespace = APPS_NAMESPACE
  _children = atom.AtomBase._children.copy()
  _attributes = atom.AtomBase._attributes.copy()
  _attributes['name'] = 'name'
  _attributes['value'] = 'value'

  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 {}


def PropertyFromString(xml_string):
  return atom.CreateClassFromXMLString(Property, xml_string)


class PropertyEntry(gdata.GDataEntry):
  """A Google Apps Property flavor of an Atom Entry"""

  _tag = 'entry'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataEntry._children.copy()
  _attributes = gdata.GDataEntry._attributes.copy()
  _children['{%s}property' % APPS_NAMESPACE] = ('property', [Property])

  def __init__(self, author=None, category=None, content=None,
               atom_id=None, link=None, published=None,
               title=None, updated=None,
               property=None,
               extended_property=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)
    self.property = property
    self.extended_property = extended_property or []
    self.text = text
    self.extension_elements = extension_elements or []
    self.extension_attributes = extension_attributes or {}


def PropertyEntryFromString(xml_string):
  return atom.CreateClassFromXMLString(PropertyEntry, xml_string)

class PropertyFeed(gdata.GDataFeed, gdata.LinkFinder):
  """A Google Apps Property feed flavor of an Atom Feed"""
  
  _tag = 'feed'
  _namespace = atom.ATOM_NAMESPACE
  _children = gdata.GDataFeed._children.copy()
  _attributes = gdata.GDataFeed._attributes.copy()
  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [PropertyEntry])

  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, extension_elements=None,
               extension_attributes=None, text=None):
    gdata.GDataFeed.__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,
                             extension_elements=extension_elements,
                             extension_attributes=extension_attributes,
                             text=text)

def PropertyFeedFromString(xml_string):
  return atom.CreateClassFromXMLString(PropertyFeed, xml_string)