Skip to content

Commit

Permalink
code polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
kaliv0 committed Nov 14, 2024
1 parent 531e846 commit 6d68fec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 4 additions & 5 deletions chancleta/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@


class Chancleta:
CONFIG_FILES = ["chancleta.toml", "chancleta.json", "chancleta.yaml", "chancleta.xml"]
CONFIG_FILE = "chancleta"
CONFIG_FORMATS = [".toml", ".json", ".yaml", ".xml"]

EMPTY_CONFIG_ERROR = "Empty configuration file {config_path}"
MISSING_CONFIG_ERROR = "Missing configuration file in {cwd}"
Expand All @@ -14,16 +15,15 @@ class Chancleta:
def __init__(self, cwd=os.getcwd()):
self.cwd = cwd
self.data = None
self.config_type = None
self.parser = None
self.subparsers = None
self.func_src = None
self.func_args = None

# ### config ###
def _handle_config(self):
for config in self.CONFIG_FILES:
config_path = os.path.join(self.cwd, config)
for config_fmt in self.CONFIG_FORMATS:
config_path = os.path.join(self.cwd, f"{self.CONFIG_FILE}{config_fmt}")
if not os.path.exists(config_path):
continue
if not os.path.getsize(config_path):
Expand Down Expand Up @@ -51,7 +51,6 @@ def _read_file(self, config_path):
import xmltodict

self.data = xmltodict.parse(f)["root"]
self.config_type = extension[1:]
return bool(self.data)

# ### CLI ###
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
[tool.poetry]
name = "chancleta"
version = "1.0.1"
version = "1.0.2"
authors = ["kaliv0 <kaloyan.ivanov88@gmail.com>"]
description = "Python library for creating Command Line Interfaces via configuration files. Supports .toml, .json, .yaml and .xml (for the brave ones)"
keywords = ["command line interface", "cli starter kit", "toml", "json", "yaml", "xml"]
readme = "README.md"
license = "LICENSE"

[tool.poetry.urls]
repository = "https://github.com/kaliv0/chancleta.git"
urls = { repository = "https://github.com/kaliv0/chancleta.git" }

[tool.poetry.dependencies]
python = "^3.12"
Expand Down

0 comments on commit 6d68fec

Please sign in to comment.