Compare commits
6 Commits
beta_0.2.1
...
a26367c0aa
| Author | SHA1 | Date | |
|---|---|---|---|
| a26367c0aa | |||
| 8bc7bf5584 | |||
| b3834f4798 | |||
| f0a7ea1874 | |||
| c41ff7e0f5 | |||
| 78f8c991bd |
179
.gitignore
vendored
179
.gitignore
vendored
@@ -1,2 +1,177 @@
|
|||||||
__pycache__
|
release
|
||||||
releases
|
|
||||||
|
# ---> Python
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# UV
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
#uv.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
#poetry.lock
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
#pdm.lock
|
||||||
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
|
# in version control.
|
||||||
|
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
||||||
|
.pdm.toml
|
||||||
|
.pdm-python
|
||||||
|
.pdm-build/
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
#.idea/
|
||||||
|
|
||||||
|
# Ruff stuff:
|
||||||
|
.ruff_cache/
|
||||||
|
|
||||||
|
# PyPI configuration file
|
||||||
|
.pypirc
|
||||||
|
|||||||
14
refit/README.md
Normal file
14
refit/README.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# refit
|
||||||
|
|
||||||
|
`refit` is a file, directory manipulation and creation tool.
|
||||||
|
|
||||||
|
## ToDos
|
||||||
|
|
||||||
|
1. folder and file creation
|
||||||
|
1.1 simple file creation
|
||||||
|
1.2 recursive file creation
|
||||||
|
1.3 file creation
|
||||||
|
2. file movement
|
||||||
|
2.1 apply a pattern what to move to where
|
||||||
|
3. file removal
|
||||||
|
3.1 remove all files like '*.tar'
|
||||||
32
refit/src/modules/refit_logger.py
Normal file
32
refit/src/modules/refit_logger.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
log_dir = Path.home() / ".local" / "share" / "refit"
|
||||||
|
log_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
log_file = log_dir / "refit.log"
|
||||||
|
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.DEBUG,
|
||||||
|
format="%(asctime)s - %(levelname)s - %(message)s",
|
||||||
|
filename=log_file,
|
||||||
|
)
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
def handle_exception(exec_type, exec_value, exec_traceback):
|
||||||
|
if issubclass(exec_type, KeyboardInterrupt):
|
||||||
|
sys.__excepthook__(exec_type, exec_value, exec_traceback)
|
||||||
|
return
|
||||||
|
logger.error(
|
||||||
|
"External error accured",
|
||||||
|
exc_info=(exec_type, exec_value, exec_traceback),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
sys.excepthook = handle_exception
|
||||||
|
|
||||||
|
logger.debug(f"Log path:\t{log_dir}")
|
||||||
|
logger.debug(f"Log file:\t{log_file}")
|
||||||
62
refit/src/refit.py
Normal file
62
refit/src/refit.py
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from modules.refit_logger import logger
|
||||||
|
|
||||||
|
|
||||||
|
# Setting Global Variables
|
||||||
|
REFIT_VERSION = "Refit Beta 0.0.0"
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------BEGIN FUNCTIONS---------------------------
|
||||||
|
# will be in seperate file at some point
|
||||||
|
def refit_create(args):
|
||||||
|
logger.info("Running in create mode")
|
||||||
|
logger.debug(f"Arguments: {args}")
|
||||||
|
print(f"executing on {args.input}")
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------END FUNCTIONS----------------------------
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------ARGPARSE START---------------------------
|
||||||
|
|
||||||
|
# Main Parser
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
prog="Refit",
|
||||||
|
description="This is a file and directory manipulation tool.\
|
||||||
|
it can create, move and delete files and directories as well as \
|
||||||
|
renaming them",
|
||||||
|
epilog=REFIT_VERSION,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Main Parser Arguments
|
||||||
|
|
||||||
|
# Create Parser
|
||||||
|
subparser = parser.add_subparsers(
|
||||||
|
title="Commands",
|
||||||
|
dest="create",
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create Parser Arguments
|
||||||
|
create_parser = subparser.add_parser(
|
||||||
|
"create",
|
||||||
|
help="creates a new file/folder",
|
||||||
|
)
|
||||||
|
create_parser.add_argument("-n", type=int, help="number of items")
|
||||||
|
create_parser.add_argument("-i", "--input", help="input file")
|
||||||
|
create_parser.set_defaults(func=refit_create)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
# ---------------------------ARGPARSE END-----------------------------
|
||||||
|
|
||||||
|
|
||||||
|
# Dispatcher
|
||||||
|
if hasattr(args, "func"):
|
||||||
|
logger.debug("In hasattr()")
|
||||||
|
args.func(args)
|
||||||
|
else:
|
||||||
|
parser.print_help()
|
||||||
|
logger.info("No input, exiting with error:1")
|
||||||
|
sys.exit(1)
|
||||||
@@ -7,7 +7,7 @@ from modules.tempbox_logger import logger
|
|||||||
tempbox_version = "Tempbox Beta b0.2.1"
|
tempbox_version = "Tempbox Beta b0.2.1"
|
||||||
# Argument parsing
|
# Argument parsing
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog="Tempbox",
|
prog="tempbox",
|
||||||
description="This program accepts an\
|
description="This program accepts an\
|
||||||
command whicht it executes in an temporary directory in /temp.",
|
command whicht it executes in an temporary directory in /temp.",
|
||||||
# epilog="helloooooooo",
|
# epilog="helloooooooo",
|
||||||
|
|||||||
Reference in New Issue
Block a user