Skip to content

Commit 458ec63

Browse files
authored
Merge pull request #5 from Spyderisk/4-construction-state-flag
Extended command line option '-u' so it negates construction state flags
2 parents 9abb5ff + c71e074 commit 458ec63

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

csv2nq.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def output_scale(nqw, saveHighest, infilename, entity, heading):
222222
#
223223
# Assets and relationships.
224224
#
225-
def output_domain_assets(nqw, heading, entities):
225+
def output_domain_assets(nqw, unfiltered, heading, entities):
226226
# Output a heading for this section
227227
nqw.write_comment("")
228228
nqw.write_comment(heading)
@@ -262,7 +262,7 @@ def output_domain_assets(nqw, heading, entities):
262262
nqw.write_quad(uri, nqw.encode_ssm_uri("core#isAssertable"), isAssertable)
263263
nqw.write_quad(uri, nqw.encode_ssm_uri("core#isVisible"), isVisible)
264264
if(HAS_CONSTRUCTION_STATE in feature_list):
265-
if(row[constructionState_index].lower() == "true"):
265+
if(row[constructionState_index].lower() == "true" and not unfiltered):
266266
nqw.write_quad(uri, nqw.encode_ssm_uri("core#isConstructionState"), isConstructionState)
267267

268268
# Output a spacer at the end of this resource
@@ -298,7 +298,7 @@ def output_domain_assets(nqw, heading, entities):
298298
# Output a spacer at the end of this section
299299
nqw.write_comment("")
300300

301-
def output_relationships(nqw, heading, entities):
301+
def output_relationships(nqw, unfiltered, heading, entities):
302302
# Output a heading for this section
303303
nqw.write_comment("")
304304
nqw.write_comment(heading)
@@ -342,7 +342,7 @@ def output_relationships(nqw, heading, entities):
342342
nqw.write_quad(uri, nqw.encode_ssm_uri("core#isVisible"), isVisible)
343343
nqw.write_quad(uri, nqw.encode_ssm_uri("core#hidden"), hidden)
344344
if(HAS_CONSTRUCTION_STATE in feature_list):
345-
if(row[constructionState_index].lower() == "true"):
345+
if(row[constructionState_index].lower() == "true" and not unfiltered):
346346
nqw.write_quad(uri, nqw.encode_ssm_uri("core#isConstructionState"), isConstructionState)
347347

348348
# Output a spacer at the end of this resource
@@ -2024,15 +2024,15 @@ def output_mapping_file(mapping_filename, ontology, domain_graph):
20242024
parser.add_argument("-i", "--input", dest="input", required=True, metavar="directory", help="Directory containing CSV files for input")
20252025
parser.add_argument("-o", "--output", dest="output", required=True, metavar="filename", help="Output NQ filename")
20262026
parser.add_argument("-m", "--mapping", dest="mapping", metavar="filename", help="Output JSON icon-mapping filename")
2027-
parser.add_argument("-u", "--unfiltered", help="Causes SSM GUI Misbehaviour and TWA visibility flags to be set to true.", action="store_true")
2027+
parser.add_argument("-u", "--unfiltered", help="Causes SSM GUI Misbehaviour and TWA visibility flags to be set to true, construction state flags to false.", action="store_true")
20282028
parser.add_argument("-e", "--expanded", help="Add population model support by expanding relevant structures", action="store_true")
20292029
parser.add_argument("-v", "--version", help="Set the versionInfo string (defaults to timestamp) '-unfiltered' will be added to the version string if '-u' is used.")
20302030
parser.add_argument("-n", "--name", help="Set the domainGraph string (defaults to what is found in DomainModel.csv). '-unexpanded' will be appended for population models unless '-e' is used.")
20312031
raw = parser.parse_args()
20322032
args = vars(raw)
20332033

20342034
if(raw.unfiltered):
2035-
print("Misbehaviour and TWA visibility flags set to TRUE")
2035+
print("Misbehaviour and TWA visibility flags set to TRUE, construction state flags to false")
20362036
else:
20372037
print("Misbehaviour and TWA visibility flags use domain model specifications")
20382038

@@ -2096,8 +2096,8 @@ def output_mapping_file(mapping_filename, ontology, domain_graph):
20962096
MIN_PERF = output_scale(nqw, False, "PerformanceImpactLevel.csv", "PerformanceImpactLevel", "Scale for Control Performance Overhead Levels")
20972097

20982098
# Output assets and relationships, saving them for later
2099-
output_domain_assets(nqw, "Domain asset definitions", assets)
2100-
output_relationships(nqw, "Asset relationship definitions", relationships)
2099+
output_domain_assets(nqw, raw.unfiltered, "Domain asset definitions", assets)
2100+
output_relationships(nqw, raw.unfiltered, "Asset relationship definitions", relationships)
21012101

21022102
# Output Roles, Controls, Misbehaviours and TWA, saving them for later
21032103
output_roles(nqw, "Role definitions", roles)

0 commit comments

Comments
 (0)