python-fhs
Python module for using the FHS and XDG basedir paths.
Loading...
Searching...
No Matches
fhs.py File Reference

Go to the source code of this file.

Namespaces

namespace  fhs

Functions

 fhs.write_config (name=None, text=True, dir=False, opened=True, packagename=None)
 Open a config file for writing.
 fhs.read_config (name=None, text=True, dir=False, multiple=False, opened=True, packagename=None)
 Open a config file for reading.
 fhs.remove_config (name=None, dir=False, packagename=None)
 Remove a config file.
 fhs.decode_value (value, argtype)
 Parse a string value into its proper type.
 fhs.encode_value (value)
 Encode a value into a string which can be stored in a config file.
 fhs.help_text (main, options, option_order)
 fhs.version_text ()
 fhs.load_config (filename, values=None, present=None, options=None)
 fhs.save_config (config, name=None, packagename=None)
 Save a dict as a configuration file.
 fhs.option (name, help, short=None, multiple=False, optional=False, default=None, noarg=None, argtype=None, module=None, options=None, option_order=None)
 Register commandline argument.
 fhs.parse_args (argv=None, options=None, extra=False)
 fhs.init (config=None, help=None, version=None, contact=None, packagename=None, system=None, game=False)
 Initialize the module.
 fhs.get_config (extra=False)
 Retrieve commandline configuration.
 fhs.module_info (modulename, desc, version, contact)
 Register information about a module.
 fhs.module_option (modulename, name, help, short=None, multiple=False, optional=False, default=None, noarg=None, argtype=None, options=None, option_order=None)
 Register a commandline option for a module.
 fhs.module_init (modulename, config)
 Add configuration for a module.
 fhs.module_get_config (modulename, extra=False)
 Retrieve module configuration.
 fhs.write_runtime (name=None, text=True, dir=False, opened=True, packagename=None)
 Open a runtime file for writing.
 fhs.read_runtime (name=None, text=True, dir=False, opened=True, packagename=None)
 Open a runtime file for reading.
 fhs.remove_runtime (name=None, dir=False, packagename=None)
 Remove a reuntime file or directory.
 fhs.write_temp (dir=False, text=True, packagename=None)
 Open a temporary file for writing.
 fhs.remove_temp (name)
 Remove a temporary directory.
 fhs.write_data (name=None, text=True, dir=False, opened=True, packagename=None)
 Open a data file for writing.
 fhs.read_data (name=None, text=True, dir=False, multiple=False, opened=True, packagename=None)
 Open a data file for reading.
 fhs.remove_data (name=None, dir=False, packagename=None)
 Remove a data file.
 fhs.write_cache (name=None, text=True, dir=False, opened=True, packagename=None)
 Open a cache file for writing.
 fhs.read_cache (name=None, text=True, dir=False, opened=True, packagename=None)
 Open a cache file for reading.
 fhs.remove_cache (name=None, dir=False, packagename=None)
 Remove a cache file.
 fhs.write_log (name=None, packagename=None)
 Open a log file for writing.
 fhs.write_spool (name=None, text=True, dir=False, opened=True, packagename=None)
 Open a spool file for writing.
 fhs.read_spool (name=None, text=True, dir=False, opened=True, packagename=None)
 Open a spool file for reading.
 fhs.remove_spool (name=None, dir=False, packagename=None)
 Remove a spool file.
 fhs.lock (name=None, info='', packagename=None)
 Acquire a lock.
 fhs.unlock (name=None, packagename=None)
 Release a lock.

Variables

bool fhs.initialized = False
 Flag that is set to True when init() is called.
bool fhs.is_system = False
 Flag that is set during init() if –system was specified, or the application set the system parameter to init().
bool fhs.is_game = False
 Flag that is set during init() if the application set the game parameter to init().
 fhs.pname = os.getenv('PACKAGE_NAME', os.path.basename(sys.argv[0]))
 Default program name; can be overridden from functions that use it.
 fhs.HOME = os.path.expanduser('~')
 Current user's home directory.
 fhs.XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config'))
 XDG home directory.
 fhs.XDG_CONFIG_DIRS = tuple([XDG_CONFIG_HOME] + os.getenv('XDG_CONFIG_DIRS', '/etc/xdg').split(':'))
 XDG config directory search path.
 fhs.XDG_RUNTIME_DIR = os.getenv('XDG_RUNTIME_DIR')
 XDG runtime directory.
 fhs.XDG_DATA_HOME = os.getenv('XDG_DATA_HOME', os.path.join(HOME, '.local', 'share'))
 XDG data directory.
 fhs.XDG_DATA_DIRS = os.getenv('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':')
 XDG data directory search path.
 fhs.XDG_CACHE_HOME = os.getenv('XDG_CACHE_HOME', os.path.join(HOME, '.cache'))
 XDG cache directory.