Skip to content

Commit

Permalink
close #537 by creating an importer for the new format
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed Jul 28, 2024
1 parent a34b435 commit 84caf20
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 330 deletions.
23 changes: 16 additions & 7 deletions application/defs/cre_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,27 @@ class ExportFormat(
Enum
): # TODO: this can likely be replaced with a method that iterates over an object's vars and formats headers to
# <doctype>:<name>:<varname>
separator = ":"
section = "section"
subsection = "subsection"
separator = "|"
section = "name"
# subsection = "subsection"
hyperlink = "hyperlink"
link_type = "link_type"
name = "name"
# link_type = "link_type"
# name = "name"
id = "id"
description = "description"
cre_link = "Linked_CRE_"
# cre_link = "Linked_CRE_"
cre = "CRE"
tooltype = "ToolType"
sectionID = "SectionID"
# sectionID = "SectionID"

@classmethod
def attributes():
return [
"name",
"hyperlink",
"description",
"id",
]

@staticmethod
def get_doctype(header: str) -> Optional["Credoctypes"]:
Expand Down
177 changes: 18 additions & 159 deletions application/tests/utils/data_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,174 +516,33 @@ def root_csv_minimum_data():
def export_format_data():
input_data = [
{
"CRE:description": "C1 description",
"CRE:id": "111-111",
"CRE:name": "C1",
"Standard:S1:hyperlink": "https://example.com/S1",
"Standard:S1:link_type": "Linked To",
"Standard:S1:section": "SE1",
"Standard:S1:subsection": "SBE1",
"Tool:S2:hyperlink": "",
"Tool:S2:link_type": "",
"Tool:S2:description": "",
"Tool:S2:ToolType": "",
"Code:S3:hyperlink": "",
"Code:S3:link_type": "",
"Code:S3:description": "",
"Linked_CRE_0:id": "",
"Linked_CRE_0:link_type": "",
"Linked_CRE_0:name": "",
"Linked_CRE_1:id": "",
"Linked_CRE_1:link_type": "",
"Linked_CRE_1:name": "",
"CRE 0": "111-111|C1",
"S1:hyperlink": "https://example.com/S1",
"S1:name": "SE1",
"S1:id": "id1",
"SL:hyperlink": "",
"SL:link_type": "",
"SL:section": "",
"SL:subsection": "",
"SL:name": "",
"SL:id": "",
"SL2:hyperlink": "",
"SL2:link_type": "",
"SL2:section": "",
"SL2:subsection": "",
"SL2:name": "",
"SL2:id": "",
"SLL:hyperlink": "",
"SLL:link_type": "",
"SLL:section": "",
"SLL:subsection": "",
"SLL:name": "",
"SLL:id": "",
},
{
"CRE:description": "C2 description",
"CRE:id": "222-222",
"CRE:name": "C2",
"Standard:S1:hyperlink": "",
"Standard:S1:link_type": "",
"Standard:S1:section": "",
"Standard:S1:subsection": "",
"Tool:S2:hyperlink": "",
"Tool:S2:link_type": "",
"Tool:S2:description": "",
"Tool:S2:ToolType": "",
"Code:S3:hyperlink": "",
"Code:S3:link_type": "",
"Code:S3:description": "",
"Linked_CRE_0:id": "333-333",
"Linked_CRE_0:link_type": "Contains",
"Linked_CRE_0:name": "C3",
"Linked_CRE_1:id": "",
"Linked_CRE_1:link_type": "",
"Linked_CRE_1:name": "",
"SL:hyperlink": "",
"SL:link_type": "",
"SL:section": "",
"SL:subsection": "",
"SL2:hyperlink": "",
"SL2:link_type": "",
"SL2:section": "",
"SL2:subsection": "",
"SLL:hyperlink": "",
"SLL:link_type": "",
"SLL:section": "",
"SLL:subsection": "",
},
{
"CRE:description": "C3 description",
"CRE:id": "333-333",
"CRE:name": "C3",
"Standard:S1:hyperlink": "",
"Standard:S1:link_type": "",
"Standard:S1:section": "",
"Standard:S1:subsection": "",
"Tool:S2:hyperlink": "",
"Tool:S2:link_type": "",
"Tool:S2:description": "",
"Tool:S2:ToolType": "",
"Code:S3:hyperlink": "https://example.com/S3",
"Code:S3:link_type": "Linked To",
"Code:S3:description": "SE3",
"Linked_CRE_0:id": "222-222",
"Linked_CRE_0:link_type": "Is Part Of",
"Linked_CRE_0:name": "C2",
"Linked_CRE_1:id": "",
"Linked_CRE_1:link_type": "",
"Linked_CRE_1:name": "",
"SL:hyperlink": "",
"SL:link_type": "",
"SL:section": "",
"SL:subsection": "",
"SL2:hyperlink": "",
"SL2:link_type": "",
"SL2:section": "",
"SL2:subsection": "",
"SLL:hyperlink": "",
"SLL:link_type": "",
"SLL:section": "",
"SLL:subsection": "",
"CRE 1": "222-222|C2",
},
{
"CRE:description": "C5 description",
"CRE:id": "555-555",
"CRE:name": "C5",
"Standard:S1:hyperlink": "https://example.com/S1",
"Standard:S1:link_type": "Linked To",
"Standard:S1:section": "SE1",
"Standard:S1:subsection": "SBE1",
"Tool:S2:hyperlink": "",
"Tool:S2:link_type": "",
"Tool:S2:description": "",
"Tool:S2:ToolType": "",
"Code:S3:hyperlink": "",
"Code:S3:link_type": "",
"Code:S3:description": "",
"Linked_CRE_0:id": "",
"Linked_CRE_0:link_type": "",
"Linked_CRE_0:name": "",
"Linked_CRE_1:id": "",
"Linked_CRE_1:link_type": "",
"Linked_CRE_1:name": "",
"SL:hyperlink": "",
"SL:link_type": "",
"SL:section": "",
"SL:subsection": "",
"SL2:hyperlink": "",
"SL2:link_type": "",
"SL2:section": "",
"SL2:subsection": "",
"SLL:hyperlink": "",
"SLL:link_type": "",
"SLL:section": "",
"SLL:subsection": "",
"CRE 3": "333-333|C3",
"S3:hyperlink": "https://example.com/S3",
"S3:description": "SE3",
"S3:name": "SE3 section",
},
{
"CRE:description": "C5 description",
"CRE:id": "555-555",
"CRE:name": "C5",
"Standard:S1:hyperlink": "https://example.com/S1",
"Standard:S1:link_type": "Linked To",
"Standard:S1:section": "SE1",
"Standard:S1:subsection": "SBE11",
"Tool:S2:hyperlink": "",
"Tool:S2:link_type": "",
"Tool:S2:description": "",
"Tool:S2:ToolType": "",
"Code:S3:hyperlink": "",
"Code:S3:link_type": "",
"Code:S3:description": "",
"Linked_CRE_0:id": "",
"Linked_CRE_0:link_type": "",
"Linked_CRE_0:name": "",
"Linked_CRE_1:id": "",
"Linked_CRE_1:link_type": "",
"Linked_CRE_1:name": "",
"SL:hyperlink": "",
"SL:link_type": "",
"SL:section": "",
"SL:subsection": "",
"SL2:hyperlink": "",
"SL2:link_type": "",
"SL2:section": "",
"SL2:subsection": "",
"SLL:hyperlink": "",
"SLL:link_type": "",
"SLL:section": "",
"SLL:subsection": "",
"CRE 4": "555-555|C5",
"S1:hyperlink": "https://example.com/S1",
"S1:name": "SE1",
},
{
"CRE:description": "C6 description",
Expand Down
Loading

0 comments on commit 84caf20

Please sign in to comment.