From b966316ed01ec714cc0df9b350547fd7b8244d80 Mon Sep 17 00:00:00 2001 From: Catherine Oborski Date: Thu, 5 Sep 2024 21:47:44 -0500 Subject: [PATCH] version 0.1.0-alpha --- main.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ readme.md | 6 +++++ test.zip | Bin 0 -> 408 bytes 3 files changed, 77 insertions(+) create mode 100644 test.zip diff --git a/main.py b/main.py index e69de29..bd7f9a8 100644 --- a/main.py +++ b/main.py @@ -0,0 +1,71 @@ +"""Zipssion. + +Usage: + zipssion.py [--quiet | --verbose] [--path=] [--zip | --7zip | --tar.gz] + zipssion.py [--quiet | --verbose] [--path=] [--json | --text] + zipssion.py (-h | --help) + zipssion.py --version + zipssion.py --quiet + zipssion.py --verbose + +Options: + -h --help show help text + --version show version + --quiet print less text + --verbose print more text + --path path to folder containing file [default: '/'] + +""" +from docopt import docopt +from pprint import pprint +import logging +import argparse +import pathlib +import shutil +import tempfile +import zipfile + +def config_log(): + # Configure logging + logging.basicConfig(level=logging.DEBUG) + + # Create a StreamHandler and set its log level to DEBUG + console_handler = logging.StreamHandler() + console_handler.setLevel(logging.DEBUG) + + # Create a formatter and attach it to the handler + formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + console_handler.setFormatter(formatter) + + # Create a logger and add the console handler + logger = logging.getLogger(__name__) + logger.addHandler(console_handler) + + return logger + +def view_files_content(filename): + + path = pathlib.Path(filename) + logger.debug('Path:' + str(path)) + zip_path = path.stem + '.zip' + logger.debug('Zip Path:' + str(zip_path)) + + if (path.exists() and path.is_file()): + shutil.copy(path, zip_path) + + logger.debug('Is the path a file?:' + 'true') + file = zipfile.ZipFile(zip_path) + file.printdir() + +if __name__ == '__main__': + VERSION = '0.1.0-alpha' + + logger = config_log() + arguments = docopt(__doc__, version=VERSION) + filename = arguments['--path'] + arguments[''] + + + logger.debug('Filename:' + filename) + view_files_content(filename) + + logger.debug(arguments) diff --git a/readme.md b/readme.md index bfd58c9..24c87f5 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,7 @@
# Zipssion +## Version: 0.1.0-alpha
@@ -23,5 +24,10 @@ This project is just getting started and only has a couple of features implement ## Credits and references - [Command Line Interface Guidelines](https://clig.dev/) +- [docopt](https://github.com/docopt/docopt) +- [pyfiglet](https://github.com/pwaller/pyfiglet) +- [rich](https://rich.readthedocs.io/en/latest/index.html) +- [asciinema](https://asciinema.org/) +- [pypager](https://github.com/prompt-toolkit/pypager) [🔝](#zipssion) diff --git a/test.zip b/test.zip new file mode 100644 index 0000000000000000000000000000000000000000..5817680655404782203e37f1051f4f11acbb3b0a GIT binary patch literal 408 zcmWIWW@h1H00HL;)krV{N^k(_lGNf7W4(gP0JthM9I6cUa#IkhtkG0)Ld`PLE2$_6 z@MdJPXTW8t3e