‘filesysobjects.configdata’ - Module¶
The filesysobjects.configdata module provides configuration related filesystem paths. For examples see HowTo Config Data.
Module¶
Platform independent path names for configuration files.
Class ConfigPath¶
-
class
filesysobjects.configdata.
ConfigPath
(**kargs)[source]¶ A small class that manages the search for configuration files located at standard paths.
Methods¶
__init__¶
-
ConfigPath.
__init__
(**kargs)[source]¶ Initializes the search paths.
- Args:
kargs:
- append:
- A list of search paths to be added to the standard search.
- filext:
A list of default file extensions to be used in search operations. Default
filext := [ini', 'conf', 'json', 'xml']
- prepend:
- A list of search paths to be checked at the beginning of the standard search.
- replace:
- A list of search paths to replace the standard search.
- Returns:
- object/None
- Raises:
- pass-through
get_config_path_list¶
get_config_filepath¶
-
ConfigPath.
get_config_filepath
(conf)[source]¶ Returns the first matched configuration file.
The standard search hierarchy is:
- absolute file path: <conf>
- relative to current workdir: <conf>
- USER context by: getdir_userconfigdata()/<conf>
- HOME of user: getdir_userhome()/<conf>
- Application config: getdir_osappconfigdata()/<conf>
- OS config: getdir_osappconfigdata()/<conf>
- the final default from distribution:
- pysourceinfo.fileinfo.getcaller_package_filepathname()/<conf>
- the final default from module:
- pysourceinfo.fileinfo.getcaller_pathname()/<conf>
The priorities 6 + 7 are the last, because the caller itself could be a library sub call, so is not necessarily closely related to the calling application.
This could be altered by the parameters replace, prepend, and append.
if replace: replace standard by list if prepend: prepend any list(standard/replace) if append: append to any list(standard/replace)
- Args:
- conf:
Configuration file name including suffix. Valid conf file name wildcard types are:
literal X re – glob X
- Returns:
- The first file path name matched by conf, else None.
- Raises:
- pass-through
get_config_filepath_list¶
-
ConfigPath.
get_config_filepath_list
(conf=None, **kargs)[source]¶ Returns a list of matched configuration files.
- Args:
- conf:
Search expression for configuration file names. Valid conf file name wildcard types are:
literal X re – glob X - kargs:
- isDir:
Include directories.
default := False
- isFile:
Include files.
default := True
- Returns:
- A list of file path names matched by ‘conf’.
- Raises:
- pass-through
get_filepathname_by_ext¶
-
ConfigPath.
get_filepathname_by_ext
(fnam, fext=[])[source]¶ Gets the file path name by specified list of extensions. Searches the defined path list by self, returns the first match.
- Args:
- fnam:
File name. Valid types are
fnam := ( <absolute-file-path-name> | <relative-file-path-name> | <filename-with-suffix> | <filename-without-suffix> )
Matches of file path name without additional suffix are returned immediately.
Valid fnam file name wildcard types are:
literal X re – glob X - fext:
- File extension list. Each will be returned in the order of the provided extensions, grouped in the order of the provided search paths.
- Returns:
- The first found absolute file path name.
- Raises:
- pass-through
Exceptions¶
Currently only passed-through.