From 6d25b320bf1cffd1fa6363ab47168fd8f4d77217 Mon Sep 17 00:00:00 2001 From: Muhammad Fiaz Date: Thu, 30 Nov 2023 19:16:44 +0530 Subject: [PATCH 1/3] Initial Commit --- .gitignore | 0 .idea/.gitignore | 8 ++++++++ CODE_OF_CONDUCT.md | 43 +++++++++++++++++++++++++++++++++++++++++++ README.md | 24 ++++++++++++++++++++++++ requirements.txt | 0 setup.py | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 CODE_OF_CONDUCT.md create mode 100644 README.md create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..3d24fc4 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,43 @@ +# Code of Conduct + +## Introduction + +We, as contributors and maintainers, pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct that could reasonably be considered inappropriate in a professional setting + +## Responsibilities of Maintainers + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [your.email@example.com]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html). + +For answers to common questions about this code of conduct, see [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). diff --git a/README.md b/README.md new file mode 100644 index 0000000..b9acb2e --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# DotSetup + +DotSetup is a Python package designed for flexible configuration management, supporting `.ini`, `.json`, `.env`, and custom file types. Simplify the storage and retrieval of settings in your projects effortlessly. + +## Features + +- **Multi-format Support:** Seamlessly handle configurations from `.ini`, `.json`, `.env`, and custom file types. +- **Intuitive API:** Easy-to-use methods for loading, accessing, and saving configurations. +- **File Type Extension:** Customize DotSetup to support additional file types beyond the included formats. + +## Installation + +```bash +pip install dotsetup +``` +## Code of Conduct + +Please review our Code of Conduct to understand the standards of behavior we expect from contributors and users of this project. + +## Contributing +Contributions are welcome! Before contributing, please read our Contributing Guidelines to ensure a smooth and collaborative development process. + +## License +This project is licensed under the MIT License. See LICENSE for more details. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e91e381 --- /dev/null +++ b/setup.py @@ -0,0 +1,32 @@ +from setuptools import setup, find_packages +from dotenv import load_dotenv +import os + +# Load environment variables from .env +load_dotenv() + +# Get the version from the environment variable +version = os.getenv("VERSION") + +with open("README.md", "r", encoding="utf-8") as readme_file: + long_description = readme_file.read() + +setup( + name='runix', + version=version, + description='A high-level Python web framework for web development.', + long_description=long_description, + long_description_content_type='text/markdown', + author='Your Name', + author_email='contactus@fiaz.dev', + packages=find_packages(), + entry_points={ + 'console_scripts': [ + 'runix = runix.cli:create', + ], + }, + install_requires=[ + 'click', + # Add other dependencies here + ], +) From dbf963381b1da51c8235cab45734b1a4183e0aa5 Mon Sep 17 00:00:00 2001 From: Muhammad Fiaz Date: Thu, 30 Nov 2023 21:35:36 +0530 Subject: [PATCH 2/3] Initial Commit --- dotsetup/.env | 1 + dotsetup/__init__.py | 74 ++++++++++++++++++++++++++++++++++++++++++++ dotsetup/parse.py | 0 tests/test.py | 6 ++++ 4 files changed, 81 insertions(+) create mode 100644 dotsetup/.env create mode 100644 dotsetup/__init__.py create mode 100644 dotsetup/parse.py create mode 100644 tests/test.py diff --git a/dotsetup/.env b/dotsetup/.env new file mode 100644 index 0000000..9036dc4 --- /dev/null +++ b/dotsetup/.env @@ -0,0 +1 @@ +VERSION=0.0.1 \ No newline at end of file diff --git a/dotsetup/__init__.py b/dotsetup/__init__.py new file mode 100644 index 0000000..181c9fc --- /dev/null +++ b/dotsetup/__init__.py @@ -0,0 +1,74 @@ +import json +import os +import warnings + +class DotSetupParser: + def __init__(self, file_path): + self.file_extension = file_path.split('.')[-1].lower() + self.data = self.parse(file_path) + + def parse(self, file_path): + if self.file_extension == 'env': + return self.parse_env(file_path) + elif self.file_extension == 'ini': + return self.parse_ini(file_path) + elif self.file_extension == 'json': + return self.parse_json(file_path) + else: + raise ValueError(f"Unsupported file type: {self.file_extension}") + + def parse_env(self, file_path): + result = {} + with open(file_path, 'r') as file: + for line in file: + line = line.strip() + if '=' in line: + key, value = map(str.strip, line.split('=', 1)) + result[key] = value + return result + + def parse_ini(self, file_path): + result = {} + with open(file_path, 'r') as file: + current_section = None + for line in file: + line = line.strip() + if line.startswith('[') and line.endswith(']'): + current_section = line[1:-1] + result[current_section] = {} + elif '=' in line and current_section is not None: + key, value = map(str.strip, line.split('=', 1)) + result[current_section][key] = value + return result + + def parse_json(self, file_path): + with open(file_path, 'r') as file: + return json.load(file) + +class DotSetup: + def __init__(self): + self.project_root = os.getcwd() + self.config_data = self.load_files() + + def load_files(self): + config_data = {} + self.load_file(config_data, 'env', ".env") + self.load_file(config_data, 'ini', "config.ini") + self.load_file(config_data, 'json', "config.json") + return config_data + + def load_file(self, config_data, file_type, file_name): + file_path = os.path.join(self.project_root, file_name) + if os.path.isfile(file_path): + config_data[file_type] = DotSetupParser(file_path) + + def load(self, key, file_type='env'): + key_upper = key.upper() + if file_type in self.config_data and key_upper in self.config_data[file_type].data: + return self.config_data[file_type].data[key_upper] + return None + +# Example usage: +ds = DotSetup() +value_env = ds.load('version', file_type='env') +print(value_env) diff --git a/dotsetup/parse.py b/dotsetup/parse.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..a5f43ec --- /dev/null +++ b/tests/test.py @@ -0,0 +1,6 @@ +from dotsetup import DotSetup + + + +ds = DotSetup() + From 9a80af296ccf133d94765377b0bb9cd9e4fd4f91 Mon Sep 17 00:00:00 2001 From: Muhammad Fiaz Date: Thu, 30 Nov 2023 21:49:19 +0530 Subject: [PATCH 3/3] Initial Commit --- .idea/aws.xml | 11 +++++++++ .idea/dotsetup.iml | 10 ++++++++ .idea/inspectionProfiles/Project_Default.xml | 24 +++++++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ .idea/misc.xml | 7 ++++++ .idea/modules.xml | 8 +++++++ .idea/vcs.xml | 6 +++++ requirements.txt | 1 + setup.py | 21 +++++----------- 9 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 .idea/aws.xml create mode 100644 .idea/dotsetup.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/dotsetup.iml b/.idea/dotsetup.iml new file mode 100644 index 0000000..60fd9dd --- /dev/null +++ b/.idea/dotsetup.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..93970c2 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,24 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6b43f93 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2d146e2 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e69de29..8b6d003 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +setuptools \ No newline at end of file diff --git a/setup.py b/setup.py index e91e381..958e328 100644 --- a/setup.py +++ b/setup.py @@ -1,32 +1,23 @@ from setuptools import setup, find_packages -from dotenv import load_dotenv -import os -# Load environment variables from .env -load_dotenv() - -# Get the version from the environment variable -version = os.getenv("VERSION") +version = "0.0.0" with open("README.md", "r", encoding="utf-8") as readme_file: long_description = readme_file.read() setup( - name='runix', + name='dotsetup', version=version, - description='A high-level Python web framework for web development.', + description='A simple setup tool for Python projects to manage environment variables and configuration files.', long_description=long_description, long_description_content_type='text/markdown', - author='Your Name', - author_email='contactus@fiaz.dev', + author='Muhammad Fiaz', + author_email='contact@muhammadfiaz.com', packages=find_packages(), entry_points={ - 'console_scripts': [ - 'runix = runix.cli:create', - ], + }, install_requires=[ - 'click', # Add other dependencies here ], )