Beispiel #1
0
def main(packageName, modules=(), force=0):
    """Perform the actual extraction"""
    packageModule = __import__(packageName, {}, {},
                               string.split(packageName, '.'))
    if not hasattr(packageModule, 'package'):
        # build the default package object...
        from resourcepackage import package
        packageObject = package.Package(
            packageModule.__name__,
            directory=os.path.dirname(os.path.abspath(packageModule.__file__)),
        )
    else:
        packageObject = packageModule.package
    if modules:
        for module in modules:
            packageObject.extractFile(module, force)
    else:
        packageObject.extract(force)
Beispiel #2
0
"""
try:
    __file__
except NameError:
    pass
else:
    import os
    if os.path.splitext(os.path.basename(__file__))[0] == "__init__":
        try:
            from resourcepackage import package, defaultgenerators
            generators = defaultgenerators.generators.copy()

            ### CUSTOMISATION POINT
            ## import specialised generators here, such as for wxPython
            #from resourcepackage import wxgenerators
            #generators.update( wxgenerators.generators )
        except ImportError:
            pass
        else:
            package = package.Package(
                packageName=__name__,
                directory=os.path.dirname(os.path.abspath(__file__)),
                generators=generators,
            )
            package.scan(
                ### CUSTOMISATION POINT
                ## force true -> always re-loads from external files, otherwise
                ## only reloads if the file is newer than the generated .py file.
                # force = 1,
            )