diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..af11b65 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +Click==7.0 +setuptools==40.8.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7454f59 --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +import os +import io +from setuptools import find_packages, setup + +DEPENDENCIES = ['Click'] +EXCLUDE_FROM_PACKAGES = [] +CURDIR = os.path.dirname(__file__) + +setup( + name="truefile", + version="1.0.0", + author="Xevion", + author_email="xevion@xevion.dev", + description="", + packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES), + include_package_data=True, + entry_points=''' + [console_scripts] + truefile=truefile.cli:cli + ''', + install_requires=DEPENDENCIES, +) \ No newline at end of file diff --git a/truefile/__init__.py b/truefile/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/truefile/cli.py b/truefile/cli.py new file mode 100644 index 0000000..063c9eb --- /dev/null +++ b/truefile/cli.py @@ -0,0 +1,33 @@ +import click +import os +import imghdr +import sys + +__file__ + +@click.group() +def cli(): + pass + +def what(*args, **kwargs): + try: + return imghdr.what(*args, **kwargs) + except PermissionError: + return None + +@cli.command() +def detect(): + path = os.getcwd() + # Filter and map files down to absolute paths for FILES (not directories) + files = map(lambda file : file, [file for file in os.listdir(path)]) # abspath of all files in curdir + files = filter(os.path.isfile, files) # file not directory + files = zip(files, map(what, files)) # get scan of file type + files = filter(lambda x : x[1] is not None, files) # filter for only images + files = map(lambda x : (x[0], os.path.splitext(x[0])[1], x[1]), files) + largest = max(map(lambda x : len(x[0]), files)) + print(largest) + print('\n'.join(map(lambda x : f'| {x[0]} -> {x[1]}', files))) + +@cli.command() +def rename(): + pass \ No newline at end of file