Name | config-path JSON |
Version |
1.0.5
JSON |
| download |
home_page | |
Summary | config_path is a library to work with paths to config folders and files in an OS independent way |
upload_time | 2023-10-03 19:41:43 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.10 |
license | Apache-2.0 |
keywords |
development
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# config-path
Python library to work out which path to use for configuration folders
and files in an operating system independent way.
Each operating system has particular conventions for where an application is expected
to stores it configuration. The information provided to ConfigPath is used
to figure out an appropiate file path or folder path for the application's
configuration data.
Supports Windows, macOS and most unix systems using the 'XDG Base Directory Specification'.
~~~~
ConfigPath( appname, vendor, filetype )
~~~~
The `vendor` should be the domain name of the application provider.
The `appname` is the name the application is know by.
The `filetype` is the use as the suffix for a config file.
Typical filetypes are .json, .ini, .xml, etc.
For example the widget application from example.com that uses a JSON
configuration file:
~~~~
from config_path import ConfigPath
conf_path = ConfigPath( 'widget', 'example.com', '.json' )
~~~~
## single configuration file
~~~~
path = conf_path.saveFilePath( mkdir=False )
~~~~
`saveFilePath` returns the path where the configuation file should be written to.
When `mkdir` is True the parent directory of the path will be created if it does not exist.
Note: the path returned from `saveFilePath()` can be different from the
path returned by `readFilePath()`.
~~~~
path = conf_path.readFilePath()
if path is not None:
# path exists and config can be read
~~~~
`readFilePath` returns the path to an existing configuration file, otherwise None
is returned. Typcially an application will use its default configuration if there
is no existing configuration file.
Note: the path returned from `readFilePath()` can be different from the
path returned by `saveFilePath()`.
For example readFilePath may return a system wide default config until the appliaction
saves a users specific configuration file.
## multiple configuration files
~~~~
path = conf_path.saveFolderPath( mkdir=False )
~~~~
`saveFolderPath` returns the path to the folder that the application should
save its configuration files into. The naming of the file is left to the application logic.
The path is a `pathlib.Path()` object for python 3 and a string for python 2
When `mkdir` is True the parent directory of the path will be created
if it does not exist.
Note: the path returned from `saveFolderPath()` can be different from the
path returned by `readFolderPath()`.
~~~~
path = conf_path.readFolderPath( mkdir=False )
~~~~
`readFolderPath` returns the path to the folder that the application should use
to read its configuration files.
The path is a `pathlib.Path()` object for python 3 and a string for python 2
When `mkdir` is True the parent directory of the path will be created
if it does not exist.
Note: the path returned from `readFolderPath()` can be different from the
path returned by `saveFolderPath()`.
## macOS conventions
On macOS configuration files are called preferences. They are expected to be stored in the
~/Library/Preferences folder using a file name that uses a reversed domain name.
For a file that will be `{reversed-vendor}.{appname}{filetype}` using the above example:
`com.example.widget.json`.
When a folder is required the folder will be `{reversed-vendor}.{appname}`.
For example: `com.example.widget`.
## windows conventions
On Windows configuration files are stored in a folder that is return from a WIN32 API call.
Exactly which folder is used has changed over time between Windows versions and maybe
language dependent.
config_path uses the convention of combining the `appname` and `vendor` to create a
path that is expected to be unique.
For a file that will be `{reversed-vendor}.{appname}{filetype}` using the above example:
`com.example.widget.json`.
When a folder is required the folder will be `{reversed-vendor}.{appname}`.
For example: `com.example.widget`.
## all others conventions
For all systems that are not macOS or Windows config-path follows
the 'XDG Base Directory Specification' for configuration data.
XDG allows for system configuration and user configuration files.
The default user configuration folder is `~/.config`.
The default system configuration folder is `/etc/xdg`.
For a file that will be `{reversed-vendor}.{appname}{filetype}` using the above example:
`com.example.widget.json`.
When a folder is required the folder will be `{reversed-vendor}.{appname}`.
For example: `com.example.widget`.
Raw data
{
"_id": null,
"home_page": "",
"name": "config-path",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "development",
"author": "",
"author_email": "Barry Scott <barry@barrys-emacs.org>",
"download_url": "https://files.pythonhosted.org/packages/32/02/75ee14911378497eb3bb1bfa576cd99bc88ecf0d9f60671721a91dbecaaf/config-path-1.0.5.tar.gz",
"platform": null,
"description": "# config-path\nPython library to work out which path to use for configuration folders\nand files in an operating system independent way.\n\nEach operating system has particular conventions for where an application is expected\nto stores it configuration. The information provided to ConfigPath is used\nto figure out an appropiate file path or folder path for the application's\nconfiguration data.\n\nSupports Windows, macOS and most unix systems using the 'XDG Base Directory Specification'.\n\n~~~~\nConfigPath( appname, vendor, filetype )\n~~~~\n\nThe `vendor` should be the domain name of the application provider.\nThe `appname` is the name the application is know by.\nThe `filetype` is the use as the suffix for a config file.\nTypical filetypes are .json, .ini, .xml, etc.\n\nFor example the widget application from example.com that uses a JSON\nconfiguration file:\n\n~~~~\nfrom config_path import ConfigPath\nconf_path = ConfigPath( 'widget', 'example.com', '.json' )\n~~~~\n\n## single configuration file\n\n~~~~\npath = conf_path.saveFilePath( mkdir=False )\n~~~~\n\n`saveFilePath` returns the path where the configuation file should be written to.\n\nWhen `mkdir` is True the parent directory of the path will be created if it does not exist.\n\nNote: the path returned from `saveFilePath()` can be different from the\npath returned by `readFilePath()`.\n\n~~~~\npath = conf_path.readFilePath()\nif path is not None:\n # path exists and config can be read\n~~~~\n\n`readFilePath` returns the path to an existing configuration file, otherwise None\nis returned. Typcially an application will use its default configuration if there\nis no existing configuration file.\n\nNote: the path returned from `readFilePath()` can be different from the\npath returned by `saveFilePath()`.\n\nFor example readFilePath may return a system wide default config until the appliaction\nsaves a users specific configuration file.\n\n## multiple configuration files\n\n~~~~\npath = conf_path.saveFolderPath( mkdir=False )\n~~~~\n\n`saveFolderPath` returns the path to the folder that the application should\nsave its configuration files into. The naming of the file is left to the application logic.\n\nThe path is a `pathlib.Path()` object for python 3 and a string for python 2\n\nWhen `mkdir` is True the parent directory of the path will be created\nif it does not exist.\n\nNote: the path returned from `saveFolderPath()` can be different from the\npath returned by `readFolderPath()`.\n\n~~~~\npath = conf_path.readFolderPath( mkdir=False )\n~~~~\n\n`readFolderPath` returns the path to the folder that the application should use\nto read its configuration files.\n\nThe path is a `pathlib.Path()` object for python 3 and a string for python 2\n\nWhen `mkdir` is True the parent directory of the path will be created\nif it does not exist.\n\nNote: the path returned from `readFolderPath()` can be different from the\npath returned by `saveFolderPath()`.\n\n## macOS conventions\n\nOn macOS configuration files are called preferences. They are expected to be stored in the\n~/Library/Preferences folder using a file name that uses a reversed domain name.\n\nFor a file that will be `{reversed-vendor}.{appname}{filetype}` using the above example:\n`com.example.widget.json`.\n\nWhen a folder is required the folder will be `{reversed-vendor}.{appname}`.\nFor example: `com.example.widget`.\n\n## windows conventions\n\nOn Windows configuration files are stored in a folder that is return from a WIN32 API call.\nExactly which folder is used has changed over time between Windows versions and maybe\nlanguage dependent.\n\nconfig_path uses the convention of combining the `appname` and `vendor` to create a\npath that is expected to be unique.\n\nFor a file that will be `{reversed-vendor}.{appname}{filetype}` using the above example:\n`com.example.widget.json`.\n\nWhen a folder is required the folder will be `{reversed-vendor}.{appname}`.\nFor example: `com.example.widget`.\n\n## all others conventions\n\nFor all systems that are not macOS or Windows config-path follows\nthe 'XDG Base Directory Specification' for configuration data.\n\nXDG allows for system configuration and user configuration files.\nThe default user configuration folder is `~/.config`.\nThe default system configuration folder is `/etc/xdg`.\n\nFor a file that will be `{reversed-vendor}.{appname}{filetype}` using the above example:\n`com.example.widget.json`.\n\nWhen a folder is required the folder will be `{reversed-vendor}.{appname}`.\nFor example: `com.example.widget`.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "config_path is a library to work with paths to config folders and files in an OS independent way",
"version": "1.0.5",
"project_urls": {
"Bug Tracker": "https://github.com/barry-scott/config-path/issues",
"Homepage": "https://github.com/barry-scott/config-path"
},
"split_keywords": [
"development"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5f51eec3b34b71799668009107b48fa146b9b9d347f60749491ca77a85ccb94c",
"md5": "6efa85b51db9ade742a2d3c980c2674d",
"sha256": "7a69fbfdacb95d7591621e67265a87960d54d56abffe95d9f93acd342f926292"
},
"downloads": -1,
"filename": "config_path-1.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6efa85b51db9ade742a2d3c980c2674d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 8800,
"upload_time": "2023-10-03T19:41:42",
"upload_time_iso_8601": "2023-10-03T19:41:42.129707Z",
"url": "https://files.pythonhosted.org/packages/5f/51/eec3b34b71799668009107b48fa146b9b9d347f60749491ca77a85ccb94c/config_path-1.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "320275ee14911378497eb3bb1bfa576cd99bc88ecf0d9f60671721a91dbecaaf",
"md5": "5871ce519d84df96c716281c49b3a97a",
"sha256": "ed17ad1a0cbdadb2781443a27a624057138611416885acb3fb41132a6d559d77"
},
"downloads": -1,
"filename": "config-path-1.0.5.tar.gz",
"has_sig": false,
"md5_digest": "5871ce519d84df96c716281c49b3a97a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 11215,
"upload_time": "2023-10-03T19:41:43",
"upload_time_iso_8601": "2023-10-03T19:41:43.639534Z",
"url": "https://files.pythonhosted.org/packages/32/02/75ee14911378497eb3bb1bfa576cd99bc88ecf0d9f60671721a91dbecaaf/config-path-1.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-03 19:41:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "barry-scott",
"github_project": "config-path",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "config-path"
}