5.4. sourceinfo.helper¶
pysourceinfo.helper - miscellaneous utilities - details see manuals
The provided interfaces are foreseen for the bottom layer of the software stack, thus provide basic handling only. This includes special cases of the file system parameters. For more advanced file system path processing refer to filesysobjects.
5.4.1. Functions¶
5.4.1.1. getfilepathname_type¶
5.4.1.2. getpythonpath¶
-
sourceinfo.helper.
getpythonpath
(pname, plist=None, **kw)[source]¶ Matches prefix from sys.path. Foreseen to be used for canonical base references in unit tests. This enables in particular for generic tests of file system positions where originally absolute pathnames were required.
- Parameters
pname – Path name to be searched an appropriate pythonpath prefix for, either absolute or relative to an item of plist.
plist –
List of possible python paths. Alternative to sys.path.
default := sys.path
kw –
- ispre:
If True adds a postfix path separator.
- presolve:
Defines the path resolution strategy:
presolve := ( P_FIRST | P_LAST | P_LONGEST | P_SHORTEST )
The default is stored in:
sourceinfo.presolve = P_FIRST
- verify:
Verify against the filesystem, else no checks are done.
default := True
- Returns
Returns the first matching path prefix from sys.path, as ‘normpath’. Else:
ispre == True: returns empty str - '' else: returns None
- Raises
pass-through –
5.4.1.3. getpythonpath_rel¶
-
sourceinfo.helper.
getpythonpath_rel
(pname, plist=None, **kw)[source]¶ Verifies an absolute or relative path name to be reachable as a relative path to one item of the search list plist.
- Parameters
pname – Path name of a path searched for relative to an item of plist. Absolute is cut, relative is searched literally.
plist –
Search path alternative to sys.path.
default := sys.path
kargs –
- presolve:
The type of path resolution:
pname is relative: presolve := ( P_FIRST ) pname is absolute: presolve := ( P_FIRST | P_LAST | P_LONGEST | P_SHORTEST )
default := pysourceinfo.presolve(P_FIRST)
- raw:
If True suppresses the call of ‘os.path.normpath()’:
raw := ( True # keep e.g. multiple and trailing *os.sep* | False # apply os.path.normpath() ) default := False
- normpath:
The method to be called for the normalization of the provided input path. This is in particular required when cross-platform path strings are provided. These are by default processed internally with the os.sep of the current platform only.
The API is as defined by ‘os.path.normpath’:
normapth := ( <custom-call> | <default-call> ) custom-call := ( ntpath | posixpath | <any-compatible-api> ) default-call := os.path.normpath
- verify:
Verify against the file system, else no checks are done.
default := True
- Returns
First matched path from sys.path as normalized path. Else:
if PYTHONPATH[i] == pname: returns empty str - '' else: if verify: raise SourceInfoError else: returns None
- Raises
pass-through –
5.4.1.4. getpythonpath_rel_oid¶
-
sourceinfo.helper.
getpythonpath_rel_oid
(pname, plist=None, **kw)[source]¶ Calls getpythonpath_rel, returns the relative path as dotted OID relative to the search path.
- Parameters
interface parameters refer to:: (For) – sourceinfo.helper.getpythonpath_rel()
kargs –
For remaining parameters refer to getpythonpath_rel.
- restype:
Result type:
restype = ( OID_STR # OID as dottedt string representation | OID_TUPLE # OID as tuple | OID_LIST # OID as list ) default := OID_STR
- sepin:
The path separator:
default := os.sep
The function internally checks the presence of the provided path. This is not cross-converted, thus requires native separator characters. While the NT file system supports multiple separators, the posix based file systems support regularly the slash ‘/’ only. Thus these fail when other separator characters are provided. For advanced cross-capabilities refer to filesysobjects.
- sepout:
The path separator:
default := '.'
- Returns
Returns the provided result by getpythonpath_rel in accordance to the requested result type - see restype.
- Raises
pass-through –
5.4.1.5. getstack_frame¶
5.4.1.6. getstack_len¶
5.4.1.7. matchpath¶
-
sourceinfo.helper.
matchpath
(path, pathlist=None, pmatch=1)[source]¶ Match a file pathname of pathname on a pathlist.
- Parameters
path – Path to be searched in pathlist.
pathlist –
Search path for a given path.
default := sys.path
pmatch –
Match criteria for search.
pmatch := ( P_FIRST, P_LAST, P_SHORTEST, P_LONGEST, P_IGNORE0 )
default := P_FIRST
- Returns
Returns the matched pathname from pathlist.
- Raises
pass-through –