mirror of
https://github.com/Xevion/truefile.git
synced 2025-12-06 05:16:56 -06:00
initial commit with most code completed
This commit is contained in:
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Click==7.0
|
||||
setuptools==40.8.0
|
||||
22
setup.py
Normal file
22
setup.py
Normal 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
0
truefile/__init__.py
Normal file
33
truefile/cli.py
Normal file
33
truefile/cli.py
Normal 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
|
||||
Reference in New Issue
Block a user