Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(3)  |  Derive(0)  |  Import(2)
Mangle C{identifier} as how would be done if it appeared in a class with
C{class_name}.  This function allows to mimic standard Python mangling of

end in two.  If C{identifier} is not considered a private name, it is returned
unchanged.

@param  class_name: name of Python class.
@type   class_name: C{basestring}

@param  identifier: name of an attribute of that class.(more...)

        def mangle_identifier (class_name, identifier):
    """
    Mangle C{identifier} as how would be done if it appeared in a class with
    C{class_name}.  This function allows to mimic standard Python mangling of
    pseudo-private attributes, i.e. those which names start with two underscores and donít
    end in two.  If C{identifier} is not considered a private name, it is returned
    unchanged.

    @param  class_name: name of Python class.
    @type   class_name: C{basestring}

    @param  identifier: name of an attribute of that class.
    @type   identifier: C{basestring}

    @rtype: C{str}

    @raises ValueError: if either C{class_name} or C{identifier} is not valid from
                        Pythonís point of view.
    """

    if not (is_valid_identifier (class_name) and is_valid_identifier (identifier)):
        raise ValueError ("'class_name' and 'identifier' must be valid Python identifiers")

    if (identifier.startswith ('__')
        and not identifier.endswith ('__')
        and class_name != '_' * len (class_name)):
        return '_%s%s' % (class_name.lstrip ('_'), identifier)
    else:
        return identifier
        


src/p/y/py-notify-0.3.1/notify/base.py   py-notify(Download)
from notify.mediator import AbstractMediator
from notify.signal   import AbstractSignal, Signal
from notify.utils    import execute, is_callable, is_valid_identifier, mangle_identifier, \
                            raise_not_implemented_exception, StringType
 
                raise ValueError ("'%s' is not a valid Python identifier" % object)
 
            yield '__slots__', mangle_identifier (options['new_class_name'], object)
 
            execute (('def __init__(self, %s):\n'
 
                execute ('%s = property (lambda self: %s)'
                         % (mangle_identifier (options['new_class_name'], property),
                            AbstractValueObject._get_object (options)),
                         functions)
 
        if 'object' in options:
            return 'self.%s' % mangle_identifier (options['new_class_name'], options['object'])
        else:
            return 'self'

src/p/y/py-notify-0.3.1/test/utils.py   py-notify(Download)
import unittest
 
from notify.utils import is_callable, is_valid_identifier, mangle_identifier, as_string, \
                         raise_not_implemented_exception, DummyReference