initial commit with most code completed

This commit is contained in:
Xevion
2019-12-24 03:52:15 -06:00
parent 41eed15692
commit 824d724784
4 changed files with 57 additions and 0 deletions

2
requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
Click==7.0
setuptools==40.8.0

22
setup.py Normal file
View File

@@ -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,
)

0
truefile/__init__.py Normal file
View File

33
truefile/cli.py Normal file
View File

@@ -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