Lines Matching full:package
5 :synopsis: Package resource reading, opening, and access
14 within *packages*. If you can import a package, you can access resources
15 within that package. Resources can be opened or read, in either binary or
21 for example, a package and its resources can be imported from a zip file using
30 without the performance overhead of that package. This makes reading
44 .. data:: Package
46 Whenever a function accepts a ``Package`` argument, you can pass in
51 The ``Package`` type is defined as ``Union[str, ModuleType]``.
53 .. function:: files(package)
56 representing the resource container for the package (think directory)
60 *package* is either a name or a module object which conforms to the
61 :data:`Package` requirements.
87 directories: they assume all resources are located directly within a *package*.
97 .. function:: open_binary(package, resource)
99 Open for binary reading the *resource* within *package*.
101 *package* is either a name or a module object which conforms to the
102 ``Package`` requirements. *resource* is the name of the resource to open
103 within *package*; it may not contain path separators and it may not have
111 files(package).joinpath(resource).open('rb')
114 .. function:: open_text(package, resource, encoding='utf-8', errors='strict')
116 Open for text reading the *resource* within *package*. By default, the
119 *package* is either a name or a module object which conforms to the
120 ``Package`` requirements. *resource* is the name of the resource to open
121 within *package*; it may not contain path separators and it may not have
132 files(package).joinpath(resource).open('r', encoding=encoding)
135 .. function:: read_binary(package, resource)
137 Read and return the contents of the *resource* within *package* as
140 *package* is either a name or a module object which conforms to the
141 ``Package`` requirements. *resource* is the name of the resource to open
142 within *package*; it may not contain path separators and it may not have
150 files(package).joinpath(resource).read_bytes()
153 .. function:: read_text(package, resource, encoding='utf-8', errors='strict')
155 Read and return the contents of *resource* within *package* as a ``str``.
158 *package* is either a name or a module object which conforms to the
159 ``Package`` requirements. *resource* is the name of the resource to open
160 within *package*; it may not contain path separators and it may not have
169 files(package).joinpath(resource).read_text(encoding=encoding)
172 .. function:: path(package, resource)
181 *package* is either a name or a module object which conforms to the
182 ``Package`` requirements. *resource* is the name of the resource to open
183 within *package*; it may not contain path separators and it may not have
190 as_file(files(package).joinpath(resource))
193 .. function:: is_resource(package, name)
195 Return ``True`` if there is a resource named *name* in the package,
198 *package* is either a name or a module object which conforms to the
199 ``Package`` requirements.
205 files(package).joinpath(resource).is_file()
208 .. function:: contents(package)
210 Return an iterable over the named items within the package. The iterable
214 *package* is either a name or a module object which conforms to the
215 ``Package`` requirements.
221 (resource.name for resource in files(package).iterdir() if resource.is_file())