diff --git a/src/ifcclash/README.md b/src/ifcclash/README.md index 7a46078732..e9c38e3756 100644 --- a/src/ifcclash/README.md +++ b/src/ifcclash/README.md @@ -55,13 +55,12 @@ defined with data sources. ], "b": [ { - "file": "/path/to/two.ifc" + "file": "/path/to/two.ifc", "selector": ".IfcWall", "mode": "i" } ] - }, - ... + } ] ``` diff --git a/src/ifcpatch/README.md b/src/ifcpatch/README.md index 3be1198fed..ac77c270b6 100644 --- a/src/ifcpatch/README.md +++ b/src/ifcpatch/README.md @@ -21,6 +21,13 @@ If you want something more Unix-like ... $ alias ifcpatch='python -m ifcpatch' ``` +Alternatively, you can package it as a distributable. + +``` +$ python make.py +$ ./dist/ifcpatch +``` + ## Usage Usage is like any other CLI app. diff --git a/src/ifcpatch/bootstrap.py b/src/ifcpatch/bootstrap.py new file mode 100644 index 0000000000..6fa8bba961 --- /dev/null +++ b/src/ifcpatch/bootstrap.py @@ -0,0 +1,8 @@ +import toposort +import ifcpatch +import ifcpatch.recipes +import ifcopenshell.util.selector +import ifcopenshell.util.element +import ifcopenshell.util.schema + +import ifcpatch.__main__ diff --git a/src/ifcpatch/ifcpatch/__init__.py b/src/ifcpatch/ifcpatch/__init__.py index d8cf8fa5e4..1675ecae94 100644 --- a/src/ifcpatch/ifcpatch/__init__.py +++ b/src/ifcpatch/ifcpatch/__init__.py @@ -3,7 +3,6 @@ import ifcopenshell import logging -import argparse def execute(args, is_library=None): @@ -28,21 +27,4 @@ def execute(args, is_library=None): text_file.write(ifc_file) else: ifc_file.write(args["output"]) - - -def main(): - parser = argparse.ArgumentParser(description="Patches IFC files to fix badly formatted data") - parser.add_argument("-i", "--input", type=str, required=True, help="The IFC file to patch") - parser.add_argument("-o", "--output", type=str, help="The output file to save the patched IFC") - parser.add_argument("-r", "--recipe", type=str, required=True, help="Name of the recipe to use when patching") - parser.add_argument("-l", "--log", type=str, help="Specify a log file", default="ifcpatch.log") - parser.add_argument("-a", "--arguments", nargs="+", help="Specify custom arguments to the patch recipe") - args = vars(parser.parse_args()) - - execute(args) - print("# All tasks are complete :-)") - - -if __name__ == "__main__": - main() diff --git a/src/ifcpatch/ifcpatch/__main__.py b/src/ifcpatch/ifcpatch/__main__.py index 3b48deed79..c6e15d309d 100644 --- a/src/ifcpatch/ifcpatch/__main__.py +++ b/src/ifcpatch/ifcpatch/__main__.py @@ -1,4 +1,12 @@ #!/usr/bin/env python3 +import argparse import ifcpatch -ifcpatch.main() +parser = argparse.ArgumentParser(description="Patches IFC files to fix badly formatted data") +parser.add_argument("-i", "--input", type=str, required=True, help="The IFC file to patch") +parser.add_argument("-o", "--output", type=str, help="The output file to save the patched IFC") +parser.add_argument("-r", "--recipe", type=str, required=True, help="Name of the recipe to use when patching") +parser.add_argument("-l", "--log", type=str, help="Specify a log file", default="ifcpatch.log") +parser.add_argument("-a", "--arguments", nargs="+", help="Specify custom arguments to the patch recipe") +args = vars(parser.parse_args()) +ifcpatch.execute(args) diff --git a/src/ifcpatch/ifcpatch/make.py b/src/ifcpatch/ifcpatch/make.py deleted file mode 100644 index a2a9da0b9a..0000000000 --- a/src/ifcpatch/ifcpatch/make.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -import os -import subprocess - -# add hidden imports in recipes here -HIDDEN_IMPORTS = [ - "ifcopenshell.util.selector", - "ifcopenshell.util.element", - "ifcopenshell.util.schema", - "toposort", -] - - -def main(): - hiddenimport_args = " ".join('--hiddenimport "{}"'.format(imp) for imp in HIDDEN_IMPORTS) - cmd = 'pyinstaller ./__init__.py --onefile --clean --add-data ".{}ifcpatch" {}'.format( - os.pathsep, hiddenimport_args - ) - subprocess.check_output(cmd, shell=True) - - -if __name__ == "__main__": - main() diff --git a/src/ifcpatch/make.py b/src/ifcpatch/make.py new file mode 100644 index 0000000000..78e13bfc03 --- /dev/null +++ b/src/ifcpatch/make.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +import os +import subprocess + +cmd = f'pyinstaller ./bootstrap.py --name ifcpatch --onefile --clean --add-data "ifcpatch{os.pathsep}ifcpatch"' +subprocess.check_output(cmd, shell=True)