معرفی شرکت ها


ConfigDmanager-0.2.0


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

A simple configuration files manager package
ویژگی مقدار
سیستم عامل -
نام فایل ConfigDmanager-0.2.0
نام ConfigDmanager
نسخه کتابخانه 0.2.0
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Dhia Hmila
ایمیل نویسنده hmiladhia@hotmail.fr
آدرس صفحه اصلی https://github.com/hmiladhia/ConfigDmanager
آدرس اینترنتی https://pypi.org/project/ConfigDmanager/
مجوز -
# ConfigDmanager ## Installation A simple pip install will do : ```bash python -m pip install ConfigDmanager ``` ## Use - Suppose we have two Configuration files ( of json type ) : - ParentConfig.json : ```json { "__name": "ParentConfig", "param1": "Value 1" } ``` - MainConfig.json : - The **__parent** parameter specifies the path to another configuration file that will give us default values ( Think of it as inheritance ). - The text contained between brackets will be reinterpreted in runtime : in the example below **${param1}** will be reinterpreted as "Value 1" - The use of environment variables for sensitive data like passwords is also possible : through this text **${os_environ[password]}** - You can also read the content of a text file with a simple : **${read_file[file_path]}** as shown in the example below. ```json { "__name": "MainConfig", "__parent": "demo.ParentConfig", "param2": "Value 2 and ${param1}", "user_info": {"user": "username", "password": "${os_environ[password]}"}, "long_text": "${read_file[./demo.py]}" } ``` - To import those configuration using **configDmanager**, use this demo code : ```python from configDmanager import import_config class RandomClass: def __init__(self, param1, param2, user_info, long_text): print(f"param1: {param1}") print(f"param2: {param2}") print(f'my user: {user_info.user}') print(f'my user: {user_info.password}') print(f'my long text: "{long_text[:40]}"') config = import_config('MainConfig') print("## Object 1") obj = RandomClass(**config) # You can also select specific keys print("## Object 2") another_obj = RandomClass(param2='Another Value', long_text="Not so long", **config[['param1', 'user_info']]) ``` ## Export Config file You can export a Config by simply using the **export_config** function ```python from configDmanager import export_config, Config config = Config({'my_param': 'my_value'}) export_config(config, 'NewConfig') ``` If you wish to modify an existing config, you can use **update_config** function : ```python from configDmanager import update_config # You can use a dict to update Config values update_config({'param' : 'value'}, 'MyConfig') # You can also use a callable that takes the config returns a dict update_config(lambda conf: {'numeric': conf['numeric'] + 1}, 'MyConfig') ```


نیازمندی

مقدار نام
- pyyaml


زبان مورد نیاز

مقدار نام
>= 3.6 Python


نحوه نصب


نصب پکیج whl ConfigDmanager-0.2.0:

    pip install ConfigDmanager-0.2.0.whl


نصب پکیج tar.gz ConfigDmanager-0.2.0:

    pip install ConfigDmanager-0.2.0.tar.gz