fcwtool: füge setup.py für setuptools hinzu

This commit is contained in:
Christopher Spinrath 2019-08-02 17:29:17 +02:00
parent abfcaa3aa1
commit f1d5d3e9fa
6 changed files with 45 additions and 35 deletions

View File

@ -1 +0,0 @@
../fcw.py

View File

@ -1 +0,0 @@
../fcw.py

View File

@ -1 +0,0 @@
../fcw.py

View File

@ -1 +0,0 @@
../fcw.py

View File

@ -275,13 +275,13 @@ class FCWFile:
@click.group()
def __cli():
def _cli():
pass
@__cli.command(name = 'topdf')
@_cli.command(name = 'topdf')
@click.argument('input', type = click.Path(exists = True, readable = True, file_okay = True, dir_okay = False))
@click.argument('output', required = False, type = click.Path(exists = False, writable = True, file_okay = True, dir_okay = False))
def __fcw2pdf(input, output):
def _fcw2pdf(input, output):
input = pathlib.Path(input)
if output is None:
@ -294,11 +294,11 @@ def __fcw2pdf(input, output):
with FCWFile(input) as fcw:
fcw.export_pdf(output, interactive = True)
@__cli.command(name = 'merge')
@_cli.command(name = 'merge')
@click.argument('input1', type = click.Path(exists = True, readable = True, file_okay = True, dir_okay = False))
@click.argument('input2', type = click.Path(exists = True, readable = True, file_okay = True, dir_okay = False))
@click.argument('output', type = click.Path(exists = False, writable = True, file_okay = True, dir_okay = False))
def __fcwmerge(input1, input2, output):
def _fcwmerge(input1, input2, output):
click.echo(":: Merging {} and {} into {}".format(input1, input2, output))
with FCWFile(input1) as fcw1, FCWFile(input2) as fcw2:
@ -318,9 +318,9 @@ def __fcwmerge(input1, input2, output):
# fcw.append_svg(svgfile)
# fcw.save(output)
@__cli.command(name = 'info')
@_cli.command(name = 'info')
@click.argument('input', type = click.Path(exists = True, readable = True, file_okay = True, dir_okay = False))
def __fcwinfo(input):
def _fcwinfo(input):
with FCWFile(input) as fcw:
click.echo("Manifest version: {}".format(fcw.manifest_version))
click.echo("Creation datetime: {}".format(fcw.creationdatetime))
@ -332,11 +332,11 @@ def __fcwinfo(input):
for resource in FCWResource:
click.echo("#{}: {}".format(resource.value, len(list(fcw.get_resources(resource)))))
@__cli.command(name = 'set-startpage')
@_cli.command(name = 'set-startpage')
@click.argument('input', type = click.Path(exists = True, readable = True, file_okay = True, dir_okay = False))
@click.argument('index', type = click.INT)
@click.argument('output', required = False, type = click.Path(exists = False, writable = True, file_okay = True, dir_okay = False))
def __fcwsetstartpage(input, index, output):
def _fcwsetstartpage(input, index, output):
print("WARNING: this function has never been tested!")
if output is None:
output = input
@ -348,37 +348,19 @@ def __fcwsetstartpage(input, index, output):
print("New startpage index is {} (internal page name is {})".format(index, newstartpage))
@__cli.command(name = 'print-manifest')
@_cli.command(name = 'print-manifest')
@click.argument('input', type = click.Path(exists = True, readable = True, file_okay = True, dir_okay = False))
def __fcwmanifest(input):
def _fcwmanifest(input):
with FCWFile(input) as fcw:
stream = io.BytesIO()
fcw.manifest.write(stream, encoding = 'utf-8', xml_declaration = True, standalone = True)
stream.seek(0)
print(stream.read().decode('utf-8'))
@__cli.command(name = 'license')
def __license():
@_cli.command(name = 'license')
def _license():
progname = pathlib.Path(sys.argv[0]).name
click.echo("{} Copyright (C) 2019 Christopher Spinrath <christopher.spinrath@tu-dortmund.de>".format(progname))
click.echo("This program comes with ABSOLUTELY NO WARRANTY.")
click.echo("This is free software, and you are welcome to redistribute it")
click.echo("under certain conditions; see the LICENSE file for details.")
def __main():
progmap = {
'fcw2pdf': __fcw2pdf,
'fcwmerge': __fcwmerge,
'fcwinfo': __fcwinfo,
}
progname = pathlib.Path(sys.argv[0]).name
if progname in progmap:
prog = progmap[progname]
else:
prog = __cli()
prog()
if __name__ == "__main__":
__main()

32
fcwtool/setup.py Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env python3
from setuptools import setup, find_packages
setup(
name="fcwtool",
version="0.1",
packages=find_packages(),
author="Christopher Spinrath",
author_email="christopher.spinrath@tu-dortmund.de",
description="Tools for reading and manipulating SMART Meeting Pro files",
license='GPLv3',
entry_points={
'console_scripts': [
'fcw2pdf = fcw:_fcw2pdf',
'fcwmerge = fcw:_fcwmerge',
'fcwinfo = fcw:_fcwinfo',
'fcwtool = fcw:_cli',
],
},
install_requires=[
'click',
'lxml',
'cairosvg',
'PyPDF2',
'tqdm',
],
)