예제 #1
0
 def test_maturity_model_parser_004(self, test_ekgmm_repo_dir,
                                    test_ekgmm_docs_root, test_output_dir):
     log_item("Git repo dir", test_ekgmm_repo_dir)
     sys.argv = [
         'pytest', '--model-root', test_ekgmm_repo_dir, '--docs-root',
         test_ekgmm_docs_root, '--fragments-root',
         str((Path(test_ekgmm_docs_root) / "../docs-fragments").resolve()),
         '--output', f"{test_output_dir}/ekgmm_test_004", '--verbose'
     ]
     assert 0 == ekglib.maturity_model_parser.main()
예제 #2
0
파일: exporter.py 프로젝트: EKGF/ekglib
 def export(self, output) -> int:
     if not output:
         warning(
             "You did not specify an output file or stream, no output file created"
         )
         return 1
     if isinstance(output, str):
         log_item("Writing output to", output)
     self.g.serialize(destination=output, format='ttl')
     if isinstance(output, str):
         log_item("Created", output)
     return 0
예제 #3
0
 def __name_with_lang_for(self, subject_uri, lang: Optional[str],
                          hint: str):
     for uri, value in self.g.preferredLabel(subject_uri, lang=lang):
         if isinstance(value, rdflib.term.Literal):
             log_item(f"{hint} Name", value.toPython())
             return value.toPython()
         log_item(f"{hint} Name", value)
         log_item("Unknown Value Type", type(value))
         return value.toPython()
     return None
예제 #4
0
 def rewrite_fragment_references(self, fragments_root: Path):
     """
     For each reference to some text-fragment rewrite the path to that markdown file
     relative to the given input directory
     """
     predicate = MATURIY_MODEL.backgroundAndIntro
     for (subject, objekt) in self.g.subject_objects(predicate):
         log_item("Subject", subject)
         log_item("Fragments Root", fragments_root)
         fragment_path = fragments_root / objekt
         log_item("Fragment Path", fragment_path)
         if not fragment_path.exists():
             raise value_error(f"Fragment {fragment_path} does not exist")
         self.g.remove((subject, predicate, objekt))
         self.g.add((subject, predicate, Literal(str(fragment_path))))
예제 #5
0
 def has_type_capability(self, subject_iri):
     if self.verbose:
         log_item("Type of",
                  f"{subject_iri} == {self.get_type(subject_iri)}")
     return self.has_type(subject_iri, MATURIY_MODEL.Capability)
예제 #6
0
 def local_name_for(self, subject_node: Node, hint: str) -> str:
     for local_name in self.g.objects(subject_node,
                                      MATURIY_MODEL.iriLocalName):
         log_item(f"{hint} Local Name", local_name)
         return str(local_name)
     raise value_error(f"{hint} has no iriLocalName: {subject_node}")
예제 #7
0
 def capability_number_for(self, capability_node, hint: str):
     for number in self.g.objects(capability_node,
                                  MATURIY_MODEL.capabilityNumber):
         log_item(f"{hint} Number", number)
         return str(number)
     raise value_error(f"{hint} has no capabilityNumber: {capability_node}")
예제 #8
0
def makedirs(path: Path, hint: str):
    log_item(f"{hint} Path", path)
    try:
        os.makedirs(path)
    except FileExistsError:
        return
예제 #9
0
 def copy(cls, mkdocs: bool, from_path: Path, to_path: Path):
     log_item("Copying", f"{from_path} -> {to_path}")
     old_file = File.existing_file(mkdocs=mkdocs, path=from_path)
     new_file = File(mkdocs=mkdocs, path=to_path)
     new_file.rewrite_all_file(old_file.read_all_content())