Skip to content

Commit

Permalink
Move to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Oct 18, 2023
1 parent 2434d66 commit 4619093
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 261 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
65 changes: 0 additions & 65 deletions setup.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

94 changes: 0 additions & 94 deletions src/unoserver/comparer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
98 changes: 0 additions & 98 deletions src/unoserver/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import logging
import os
import unohelper
import warnings

from pathlib import Path
from com.sun.star.beans import PropertyValue
Expand Down Expand Up @@ -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()

0 comments on commit 4619093

Please sign in to comment.