Skip to content

Commit

Permalink
clean directory only if flag
Browse files Browse the repository at this point in the history
  • Loading branch information
chicco785 committed Dec 21, 2023
1 parent 4f268ef commit 5a286a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CIMgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ def generate_clean_sub_classes(class_dict_with_origins, clean_class_dict):

add_sub_classes_of_sub_classes_clean(clean_class_dict, class_dict_with_origins)

def cim_generate(directory, outputPath, version, langPack):
def cim_generate(directory, outputPath, version, langPack, clean_outdir):
"""Generates cgmes python classes from cgmes ontology
This function uses package xmltodict to parse the RDF files. The parse_rdf function sorts the classes to
Expand All @@ -712,7 +712,8 @@ def cim_generate(directory, outputPath, version, langPack):
"""

# clean directory
remove_tree(Path(outputPath))
if clean_outdir:
remove_tree(Path(outputPath))

profiles_array = []

Expand Down
3 changes: 2 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
parser.add_argument('--schemadir', type=str, help='The schema directory', required=True)
parser.add_argument('--langdir', type=str, help='The langpack directory', required=True)
parser.add_argument('--cgmes_version', type=str, choices=['cgmes_v2_4_13', 'cgmes_v2_4_15', 'cgmes_v3_0_0'], default='cgmes_v2_4_15', help='CGMES Version')
parser.add_argument('--clean_outdir', type=bool, help='Clean the output directory', required=False, default=False)
args = parser.parse_args()

langPack = importlib.import_module(args.langdir + ".langPack")
schema_path = os.path.join(os.getcwd(), args.schemadir)
CIMgen.cim_generate(schema_path, args.outdir, args.cgmes_version, langPack)
CIMgen.cim_generate(schema_path, args.outdir, args.cgmes_version, langPack, args.clean_outdir)

0 comments on commit 5a286a7

Please sign in to comment.