Skip to main content

A Python package to read "config.json" in the working directory and access its content using the package name itself.

Project description

configjs

configjs is a Python package designed to simplify the process of reading and accessing configuration settings stored in a JSON file. With configjs, you can effortlessly load a "config.json" file from the working directory and access its contents using the package name as attributes.

Installation

Install configjs using pip:

pip install configjs

Usage

  • Create a "config.json" file in your project's working directory with the desired configuration settings in JSON format:
{
  "database": {
    "host": "localhost",
    "port": 5432,
    "username": "user",
    "password": "secret"
  },
  "api_key": "your_api_key"
}
  • Import and use configjs in your Python code:
from configjs import Config

# Load the "config.json" file
config = Config()

# Access configuration settings using the package name as attributes
db_host = config.database.host
db_port = config.database.port
db_username = config.database.username
db_password = config.database.password
api_key = config.api_key

print(f"Database Host: {db_host}")
print(f"Database Port: {db_port}")
print(f"Database Username: {db_username}")
print(f"Database Password: {db_password}")
print(f"API Key: {api_key}")
  • Replace the attribute names (database, host, port, username, password, api_key) with your actual configuration structure.

Notes

configjs assumes that the "config.json" file is in the working directory. The package name itself (config) is used as the top-level attribute to access the configuration settings. Feel free to customize "config.json" based on your project's needs and easily manage your configuration settings using configjs.

Project details


Download files

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

Source Distribution

configjs-0.1.2.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file configjs-0.1.2.tar.gz.

File metadata

  • Download URL: configjs-0.1.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for configjs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d59246918c42680b15484d84070a36a71a09f6b1435f61c684e76984c72750da
MD5 a4ddf9964397884b0bd026b59053614a
BLAKE2b-256 3250a9ddae8424cf6bec2ea2020523ee9cebec1b9c0c3f2c4bf743a23059eae9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page