~mrooney/awn-extras/bugfix.359668

« back to all changes in this revision

Viewing changes to src/calendar/google/gdata/docs/__init__.py

  • Committer: Mark Lee
  • Date: 2009-03-29 18:15:01 UTC
  • mfrom: (1139.1.4 awn-extras trunk)
  • Revision ID: bzr@lazymalevolence.com-20090329181501-tl6igg7c250kf448
Merge Calendar applet cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
#
3
 
# Copyright (C) 2006 Google 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 extensions to Atom objects used with Google Documents."""
18
 
 
19
 
__author__ = 'api.jfisher (Jeff Fisher)'
20
 
 
21
 
try:
22
 
  from xml.etree import cElementTree as ElementTree
23
 
except ImportError:
24
 
  try:
25
 
    import cElementTree as ElementTree
26
 
  except ImportError:
27
 
    from elementtree import ElementTree
28
 
import atom
29
 
import gdata
30
 
 
31
 
 
32
 
class DocumentListEntry(gdata.GDataEntry):
33
 
  """The Google Documents version of an Atom Entry"""
34
 
  
35
 
  _tag = 'entry'
36
 
  _namespace = atom.ATOM_NAMESPACE
37
 
  _children = gdata.GDataEntry._children.copy()
38
 
  _attributes = gdata.GDataEntry._attributes.copy()
39
 
 
40
 
 
41
 
def DocumentListEntryFromString(xml_string):
42
 
  """Converts an XML string into a DocumentListEntry object.
43
 
 
44
 
  Args:
45
 
    xml_string: string The XML describing a Document List feed entry.
46
 
 
47
 
  Returns:
48
 
    A DocumentListEntry object corresponding to the given XML.
49
 
  """
50
 
  return atom.CreateClassFromXMLString(DocumentListEntry, xml_string)
51
 
 
52
 
 
53
 
class DocumentListFeed(gdata.GDataFeed):
54
 
  """A feed containing a list of Google Documents Items"""
55
 
  
56
 
  _tag = 'feed'
57
 
  _namespace = atom.ATOM_NAMESPACE
58
 
  _children = gdata.GDataFeed._children.copy()
59
 
  _attributes = gdata.GDataFeed._attributes.copy()
60
 
  _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', 
61
 
                                                  [DocumentListEntry])
62
 
 
63
 
 
64
 
def DocumentListFeedFromString(xml_string):
65
 
  """Converts an XML string into a DocumentListFeed object.
66
 
 
67
 
  Args:
68
 
    xml_string: string The XML describing a DocumentList feed.
69
 
 
70
 
  Returns:
71
 
    A DocumentListFeed object corresponding to the given XML.
72
 
  """
73
 
  return atom.CreateClassFromXMLString(DocumentListFeed, xml_string)
74
 
  
75