[Python-modules-commits] [lazr.delegates] 02/07: Import lazr.delegates_2.0.1.orig.tar.gz

Barry Warsaw barry at moszumanska.debian.org
Fri Jan 9 22:25:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

barry pushed a commit to branch master
in repository lazr.delegates.

commit d1db76af484db4f5eae433afb292b52f84f323c7
Author: Barry Warsaw <barry at python.org>
Date:   Fri Jan 9 17:02:38 2015 -0500

    Import lazr.delegates_2.0.1.orig.tar.gz
---
 COPYING.txt                                    | 165 +++++++++++++++
 HACKING.rst                                    |  51 +++++
 MANIFEST.in                                    |   3 +
 PKG-INFO                                       |  24 +++
 README.rst                                     |  21 ++
 conf.py                                        | 266 +++++++++++++++++++++++++
 lazr.delegates.egg-info/PKG-INFO               |  24 +++
 lazr.delegates.egg-info/SOURCES.txt            |  31 +++
 lazr.delegates.egg-info/dependency_links.txt   |   1 +
 lazr.delegates.egg-info/namespace_packages.txt |   1 +
 lazr.delegates.egg-info/not-zip-safe           |   1 +
 lazr.delegates.egg-info/requires.txt           |   3 +
 lazr.delegates.egg-info/top_level.txt          |   1 +
 lazr/__init__.py                               |  27 +++
 lazr/delegates/__init__.py                     |  36 ++++
 lazr/delegates/_delegates.py                   | 111 +++++++++++
 lazr/delegates/_passthrough.py                 |  55 +++++
 lazr/delegates/_python2.py                     |  38 ++++
 lazr/delegates/_python3.py                     |  38 ++++
 lazr/delegates/docs/NEWS.rst                   |  42 ++++
 lazr/delegates/docs/__init__.py                |   0
 lazr/delegates/docs/fixture.py                 |  34 ++++
 lazr/delegates/docs/usage.rst                  | 136 +++++++++++++
 lazr/delegates/docs/usage_fixture.py           |  27 +++
 lazr/delegates/tests/__init__.py               |   0
 lazr/delegates/tests/test_api.py               |  35 ++++
 lazr/delegates/tests/test_passthrough.py       |  85 ++++++++
 lazr/delegates/tests/test_python2.py           | 166 +++++++++++++++
 lazr/delegates/version.txt                     |   1 +
 setup.cfg                                      |  15 ++
 setup.py                                       |  73 +++++++
 tox.ini                                        |   5 +
 32 files changed, 1516 insertions(+)

diff --git a/COPYING.txt b/COPYING.txt
new file mode 100644
index 0000000..cca7fc2
--- /dev/null
+++ b/COPYING.txt
@@ -0,0 +1,165 @@
+		   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/HACKING.rst b/HACKING.rst
new file mode 100644
index 0000000..55984d8
--- /dev/null
+++ b/HACKING.rst
@@ -0,0 +1,51 @@
+..
+    This file is part of lazr.delegates.
+
+    lazr.delegates is free software: you can redistribute it and/or modify it
+    under the terms of the GNU Lesser General Public License as published by
+    the Free Software Foundation, version 3 of the License.
+
+    lazr.delegates is distributed in the hope that it will be useful, but
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+    License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with lazr.delegates.  If not, see <http://www.gnu.org/licenses/>.
+
+=========================
+Hacking on lazr.delegates
+=========================
+
+These are guidelines for hacking on the lazr.delegates project.  But first,
+please see the common hacking guidelines at:
+
+    http://dev.launchpad.net/Hacking
+
+
+Getting help
+------------
+
+If you find bugs in this package, you can report them here:
+
+    https://launchpad.net/lazr.delegates
+
+If you want to discuss this package, join the team and mailing list here:
+
+    https://launchpad.net/~lazr-developers
+
+or send a message to:
+
+    lazr-developers at lists.launchpad.net
+
+
+Running the tests
+=================
+
+The tests suite requires tox_ and nose_ and is compatible with both Python 2
+and Python 3.  To run the full test suite::
+
+    $ tox
+
+.. _nose: https://nose.readthedocs.org/en/latest/
+.. _tox: https://testrun.org/tox/latest/
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..1120099
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include *.py *.txt *.rst MANIFEST.in *.ini
+recursive-include lazr *.txt *.rst
+exclude .bzrignore
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..a8ab6a8
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,24 @@
+Metadata-Version: 1.1
+Name: lazr.delegates
+Version: 2.0.1
+Summary: Easily write objects that delegate behavior
+Home-page: https://launchpad.net/lazr.delegates
+Author: LAZR Developers
+Author-email: lazr-developers at lists.launchpad.net
+License: LGPL v3
+Download-URL: https://launchpad.net/lazr.delegates/+download
+Description: 
+        The ``lazr.delegates`` package makes it easy to write objects that delegate
+        behavior to another object. The new object adds some property or behavior on
+        to the other object, while still providing the underlying interface, and
+        delegating behavior.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..29736e3
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,21 @@
+=========================
+Welcome to lazr.delegates
+=========================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   lazr/delegates/docs/usage
+   lazr/delegates/docs/NEWS
+   HACKING
+
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/conf.py b/conf.py
new file mode 100644
index 0000000..35dfaa0
--- /dev/null
+++ b/conf.py
@@ -0,0 +1,266 @@
+# -*- coding: utf-8 -*-
+#
+# lazr.delegates documentation build configuration file, created by
+# sphinx-quickstart on Mon Jan  7 10:37:37 2013.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+from __future__ import print_function
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'README'
+
+# General information about the project.
+project = u'lazr.delegates'
+copyright = u'2013-2014, LAZR developers'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = open('lazr/delegates/version.txt').read().strip()
+# The full version, including alpha/beta/rc tags.
+release = version
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build', 'eggs']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'lazrdelegatesdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'lazrdelegates.tex', u'lazr.delegates Documentation',
+   u'LAZR developers', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'lazrdelegates', u'lazr.delegates Documentation',
+     [u'LAZR developers'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'lazrdelegates', u'lazr.delegates Documentation',
+   u'LAZR developers', 'lazrdelegates', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# Make upload to packages.python.org happy.
+def index_html():
+    import errno
+    cwd = os.getcwd()
+    try:
+        try:
+            os.makedirs('build/sphinx/html')
+        except OSError as error:
+            if error.errno != errno.EEXIST:
+                raise
+        os.chdir('build/sphinx/html')
+        try:
+            os.symlink('README.html', 'index.html')
+            print('index.html -> README.html')
+        except OSError as error:
+            if error.errno != errno.EEXIST:
+                raise
+    finally:
+        os.chdir(cwd)
+
+import atexit
+atexit.register(index_html)
diff --git a/lazr.delegates.egg-info/PKG-INFO b/lazr.delegates.egg-info/PKG-INFO
new file mode 100644
index 0000000..a8ab6a8
--- /dev/null
+++ b/lazr.delegates.egg-info/PKG-INFO
@@ -0,0 +1,24 @@
+Metadata-Version: 1.1
+Name: lazr.delegates
+Version: 2.0.1
+Summary: Easily write objects that delegate behavior
+Home-page: https://launchpad.net/lazr.delegates
+Author: LAZR Developers
+Author-email: lazr-developers at lists.launchpad.net
+License: LGPL v3
+Download-URL: https://launchpad.net/lazr.delegates/+download
+Description: 
+        The ``lazr.delegates`` package makes it easy to write objects that delegate
+        behavior to another object. The new object adds some property or behavior on
+        to the other object, while still providing the underlying interface, and
+        delegating behavior.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
diff --git a/lazr.delegates.egg-info/SOURCES.txt b/lazr.delegates.egg-info/SOURCES.txt
new file mode 100644
index 0000000..6504342
--- /dev/null
+++ b/lazr.delegates.egg-info/SOURCES.txt
@@ -0,0 +1,31 @@
+COPYING.txt
+HACKING.rst
+MANIFEST.in
+README.rst
+conf.py
+setup.cfg
+setup.py
+tox.ini
+lazr/__init__.py
+lazr.delegates.egg-info/PKG-INFO
+lazr.delegates.egg-info/SOURCES.txt
+lazr.delegates.egg-info/dependency_links.txt
+lazr.delegates.egg-info/namespace_packages.txt
+lazr.delegates.egg-info/not-zip-safe
+lazr.delegates.egg-info/requires.txt
+lazr.delegates.egg-info/top_level.txt
+lazr/delegates/__init__.py
+lazr/delegates/_delegates.py
+lazr/delegates/_passthrough.py
+lazr/delegates/_python2.py
+lazr/delegates/_python3.py
+lazr/delegates/version.txt
+lazr/delegates/docs/NEWS.rst
+lazr/delegates/docs/__init__.py
+lazr/delegates/docs/fixture.py
+lazr/delegates/docs/usage.rst
+lazr/delegates/docs/usage_fixture.py
+lazr/delegates/tests/__init__.py
+lazr/delegates/tests/test_api.py
+lazr/delegates/tests/test_passthrough.py
+lazr/delegates/tests/test_python2.py
\ No newline at end of file
diff --git a/lazr.delegates.egg-info/dependency_links.txt b/lazr.delegates.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/lazr.delegates.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/lazr.delegates.egg-info/namespace_packages.txt b/lazr.delegates.egg-info/namespace_packages.txt
new file mode 100644
index 0000000..bc6f987
--- /dev/null
+++ b/lazr.delegates.egg-info/namespace_packages.txt
@@ -0,0 +1 @@
+lazr
diff --git a/lazr.delegates.egg-info/not-zip-safe b/lazr.delegates.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/lazr.delegates.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/lazr.delegates.egg-info/requires.txt b/lazr.delegates.egg-info/requires.txt
new file mode 100644
index 0000000..71582ad
--- /dev/null
+++ b/lazr.delegates.egg-info/requires.txt
@@ -0,0 +1,3 @@
+nose
+setuptools
+zope.interface
diff --git a/lazr.delegates.egg-info/top_level.txt b/lazr.delegates.egg-info/top_level.txt
new file mode 100644
index 0000000..bc6f987
--- /dev/null
+++ b/lazr.delegates.egg-info/top_level.txt
@@ -0,0 +1 @@
+lazr
diff --git a/lazr/__init__.py b/lazr/__init__.py
new file mode 100644
index 0000000..fc8642a
--- /dev/null
+++ b/lazr/__init__.py
@@ -0,0 +1,27 @@
+# Copyright 2008-2014 Canonical Ltd.  All rights reserved.
+#
+# This file is part of lazr.delegates.
+#
+# lazr.delegates is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# lazr.delegates is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with lazr.delegates.  If not, see <http://www.gnu.org/licenses/>.
+
+# This is a namespace package, however under >= Python 3.3, let it be a true
+# namespace package (i.e. this cruft isn't necessary).
+import sys
+
+if sys.hexversion < 0x30300f0:
+    try:
+        import pkg_resources
+        pkg_resources.declare_namespace(__name__)
+    except ImportError:
+        import pkgutil
+        __path__ = pkgutil.extend_path(__path__, __name__)
diff --git a/lazr/delegates/__init__.py b/lazr/delegates/__init__.py
new file mode 100644
index 0000000..88bee95
--- /dev/null
+++ b/lazr/delegates/__init__.py
@@ -0,0 +1,36 @@
+# Copyright 2008-2014 Canonical Ltd.  All rights reserved.
+#
+# This file is part of lazr.delegates.
+#
+# lazr.delegates is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# lazr.delegates is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with lazr.delegates.  If not, see <http://www.gnu.org/licenses/>.
+
+"""Decorator helpers that simplify class composition."""
+
+__all__ = [
+    'delegate_to',
+    ]
+
+
+import pkg_resources
+__version__ = pkg_resources.resource_string(
+    "lazr.delegates", "version.txt").strip()
+
+# The class decorator syntax is different in Python 2 vs. Python 3.
+import sys
+if sys.version_info[0] == 2:
+    from lazr.delegates._python2 import delegate_to
+    # The legacy API is only compatible with Python 2.
+    from lazr.delegates._delegates import delegates
+    __all__.append('delegates')
+else:
+    from lazr.delegates._python3 import delegate_to
diff --git a/lazr/delegates/_delegates.py b/lazr/delegates/_delegates.py
new file mode 100644
index 0000000..776bfdc
--- /dev/null
+++ b/lazr/delegates/_delegates.py
@@ -0,0 +1,111 @@
+# Copyright 2008-2014 Canonical Ltd.  All rights reserved.
+#
+# This file is part of lazr.delegates.
+#
+# lazr.delegates is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# lazr.delegates is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with lazr.delegates.  If not, see <http://www.gnu.org/licenses/>.
+
+"""Decorator helpers that simplify class composition."""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+
+__metaclass__ = type
+__all__ = [
+    'delegates',
+    ]
+
+
+import sys
+from types import ClassType
+
+from zope.interface.advice import addClassAdvisor
+from zope.interface import classImplements
+from zope.interface.interfaces import IInterface
+
+from lazr.delegates._passthrough import Passthrough
+
+
+def delegates(interface_spec, context='context'):
+    """Make an adapter into a decorator.
+
+    Use like:
+
+        class RosettaProject:
+            implements(IRosettaProject)
+            delegates(IProject)
+
+            def __init__(self, context):
+                self.context = context
+
+            def methodFromRosettaProject(self):
+                return self.context.methodFromIProject()
+
+    If you want to use a different name than "context" then you can explicitly
+    say so:
+
+        class RosettaProject:
+            implements(IRosettaProject)
+            delegates(IProject, context='project')
+
+            def __init__(self, project):
+                self.project = project
+
+            def methodFromRosettaProject(self):
+                return self.project.methodFromIProject()
+
+    The adapter class will implement the interface it is decorating.
+
+    The minimal decorator looks like this:
+
+    class RosettaProject:
+        delegates(IProject)
+
+        def __init__(self, context):
+            self.context = context
+
+    """
+    # pylint: disable-msg=W0212
+    frame = sys._getframe(1)
+    locals = frame.f_locals
+
+    # Try to make sure we were called from a class def
+    if (locals is frame.f_globals) or ('__module__' not in locals):
+        raise TypeError(
+            "delegates() can be used only from a class definition.")
+
+    locals['__delegates_advice_data__'] = interface_spec, context
+    addClassAdvisor(_delegates_advice, depth=2)
+
+
+def _delegates_advice(cls):
+    """Add a Passthrough class for each missing interface attribute.
+
+    This function connects the decorator class to the delegate class.
+    Only new-style classes are supported.
+    """
+    interface_spec, contextvar = cls.__dict__['__delegates_advice_data__']
+    del cls.__delegates_advice_data__
+    if isinstance(cls, ClassType):
+        raise TypeError(
+            'Cannot use delegates() on a classic class: %s.' % cls)
+    if IInterface.providedBy(interface_spec):
+        interfaces = [interface_spec]
+    else:
+        interfaces = interface_spec
+    not_found = object()
+    for interface in interfaces:
+        classImplements(cls, interface)
+        for name in interface:
+            if getattr(cls, name, not_found) is not_found:
+                setattr(cls, name, Passthrough(name, contextvar))
+    return cls
diff --git a/lazr/delegates/_passthrough.py b/lazr/delegates/_passthrough.py
new file mode 100644
index 0000000..a9f58f3
--- /dev/null
+++ b/lazr/delegates/_passthrough.py
@@ -0,0 +1,55 @@
+# Copyright 2008-2014 Canonical Ltd.  All rights reserved.
+#
+# This file is part of lazr.delegates.
+#
+# lazr.delegates is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# lazr.delegates is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with lazr.delegates.  If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+
+__metaclass__ = type
+__all__ = [
+    'Passthrough',
+    ]
+
+
+class Passthrough:
+    """Call the delegated class for the decorator class.
+
+    If the ``adaptation`` argument is not None, it should be a callable. It
+    will be called with the context, and should return an object that will
+    have the delegated attribute. The ``adaptation`` argument is expected to
+    be used with an interface, to adapt the context.
+    """
+    def __init__(self, name, contextvar, adaptation=None):
+        self.name = name
+        self.contextvar = contextvar
+        self.adaptation = adaptation
+
+    def __get__(self, inst, cls=None):
+        if inst is None:
+            return self
+        else:
+            context = getattr(inst, self.contextvar)
+            if self.adaptation is not None:
+                context = self.adaptation(context)
+            return getattr(context, self.name)
+
+    def __set__(self, inst, value):
+        context = getattr(inst, self.contextvar)
+        if self.adaptation is not None:
+            context = self.adaptation(context)
+        setattr(context, self.name, value)
+
+    def __delete__(self, inst):
+        raise NotImplementedError
diff --git a/lazr/delegates/_python2.py b/lazr/delegates/_python2.py
new file mode 100644
index 0000000..12f3545
--- /dev/null
+++ b/lazr/delegates/_python2.py
@@ -0,0 +1,38 @@
+# Copyright 2014 Canonical Ltd.  All rights reserved.
+#
+# This file is part of lazr.delegates.
+#
+# lazr.delegates is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# lazr.delegates is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with lazr.delegates.  If not, see <http://www.gnu.org/licenses/>.
+
+"""Class decorator definition for Python 2."""
+
+from zope.interface import classImplements
+
+from lazr.delegates._passthrough import Passthrough
+
+
+def delegate_to(*interfaces, **kws):
+    context = kws.pop('context', 'context')
+    if len(kws) > 0:
+        raise TypeError('Too many arguments')
+    if len(interfaces) == 0:
+        raise TypeError('At least one interface is required')
+    def _decorator(cls):
... 743 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/lazr.delegates.git



More information about the Python-modules-commits mailing list