diff --git a/fcwtool/bin/fcw2pdf b/fcwtool/bin/fcw2pdf deleted file mode 120000 index b25e227..0000000 --- a/fcwtool/bin/fcw2pdf +++ /dev/null @@ -1 +0,0 @@ -../fcw.py \ No newline at end of file diff --git a/fcwtool/bin/fcwinfo b/fcwtool/bin/fcwinfo deleted file mode 120000 index b25e227..0000000 --- a/fcwtool/bin/fcwinfo +++ /dev/null @@ -1 +0,0 @@ -../fcw.py \ No newline at end of file diff --git a/fcwtool/bin/fcwmerge b/fcwtool/bin/fcwmerge deleted file mode 120000 index b25e227..0000000 --- a/fcwtool/bin/fcwmerge +++ /dev/null @@ -1 +0,0 @@ -../fcw.py \ No newline at end of file diff --git a/fcwtool/bin/fcwtool b/fcwtool/bin/fcwtool deleted file mode 120000 index b25e227..0000000 --- a/fcwtool/bin/fcwtool +++ /dev/null @@ -1 +0,0 @@ -../fcw.py \ No newline at end of file diff --git a/fcwtool/fcw.py b/fcwtool/fcw.py index ae617f1..dd5947d 100755 --- a/fcwtool/fcw.py +++ b/fcwtool/fcw.py @@ -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 ".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() diff --git a/fcwtool/setup.py b/fcwtool/setup.py new file mode 100755 index 0000000..36374ff --- /dev/null +++ b/fcwtool/setup.py @@ -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', + ], +)