![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Manage user configuration for python projects.
For easy and well-documented user-defined configuration.
~/.config/<app>/config.<extension>
/etc/xdg/<app>/config.<extension>
For directories on operating systems than linux, see: https://github.com/ActiveState/appdirs
Supported out of the box: ini
Other config formats can be supported via plug-ins.
.. code-block:: python
"""Usage example for user_config."""
from user_config import Config, Section, StringOption, IntegerOption
class MyConfig(Config):
"""This will be displayed in the configuration documentation."""
application = "my_application"
author = "me"
class GeneralSection(Section):
"""General information."""
name = StringOption(
doc="your name",
default="unknown person")
age = IntegerOption(
doc="your age",
required=True)
general = GeneralSection()
class AddressSection(Section):
"""shipping address"""
street = StringOption(
doc="street including house number",
required=True)
city = StringOption(required=True)
address = AddressSection(required=False)
if __name__ == "__main__":
CONFIG = MyConfig()
print("hello there, {}!".format(CONFIG.general.name))
Command line help text:
.. code-block:: shell
$ python examples/simple_example.py -h
usage: my_application [-h] [--generate-config] [--city CITY] [--street STREET]
[--age AGE] [--name NAME]
This will be displayed in the configuration documentation. Command line
arguments overwrite configuration found in:
/root/.config/my_application/config.cfg /etc/xdg/my_application/config.cfg
optional arguments:
-h, --help show this help message and exit
--generate-config print a complete configuration file with current settings
--city CITY
--street STREET street including house number
--age AGE your age
--name NAME your name
Command line use with default value:
.. code-block:: shell
$ python examples/simple_example.py --age 211
hello there, unknown person!
Command line use without required value:
.. code-block:: shell
$ python examples/simple_example.py
Traceback (most recent call last):
File "examples/simple_example.py", line 29, in <module>
CONFIG = MyConfig()
File "/git/user_config/user_config/user_config/__init__.py", line 622, in __init__
self._elements[element].validate_data(self._data)
File "/git/user_config/user_config/user_config/__init__.py", line 464, in validate_data
self._elements[element].validate_data(self._data)
File "/git/user_config/user_config/user_config/__init__.py", line 380, in validate_data
self.element_name))
user_config.MissingData: no value was provided for required option age
Command line use:
.. code-block:: shell
$ python examples/simple_example.py --age 211 --name mystery_user
hello there, mystery_user!
Generate configuration file:
.. code-block:: shell
$ python examples/simple_example.py --generate-config
## This will be displayed in the configuration documentation.
[general]
## General information.
## your name
# name = unknown person
name = tamara
## your age
## REQUIRED
# age =
age =
[address]
## shipping address
## OPTIONAL_SECTION
## street including house number
## REQUIRED
# street =
street =
## REQUIRED
# city =
city =
.. code-block:: shell
$ pip install -e ".[doc]"
$ python setup.py build_sphinx
.. code-block:: shell
$ python -m pytest --cov=user_config --cov-report xml
FAQs
manage user configuration for python packages
We found that user-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.