From 4619093dc3b493be4245c9da28c3fdcca1ea78fb Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 18 Oct 2023 10:50:09 +0200 Subject: [PATCH] Move to pyproject.toml --- Makefile | 2 +- setup.cfg | 65 ------------------------- setup.py | 3 -- src/unoserver/comparer.py | 94 ------------------------------------ src/unoserver/converter.py | 98 -------------------------------------- 5 files changed, 1 insertion(+), 261 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/Makefile b/Makefile index 4414440..6740bd5 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ devenv: ve/bin/fullrelease ve/bin/fullrelease: virtualenv $(root_dir)/ve --python python3 --system-site-packages - $(bin_dir)/pip install setuptools$(setuptools_ver) -e .[devenv] + $(bin_dir)/pip install -I setuptools$(setuptools_ver) -e .[devenv] check: devenv $(bin_dir)/black src/unoserver tests diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 54a02b7..0000000 --- a/setup.cfg +++ /dev/null @@ -1,65 +0,0 @@ -[metadata] -name = unoserver -version = 2.0b2.dev0 -description = A server for file conversions with Libre Office -long_description = file: README.rst, CONTRIBUTORS.rst, CHANGES.rst -classifiers = - Development Status :: 5 - Production/Stable - Topic :: Office/Business - Operating System :: POSIX :: Linux - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - License :: OSI Approved :: MIT License -keywords = libreoffice,conversion,documents,uno,unoconv -author = Lennart Regebro -author_email = regebro@gmail.com -url = https://github.com/unoconv/unoserver -license = MIT - -[options] -packages = unoserver -package_dir = - = src -include_package_data = True -zip_safe = False -install_requires = - setuptools -test_suite = tests -python_requires = >= 3.8 - -[options.entry_points] -console_scripts = - unoserver = unoserver.server:main - unoconvert = unoserver.client:converter_main - unocompare = unoserver.client:comparer_main - -[options.extras_require] -devenv = - pytest - pytest-cov - black - flake8 - pyroma - check-manifest - zest.releaser - -[flake8] -max-line-length=120 - -[tool:pytest] -testpaths = - tests - -[check-manifest] -ignore = - .pre-commit-config.yaml - tests/* - tests/documents/* - -[bdist_wheel] -universal=0 diff --git a/setup.py b/setup.py deleted file mode 100644 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/src/unoserver/comparer.py b/src/unoserver/comparer.py index 8102848..b3858d8 100644 --- a/src/unoserver/comparer.py +++ b/src/unoserver/comparer.py @@ -11,7 +11,6 @@ import logging import os import unohelper -import warnings from com.sun.star.beans import PropertyValue from com.sun.star.io import XOutputStream @@ -269,96 +268,3 @@ def compare( return output_stream.buffer.getvalue() else: return None - - -def main(): - logging.basicConfig() - logger.setLevel(logging.DEBUG) - - parser = argparse.ArgumentParser("unocompare") - parser.add_argument( - "infile", - help="The path to the modified file to be compared with the original one (use - for stdin)", - ) - parser.add_argument( - "inOrigfile", - help="The path to the original file to be compared with the modified one (use - for stdin)", - ) - parser.add_argument( - "outfile", - help="The path to the result of the comparison and converted file (use - for stdout)", - ) - parser.add_argument( - "--convert-to", - help="The file type/extension of the output file (ex pdf). Deprecated in favor for --file-type", - ) - parser.add_argument( - "--file-type", - help="The file type/extension of the output file (ex pdf). Required when using stdout", - ) - parser.add_argument( - "--interface", - default=None, - help="The interface used by the server. Deprecated in favor for --host", - ) - parser.add_argument( - "--host", default="127.0.0.1", help="The host used by the server" - ) - parser.add_argument("--port", default="2002", help="The port used by the server") - args = parser.parse_args() - - if not sys.warnoptions: - warnings.simplefilter("default") # Change the filter in this process - - warnings.warn( - "Note that the order of the file parameters will change in 2.0.", - DeprecationWarning, - ) - - if args.interface is not None: - warnings.warn( - "The argument --interface has been renamed --host and will stop working in 2.0.", - DeprecationWarning, - ) - if args.interface is None and args.host is not None: - args.interface = args.host - - if args.convert_to is not None: - warnings.warn( - "The argument --convert-to has been renamed --file-type and will stop working in 2.0.", - DeprecationWarning, - ) - if args.file_type is not None: - args.convert_to = args.file_type - - comparer = UnoComparer(args.interface, args.port) - - if args.outfile == "-": - # Set outfile to None, to get the data returned from the function, - # instead of written to a file. - args.outfile = None - - if args.infile == "-": - # Get data from stdin - indata = sys.stdin.buffer.read() - result = comparer.compare( - indata=indata, - inOrgpath=args.inOrigfile, - outpath=args.outfile, - convert_to=args.convert_to, - ) - else: - result = comparer.compare( - inpath=args.infile, - inOrgpath=args.inOrigfile, - outpath=args.outfile, - convert_to=args.convert_to, - ) - - if args.outfile is None: - # Pipe result to stdout - sys.stdout.buffer.write(result) - - -if __name__ == "__main__": - main() diff --git a/src/unoserver/converter.py b/src/unoserver/converter.py index d71db43..90f34b9 100644 --- a/src/unoserver/converter.py +++ b/src/unoserver/converter.py @@ -11,7 +11,6 @@ import logging import os import unohelper -import warnings from pathlib import Path from com.sun.star.beans import PropertyValue @@ -269,100 +268,3 @@ def convert( return output_stream.buffer.getvalue() else: return None - - -def main(): - logging.basicConfig() - logger.setLevel(logging.DEBUG) - - parser = argparse.ArgumentParser("unoconvert") - parser.add_argument( - "infile", help="The path to the file to be converted (use - for stdin)" - ) - parser.add_argument( - "outfile", help="The path to the converted file (use - for stdout)" - ) - parser.add_argument( - "--convert-to", - help="The file type/extension of the output file (ex pdf). Required when using stdout", - ) - parser.add_argument( - "--filter", - default=None, - help="The export filter to use when converting. It is selected automatically if not specified.", - ) - parser.add_argument( - "--filter-options", - default=[], - action="append", - help="Options for the export filter, in name=value format. Use true/false for boolean values.", - ) - parser.add_argument( - "--update-index", - action="store_true", - help="Updes the indexes before conversion. Can be time consuming.", - ) - parser.add_argument( - "--dont-update-index", - action="store_false", - dest="update_index", - help="Skip updating the indexes.", - ) - parser.set_defaults(update_index=True) - parser.add_argument( - "--interface", - default=None, - help="The interface used by the server. Deprecated in favor for --host", - ) - parser.add_argument( - "--host", default="127.0.0.1", help="The host used by the server" - ) - parser.add_argument("--port", default="2002", help="The port used by the server") - args = parser.parse_args() - - if not sys.warnoptions: - warnings.simplefilter("default") # Change the filter in this process - - if args.interface is not None: - warnings.warn( - "The argument --interface has been renamed --host and will stop working in 2.0.", - DeprecationWarning, - ) - if args.interface is None and args.host is not None: - args.interface = args.host - - converter = UnoConverter(args.interface, args.port) - - if args.outfile == "-": - # Set outfile to None, to get the data returned from the function, - # instead of written to a file. - args.outfile = None - - if args.infile == "-": - # Get data from stdin - indata = sys.stdin.buffer.read() - result = converter.convert( - indata=indata, - outpath=args.outfile, - convert_to=args.convert_to, - filtername=args.filter, - filter_options=args.filter_options, - update_index=args.update_index, - ) - else: - result = converter.convert( - inpath=args.infile, - outpath=args.outfile, - convert_to=args.convert_to, - filtername=args.filter, - filter_options=args.filter_options, - update_index=args.update_index, - ) - - if args.outfile is None: - # Pipe result to stdout - sys.stdout.buffer.write(result) - - -if __name__ == "__main__": - main()