Skip to main content

python configuration file loading package

Project description

Python ConfigFile Package

说明

这是一个 Python 配置文件加载模块,主要解决 Ymal, Json 配置文件的快速加载,同时支持网络配置动态加载。

使用

from configfile import ConfigFile

configfile = ConfigFile('config_dir')

print(configfile.load_app('config'))
print(configfile.load_app_json('config'))

加载动态配置

import json
import time
from configfile import ConfigFile


timestamp1 = time.time()
timestamp2 = False

configfile = ConfigFile('config_dir)

def callback():
    global timestamp1
    global timestamp2
    if timestamp2 is False:
        timestamp2 = timestamp1
    else:
        timestamp2 = time.time()
    return json.dumps({"timestamp": timestamp2})

print(configfile.load_dynamic_json('config', callback, 3))
time.sleep(1)
print(configfile.load_dynamic_json('config', callback, 3))
time.sleep(3)
print(configfile.load_dynamic_json('config', callback, 3))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for py-configfile, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size py_configfile-0.0.4-py3-none-any.whl (3.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size py_configfile-0.0.4.tar.gz (2.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page