PageRenderTime 53ms CodeModel.GetById 16ms app.highlight 32ms RepoModel.GetById 1ms app.codeStats 0ms

/gdata/apps/__init__.py

http://radioappz.googlecode.com/
Python | 526 lines | 381 code | 109 blank | 36 comment | 31 complexity | 1183412d4438372e7e54b8f3256bc3cf MD5 | raw file
  1#!/usr/bin/python
  2#
  3# Copyright (C) 2007 SIOS Technology, Inc.
  4#
  5# Licensed under the Apache License, Version 2.0 (the "License");
  6# you may not use this file except in compliance with the License.
  7# You may obtain a copy of the License at
  8#
  9#      http://www.apache.org/licenses/LICENSE-2.0
 10#
 11# Unless required by applicable law or agreed to in writing, software
 12# distributed under the License is distributed on an "AS IS" BASIS,
 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14# See the License for the specific language governing permissions and
 15# limitations under the License.
 16
 17"""Contains objects used with Google Apps."""
 18
 19__author__ = 'tmatsuo@sios.com (Takashi MATSUO)'
 20
 21
 22import atom
 23import gdata
 24
 25
 26# XML namespaces which are often used in Google Apps entity.
 27APPS_NAMESPACE = 'http://schemas.google.com/apps/2006'
 28APPS_TEMPLATE = '{http://schemas.google.com/apps/2006}%s'
 29
 30
 31class EmailList(atom.AtomBase):
 32  """The Google Apps EmailList element"""
 33  
 34  _tag = 'emailList'
 35  _namespace = APPS_NAMESPACE
 36  _children = atom.AtomBase._children.copy()
 37  _attributes = atom.AtomBase._attributes.copy()
 38  _attributes['name'] = 'name'
 39
 40  def __init__(self, name=None, extension_elements=None,
 41               extension_attributes=None, text=None):
 42    self.name = name
 43    self.text = text
 44    self.extension_elements = extension_elements or []
 45    self.extension_attributes = extension_attributes or {}
 46
 47def EmailListFromString(xml_string):
 48  return atom.CreateClassFromXMLString(EmailList, xml_string)
 49  
 50
 51class Who(atom.AtomBase):
 52  """The Google Apps Who element"""
 53  
 54  _tag = 'who'
 55  _namespace = gdata.GDATA_NAMESPACE
 56  _children = atom.AtomBase._children.copy()
 57  _attributes = atom.AtomBase._attributes.copy()
 58  _attributes['rel'] = 'rel'
 59  _attributes['email'] = 'email'
 60
 61  def __init__(self, rel=None, email=None, extension_elements=None,
 62               extension_attributes=None, text=None):
 63    self.rel = rel
 64    self.email = email
 65    self.text = text
 66    self.extension_elements = extension_elements or []
 67    self.extension_attributes = extension_attributes or {}
 68
 69def WhoFromString(xml_string):
 70  return atom.CreateClassFromXMLString(Who, xml_string)
 71  
 72
 73class Login(atom.AtomBase):
 74  """The Google Apps Login element"""
 75  
 76  _tag = 'login'
 77  _namespace = APPS_NAMESPACE
 78  _children = atom.AtomBase._children.copy()
 79  _attributes = atom.AtomBase._attributes.copy()
 80  _attributes['userName'] = 'user_name'
 81  _attributes['password'] = 'password'
 82  _attributes['suspended'] = 'suspended'
 83  _attributes['admin'] = 'admin'
 84  _attributes['changePasswordAtNextLogin'] = 'change_password'
 85  _attributes['agreedToTerms'] = 'agreed_to_terms'
 86  _attributes['ipWhitelisted'] = 'ip_whitelisted'
 87  _attributes['hashFunctionName'] = 'hash_function_name'
 88
 89  def __init__(self, user_name=None, password=None, suspended=None,
 90               ip_whitelisted=None, hash_function_name=None, 
 91               admin=None, change_password=None, agreed_to_terms=None, 
 92               extension_elements=None, extension_attributes=None, 
 93               text=None):
 94    self.user_name = user_name
 95    self.password = password
 96    self.suspended = suspended
 97    self.admin = admin
 98    self.change_password = change_password
 99    self.agreed_to_terms = agreed_to_terms
100    self.ip_whitelisted = ip_whitelisted
101    self.hash_function_name = hash_function_name
102    self.text = text
103    self.extension_elements = extension_elements or []
104    self.extension_attributes = extension_attributes or {}
105
106    
107def LoginFromString(xml_string):
108    return atom.CreateClassFromXMLString(Login, xml_string)
109    
110
111class Quota(atom.AtomBase):
112  """The Google Apps Quota element"""
113  
114  _tag = 'quota'
115  _namespace = APPS_NAMESPACE
116  _children = atom.AtomBase._children.copy()
117  _attributes = atom.AtomBase._attributes.copy()
118  _attributes['limit'] = 'limit'
119
120  def __init__(self, limit=None, extension_elements=None,
121               extension_attributes=None, text=None):
122    self.limit = limit
123    self.text = text
124    self.extension_elements = extension_elements or []
125    self.extension_attributes = extension_attributes or {}
126
127    
128def QuotaFromString(xml_string):
129    return atom.CreateClassFromXMLString(Quota, xml_string)
130
131    
132class Name(atom.AtomBase):
133  """The Google Apps Name element"""
134
135  _tag = 'name'
136  _namespace = APPS_NAMESPACE
137  _children = atom.AtomBase._children.copy()
138  _attributes = atom.AtomBase._attributes.copy()  
139  _attributes['familyName'] = 'family_name'
140  _attributes['givenName'] = 'given_name'
141  
142  def __init__(self, family_name=None, given_name=None,
143               extension_elements=None, extension_attributes=None, text=None):
144    self.family_name = family_name
145    self.given_name = given_name
146    self.text = text
147    self.extension_elements = extension_elements or []
148    self.extension_attributes = extension_attributes or {}
149
150
151def NameFromString(xml_string):
152    return atom.CreateClassFromXMLString(Name, xml_string)
153
154
155class Nickname(atom.AtomBase):
156  """The Google Apps Nickname element"""
157  
158  _tag = 'nickname'
159  _namespace = APPS_NAMESPACE
160  _children = atom.AtomBase._children.copy()
161  _attributes = atom.AtomBase._attributes.copy() 
162  _attributes['name'] = 'name'
163
164  def __init__(self, name=None,
165               extension_elements=None, extension_attributes=None, text=None):
166    self.name = name
167    self.text = text
168    self.extension_elements = extension_elements or []
169    self.extension_attributes = extension_attributes or {}
170
171
172def NicknameFromString(xml_string):
173    return atom.CreateClassFromXMLString(Nickname, xml_string)
174  
175
176class NicknameEntry(gdata.GDataEntry):
177  """A Google Apps flavor of an Atom Entry for Nickname"""
178  
179  _tag = 'entry'
180  _namespace = atom.ATOM_NAMESPACE
181  _children = gdata.GDataEntry._children.copy()
182  _attributes = gdata.GDataEntry._attributes.copy()
183  _children['{%s}login' % APPS_NAMESPACE] = ('login', Login)
184  _children['{%s}nickname' % APPS_NAMESPACE] = ('nickname', Nickname)
185
186  def __init__(self, author=None, category=None, content=None,
187               atom_id=None, link=None, published=None, 
188               title=None, updated=None,
189               login=None, nickname=None,
190               extended_property=None, 
191               extension_elements=None, extension_attributes=None, text=None):
192
193    gdata.GDataEntry.__init__(self, author=author, category=category, 
194                              content=content,
195                              atom_id=atom_id, link=link, published=published,
196                              title=title, updated=updated)
197    self.login = login
198    self.nickname = nickname
199    self.extended_property = extended_property or []
200    self.text = text
201    self.extension_elements = extension_elements or []
202    self.extension_attributes = extension_attributes or {}
203
204
205def NicknameEntryFromString(xml_string):
206  return atom.CreateClassFromXMLString(NicknameEntry, xml_string)
207
208
209class NicknameFeed(gdata.GDataFeed, gdata.LinkFinder):
210  """A Google Apps Nickname feed flavor of an Atom Feed"""
211  
212  _tag = 'feed'
213  _namespace = atom.ATOM_NAMESPACE
214  _children = gdata.GDataFeed._children.copy()
215  _attributes = gdata.GDataFeed._attributes.copy()
216  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [NicknameEntry])
217
218  def __init__(self, author=None, category=None, contributor=None,
219               generator=None, icon=None, atom_id=None, link=None, logo=None, 
220               rights=None, subtitle=None, title=None, updated=None,
221               entry=None, total_results=None, start_index=None,
222               items_per_page=None, extension_elements=None,
223               extension_attributes=None, text=None):
224    gdata.GDataFeed.__init__(self, author=author, category=category,
225                             contributor=contributor, generator=generator,
226                             icon=icon,  atom_id=atom_id, link=link,
227                             logo=logo, rights=rights, subtitle=subtitle,
228                             title=title, updated=updated, entry=entry,
229                             total_results=total_results,
230                             start_index=start_index,
231                             items_per_page=items_per_page,
232                             extension_elements=extension_elements,
233                             extension_attributes=extension_attributes,
234                             text=text)
235
236
237def NicknameFeedFromString(xml_string):
238  return atom.CreateClassFromXMLString(NicknameFeed, xml_string)
239
240
241class UserEntry(gdata.GDataEntry):
242  """A Google Apps flavor of an Atom Entry"""
243  
244  _tag = 'entry'
245  _namespace = atom.ATOM_NAMESPACE
246  _children = gdata.GDataEntry._children.copy()
247  _attributes = gdata.GDataEntry._attributes.copy()
248  _children['{%s}login' % APPS_NAMESPACE] = ('login', Login)
249  _children['{%s}name' % APPS_NAMESPACE] = ('name', Name)
250  _children['{%s}quota' % APPS_NAMESPACE] = ('quota', Quota)
251  # This child may already be defined in GDataEntry, confirm before removing.
252  _children['{%s}feedLink' % gdata.GDATA_NAMESPACE] = ('feed_link', 
253                                                       [gdata.FeedLink])
254  _children['{%s}who' % gdata.GDATA_NAMESPACE] = ('who', Who)
255
256  def __init__(self, author=None, category=None, content=None,
257               atom_id=None, link=None, published=None, 
258               title=None, updated=None,
259               login=None, name=None, quota=None, who=None, feed_link=None,
260               extended_property=None, 
261               extension_elements=None, extension_attributes=None, text=None):
262
263    gdata.GDataEntry.__init__(self, author=author, category=category, 
264                              content=content,
265                              atom_id=atom_id, link=link, published=published,
266                              title=title, updated=updated)
267    self.login = login
268    self.name = name
269    self.quota = quota
270    self.who = who
271    self.feed_link = feed_link or []
272    self.extended_property = extended_property or []
273    self.text = text
274    self.extension_elements = extension_elements or []
275    self.extension_attributes = extension_attributes or {}
276    
277
278def UserEntryFromString(xml_string):
279  return atom.CreateClassFromXMLString(UserEntry, xml_string)
280
281  
282class UserFeed(gdata.GDataFeed, gdata.LinkFinder):
283  """A Google Apps User feed flavor of an Atom Feed"""
284  
285  _tag = 'feed'
286  _namespace = atom.ATOM_NAMESPACE
287  _children = gdata.GDataFeed._children.copy()
288  _attributes = gdata.GDataFeed._attributes.copy()
289  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [UserEntry])
290
291  def __init__(self, author=None, category=None, contributor=None,
292               generator=None, icon=None, atom_id=None, link=None, logo=None, 
293               rights=None, subtitle=None, title=None, updated=None,
294               entry=None, total_results=None, start_index=None,
295               items_per_page=None, extension_elements=None,
296               extension_attributes=None, text=None):
297    gdata.GDataFeed.__init__(self, author=author, category=category,
298                             contributor=contributor, generator=generator,
299                             icon=icon,  atom_id=atom_id, link=link,
300                             logo=logo, rights=rights, subtitle=subtitle,
301                             title=title, updated=updated, entry=entry,
302                             total_results=total_results,
303                             start_index=start_index,
304                             items_per_page=items_per_page,
305                             extension_elements=extension_elements,
306                             extension_attributes=extension_attributes,
307                             text=text)
308
309
310def UserFeedFromString(xml_string):
311  return atom.CreateClassFromXMLString(UserFeed, xml_string)
312
313
314class EmailListEntry(gdata.GDataEntry):
315  """A Google Apps EmailList flavor of an Atom Entry"""
316  
317  _tag = 'entry'
318  _namespace = atom.ATOM_NAMESPACE
319  _children = gdata.GDataEntry._children.copy()
320  _attributes = gdata.GDataEntry._attributes.copy()
321  _children['{%s}emailList' % APPS_NAMESPACE] = ('email_list', EmailList)
322  # Might be able to remove this _children entry.
323  _children['{%s}feedLink' % gdata.GDATA_NAMESPACE] = ('feed_link', 
324                                                       [gdata.FeedLink])
325
326  def __init__(self, author=None, category=None, content=None,
327               atom_id=None, link=None, published=None, 
328               title=None, updated=None,
329               email_list=None, feed_link=None,
330               extended_property=None, 
331               extension_elements=None, extension_attributes=None, text=None):
332
333    gdata.GDataEntry.__init__(self, author=author, category=category, 
334                              content=content,
335                              atom_id=atom_id, link=link, published=published,
336                              title=title, updated=updated)
337    self.email_list = email_list
338    self.feed_link = feed_link or []
339    self.extended_property = extended_property or []
340    self.text = text
341    self.extension_elements = extension_elements or []
342    self.extension_attributes = extension_attributes or {}
343
344
345def EmailListEntryFromString(xml_string):
346  return atom.CreateClassFromXMLString(EmailListEntry, xml_string)
347  
348
349class EmailListFeed(gdata.GDataFeed, gdata.LinkFinder):
350  """A Google Apps EmailList feed flavor of an Atom Feed"""
351  
352  _tag = 'feed'
353  _namespace = atom.ATOM_NAMESPACE
354  _children = gdata.GDataFeed._children.copy()
355  _attributes = gdata.GDataFeed._attributes.copy()
356  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [EmailListEntry])
357
358  def __init__(self, author=None, category=None, contributor=None,
359               generator=None, icon=None, atom_id=None, link=None, logo=None, 
360               rights=None, subtitle=None, title=None, updated=None,
361               entry=None, total_results=None, start_index=None,
362               items_per_page=None, extension_elements=None,
363               extension_attributes=None, text=None):
364    gdata.GDataFeed.__init__(self, author=author, category=category,
365                             contributor=contributor, generator=generator,
366                             icon=icon,  atom_id=atom_id, link=link,
367                             logo=logo, rights=rights, subtitle=subtitle,
368                             title=title, updated=updated, entry=entry,
369                             total_results=total_results,
370                             start_index=start_index,
371                             items_per_page=items_per_page,
372                             extension_elements=extension_elements,
373                             extension_attributes=extension_attributes,
374                             text=text)
375                             
376
377def EmailListFeedFromString(xml_string):
378  return atom.CreateClassFromXMLString(EmailListFeed, xml_string)
379
380
381class EmailListRecipientEntry(gdata.GDataEntry):
382  """A Google Apps EmailListRecipient flavor of an Atom Entry"""
383  
384  _tag = 'entry'
385  _namespace = atom.ATOM_NAMESPACE
386  _children = gdata.GDataEntry._children.copy()
387  _attributes = gdata.GDataEntry._attributes.copy()
388  _children['{%s}who' % gdata.GDATA_NAMESPACE] = ('who', Who)
389
390  def __init__(self, author=None, category=None, content=None,
391               atom_id=None, link=None, published=None, 
392               title=None, updated=None,
393               who=None,
394               extended_property=None, 
395               extension_elements=None, extension_attributes=None, text=None):
396
397    gdata.GDataEntry.__init__(self, author=author, category=category, 
398                              content=content,
399                              atom_id=atom_id, link=link, published=published,
400                              title=title, updated=updated)
401    self.who = who
402    self.extended_property = extended_property or []
403    self.text = text
404    self.extension_elements = extension_elements or []
405    self.extension_attributes = extension_attributes or {}
406
407
408def EmailListRecipientEntryFromString(xml_string):
409  return atom.CreateClassFromXMLString(EmailListRecipientEntry, xml_string)
410
411
412class EmailListRecipientFeed(gdata.GDataFeed, gdata.LinkFinder):
413  """A Google Apps EmailListRecipient feed flavor of an Atom Feed"""
414  
415  _tag = 'feed'
416  _namespace = atom.ATOM_NAMESPACE
417  _children = gdata.GDataFeed._children.copy()
418  _attributes = gdata.GDataFeed._attributes.copy()
419  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', 
420                                                  [EmailListRecipientEntry])
421
422  def __init__(self, author=None, category=None, contributor=None,
423               generator=None, icon=None, atom_id=None, link=None, logo=None, 
424               rights=None, subtitle=None, title=None, updated=None,
425               entry=None, total_results=None, start_index=None,
426               items_per_page=None, extension_elements=None,
427               extension_attributes=None, text=None):
428    gdata.GDataFeed.__init__(self, author=author, category=category,
429                             contributor=contributor, generator=generator,
430                             icon=icon,  atom_id=atom_id, link=link,
431                             logo=logo, rights=rights, subtitle=subtitle,
432                             title=title, updated=updated, entry=entry,
433                             total_results=total_results,
434                             start_index=start_index,
435                             items_per_page=items_per_page,
436                             extension_elements=extension_elements,
437                             extension_attributes=extension_attributes,
438                             text=text)
439
440
441def EmailListRecipientFeedFromString(xml_string):
442  return atom.CreateClassFromXMLString(EmailListRecipientFeed, xml_string)
443
444
445class Property(atom.AtomBase):
446  """The Google Apps Property element"""
447
448  _tag = 'property'
449  _namespace = APPS_NAMESPACE
450  _children = atom.AtomBase._children.copy()
451  _attributes = atom.AtomBase._attributes.copy()
452  _attributes['name'] = 'name'
453  _attributes['value'] = 'value'
454
455  def __init__(self, name=None, value=None, extension_elements=None,
456               extension_attributes=None, text=None):
457    self.name = name
458    self.value = value
459    self.text = text
460    self.extension_elements = extension_elements or []
461    self.extension_attributes = extension_attributes or {}
462
463
464def PropertyFromString(xml_string):
465  return atom.CreateClassFromXMLString(Property, xml_string)
466
467
468class PropertyEntry(gdata.GDataEntry):
469  """A Google Apps Property flavor of an Atom Entry"""
470
471  _tag = 'entry'
472  _namespace = atom.ATOM_NAMESPACE
473  _children = gdata.GDataEntry._children.copy()
474  _attributes = gdata.GDataEntry._attributes.copy()
475  _children['{%s}property' % APPS_NAMESPACE] = ('property', [Property])
476
477  def __init__(self, author=None, category=None, content=None,
478               atom_id=None, link=None, published=None,
479               title=None, updated=None,
480               property=None,
481               extended_property=None,
482               extension_elements=None, extension_attributes=None, text=None):
483
484    gdata.GDataEntry.__init__(self, author=author, category=category,
485                              content=content,
486                              atom_id=atom_id, link=link, published=published,
487                              title=title, updated=updated)
488    self.property = property
489    self.extended_property = extended_property or []
490    self.text = text
491    self.extension_elements = extension_elements or []
492    self.extension_attributes = extension_attributes or {}
493
494
495def PropertyEntryFromString(xml_string):
496  return atom.CreateClassFromXMLString(PropertyEntry, xml_string)
497
498class PropertyFeed(gdata.GDataFeed, gdata.LinkFinder):
499  """A Google Apps Property feed flavor of an Atom Feed"""
500  
501  _tag = 'feed'
502  _namespace = atom.ATOM_NAMESPACE
503  _children = gdata.GDataFeed._children.copy()
504  _attributes = gdata.GDataFeed._attributes.copy()
505  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [PropertyEntry])
506
507  def __init__(self, author=None, category=None, contributor=None,
508               generator=None, icon=None, atom_id=None, link=None, logo=None, 
509               rights=None, subtitle=None, title=None, updated=None,
510               entry=None, total_results=None, start_index=None,
511               items_per_page=None, extension_elements=None,
512               extension_attributes=None, text=None):
513    gdata.GDataFeed.__init__(self, author=author, category=category,
514                             contributor=contributor, generator=generator,
515                             icon=icon,  atom_id=atom_id, link=link,
516                             logo=logo, rights=rights, subtitle=subtitle,
517                             title=title, updated=updated, entry=entry,
518                             total_results=total_results,
519                             start_index=start_index,
520                             items_per_page=items_per_page,
521                             extension_elements=extension_elements,
522                             extension_attributes=extension_attributes,
523                             text=text)
524
525def PropertyFeedFromString(xml_string):
526  return atom.CreateClassFromXMLString(PropertyFeed, xml_string)