Commit 1ceb707f authored by Daniel Stender's avatar Daniel Stender

New upstream version 1.4

parent 1aac63f4
# These lines are suggested according to the svn:ignore property
# Feel free to enable them by uncommenting them
syntax:glob
*.pyc
*.pyo
*.swp
*.html
*.class
.tox
build
dist
apipkg.egg-info
.cache/
.eggs/
.env/
4e25c6a58cb618bdcd061289dd66b3ceb11a495a 1.0.0b5
976aa691cfaeeb9793057d09ae9f9e6fd162be69 1.0b5
6cb3976c8d8aac3d332ed8f507cfdad34b4279a1 1.0b6
d83f3dccbd847d054cacaaca24f4a93e04f57219 1.0
99c97a16360ab551455e00861c3e92269d3fa3f7 1.2
82fd1ef6991cfb25b903944684291bf146c86f95 1.3
Metadata-Version: 1.1
Name: apipkg
Version: 1.4
Summary: apipkg: namespace control and lazy-import mechanism
Home-page: http://bitbucket.org/hpk42/apipkg
Author: holger krekel
Author-email: holger at merlinux.eu
License: MIT License
Description: Welcome to apipkg!
------------------------
With apipkg you can control the exported namespace of a
python package and greatly reduce the number of imports for your users.
It is a `small pure python module`_ that works on virtually all Python
versions, including CPython2.3 to Python3.1, Jython and PyPy. It co-operates
well with Python's ``help()`` system, custom importers (PEP302) and common
command line completion tools.
Usage is very simple: you can require 'apipkg' as a dependency or you
can copy paste the <200 Lines of code into your project.
Tutorial example
-------------------
Here is a simple ``mypkg`` package that specifies one namespace
and exports two objects imported from different modules::
# mypkg/__init__.py
import apipkg
apipkg.initpkg(__name__, {
'path': {
'Class1': "_mypkg.somemodule:Class1",
'clsattr': "_mypkg.othermodule:Class2.attr",
}
}
The package is initialized with a dictionary as namespace.
You need to create a ``_mypkg`` package with a ``somemodule.py``
and ``othermodule.py`` containing the respective classes.
The ``_mypkg`` is not special - it's a completely
regular python package.
Namespace dictionaries contain ``name: value`` mappings
where the value may be another namespace dictionary or
a string specifying an import location. On accessing
an namespace attribute an import will be performed::
>>> import mypkg
>>> mypkg.path
<ApiModule 'mypkg.path'>
>>> mypkg.path.Class1 # '_mypkg.somemodule' gets imported now
<class _mypkg.somemodule.Class1 at 0xb7d428fc>
>>> mypkg.path.clsattr # '_mypkg.othermodule' gets imported now
4 # the value of _mypkg.othermodule.Class2.attr
The ``mypkg.path`` namespace and its two entries are
loaded when they are accessed. This means:
* lazy loading - only what is actually needed is ever loaded
* only the root "mypkg" ever needs to be imported to get
access to the complete functionality.
* the underlying modules are also accessible, for example::
from mypkg.sub import Class1
Including apipkg in your package
--------------------------------------
If you don't want to add an ``apipkg`` dependency to your package you
can copy the `apipkg.py`_ file somewhere to your own package,
for example ``_mypkg/apipkg.py`` in the above example. You
then import the ``initpkg`` function from that new place and
are good to go.
.. _`small pure python module`:
.. _`apipkg.py`: http://bitbucket.org/hpk42/apipkg/src/tip/apipkg.py
Feedback?
-----------------------
If you have questions you are welcome to
* join the #pylib channel on irc.freenode.net
* subscribe to the http://codespeak.net/mailman/listinfo/py-dev list.
* create an issue on http://bitbucket.org/hpk42/apipkg/issues
have fun,
holger krekel
Platform: unix
Platform: linux
Platform: osx
Platform: cygwin
Platform: win32
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python
.hgignore
.hgtags
CHANGELOG
LICENSE
MANIFEST.in
README.txt
apipkg.py
setup.cfg
setup.py
test_apipkg.py
tox.ini
apipkg.egg-info/PKG-INFO
apipkg.egg-info/SOURCES.txt
apipkg.egg-info/dependency_links.txt
apipkg.egg-info/top_level.txt
example/_mypkg/__init__.py
example/_mypkg/othermodule.py
example/_mypkg/somemodule.py
example/mypkg/__init__.py
example/mypkg/othermodule.py
example/mypkg/somemodule.py
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment