{"id":23047272,"url":"https://github.com/juliusthejules/pydonfig","last_synced_at":"2025-04-03T02:44:49.770Z","repository":{"id":266709983,"uuid":"899118171","full_name":"juliusthejules/pydonfig","owner":"juliusthejules","description":"PyDonfig: A simple, human-readable configuration language for Python, with a runtime parser to integrate .pydl files seamlessly into your code.","archived":false,"fork":false,"pushed_at":"2024-12-26T06:45:05.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T17:09:27.573Z","etag":null,"topics":["declarative-language","developer-tools","human-readable-configs","python-configuration","runtime-parser"],"latest_commit_sha":null,"homepage":"https://juliusthejules.github.io/pydonfig/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliusthejules.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://paylinkz.app/juliusthejules"]}},"created_at":"2024-12-05T16:48:20.000Z","updated_at":"2024-12-26T06:45:08.000Z","dependencies_parsed_at":"2024-12-05T17:42:32.822Z","dependency_job_id":"be2881a4-c482-4d05-8e36-996e6b456a64","html_url":"https://github.com/juliusthejules/pydonfig","commit_stats":null,"previous_names":["juliusthejules/pydonfig"],"tags_count":1,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliusthejules%2Fpydonfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliusthejules%2Fpydonfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliusthejules%2Fpydonfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliusthejules%2Fpydonfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliusthejules","download_url":"https://codeload.github.com/juliusthejules/pydonfig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246927808,"owners_count":20856193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["declarative-language","developer-tools","human-readable-configs","python-configuration","runtime-parser"],"created_at":"2024-12-15T22:32:20.465Z","updated_at":"2025-04-03T02:44:49.749Z","avatar_url":"https://github.com/juliusthejules.png","language":"HTML","funding_links":["https://paylinkz.app/juliusthejules"],"categories":[],"sub_categories":[],"readme":"# **Specification for Python Declarative Language (PyDonfig)**  \n**Version**: 1.0  \n**Author**: Joseph D. Smith  \n**File Extension:** `.pydl`  \n**Purpose:** PyDonfig provides a simple, declarative syntax for configuring Python applications. It eliminates the need for hardcoding settings directly into Python scripts by allowing developers to define configuration files in a clear, human-readable format that can be parsed at runtime using a lightweight parsing function.\n\n---\n\n### **Specification for PyDonfig**\n\n#### **1. Structure**\nPyDonfig files use a hierarchical structure consisting of **sections** and **key-value pairs**.  \n\n- **Sections:** Represented by identifiers followed by a colon (`:`).  \n  Example:  \n  ```pydl\n  device:\n  ```\n- **Key-Value Pairs:** Defined using the format `key \u003e value`.  \n  - Keys are case-sensitive and written in **camelCase**.  \n  - Values can be strings, numbers, booleans (`true` or `false`), or null.  \n\n  Example:  \n  ```pydl\n  macAddress \u003e \"00:00:00:00:00:00\"\n  ```\n\n#### **2. Comments**\nComments are prefixed with `//`. Anything after `//` is ignored during parsing.  \nExample:  \n```pydl\n// This is a comment\n```\n\n#### **3. Key-Value Pair Details**\n- **Strings:** Enclosed in double quotes (`\"`).  \n  Example:  \n  ```pydl\n  hostname \u003e \"localhost\"\n  ```\n- **Numbers:** Written as-is (integers or floats).  \n  Example:  \n  ```pydl\n  port \u003e 8080\n  ```\n- **Booleans:** Written as `true` or `false` (case-insensitive).  \n  Example:  \n  ```pydl\n  enabled \u003e false\n  ```\n- **Null:** Represented as `null`.  \n  Example:  \n  ```pydl\n  primary \u003e null\n  ```\n\n---\n\n### **Example PyDonfig File (`config.pydl`)**\n\n```pydl\n// Device configuration\ndevice:\n    macAddress \u003e \"00:00:00:00:00:00\"\n    btAddress \u003e \"00:00:00:00:00:00\"\n\n// IP configuration\nipAddress:\n    ip4 \u003e \"127.0.0.1\"\n    ip6 \u003e \"::1\"\n\n// Firewall rules\nfirewallRule:\n    deny \u003e true\n    port \u003e 0\n    protocol \u003e \"ALL\"\n\n// Telemetry settings\ntelemetry:\n    enabled \u003e false\n\n// Hostname configuration\nhostname \u003e \"localhost\"\n\n// DNS configuration\ndns:\n    primary \u003e \"127.0.0.0\"\n    secondary \u003e \"::1\"\n\n// Encryption settings\nencryption:\n    method \u003e \"AES-256\"\n    enable \u003e true\n\n// Traceroute blocking\ntraceroute:\n    block \u003e true\n\n// Fingerprinting settings\nfingerprinting:\n    obfuscate \u003e true\n```\n\n---\n\n### **4. Parsing PyDonfig Files in Python**\n\n#### **Parsing Function**\nThe following function can be used to parse `.pydl` files into a Python dictionary.\n\n```python\ndef load_pydl(file_path):\n    config = {}\n    with open(file_path, \"r\") as file:\n        current_section = None\n        for line in file:\n            line = line.strip()\n\n            # Skip comments and empty lines\n            if line.startswith(\"//\") or not line:\n                continue\n\n            if line.endswith(\":\"):  # Section header\n                current_section = line[:-1]\n                config[current_section] = {}\n            else:  # Key-value pair\n                key, value = line.split(\"\u003e\", 1)\n                key = key.strip()\n                value = value.strip().strip('\"')  # Remove quotes\n                # Convert booleans and numbers\n                if value.lower() == \"true\":\n                    value = True\n                elif value.lower() == \"false\":\n                    value = False\n                elif value.lower() == \"null\":\n                    value = None\n                elif value.isdigit():\n                    value = int(value)\n                elif value.replace(\".\", \"\", 1).isdigit():\n                    value = float(value)\n\n                if current_section:\n                    config[current_section][key] = value\n                else:\n                    config[key] = value\n    return config\n```\n\n---\n\n### **5. Accessing Configuration**\n\nOnce parsed, the `.pydl` configuration is stored in a Python dictionary, making it easy to access and use in your code.\n\n#### **Example Usage**\n```python\n# Load PyDonfig file\nconfig = load_pydl(\"config.pydl\")\n\n# Access values\nprint(config[\"device\"][\"macAddress\"])  # Output: 00:00:00:00:00:00\nprint(config[\"dns\"][\"primary\"])        # Output: 127.0.0.1\nprint(config[\"firewallRule\"][\"deny\"])  # Output: True\n```\n\n---\n\n### **6. Benefits of PyDonfig**\n- **Human-Readable:** Simple syntax for quick configuration changes.\n- **Lightweight:** No external libraries or parsers needed.\n- **Extensible:** Easy to modify and adapt to additional use cases.\n- **Seamless Integration:** Works directly with Python scripts, just like standard config files.\n\n---\n\nThis specification ensures PyDonfig remains consistent, user-friendly, and versatile for Python application configuration.\n\n## **7. Licensing**  \nPyDonfig is open-source and available under the **MIT License**, allowing developers to freely use, modify, and distribute it.\n\n---\n\n## **8. Future Directions**  \n- **Community Contributions**: Expand the capabilities of PyDonfig with more advanced features.  \n- **Tooling**: Develop an official PyDonfig parser library to simplify integration.  \n- **Documentation**: Provide more detailed documentation and examples for users.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliusthejules%2Fpydonfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliusthejules%2Fpydonfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliusthejules%2Fpydonfig/lists"}