Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of https://github.com/streeter/pretty-picasa-ga…

…llery into streeter-master
  • Loading branch information...
commit da8cdd85a2d39d670a934331d776a3187eae5643 2 parents 29e7ad2 + 0f18127
wenzhe authored

Showing 179 changed files with 27,664 additions and 0 deletions. Show diff stats Hide diff stats

  1. +56 0 README.markdown
  2. +104 0 admin.html
  3. +12 0 admin.py
  4. +29 0 app.yaml
  5. +1,484 0 atom/__init__.py
  6. +43 0 atom/auth.py
  7. +182 0 atom/client.py
  8. +545 0 atom/core.py
  9. +339 0 atom/data.py
  10. +318 0 atom/http.py
  11. +597 0 atom/http_core.py
  12. +158 0 atom/http_interface.py
  13. +132 0 atom/mock_http.py
  14. +323 0 atom/mock_http_core.py
  15. +243 0 atom/mock_service.py
  16. +740 0 atom/service.py
  17. +117 0 atom/token_store.py
  18. +139 0 atom/url.py
  19. +97 0 base.html
  20. +147 0 css/gallery.css
  21. +22 0 css/gallery.min.css
  22. +101 0 css/jquery.lightbox-0.5.css
  23. +18 0 css/jquery.lightbox-0.5.min.css
  24. +1,093 0 flickr.py
  25. BIN  gdata/Crypto/Cipher/AES.pyd
  26. BIN  gdata/Crypto/Cipher/ARC2.pyd
  27. BIN  gdata/Crypto/Cipher/ARC4.pyd
  28. BIN  gdata/Crypto/Cipher/Blowfish.pyd
  29. BIN  gdata/Crypto/Cipher/CAST.pyd
  30. BIN  gdata/Crypto/Cipher/DES.pyd
  31. BIN  gdata/Crypto/Cipher/DES3.pyd
  32. BIN  gdata/Crypto/Cipher/IDEA.pyd
  33. BIN  gdata/Crypto/Cipher/RC5.pyd
  34. BIN  gdata/Crypto/Cipher/XOR.pyd
  35. +33 0 gdata/Crypto/Cipher/__init__.py
  36. +108 0 gdata/Crypto/Hash/HMAC.py
  37. BIN  gdata/Crypto/Hash/MD2.pyd
  38. BIN  gdata/Crypto/Hash/MD4.pyd
  39. +13 0 gdata/Crypto/Hash/MD5.py
  40. BIN  gdata/Crypto/Hash/RIPEMD.pyd
  41. +11 0 gdata/Crypto/Hash/SHA.py
  42. BIN  gdata/Crypto/Hash/SHA256.pyd
  43. +24 0 gdata/Crypto/Hash/__init__.py
  44. +295 0 gdata/Crypto/Protocol/AllOrNothing.py
  45. +229 0 gdata/Crypto/Protocol/Chaffing.py
  46. +17 0 gdata/Crypto/Protocol/__init__.py
  47. +238 0 gdata/Crypto/PublicKey/DSA.py
  48. +132 0 gdata/Crypto/PublicKey/ElGamal.py
  49. +256 0 gdata/Crypto/PublicKey/RSA.py
  50. +17 0 gdata/Crypto/PublicKey/__init__.py
  51. +172 0 gdata/Crypto/PublicKey/pubkey.py
  52. +170 0 gdata/Crypto/PublicKey/qNEW.py
  53. +342 0 gdata/Crypto/Util/RFC1751.py
  54. +16 0 gdata/Crypto/Util/__init__.py
  55. +201 0 gdata/Crypto/Util/number.py
  56. +421 0 gdata/Crypto/Util/randpool.py
  57. +453 0 gdata/Crypto/Util/test.py
  58. +25 0 gdata/Crypto/__init__.py
  59. +38 0 gdata/Crypto/test.py
  60. +835 0 gdata/__init__.py
  61. +15 0 gdata/acl/__init__.py
  62. +55 0 gdata/acl/data.py
  63. +20 0 gdata/alt/__init__.py
  64. +101 0 gdata/alt/app_engine.py
  65. +321 0 gdata/alt/appengine.py
  66. +39 0 gdata/apps_property.py
  67. +952 0 gdata/auth.py
  68. +697 0 gdata/base/__init__.py
  69. +256 0 gdata/base/service.py
  70. +1,126 0 gdata/client.py
  71. +279 0 gdata/core.py
  72. +1,186 0 gdata/data.py
  73. +15 0 gdata/dublincore/__init__.py
  74. +78 0 gdata/dublincore/data.py
  75. +217 0 gdata/exif/__init__.py
  76. +1,306 0 gdata/gauth.py
  77. +185 0 gdata/geo/__init__.py
  78. +92 0 gdata/geo/data.py
  79. +355 0 gdata/media/__init__.py
  80. +159 0 gdata/media/data.py
  81. +17 0 gdata/oauth/CHANGES.txt
  82. +529 0 gdata/oauth/__init__.py
  83. +120 0 gdata/oauth/rsa.py
  84. +1,112 0 gdata/photos/__init__.py
  85. +680 0 gdata/photos/service.py
  86. +1,717 0 gdata/service.py
  87. +120 0 gdata/tlslite/BaseDB.py
  88. +146 0 gdata/tlslite/Checker.py
  89. +220 0 gdata/tlslite/FileObject.py
  90. +159 0 gdata/tlslite/HandshakeSettings.py
  91. +131 0 gdata/tlslite/Session.py
  92. +103 0 gdata/tlslite/SessionCache.py
  93. +58 0 gdata/tlslite/SharedKeyDB.py
  94. +1,600 0 gdata/tlslite/TLSConnection.py
  95. +1,123 0 gdata/tlslite/TLSRecordLayer.py
  96. +90 0 gdata/tlslite/VerifierDB.py
  97. +133 0 gdata/tlslite/X509.py
  98. +181 0 gdata/tlslite/X509CertChain.py
  99. +39 0 gdata/tlslite/__init__.py
  100. +75 0 gdata/tlslite/api.py
  101. +225 0 gdata/tlslite/constants.py
  102. +149 0 gdata/tlslite/errors.py
  103. +235 0 gdata/tlslite/integration/AsyncStateMachine.py
  104. +163 0 gdata/tlslite/integration/ClientHelper.py
Sorry, we could not display the entire diff because it was too big.
56 README.markdown
Source Rendered
... ... @@ -0,0 +1,56 @@
  1 +Pretty Picasa Gallery
  2 +=====================
  3 +
  4 +## About
  5 +
  6 +This is a python photo gallery designed to run on Google's App Engine. Currently, photos are hosted on Picasa and the gallery reads the album list and displays those on a more professional looking gallery page, complete with Lightbox support.
  7 +
  8 +## Features
  9 +* Picasa photo backend support
  10 +* User configurable album support
  11 +* Various photo sizes support
  12 +* Random front page photo
  13 +* Permalinks to photos
  14 +
  15 +## Running
  16 +
  17 +Download the source code from github and install the Google App Engine SDK. Once the source is downloaded, go to that location in a terminal and run the dev_appserver.py command. For instance:
  18 +
  19 +
  20 + [streeter@mordecai]:~$ cd pretty-picasa-gallery/
  21 + [streeter@mordecai]:~/pretty-picasa-gallery$ dev_appserver.py .
  22 + INFO 2010-12-17 21:04:32,643 appengine_rpc.py:153] Server: appengine.google.com
  23 + INFO 2010-12-17 21:04:32,927 appcfg.py:414] Checking for updates to the SDK.
  24 + INFO 2010-12-17 21:04:35,173 appcfg.py:428] The SDK is up to date.
  25 + INFO 2010-12-17 21:04:35,435 dev_appserver_main.py:485] Running application chris-gallery on port 8080: http://localhost:8080
  26 +
  27 +Then go to the site `http://localhost:8080/admin/` in your browser. You should be asked to log into your account. From here, enter in your google account id (or whatever email is associated with your picasa account) and choose to log in as an administrator. For example, log in as `<your gmail id>@gmail.com` This will redirect you to the admin page. On this page, fill in some values:
  28 +
  29 +* Photo provider id should be your gmail id without the `@gmail.com`
  30 +* Site title should be whatever you want it to be
  31 +* Site header should be whatever you want it to be
  32 +
  33 +Click save which will refresh the page and list your albums. Here, choose your homepage album and check the boxes for the albums you want to be displayed, and, optionally, if you want an album that displays all the featured albums together on one page.
  34 +
  35 +Optionally fill in the last two boxes with your Google Analytics ID and your Google Checkout Merchant ID.
  36 +
  37 +## Installation
  38 +
  39 +To run this, you'll want to deploy to App Engine. To do this, edit the file `app.yaml` and change the `application` and `version` parameters. `application` should be set to whatever your application is named, in other words, if your app's url is `your-app-name.appspot.com`, then use `your-app-name`. `version` is used for rollbacks. So it should be set to 1 if this is your first time deploying.
  40 +
  41 +Then, from within the source directory, run
  42 +
  43 + appcfg.py update .
  44 +
  45 +and enter your login and password. Once the upload finishes, go to your application's url and run through the steps in the **Running** section above.
  46 +
  47 +## Known Issues
  48 +* Flickr backend doesn't work
  49 +* Installation process could use some work
  50 +* When no merchant ID is entered, we still show a price for photos
  51 +* Photo price is hard coded
  52 +* Picasa albums must be public
  53 +* Spaces in album names does not work
  54 +
  55 +
  56 +Current release is version 1.1
104 admin.html
... ... @@ -0,0 +1,104 @@
  1 +{% extends "base.html" %}
  2 +
  3 +{% block container %}
  4 +<!-- thumb-container -->
  5 +<div id="thumb-container">
  6 + {% if error %}
  7 + <div class="message error">An error occured! [{{ error_message }}]</div>
  8 + {% endif %}
  9 + {% if saved %}
  10 + <div class="message success">Successfully saved the settings.</div>
  11 + {% endif %}
  12 + {% if cache_cleared %}
  13 + <div class="message success">Successfully cleared the cache.</div>
  14 + {% endif %}
  15 + <form id="admin-form" method="post" action="/admin/">
  16 + <div class="admin-option">
  17 + <label for="backend">Gallery backend:</label>
  18 + <select id="backend" name="backend">
  19 + {% for o in settings.PHOTO_BACKENDS %}
  20 + <option {% ifequal o user.photo_backend %}selected="selected"{% endifequal %} value="{{ o }}">{{ o }}</option>
  21 + {% endfor %}
  22 + </select>
  23 + </div>
  24 + <div class="admin-option">
  25 + <label for="backend-id">Photo provider ID:</label>
  26 + <input id="backend-id" name="backend-id" type="text" value="{{ user.GetUsername }}" />
  27 + </div>
  28 + <div class="admin-option">
  29 + <label for="site-title">Site title:</label>
  30 + <input id="site-title" name="site-title" type="text" value="{{ user.site_title }}" />
  31 + </div>
  32 + <div class="admin-option">
  33 + <label for="site-header">Site header:</label>
  34 + <input id="site-header" name="site-header" type="text" value="{{ user.site_header }}" />
  35 + </div>
  36 + <div class="admin-option">
  37 + <label for="thumb-size">Thumbnail size:</label>
  38 + <select id="thumb-size" name="thumb-size">
  39 + {% for o in settings.THUMB_SIZES %}
  40 + <option {% ifequal o user.thumb_size %}selected="selected"{% endifequal %}>{{ o }}</option>
  41 + {% endfor %}
  42 + </select>
  43 + </div>
  44 + <div class="admin-option">
  45 + <label for="thumb-cropped">Thumbnails are cropped:</label>
  46 + <select id="thumb-cropped" name="thumb-cropped">
  47 + <option value='1' {% if user.thumb_cropped %}selected="selected"{% endif %}>true</option>
  48 + <option value='' {% if not user.thumb_cropped %}selected="selected"{% endif %}>false</option>
  49 + </select>
  50 + </div>
  51 + <div class="admin-option">
  52 + <label for="full-size">Lightbox size:</label>
  53 + <select id="full-size" name="full-size">
  54 + {% for o in settings.FULL_SIZES %}
  55 + <option {% ifequal o user.full_size %}selected="selected"{% endifequal %}>{{ o }}</option>
  56 + {% endfor %}
  57 + </select>
  58 + </div>
  59 + <div class="admin-option">
  60 + <label for="homepage-size">Homepage size:</label>
  61 + <select id="homepage-size" name="homepage-size">
  62 + {% for o in settings.FULL_SIZES %}
  63 + <option {% ifequal o user.homepage_size %}selected="selected"{% endifequal %}>{{ o }}</option>
  64 + {% endfor %}
  65 + </select>
  66 + </div>
  67 + <div class="admin-option">
  68 + <label for="homepage-album">Homepage album:</label>
  69 + <select id="homepage-album" name="homepage-album">
  70 + {% for a in all_albums %}
  71 + <option {% ifequal a.title user.homepage_album %}selected="selected"{% endifequal %}>{{ a.title }}</option>
  72 + {% endfor %}
  73 + </select>
  74 + </div>
  75 + <div class="admin-option">
  76 + <label for="featured-albums">Featured albums:</label>
  77 + <br />
  78 + {% for a in all_albums %}
  79 + <input id="featured-album{{ forloop.counter0 }}"
  80 + type="checkbox"
  81 + name="featured-album"
  82 + {% if a.featured %}checked="checked"{% endif %}
  83 + value="{{ a.title }}" />
  84 + <label for="featured-album{{ forloop.counter0 }}">{{ a.title }}</label>
  85 + <br />
  86 + {% endfor %}
  87 + </div>
  88 + <div class="admin-option">
  89 + <label for="merchant-id">Google Checkout merchant ID:</label>
  90 + <input id="merchant-id" name="merchant-id" type="text" value="{{ user.merchant_id|default_if_none:"" }}" />
  91 + <a href="https://checkout.google.com/sell/settings?section=Profile">lookup</a>
  92 + </div>
  93 + <div class="admin-option">
  94 + <label for="analytics-id">Google Analytics ID:</label>
  95 + <input id="analytics-id" name="analytics-id" type="text" value="{{ user.analytics_id|default_if_none:"" }}" />
  96 + </div>
  97 + <div class="admin-option">
  98 + <input type="submit" name="submit" value="Save" />
  99 + <input type="submit" name="clear-cache" value="Clear Cache" />
  100 + </div>
  101 + </form>
  102 +</div>
  103 +<!-- end thumb-container -->
  104 +{% endblock container %}
12 admin.py
... ... @@ -0,0 +1,12 @@
  1 +import settings
  2 +from google.appengine.ext import webapp
  3 +from google.appengine.ext.webapp.util import run_wsgi_app
  4 +from views import AdminPage
  5 +
  6 +application = webapp.WSGIApplication([('.*', AdminPage)], debug=settings.DEBUG)
  7 +
  8 +def main():
  9 + run_wsgi_app(application)
  10 +
  11 +if __name__ == "__main__":
  12 + main()
29 app.yaml
... ... @@ -0,0 +1,29 @@
  1 +application: chris-gallery
  2 +version: 4
  3 +runtime: python
  4 +api_version: 1
  5 +
  6 +handlers:
  7 +- url: /favicon.ico
  8 + static_files: images/favicon.ico
  9 + upload: images/favicon.ico
  10 +
  11 +- url: /robots.txt
  12 + static_files: robots.txt
  13 + upload: robots.txt
  14 +
  15 +- url: /css
  16 + static_dir: css
  17 +
  18 +- url: /images
  19 + static_dir: images
  20 +
  21 +- url: /js
  22 + static_dir: js
  23 +
  24 +- url: /admin/.*
  25 + script: admin.py
  26 + login: admin
  27 +
  28 +- url: /.*
  29 + script: photography.py
1,484 atom/__init__.py
... ... @@ -0,0 +1,1484 @@
  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 +
  18 +"""Contains classes representing Atom elements.
  19 +
  20 + Module objective: provide data classes for Atom constructs. These classes hide
  21 + the XML-ness of Atom and provide a set of native Python classes to interact
  22 + with.
  23 +
  24 + Conversions to and from XML should only be necessary when the Atom classes
  25 + "touch the wire" and are sent over HTTP. For this reason this module
  26 + provides methods and functions to convert Atom classes to and from strings.
  27 +
  28 + For more information on the Atom data model, see RFC 4287
  29 + (http://www.ietf.org/rfc/rfc4287.txt)
  30 +
  31 + AtomBase: A foundation class on which Atom classes are built. It
  32 + handles the parsing of attributes and children which are common to all
  33 + Atom classes. By default, the AtomBase class translates all XML child
  34 + nodes into ExtensionElements.
  35 +
  36 + ExtensionElement: Atom allows Atom objects to contain XML which is not part
  37 + of the Atom specification, these are called extension elements. If a
  38 + classes parser encounters an unexpected XML construct, it is translated
  39 + into an ExtensionElement instance. ExtensionElement is designed to fully
  40 + capture the information in the XML. Child nodes in an XML extension are
  41 + turned into ExtensionElements as well.
  42 +"""
  43 +
  44 +
  45 +__author__ = 'api.jscudder (Jeffrey Scudder)'
  46 +
  47 +try:
  48 + from xml.etree import cElementTree as ElementTree
  49 +except ImportError:
  50 + try:
  51 + import cElementTree as ElementTree
  52 + except ImportError:
  53 + try:
  54 + from xml.etree import ElementTree
  55 + except ImportError:
  56 + from elementtree import ElementTree
  57 +import warnings
  58 +
  59 +
  60 +# XML namespaces which are often used in Atom entities.
  61 +ATOM_NAMESPACE = 'http://www.w3.org/2005/Atom'
  62 +ELEMENT_TEMPLATE = '{http://www.w3.org/2005/Atom}%s'
  63 +APP_NAMESPACE = 'http://purl.org/atom/app#'
  64 +APP_TEMPLATE = '{http://purl.org/atom/app#}%s'
  65 +
  66 +# This encoding is used for converting strings before translating the XML
  67 +# into an object.
  68 +XML_STRING_ENCODING = 'utf-8'
  69 +# The desired string encoding for object members. set or monkey-patch to
  70 +# unicode if you want object members to be Python unicode strings, instead of
  71 +# encoded strings
  72 +MEMBER_STRING_ENCODING = 'utf-8'
  73 +#MEMBER_STRING_ENCODING = unicode
  74 +
  75 +# If True, all methods which are exclusive to v1 will raise a
  76 +# DeprecationWarning
  77 +ENABLE_V1_WARNINGS = False
  78 +
  79 +
  80 +def v1_deprecated(warning=None):
  81 + """Shows a warning if ENABLE_V1_WARNINGS is True.
  82 +
  83 + Function decorator used to mark methods used in v1 classes which
  84 + may be removed in future versions of the library.
  85 + """
  86 + warning = warning or ''
  87 + # This closure is what is returned from the deprecated function.
  88 + def mark_deprecated(f):
  89 + # The deprecated_function wraps the actual call to f.
  90 + def optional_warn_function(*args, **kwargs):
  91 + if ENABLE_V1_WARNINGS:
  92 + warnings.warn(warning, DeprecationWarning, stacklevel=2)
  93 + return f(*args, **kwargs)
  94 + # Preserve the original name to avoid masking all decorated functions as
  95 + # 'deprecated_function'
  96 + try:
  97 + optional_warn_function.func_name = f.func_name
  98 + except TypeError:
  99 + pass # In Python2.3 we can't set the func_name
  100 + return optional_warn_function
  101 + return mark_deprecated
  102 +
  103 +
  104 +def CreateClassFromXMLString(target_class, xml_string, string_encoding=None):
  105 + """Creates an instance of the target class from the string contents.
  106 +
  107 + Args:
  108 + target_class: class The class which will be instantiated and populated
  109 + with the contents of the XML. This class must have a _tag and a
  110 + _namespace class variable.
  111 + xml_string: str A string which contains valid XML. The root element
  112 + of the XML string should match the tag and namespace of the desired
  113 + class.
  114 + string_encoding: str The character encoding which the xml_string should
  115 + be converted to before it is interpreted and translated into
  116 + objects. The default is None in which case the string encoding
  117 + is not changed.
  118 +
  119 + Returns:
  120 + An instance of the target class with members assigned according to the
  121 + contents of the XML - or None if the root XML tag and namespace did not
  122 + match those of the target class.
  123 + """
  124 + encoding = string_encoding or XML_STRING_ENCODING
  125 + if encoding and isinstance(xml_string, unicode):
  126 + xml_string = xml_string.encode(encoding)
  127 + tree = ElementTree.fromstring(xml_string)
  128 + return _CreateClassFromElementTree(target_class, tree)
  129 +
  130 +
  131 +CreateClassFromXMLString = v1_deprecated(
  132 + 'Please use atom.core.parse with atom.data classes instead.')(
  133 + CreateClassFromXMLString)
  134 +
  135 +
  136 +def _CreateClassFromElementTree(target_class, tree, namespace=None, tag=None):
  137 + """Instantiates the class and populates members according to the tree.
  138 +
  139 + Note: Only use this function with classes that have _namespace and _tag
  140 + class members.
  141 +
  142 + Args:
  143 + target_class: class The class which will be instantiated and populated
  144 + with the contents of the XML.
  145 + tree: ElementTree An element tree whose contents will be converted into
  146 + members of the new target_class instance.
  147 + namespace: str (optional) The namespace which the XML tree's root node must
  148 + match. If omitted, the namespace defaults to the _namespace of the
  149 + target class.
  150 + tag: str (optional) The tag which the XML tree's root node must match. If
  151 + omitted, the tag defaults to the _tag class member of the target
  152 + class.
  153 +
  154 + Returns:
  155 + An instance of the target class - or None if the tag and namespace of
  156 + the XML tree's root node did not match the desired namespace and tag.
  157 + """
  158 + if namespace is None:
  159 + namespace = target_class._namespace
  160 + if tag is None:
  161 + tag = target_class._tag
  162 + if tree.tag == '{%s}%s' % (namespace, tag):
  163 + target = target_class()
  164 + target._HarvestElementTree(tree)
  165 + return target
  166 + else:
  167 + return None
  168 +
  169 +
  170 +class ExtensionContainer(object):
  171 +
  172 + def __init__(self, extension_elements=None, extension_attributes=None,
  173 + text=None):
  174 + self.extension_elements = extension_elements or []
  175 + self.extension_attributes = extension_attributes or {}
  176 + self.text = text
  177 +
  178 + __init__ = v1_deprecated(
  179 + 'Please use data model classes in atom.data instead.')(
  180 + __init__)
  181 +
  182 + # Three methods to create an object from an ElementTree
  183 + def _HarvestElementTree(self, tree):
  184 + # Fill in the instance members from the contents of the XML tree.
  185 + for child in tree:
  186 + self._ConvertElementTreeToMember(child)
  187 + for attribute, value in tree.attrib.iteritems():
  188 + self._ConvertElementAttributeToMember(attribute, value)
  189 + # Encode the text string according to the desired encoding type. (UTF-8)
  190 + if tree.text:
  191 + if MEMBER_STRING_ENCODING is unicode:
  192 + self.text = tree.text
  193 + else:
  194 + self.text = tree.text.encode(MEMBER_STRING_ENCODING)
  195 +
  196 + def _ConvertElementTreeToMember(self, child_tree, current_class=None):
  197 + self.extension_elements.append(_ExtensionElementFromElementTree(
  198 + child_tree))
  199 +
  200 + def _ConvertElementAttributeToMember(self, attribute, value):
  201 + # Encode the attribute value's string with the desired type Default UTF-8
  202 + if value:
  203 + if MEMBER_STRING_ENCODING is unicode:
  204 + self.extension_attributes[attribute] = value
  205 + else:
  206 + self.extension_attributes[attribute] = value.encode(
  207 + MEMBER_STRING_ENCODING)
  208 +
  209 + # One method to create an ElementTree from an object
  210 + def _AddMembersToElementTree(self, tree):
  211 + for child in self.extension_elements:
  212 + child._BecomeChildElement(tree)
  213 + for attribute, value in self.extension_attributes.iteritems():
  214 + if value:
  215 + if isinstance(value, unicode) or MEMBER_STRING_ENCODING is unicode:
  216 + tree.attrib[attribute] = value
  217 + else:
  218 + # Decode the value from the desired encoding (default UTF-8).
  219 + tree.attrib[attribute] = value.decode(MEMBER_STRING_ENCODING)
  220 + if self.text:
  221 + if isinstance(self.text, unicode) or MEMBER_STRING_ENCODING is unicode:
  222 + tree.text = self.text
  223 + else:
  224 + tree.text = self.text.decode(MEMBER_STRING_ENCODING)
  225 +
  226 + def FindExtensions(self, tag=None, namespace=None):
  227 + """Searches extension elements for child nodes with the desired name.
  228 +
  229 + Returns a list of extension elements within this object whose tag
  230 + and/or namespace match those passed in. To find all extensions in
  231 + a particular namespace, specify the namespace but not the tag name.
  232 + If you specify only the tag, the result list may contain extension
  233 + elements in multiple namespaces.
  234 +
  235 + Args:
  236 + tag: str (optional) The desired tag
  237 + namespace: str (optional) The desired namespace
  238 +
  239 + Returns:
  240 + A list of elements whose tag and/or namespace match the parameters
  241 + values
  242 + """
  243 +
  244 + results = []
  245 +
  246 + if tag and namespace:
  247 + for element in self.extension_elements:
  248 + if element.tag == tag and element.namespace == namespace:
  249 + results.append(element)
  250 + elif tag and not namespace:
  251 + for element in self.extension_elements:
  252 + if element.tag == tag:
  253 + results.append(element)
  254 + elif namespace and not tag:
  255 + for element in self.extension_elements:
  256 + if element.namespace == namespace:
  257 + results.append(element)
  258 + else:
  259 + for element in self.extension_elements:
  260 + results.append(element)
  261 +
  262 + return results
  263 +
  264 +
  265 +class AtomBase(ExtensionContainer):
  266 +
  267 + _children = {}
  268 + _attributes = {}
  269 +
  270 + def __init__(self, extension_elements=None, extension_attributes=None,
  271 + text=None):
  272 + self.extension_elements = extension_elements or []
  273 + self.extension_attributes = extension_attributes or {}
  274 + self.text = text
  275 +
  276 + __init__ = v1_deprecated(
  277 + 'Please use data model classes in atom.data instead.')(
  278 + __init__)
  279 +
  280 + def _ConvertElementTreeToMember(self, child_tree):
  281 + # Find the element's tag in this class's list of child members
  282 + if self.__class__._children.has_key(child_tree.tag):
  283 + member_name = self.__class__._children[child_tree.tag][0]
  284 + member_class = self.__class__._children[child_tree.tag][1]
  285 + # If the class member is supposed to contain a list, make sure the
  286 + # matching member is set to a list, then append the new member
  287 + # instance to the list.
  288 + if isinstance(member_class, list):
  289 + if getattr(self, member_name) is None:
  290 + setattr(self, member_name, [])
  291 + getattr(self, member_name).append(_CreateClassFromElementTree(
  292 + member_class[0], child_tree))
  293 + else:
  294 + setattr(self, member_name,
  295 + _CreateClassFromElementTree(member_class, child_tree))
  296 + else:
  297 + ExtensionContainer._ConvertElementTreeToMember(self, child_tree)
  298 +
  299 + def _ConvertElementAttributeToMember(self, attribute, value):
  300 + # Find the attribute in this class's list of attributes.
  301 + if self.__class__._attributes.has_key(attribute):
  302 + # Find the member of this class which corresponds to the XML attribute
  303 + # (lookup in current_class._attributes) and set this member to the
  304 + # desired value (using self.__dict__).
  305 + if value:
  306 + # Encode the string to capture non-ascii characters (default UTF-8)
  307 + if MEMBER_STRING_ENCODING is unicode:
  308 + setattr(self, self.__class__._attributes[attribute], value)
  309 + else:
  310 + setattr(self, self.__class__._attributes[attribute],
  311 + value.encode(MEMBER_STRING_ENCODING))
  312 + else:
  313 + ExtensionContainer._ConvertElementAttributeToMember(
  314 + self, attribute, value)
  315 +
  316 + # Three methods to create an ElementTree from an object
  317 + def _AddMembersToElementTree(self, tree):
  318 + # Convert the members of this class which are XML child nodes.
  319 + # This uses the class's _children dictionary to find the members which
  320 + # should become XML child nodes.
  321 + member_node_names = [values[0] for tag, values in
  322 + self.__class__._children.iteritems()]
  323 + for member_name in member_node_names:
  324 + member = getattr(self, member_name)
  325 + if member is None:
  326 + pass
  327 + elif isinstance(member, list):
  328 + for instance in member:
  329 + instance._BecomeChildElement(tree)
  330 + else:
  331 + member._BecomeChildElement(tree)
  332 + # Convert the members of this class which are XML attributes.
  333 + for xml_attribute, member_name in self.__class__._attributes.iteritems():
  334 + member = getattr(self, member_name)
  335 + if member is not None:
  336 + if isinstance(member, unicode) or MEMBER_STRING_ENCODING is unicode:
  337 + tree.attrib[xml_attribute] = member
  338 + else:
  339 + tree.attrib[xml_attribute] = member.decode(MEMBER_STRING_ENCODING)
  340 + # Lastly, call the ExtensionContainers's _AddMembersToElementTree to
  341 + # convert any extension attributes.
  342 + ExtensionContainer._AddMembersToElementTree(self, tree)
  343 +
  344 +
  345 + def _BecomeChildElement(self, tree):
  346 + """
  347 +
  348 + Note: Only for use with classes that have a _tag and _namespace class
  349 + member. It is in AtomBase so that it can be inherited but it should
  350 + not be called on instances of AtomBase.
  351 +
  352 + """
  353 + new_child = ElementTree.Element('')
  354 + tree.append(new_child)
  355 + new_child.tag = '{%s}%s' % (self.__class__._namespace,
  356 + self.__class__._tag)
  357 + self._AddMembersToElementTree(new_child)
  358 +
  359 + def _ToElementTree(self):
  360 + """
  361 +
  362 + Note, this method is designed to be used only with classes that have a
  363 + _tag and _namespace. It is placed in AtomBase for inheritance but should
  364 + not be called on this class.
  365 +
  366 + """
  367 + new_tree = ElementTree.Element('{%s}%s' % (self.__class__._namespace,
  368 + self.__class__._tag))
  369 + self._AddMembersToElementTree(new_tree)
  370 + return new_tree
  371 +
  372 + def ToString(self, string_encoding='UTF-8'):
  373 + """Converts the Atom object to a string containing XML."""
  374 + return ElementTree.tostring(self._ToElementTree(), encoding=string_encoding)
  375 +
  376 + def __str__(self):
  377 + return self.ToString()
  378 +
  379 +
  380 +class Name(AtomBase):
  381 + """The atom:name element"""
  382 +
  383 + _tag = 'name'
  384 + _namespace = ATOM_NAMESPACE
  385 + _children = AtomBase._children.copy()
  386 + _attributes = AtomBase._attributes.copy()
  387 +
  388 + def __init__(self, text=None, extension_elements=None,
  389 + extension_attributes=None):
  390 + """Constructor for Name
  391 +
  392 + Args:
  393 + text: str The text data in the this element
  394 + extension_elements: list A list of ExtensionElement instances
  395 + extension_attributes: dict A dictionary of attribute value string pairs
  396 + """
  397 +
  398 + self.text = text
  399 + self.extension_elements = extension_elements or []
  400 + self.extension_attributes = extension_attributes or {}
  401 +
  402 +
  403 +def NameFromString(xml_string):
  404 + return CreateClassFromXMLString(Name, xml_string)
  405 +
  406 +
  407 +class Email(AtomBase):
  408 + """The atom:email element"""
  409 +
  410 + _tag = 'email'
  411 + _namespace = ATOM_NAMESPACE
  412 + _children = AtomBase._children.copy()
  413 + _attributes = AtomBase._attributes.copy()
  414 +
  415 + def __init__(self, text=None, extension_elements=None,
  416 + extension_attributes=None):
  417 + """Constructor for Email
  418 +
  419 + Args:
  420 + extension_elements: list A list of ExtensionElement instances
  421 + extension_attributes: dict A dictionary of attribute value string pairs
  422 + text: str The text data in the this element
  423 + """
  424 +
  425 + self.text = text
  426 + self.extension_elements = extension_elements or []
  427 + self.extension_attributes = extension_attributes or {}
  428 +
  429 +
  430 +def EmailFromString(xml_string):
  431 + return CreateClassFromXMLString(Email, xml_string)
  432 +
  433 +
  434 +class Uri(AtomBase):
  435 + """The atom:uri element"""
  436 +
  437 + _tag = 'uri'
  438 + _namespace = ATOM_NAMESPACE
  439 + _children = AtomBase._children.copy()
  440 + _attributes = AtomBase._attributes.copy()
  441 +
  442 + def __init__(self, text=None, extension_elements=None,
  443 + extension_attributes=None):
  444 + """Constructor for Uri
  445 +
  446 + Args:
  447 + extension_elements: list A list of ExtensionElement instances
  448 + extension_attributes: dict A dictionary of attribute value string pairs
  449 + text: str The text data in the this element
  450 + """
  451 +
  452 + self.text = text
  453 + self.extension_elements = extension_elements or []
  454 + self.extension_attributes = extension_attributes or {}
  455 +
  456 +
  457 +def UriFromString(xml_string):
  458 + return CreateClassFromXMLString(Uri, xml_string)
  459 +
  460 +
  461 +class Person(AtomBase):
  462 + """A foundation class from which atom:author and atom:contributor extend.
  463 +
  464 + A person contains information like name, email address, and web page URI for
  465 + an author or contributor to an Atom feed.
  466 + """
  467 +
  468 + _children = AtomBase._children.copy()
  469 + _attributes = AtomBase._attributes.copy()
  470 + _children['{%s}name' % (ATOM_NAMESPACE)] = ('name', Name)
  471 + _children['{%s}email' % (ATOM_NAMESPACE)] = ('email', Email)
  472 + _children['{%s}uri' % (ATOM_NAMESPACE)] = ('uri', Uri)
  473 +
  474 + def __init__(self, name=None, email=None, uri=None,
  475 + extension_elements=None, extension_attributes=None, text=None):
  476 + """Foundation from which author and contributor are derived.
  477 +
  478 + The constructor is provided for illustrative purposes, you should not
  479 + need to instantiate a Person.
  480 +
  481 + Args:
  482 + name: Name The person's name
  483 + email: Email The person's email address
  484 + uri: Uri The URI of the person's webpage
  485 + extension_elements: list A list of ExtensionElement instances which are
  486 + children of this element.
  487 + extension_attributes: dict A dictionary of strings which are the values
  488 + for additional XML attributes of this element.
  489 + text: String The text contents of the element. This is the contents
  490 + of the Entry's XML text node. (Example: <foo>This is the text</foo>)
  491 + """
  492 +
  493 + self.name = name
  494 + self.email = email
  495 + self.uri = uri
  496 + self.extension_elements = extension_elements or []
  497 + self.extension_attributes = extension_attributes or {}
  498 + self.text = text
  499 +
  500 +
  501 +class Author(Person):
  502 + """The atom:author element
  503 +
  504 + An author is a required element in Feed.
  505 + """
  506 +
  507 + _tag = 'author'
  508 + _namespace = ATOM_NAMESPACE
  509 + _children = Person._children.copy()
  510 + _attributes = Person._attributes.copy()
  511 + #_children = {}
  512 + #_attributes = {}
  513 +
  514 + def __init__(self, name=None, email=None, uri=None,
  515 + extension_elements=None, extension_attributes=None, text=None):
  516 + """Constructor for Author
  517 +
  518 + Args:
  519 + name: Name
  520 + email: Email
  521 + uri: Uri
  522 + extension_elements: list A list of ExtensionElement instances
  523 + extension_attributes: dict A dictionary of attribute value string pairs
  524 + text: str The text data in the this element
  525 + """
  526 +
  527 + self.name = name
  528 + self.email = email
  529 + self.uri = uri
  530 + self.extension_elements = extension_elements or []
  531 + self.extension_attributes = extension_attributes or {}
  532 + self.text = text
  533 +
  534 +
  535 +def AuthorFromString(xml_string):
  536 + return CreateClassFromXMLString(Author, xml_string)
  537 +
  538 +
  539 +class Contributor(Person):
  540 + """The atom:contributor element"""
  541 +
  542 + _tag = 'contributor'
  543 + _namespace = ATOM_NAMESPACE
  544 + _children = Person._children.copy()
  545 + _attributes = Person._attributes.copy()
  546 +
  547 + def __init__(self, name=None, email=None, uri=None,
  548 + extension_elements=None, extension_attributes=None, text=None):
  549 + """Constructor for Contributor
  550 +
  551 + Args:
  552 + name: Name
  553 + email: Email
  554 + uri: Uri
  555 + extension_elements: list A list of ExtensionElement instances
  556 + extension_attributes: dict A dictionary of attribute value string pairs
  557 + text: str The text data in the this element
  558 + """
  559 +
  560 + self.name = name
  561 + self.email = email
  562 + self.uri = uri
  563 + self.extension_elements = extension_elements or []
  564 + self.extension_attributes = extension_attributes or {}
  565 + self.text = text
  566 +
  567 +
  568 +def ContributorFromString(xml_string):
  569 + return CreateClassFromXMLString(Contributor, xml_string)
  570 +
  571 +
  572 +class Link(AtomBase):
  573 + """The atom:link element"""
  574 +
  575 + _tag = 'link'
  576 + _namespace = ATOM_NAMESPACE
  577 + _children = AtomBase._children.copy()
  578 + _attributes = AtomBase._attributes.copy()
  579 + _attributes['rel'] = 'rel'
  580 + _attributes['href'] = 'href'
  581 + _attributes['type'] = 'type'
  582 + _attributes['title'] = 'title'
  583 + _attributes['length'] = 'length'
  584 + _attributes['hreflang'] = 'hreflang'
  585 +
  586 + def __init__(self, href=None, rel=None, link_type=None, hreflang=None,
  587 + title=None, length=None, text=None, extension_elements=None,
  588 + extension_attributes=None):
  589 + """Constructor for Link
  590 +
  591 + Args:
  592 + href: string The href attribute of the link
  593 + rel: string
  594 + type: string
  595 + hreflang: string The language for the href
  596 + title: string
  597 + length: string The length of the href's destination
  598 + extension_elements: list A list of ExtensionElement instances
  599 + extension_attributes: dict A dictionary of attribute value string pairs
  600 + text: str The text data in the this element
  601 + """
  602 +
  603 + self.href = href
  604 + self.rel = rel
  605 + self.type = link_type
  606 + self.hreflang = hreflang
  607 + self.title = title
  608 + self.length = length
  609 + self.text = text
  610 + self.extension_elements = extension_elements or []
  611 + self.extension_attributes = extension_attributes or {}
  612 +
  613 +
  614 +def LinkFromString(xml_string):
  615 + return CreateClassFromXMLString(Link, xml_string)
  616 +
  617 +
  618 +class Generator(AtomBase):
  619 + """The atom:generator element"""
  620 +
  621 + _tag = 'generator'
  622 + _namespace = ATOM_NAMESPACE
  623 + _children = AtomBase._children.copy()
  624 + _attributes = AtomBase._attributes.copy()
  625 + _attributes['uri'] = 'uri'
  626 + _attributes['version'] = 'version'
  627 +
  628 + def __init__(self, uri=None, version=None, text=None,
  629 + extension_elements=None, extension_attributes=None):
  630 + """Constructor for Generator
  631 +
  632 + Args:
  633 + uri: string
  634 + version: string
  635 + text: str The text data in the this element
  636 + extension_elements: list A list of ExtensionElement instances
  637 + extension_attributes: dict A dictionary of attribute value string pairs
  638 + """
  639 +
  640 + self.uri = uri
  641 + self.version = version
  642 + self.text = text
  643 + self.extension_elements = extension_elements or []
  644 + self.extension_attributes = extension_attributes or {}
  645 +
  646 +def GeneratorFromString(xml_string):
  647 + return CreateClassFromXMLString(Generator, xml_string)
  648 +
  649 +
  650 +class Text(AtomBase):
  651 + """A foundation class from which atom:title, summary, etc. extend.
  652 +
  653 + This class should never be instantiated.
  654 + """
  655 +
  656 + _children = AtomBase._children.copy()
  657 + _attributes = AtomBase._attributes.copy()
  658 + _attributes['type'] = 'type'
  659 +
  660 + def __init__(self, text_type=None, text=None, extension_elements=None,
  661 + extension_attributes=None):
  662 + """Constructor for Text
  663 +
  664 + Args:
  665 + text_type: string
  666 + text: str The text data in the this element
  667 + extension_elements: list A list of ExtensionElement instances
  668 + extension_attributes: dict A dictionary of attribute value string pairs
  669 + """
  670 +
  671 + self.type = text_type
  672 + self.text = text
  673 + self.extension_elements = extension_elements or []
  674 + self.extension_attributes = extension_attributes or {}
  675 +
  676 +
  677 +class Title(Text):
  678 + """The atom:title element"""
  679 +
  680 + _tag = 'title'
  681 + _namespace = ATOM_NAMESPACE
  682 + _children = Text._children.copy()
  683 + _attributes = Text._attributes.copy()
  684 +
  685 + def __init__(self, title_type=None, text=None, extension_elements=None,
  686 + extension_attributes=None):
  687 + """Constructor for Title
  688 +
  689 + Args:
  690 + title_type: string
  691 + text: str The text data in the this element
  692 + extension_elements: list A list of ExtensionElement instances
  693 + extension_attributes: dict A dictionary of attribute value string pairs
  694 + """
  695 +
  696 + self.type = title_type
  697 + self.text = text
  698 + self.extension_elements = extension_elements or []
  699 + self.extension_attributes = extension_attributes or {}
  700 +
  701 +
  702 +def TitleFromString(xml_string):
  703 + return CreateClassFromXMLString(Title, xml_string)
  704 +
  705 +
  706 +class Subtitle(Text):
  707 + """The atom:subtitle element"""
  708 +
  709 + _tag = 'subtitle'
  710 + _namespace = ATOM_NAMESPACE
  711 + _children = Text._children.copy()
  712 + _attributes = Text._attributes.copy()
  713 +
  714 + def __init__(self, subtitle_type=None, text=None, extension_elements=None,
  715 + extension_attributes=None):
  716 + """Constructor for Subtitle
  717 +
  718 + Args:
  719 + subtitle_type: string
  720 + text: str The text data in the this element
  721 + extension_elements: list A list of ExtensionElement instances
  722 + extension_attributes: dict A dictionary of attribute value string pairs
  723 + """
  724 +
  725 + self.type = subtitle_type
  726 + self.text = text
  727 + self.extension_elements = extension_elements or []
  728 + self.extension_attributes = extension_attributes or {}
  729 +
  730 +
  731 +def SubtitleFromString(xml_string):
  732 + return CreateClassFromXMLString(Subtitle, xml_string)
  733 +
  734 +
  735 +class Rights(Text):
  736 + """The atom:rights element"""
  737 +
  738 + _tag = 'rights'
  739 + _namespace = ATOM_NAMESPACE
  740 + _children = Text._children.copy()
  741 + _attributes = Text._attributes.copy()
  742 +
  743 + def __init__(self, rights_type=None, text=None, extension_elements=None,
  744 + extension_attributes=None):
  745 + """Constructor for Rights
  746 +
  747 + Args:
  748 + rights_type: string
  749 + text: str The text data in the this element
  750 + extension_elements: list A list of ExtensionElement instances
  751 + extension_attributes: dict A dictionary of attribute value string pairs
  752 + """
  753 +
  754 + self.type = rights_type
  755 + self.text = text
  756 + self.extension_elements = extension_elements or []
  757 + self.extension_attributes = extension_attributes or {}
  758 +
  759 +
  760 +def RightsFromString(xml_string):
  761 + return CreateClassFromXMLString(Rights, xml_string)
  762 +
  763 +
  764 +class Summary(Text):
  765 + """The atom:summary element"""
  766 +
  767 + _tag = 'summary'
  768 + _namespace = ATOM_NAMESPACE
  769 + _children = Text._children.copy()
  770 + _attributes = Text._attributes.copy()
  771 +
  772 + def __init__(self, summary_type=None, text=None, extension_elements=None,
  773 + extension_attributes=None):
  774 + """Constructor for Summary
  775 +
  776 + Args:
  777 + summary_type: string
  778 + text: str The text data in the this element
  779 + extension_elements: list A list of ExtensionElement instances
  780 + extension_attributes: dict A dictionary of attribute value string pairs
  781 + """
  782 +
  783 + self.type = summary_type
  784 + self.text = text
  785 + self.extension_elements = extension_elements or []
  786 + self.extension_attributes = extension_attributes or {}
  787 +
  788 +
  789 +def SummaryFromString(xml_string):
  790 + return CreateClassFromXMLString(Summary, xml_string)
  791 +
  792 +
  793 +class Content(Text):
  794 + """The atom:content element"""
  795 +
  796 + _tag = 'content'
  797 + _namespace = ATOM_NAMESPACE
  798 + _children = Text._children.copy()
  799 + _attributes = Text._attributes.copy()
  800 + _attributes['src'] = 'src'
  801 +
  802 + def __init__(self, content_type=None, src=None, text=None,
  803 + extension_elements=None, extension_attributes=None):
  804 + """Constructor for Content
  805 +
  806 + Args:
  807 + content_type: string
  808 + src: string
  809 + text: str The text data in the this element
  810 + extension_elements: list A list of ExtensionElement instances
  811 + extension_attributes: dict A dictionary of attribute value string pairs
  812 + """
  813 +
  814 + self.type = content_type
  815 + self.src = src
  816 + self.text = text
  817 + self.extension_elements = extension_elements or []
  818 + self.extension_attributes = extension_attributes or {}
  819 +
  820 +def ContentFromString(xml_string):
  821 + return CreateClassFromXMLString(Content, xml_string)
  822 +
  823 +
  824 +class Category(AtomBase):
  825 + """The atom:category element"""
  826 +
  827 + _tag = 'category'
  828 + _namespace = ATOM_NAMESPACE
  829 + _children = AtomBase._children.copy()
  830 + _attributes = AtomBase._attributes.copy()
  831 + _attributes['term'] = 'term'
  832 + _attributes['scheme'] = 'scheme'
  833 + _attributes['label'] = 'label'
  834 +
  835 + def __init__(self, term=None, scheme=None, label=None, text=None,
  836 + extension_elements=None, extension_attributes=None):
  837 + """Constructor for Category
  838 +
  839 + Args:
  840 + term: str
  841 + scheme: str
  842 + label: str
  843 + text: str The text data in the this element
  844 + extension_elements: list A list of ExtensionElement instances
  845 + extension_attributes: dict A dictionary of attribute value string pairs
  846 + """
  847 +
  848 + self.term = term
  849 + self.scheme = scheme
  850 + self.label = label
  851 + self.text = text
  852 + self.extension_elements = extension_elements or []
  853 + self.extension_attributes = extension_attributes or {}
  854 +
  855 +
  856 +def CategoryFromString(xml_string):
  857 + return CreateClassFromXMLString(Category, xml_string)
  858 +
  859 +
  860 +class Id(AtomBase):
  861 + """The atom:id element."""
  862 +
  863 + _tag = 'id'
  864 + _namespace = ATOM_NAMESPACE
  865 + _children = AtomBase._children.copy()
  866 + _attributes = AtomBase._attributes.copy()
  867 +
  868 + def __init__(self, text=None, extension_elements=None,
  869 + extension_attributes=None):
  870 + """Constructor for Id
  871 +
  872 + Args:
  873 + text: str The text data in the this element
  874 + extension_elements: list A list of ExtensionElement instances
  875 + extension_attributes: dict A dictionary of attribute value string pairs
  876 + """
  877 +
  878 + self.text = text
  879 + self.extension_elements = extension_elements or []
  880 + self.extension_attributes = extension_attributes or {}
  881 +
  882 +
  883 +def IdFromString(xml_string):
  884 + return CreateClassFromXMLString(Id, xml_string)
  885 +
  886 +
  887 +class Icon(AtomBase):
  888 + """The atom:icon element."""
  889 +
  890 + _tag = 'icon'
  891 + _namespace = ATOM_NAMESPACE
  892 + _children = AtomBase._children.copy()
  893 + _attributes = AtomBase._attributes.copy()
  894 +
  895 + def __init__(self, text=None, extension_elements=None,
  896 + extension_attributes=None):
  897 + """Constructor for Icon
  898 +
  899 + Args:
  900 + text: str The text data in the this element
  901 + extension_elements: list A list of ExtensionElement instances
  902 + extension_attributes: dict A dictionary of attribute value string pairs
  903 + """
  904 +
  905 + self.text = text
  906 + self.extension_elements = extension_elements or []
  907 + self.extension_attributes = extension_attributes or {}
  908 +
  909 +
  910 +def IconFromString(xml_string):
  911 + return CreateClassFromXMLString(Icon, xml_string)
  912 +
  913 +
  914 +class Logo(AtomBase):
  915 + """The atom:logo element."""
  916 +
  917 + _tag = 'logo'
  918 + _namespace = ATOM_NAMESPACE
  919 + _children = AtomBase._children.copy()
  920 + _attributes = AtomBase._attributes.copy()
  921 +
  922 + def __init__(self, text=None, extension_elements=None,
  923 + extension_attributes=None):
  924 + """Constructor for Logo
  925 +
  926 + Args:
  927 + text: str The text data in the this element
  928 + extension_elements: list A list of ExtensionElement instances
  929 + extension_attributes: dict A dictionary of attribute value string pairs
  930 + """
  931 +
  932 + self.text = text
  933 + self.extension_elements = extension_elements or []
  934 + self.extension_attributes = extension_attributes or {}
  935 +
  936 +