Skip to content

Commit

Permalink
Big doc revamp - get it working with epydoc again.
Browse files Browse the repository at this point in the history
  • Loading branch information
njoyce committed Aug 3, 2010
1 parent 0eef93d commit 392c37e
Show file tree
Hide file tree
Showing 32 changed files with 380 additions and 543 deletions.
4 changes: 2 additions & 2 deletions cpyamf/codec.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ cdef class Context(object):
Returns the corresponding unicode object for a given string. If there
is no unicode object, one is created.
:since: 0.6
@since: 0.6
"""
cdef object h = hash(s)
cdef object ret = self.unicodes.get(h, None)
Expand All @@ -279,7 +279,7 @@ cdef class Context(object):
Returns the corresponding utf-8 encoded string for a given unicode
object. If there is no string, one is encoded.
:since: 0.6
@since: 0.6
"""
cdef object h = hash(u)
cdef object ret = self.unicodes.get(h, None)
Expand Down
2 changes: 1 addition & 1 deletion cpyamf/util.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
C-extension for L{pyamf.util} Python module in L{PyAMF<pyamf>}.
:since: 0.4
@since: 0.4
"""

from cpython cimport *
Expand Down
2 changes: 1 addition & 1 deletion ez_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
If you want to require a specific version of setuptools, set a download
mirror, or use an alternate download directory, you can do so by supplying
the appropriate options to ``use_setuptools()``.
the appropriate options to C{use_setuptools()}.
This file can also be run as a script to install or upgrade setuptools.
"""
Expand Down
38 changes: 19 additions & 19 deletions pyamf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# See LICENSE.txt for details.

"""
L{PyAMF<http://pyamf.org>} provides Action Message Format (L{AMF
U{PyAMF<http://pyamf.org>} provides Action Message Format (U{AMF
<http://en.wikipedia.org/wiki/Action_Message_Format>}) support for Python that
is compatible with the Adobe L{Flash Player
is compatible with the Adobe U{Flash Player
<http://en.wikipedia.org/wiki/Flash_Player>}.
@since: October 2007
Expand Down Expand Up @@ -111,7 +111,7 @@ class UnknownClassAlias(BaseError):
Raised if the AMF stream specifies an Actionscript class that does not
have a Python class alias.
@see L{register_class}
@see: L{register_class}
"""


Expand Down Expand Up @@ -658,11 +658,11 @@ def getCustomProperties(self):
@since: 0.5
"""

def createInstance(self, codec=None, *args, **kwargs):
def createInstance(self, codec=None):
"""
Creates an instance of the klass.
@return: Instance of L{self.klass}.
@return: Instance of C{self.klass}.
"""
if type(self.klass) is type:
return self.klass.__new__(self.klass)
Expand All @@ -679,7 +679,7 @@ class TypedObject(dict):
data. If encountered, a L{DecodeError} will be raised.
@ivar alias: The alias of the typed object.
@type alias: L{string}
@type alias: C{string}
@since: 0.4
"""

Expand Down Expand Up @@ -816,20 +816,20 @@ def register_class_loader(loader):
If the loader succeeds in finding a suitable class then it should return
that class, otherwise it should return C{None}.
An example:
An example::
def lazy_load_from_my_module(alias):
if not alias.startswith('foo.bar.'):
return None
def lazy_load_from_my_module(alias):
if not alias.startswith('foo.bar.'):
return None
from foo import bar
from foo import bar
if alias == 'foo.bar.Spam':
return bar.Spam
elif alias == 'foo.bar.Eggs':
return bar.Eggs
if alias == 'foo.bar.Spam':
return bar.Spam
elif alias == 'foo.bar.Eggs':
return bar.Eggs
pyamf.register_class_loader(lazy_load_from_my_module)
pyamf.register_class_loader(lazy_load_from_my_module)
"""
if not hasattr(loader, '__call__'):
raise TypeError("loader must be callable")
Expand Down Expand Up @@ -865,7 +865,7 @@ def load_class(alias):
@raise UnknownClassAlias: The C{alias} was not found.
@raise TypeError: Expecting class type or L{ClassAlias} from loader.
@return: Class registered to the alias.
@rtype: L{classobj}
@rtype: C{classobj}
"""
# Try the CLASS_CACHE first
try:
Expand Down Expand Up @@ -1013,7 +1013,7 @@ def blaze_loader(alias):
Loader for BlazeDS framework compatibility classes, specifically
implementing C{ISmallMessage}.
@see: L{BlazeDS <http://opensource.adobe.com/wiki/display/blazeds/BlazeDS>}
@see: U{BlazeDS<http://opensource.adobe.com/wiki/display/blazeds/BlazeDS>}
@since: 0.5
"""
if alias not in ['DSC', 'DSK']:
Expand Down Expand Up @@ -1197,7 +1197,7 @@ def check_type_registered(arg):

def unregister_alias_type(klass):
"""
Removes the klass from the L{ALIAS_TYPE} register.
Removes the klass from the L{ALIAS_TYPES} register.
@see: L{register_alias_type}
"""
Expand Down
16 changes: 7 additions & 9 deletions pyamf/adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The adapter package provides additional functionality for other Python
packages. This includes registering classes, setting up type maps etc.
:since: 0.1.0
@since: 0.1.0
"""

import os.path
Expand Down Expand Up @@ -62,19 +62,17 @@ def register_adapter(mod, func):
executed in the order they were registered. The root module must exist
(i.e. be importable) otherwise an `ImportError` will be thrown.
:param mod: The fully qualified module string, as used in the imports
@param mod: The fully qualified module string, as used in the imports
statement. E.g. 'foo.bar.baz'. The string must map to a module
otherwise the callable will not fire.
:type mod: `str`
:param func: The function to call when `mod` is imported. This function
must take one arg, the newly imported `module` object.
:type func: callable
:raise TypeError: `func` must be callable
@param func: The function to call when C{mod} is imported. This function
must take one arg, the newly imported C{module} object.
@type func: callable
"""
if not callable(func):
if not hasattr(func, '__call__'):
raise TypeError('func must be callable')

imports.when_imported(str(mod), func)
imports.when_imported(mod, func)


def get_adapter(mod):
Expand Down
4 changes: 2 additions & 2 deletions pyamf/adapters/_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See LICENSE.txt for details.

"""
`array` adapter module.
U{array<http://docs.python.org/library/array.html>} adapter module.
Will convert all array.array instances to a python list before encoding. All
type information is lost (but degrades nicely).
Expand All @@ -16,5 +16,5 @@
from pyamf.adapters import util


if hasattr(array, 'array'):
if hasattr(array, 'ArrayType'):
pyamf.add_type(array.ArrayType, util.to_list)
2 changes: 1 addition & 1 deletion pyamf/adapters/_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See LICENSE.txt for details.

"""
collections adapter module.
U{collections<http://docs.python.org/library/collections.html>} adapter module.
@since: 0.5
"""
Expand Down
11 changes: 5 additions & 6 deletions pyamf/adapters/_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See LICENSE.txt for details.

"""
Adapter for the C{decimal} module.
Adapter for the U{decimal<http://docs.python.org/library/decimal.html>} module.
@since: 0.4
"""
Expand All @@ -14,12 +14,10 @@

def convert_Decimal(x, encoder):
"""
Called when an instance of L{decimal.Decimal} is about to be encoded to
an AMF stream.
Called when an instance of U{decimal.Decimal<http://
docs.python.org/library/decimal.html#decimal-objects>} is about to be
encoded to an AMF stream.
@param x: The L{decimal.Decimal} instance to encode.
@param encoder: The L{pyamf.BaseEncoder} instance about to perform the
operation.
@return: If the encoder is in 'strict' mode then C{x} will be converted to
a float. Otherwise an L{pyamf.EncodeError} with a friendly message is
raised.
Expand All @@ -31,5 +29,6 @@ def convert_Decimal(x, encoder):
'there is no way to guarantee exact conversion. Use strict=False to '
'convert to a float.')


if hasattr(decimal, 'Decimal'):
pyamf.add_type(decimal.Decimal, convert_Decimal)
38 changes: 17 additions & 21 deletions pyamf/adapters/_django_db_models_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
# See LICENSE.txt for details.

"""
`django.db.models` adapter module.
C{django.db.models} adapter module.
:see: `Django Project <http://www.djangoproject.com>`_
:since: 0.4.1
@see: U{Django Project<http://www.djangoproject.com>}
@since: 0.4.1
"""

from django.db.models.base import Model
Expand All @@ -23,7 +22,7 @@ class DjangoReferenceCollection(dict):
This helper class holds a dict of klass to pk/objects loaded from the
underlying db.
:since: 0.5
@since: 0.5
"""

def _getClass(self, klass):
Expand All @@ -36,12 +35,12 @@ def getClassKey(self, klass, key):
"""
Return an instance based on klass/key.
If an instance cannot be found then `KeyError` is raised.
If an instance cannot be found then C{KeyError} is raised.
:param klass: The class of the instance.
:param key: The primary_key of the instance.
:return: The instance linked to the `klass`/`key`.
:rtype: Instance of `klass`.
@param klass: The class of the instance.
@param key: The primary_key of the instance.
@return: The instance linked to the C{klass}/C{key}.
@rtype: Instance of C{klass}.
"""
d = self._getClass(klass)

Expand All @@ -51,9 +50,9 @@ def addClassKey(self, klass, key, obj):
"""
Adds an object to the collection, based on klass and key.
:param klass: The class of the object.
:param key: The datastore key of the object.
:param obj: The loaded instance from the datastore.
@param klass: The class of the object.
@param key: The datastore key of the object.
@param obj: The loaded instance from the datastore.
"""
d = self._getClass(klass)

Expand Down Expand Up @@ -225,14 +224,11 @@ def getDecodableAttributes(self, obj, attrs, **kwargs):

def getDjangoObjects(context):
"""
Returns a reference to the `django_objects` on the context. If it doesn't
Returns a reference to the C{django_objects} on the context. If it doesn't
exist then it is created.
:param context: The context to load the `django_objects` index from.
:type context: Instance of :class:`pyamf.BaseContext`
:return: The `django_objects` index reference.
:rtype: Instance of :class:`DjangoReferenceCollection`
:since: 0.5
@rtype: Instance of L{DjangoReferenceCollection}
@since: 0.5
"""
c = context.extra
k = 'django_objects'
Expand All @@ -248,7 +244,7 @@ def getDjangoObjects(context):
def writeDjangoObject(obj, encoder=None):
"""
The Django ORM creates new instances of objects for each db request.
This is a problem for PyAMF as it uses the id(obj) of the object to do
This is a problem for PyAMF as it uses the C{id(obj)} of the object to do
reference checking.
We could just ignore the problem, but the objects are conceptually the
Expand All @@ -259,7 +255,7 @@ def writeDjangoObject(obj, encoder=None):
C{object.__class__: {key1: object1, key2: object2, .., keyn: objectn}}. We
use the primary key to do the reference checking.
:since: 0.5
@since: 0.5
"""
s = obj.pk

Expand Down
2 changes: 1 addition & 1 deletion pyamf/adapters/_elixir.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
Elixir adapter module. Elixir adds a number of properties to the mapped instances.
@see: U{Elixir homepage (external)<http://elixir.ematia.de>}
@see: U{Elixir homepage<http://elixir.ematia.de>}
@since: 0.6
"""

Expand Down
11 changes: 6 additions & 5 deletions pyamf/adapters/_google_appengine_ext_blobstore.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright (c) 2007-2009 The PyAMF Project.
# Copyright (c) The PyAMF Project.
# See LICENSE.txt for details.

"""
Adapter module for L{google.appengine.ext.blobstore}.
Adapter module for U{google.appengine.ext.blobstore<http://
code.google.com/appengine/docs/python/blobstore/}.
@since: 0.6
"""
Expand All @@ -17,15 +18,15 @@

class BlobInfoStub(object):
"""
Since L{blobstore.BlobInfo} requires __init__ args, we stub the object until
Since C{blobstore.BlobInfo} requires __init__ args, we stub the object until
C{applyAttributes} is called which then magically converts it to the correct
type.
"""


class BlobInfoClassAlias(pyamf.ClassAlias):
"""
Fine grain control over L{blobstore.BlobInfo} instances. Required to encode
Fine grain control over C{blobstore.BlobInfo} instances. Required to encode
the C{key} attribute correctly.
"""

Expand All @@ -48,7 +49,7 @@ def getEncodableAttributes(self, obj, codec=None):

def applyAttributes(self, obj, attrs, **kwargs):
"""
Applies C{attrs} to C{obj}. Since L{blobstore.BlobInfo} objects are
Applies C{attrs} to C{obj}. Since C{blobstore.BlobInfo} objects are
read-only entities, we only care about the C{key} attribute.
"""
assert type(obj) is BlobInfoStub
Expand Down
Loading

0 comments on commit 392c37e

Please sign in to comment.