5.5. yapyutils.files.finder¶
5.5.1. Module¶
yapyutils.files.finder provides file locations.
5.5.2. Functions¶
5.5.2.1. find_files¶
-
yapyutils.files.finder.
find_files
(srcdir, *wildcards, **kargs)[source]¶ Assembles a list of package files for package_files.
- Parameters
srcdir – Source root.
*wildcards – List of globs.
kargs –
- single_level:
Flat only.
- subpath:
Cut topmost path elemenr from listelements, special for dictionaries.
- nopostfix:
Drop filename postfix.
- packages:
List packages only, else files.
- yield_folders:
List folders only.
- Returns
Results in an list.
- Raises
pass-through –
5.5.2.2. get_filelocation¶
-
yapyutils.files.finder.
get_filelocation
(fname, spaths=None)[source]¶ A very basic function for the detection of the absolute path and the relative module search-path-name for a given path of a module. The values are the same as would be present in sys.modules. Supports source modules as input only.
The platformids is a low-level library within the software stack. The generic functions for the allocation of module sources and binaries are provided by sourceinfo [sourceinfo], which itself depends on the platformids. Thus sourceinfo could not be used in order to avoid circular dependencies. So implemented this function to keep platformids on lowest possible software-stack level only.
- Parameters
fname –
The relative path of the module in dotted Python notation, without file suffix.
mname := ( <dotted-module-name-str> | <dotted-module-name-path-name-str> )
spaths –
List of search paths,
default := sys.path + os.environ['PATH'].split(os.pathsep)
- Returns
match -> (<abs-file-path>, <file-name>,)
The default when no match occured is to rely on the more versatile search mechanism of the import implementation of the concrete Python implementation for another final trial by the caller:
default -> ('', <fime-name>,)
- Return type
Returns in case of a match the resulting entry within sys.modules
- Raises
PlatformIDsError – ‘mbase’ does not match ‘mpaths’
PlatformIDsPresentError – missing ‘mbase’
pass-through –
5.5.2.3. get_filesysposition¶
-
yapyutils.files.finder.
get_filesysposition
(rfpname, toppath=None, spaths=None)[source]¶ Loads the specified module by it’s name and file system path. Provides a common interface for all supported platforms and Python implementations: CPyhton, IPython, IronPython, Jython, and PyPy. For the syntaxversions Python2.7 and Python3.
- Parameters
rfpname – File path name of file to be searched, which is either absolute, or relative. An absolute file path is vallidated only, while a relative is searched within the set of spaths, which are resolved iterative from longest upward. The limiting top node is toppath as the highest valid hook for ‘rfpname’ as subpath.
toppath – The constraint of the top level for the search operation.
spaths –
The list of search paths as insertion points of the subpath ‘rfpname’:
default := [ os.getcwd(),] \ + sys.path \ + os.environ['PATH'].split(os.pathsep)
- Returns
The module object on success:
res := (<path-name>, <filename>)
else:
res := ('', '')
- Raises
PlatformIDsError –
pass-through –