Python: module boopak.package

boopak.package | index boopak/package.py

`package: Import and export utilities for Boodler sound packages.
These functions allow a Boodler package to manage itself, its metadata,
and its dependencies. Most Python scripts in sound packages will start
with "import package".
Some of these functions are meant to be called only during a package
import operation. That is, when the package's module code is being
evaluated. You can call these functions at the module's top level, but
not later on. Do not try to call them from inside your module's functions
or methods.
Public functions:
now_building() -- locate the module which is currently being imported
get_info() -- get the PackageInfo which describes a Boodler module
get_metadata() -- get the metadata which describes a Boodler module
open_file() -- open a file by name, in a Boodler module
get_file() -- get a File by name, in a Boodler module
subimport() -- import a submodule from a Boodler module
bimport() -- import and return a Boodler sound module
bexport() -- make a module's file resources available in the module's namespace
Internal functions:
info_being_imported() -- locate the PackageInfo which is being imported`

Modules
`` |  |
boopak.pinfo | boopak.pload |  |

Functions
`` |  | bexport(resname=None) `bexport(resname=None) -> None Make a module's file resources available in the module's namespace. (This exports them, in the sense that another module will be able to look up yourmodule.file_resource to get the file.) If you provide no argument (resname=None), all file resources are loaded in. If you provide the name of a resource, it alone is loaded; if you provide the name of a resource group, all resources in that group (and subgroups) are loaded. In all cases, submodules are created where necessary. (So if the resource name is 'sub.file', your module will end up with a 'dir' submodule, if it didn't have one already.) If you plan a submodule which contains both Python code and file resources, you must call subimport() before bexport(). You may only call this from a sound module's top level.` bimport(pkgname, spec=None) `bimport(pkgname, spec=None) -> module Import and return a Boodler sound module. You must pass the fully- qualified module name. You may also supply a version specification. (If you do not, you will get the latest available version.) The spec may be a VersionSpec object, a string (representing a VersionSpec), or a VersionNumber (to request an exact version). You may only call this from a sound module's top level. (When one sound module depends on another, it generally wants to load it immediately. This ensures that dependency problems show up right away. The dependency tracking system in Boodler's package creator also relies on this pattern.) (To load packages and agents at runtime, based on user input, use Agent.load_described().)` get_file(filename, mod=None) `get_file(filename, mod=None) -> File Get a File by name, in a Boodler module. This returns a File object -- see the pinfo package -- not an open Python file. The filename should be relative to the module root, and written in universal form -- forward slashes only. An invalid or unsafe filename will raise ValueError. If no argument is given (mod=None), this gets a file from the module itself. You may only use this form from a sound module's top level. If mod is an already-imported module, this gets a file from it. You may call this form at any time. If mod is a PackageInfo, this gets a file from the module it describes.` get_info(mod=None) `get_info(mod=None) -> PackageInfo Get the PackageInfo which describes a Boodler module. If no argument is given (mod=None), this returns information about the module itself. You may only use this form from a sound module's top level. If mod is an already-imported module, this returns information about it. You may call this form at any time. If mod is a PackageInfo, this returns it. (This form exists for consistency with other functions in this package.)` get_metadata(mod=None) `get_metadata(mod=None) -> Metadata Get the metadata which describes a Boodler module. If no argument is given (mod=None), this returns metadata about the module itself. You may only use this form from a sound module's top level. If mod is an already-imported module, this returns metadata about it. You may call this form at any time. If mod is a PackageInfo, this returns metadata from the module it describes.` now_building() `now_building() -> module Locate the module which is currently being imported. You may only call this from a sound module's top level; it returns the very module in whose top level it is. This function exists because various parts of Boodler associate information with the module, and a module might want to get that information for itself.` open_file(filename, binary=False, mod=None) `open_file(filename, binary=False, mod=None) -> file Open a file by name, in a Boodler module. This is equivalent to get_file(filename, mod).open(binary). The filename should be relative to the module root, and written in universal form -- forward slashes only. An invalid or unsafe filename will raise ValueError. If no argument is given (mod=None), this opens a file from the module itself. You may only use this form from a sound module's top level. If mod is an already-imported module, this opens a file from it. You may call this form at any time. If mod is a PackageInfo, this opens a file from the module it describes.` subimport(modname, mod=None) `subimport(modname, mod=None) -> value or None Import a submodule from a Boodler sound module. This replicates the standard "import" statement. The modname may be a qualified symbol name, or '*', or a symbol name ending with '.*' If no argument is given (mod=None), this imports symbols from the module itself. You may only use this form from a sound module's top level. If mod is an already-imported module, this imports symbols from it. You may call this form at any time. If mod is a PackageInfo, this imports symbols from the module it describes. NOTE: The exact behavior of this function may change, as I figure out what it's good for. At the moment, the primary use is to allow a module to import its submodules: import package # A top-level declaration in the module: package.subimport('submodule')`

Data
`` |  | __all__ = ['now_building', 'get_info', 'get_metadata', 'open_file', 'get_file', 'subimport', 'bimport', 'bexport']