Require path to files to be given for codegen
Signed-off-by: Dan Yeaw <dan@yeaw.me>
This commit is contained in:
parent
801fa23f42
commit
77cc2e359f
4
Makefile
4
Makefile
@ -21,9 +21,9 @@ translate: ## Translate and update .po and .mo files (requires PyBabel)
|
||||
model: gaphor/core/modeling/coremodel.py gaphor/UML/uml.py ## Generate Python model files from Gaphor models (requires Black, MyPy)
|
||||
|
||||
gaphor/core/modeling/coremodel.py: models/Core.gaphor models/Core.override gaphor/codegen/autocoder.py gaphor/codegen/override.py gaphor/codegen/writer.py
|
||||
gaphor/codegen/codegen.py Core.gaphor gaphor/core/modeling/coremodel.py Core.override && black $@ && mypy gaphor/core/modeling && isort gaphor/core/modeling/coremodel.py
|
||||
gaphor/codegen/codegen.py models/Core.gaphor gaphor/core/modeling/coremodel.py models/Core.override && black $@ && mypy gaphor/core/modeling && isort gaphor/core/modeling/coremodel.py
|
||||
|
||||
gaphor/UML/uml.py: models/UML.gaphor models/UML.override gaphor/codegen/autocoder.py gaphor/codegen/override.py gaphor/codegen/writer.py
|
||||
gaphor/codegen/codegen.py UML.gaphor uml.py UML.override && black $@ && mypy gaphor/UML && isort gaphor/UML/UML.gaphor
|
||||
gaphor/codegen/codegen.py models/UML.gaphor uml.py models/UML.override && black $@ && mypy gaphor/UML && isort gaphor/UML/UML.gaphor
|
||||
|
||||
.PHONY: help dist test docs icons translate model
|
||||
|
@ -14,45 +14,15 @@ from gaphor.codegen import autocoder
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"modelfile",
|
||||
type=Path,
|
||||
help="gaphor model filename, default location is the "
|
||||
"models package if full filename not given.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"outfile",
|
||||
type=Path,
|
||||
help="python data model filename, default location is "
|
||||
"the model name package if full filename not "
|
||||
"given.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"overrides",
|
||||
type=Path,
|
||||
help="override filename, default location is the "
|
||||
"models package if full filename not given.",
|
||||
)
|
||||
parser.add_argument("modelfile", type=Path, help="gaphor model filename")
|
||||
parser.add_argument("outfile", type=Path, help="python data model filename")
|
||||
parser.add_argument("overrides", type=Path, help="override filename")
|
||||
args = parser.parse_args()
|
||||
modelfile: Path = args.modelfile
|
||||
outfile: Path = args.outfile
|
||||
if str(modelfile) == modelfile.name:
|
||||
modelfile = (
|
||||
Path(__file__).absolute().parent.parent.parent / "models" / modelfile
|
||||
)
|
||||
if str(outfile) == outfile.name:
|
||||
outfile = Path(__file__).absolute().parent.parent / modelfile.stem / outfile
|
||||
overrides: Path = args.overrides
|
||||
if str(overrides) == overrides.name:
|
||||
overrides = (
|
||||
Path(__file__).absolute().parent.parent.parent / "models" / overrides
|
||||
)
|
||||
|
||||
print(f"Generating {args.outfile} from {args.modelfile}...")
|
||||
print(" (warnings can be ignored)")
|
||||
|
||||
autocoder.generate(modelfile, outfile, overrides)
|
||||
byte_compile([str(outfile)])
|
||||
autocoder.generate(args.modelfile, args.outfile, args.overrides)
|
||||
byte_compile([str(args.outfile)])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user