示例#1
0
def handle_single_ofile(changed_file, base_dir, target_repo):
    """
    assuming the change_file is an ontology file
    :param changed_file: relative directory of the file e.g. dir1/dir2/my.owl
    :return:
    """
    import ar2dtool
    import widoco
    import oops
    dolog("will call create or get conf")
    conf = create_of_get_conf(changed_file, base_dir)
    dolog("conf: "+str(conf))
    if conf['ar2dtool_enable']:
        dolog("will call draw diagrams")
        ar2dtool.draw_diagrams([changed_file], base_dir)
    if conf['widoco_enable']:
        dolog('will call widoco')
        widoco.generate_widoco_docs([changed_file], base_dir)
    if conf['oops_enable']:
        dolog('will call oops')
        oops.oops_ont_files(target_repo=target_repo, changed_files=[changed_file], base_dir=base_dir)
示例#2
0
def handle_single_ofile(changed_file, base_dir, target_repo):
    """
    assuming the change_file is an ontology file
    :param changed_file: relative directory of the file e.g. dir1/dir2/my.owl
    :return:
    """
    import ar2dtool
    import widoco
    import oops
    dolog("will call create or get conf")
    conf = create_of_get_conf(changed_file, base_dir)
    dolog("conf: " + str(conf))
    if conf['ar2dtool_enable']:
        dolog("will call draw diagrams")
        ar2dtool.draw_diagrams([changed_file], base_dir)
    if conf['widoco_enable']:
        dolog('will call widoco')
        widoco.generate_widoco_docs([changed_file], base_dir)
    if conf['oops_enable']:
        dolog('will call oops')
        oops.oops_ont_files(target_repo=target_repo,
                            changed_files=[changed_file],
                            base_dir=base_dir)
示例#3
0
def handle_single_ofile(changed_file,
                        base_dir,
                        target_repo,
                        change_status,
                        repo=None,
                        progress_inc=0.0):
    """
    assuming the change_file is an ontology file
    :param changed_file: relative directory of the file e.g. dir1/dir2/my.owl
    :param base_dir:
    :param target_repo:
    :param change_status:
    :param repo: a Repo instance of the target repo
    :param progress_inc: how much to increment the progress after each
    :return:
    """
    import ar2dtool
    import widoco
    import oops
    import owl2jsonld
    import syntaxchecker
    import themis
    dolog("will call create or get conf")
    conf = create_of_get_conf(changed_file, base_dir)
    dolog("conf: " + str(conf))
    if not syntaxchecker.valid_syntax(os.path.join(base_dir, changed_file)):
        repo.notes += "syntax error in %s\n" % changed_file
        repo.save()
        return
    if conf['ar2dtool']['enable']:
        dolog("will call draw diagrams")
        change_status(target_repo, 'drawing diagrams for: ' + changed_file)
        repo.update_ontology_status(ontology=changed_file, status='diagram')
        repo.save()
        try:
            r = ar2dtool.draw_diagrams([changed_file], base_dir)
            # if r != "":
            #     print 'in init draw detected an error'
            #     # repo.notes += 'Error generating diagrams for %s. ' % changed_file
            #     repo.save()
        except Exception as e:
            dolog("Exception in running ar2dtool.draw_diagrams: " + str(e))
    repo.progress += progress_inc
    repo.save()
    if conf['widoco']['enable']:
        dolog('will call widoco')
        change_status(target_repo, 'generating docs for: ' + changed_file)
        repo.update_ontology_status(ontology=changed_file,
                                    status='documentation')
        repo.save()
        try:
            r = widoco.generate_widoco_docs(
                [changed_file],
                base_dir,
                languages=conf['widoco']['languages'])
            # if r != "":
            #     print 'in init documentation detected an error for ontology file: %s' % changed_file
            #     # repo.notes += 'Error generating documentation for %s. ' % changed_file
            #     repo.save()
        except Exception as e:
            dolog("Exception in running widoco.generate_widoco_docs: " +
                  str(e))
    repo.progress += progress_inc
    repo.save()
    if conf['oops']['enable']:
        dolog('will call oops')
        change_status(target_repo, 'evaluating: ' + changed_file)
        repo.update_ontology_status(ontology=changed_file, status='evaluation')
        repo.save()
        try:
            r = oops.oops_ont_files(target_repo=target_repo,
                                    changed_files=[changed_file],
                                    base_dir=base_dir)
            # if r != "":
            #     print 'in init evaluation detected an error'
            #     # repo.notes += 'Error generating evaluation for %s. ' % changed_file
            #     repo.save()
            if r != "":
                dolog("Error in producing OOPS! report: " + str(r))
                repo.notes += "Error in producing the evaluation report for: %s" % str(
                    changed_file)
                repo.save()
        except Exception as e:
            dolog("Exception in running oops.oops.oops_ont_files: " + str(e))
    repo.progress += progress_inc
    repo.save()
    if conf['owl2jsonld']['enable']:
        dolog('will call owl2jsonld')
        change_status(target_repo, 'generating context for: ' + changed_file)
        repo.update_ontology_status(ontology=changed_file, status='jsonld')
        repo.save()
        try:
            owl2jsonld.generate_owl2jsonld_file([changed_file],
                                                base_dir=base_dir)
        except Exception as e:
            dolog(
                "Exception in running owl2jsonld.generate_owl2jsonld_file: " +
                str(e))
    repo.progress += progress_inc
    if conf['themis']['enable']:
        dolog('will call themis')
        change_status(target_repo,
                      'generating validation for: ' + changed_file)
        repo.update_ontology_status(ontology=changed_file, status='validation')
        repo.save()
        try:
            themis.validate_ontologies(target_repo=target_repo,
                                       changed_files=[changed_file],
                                       base_dir=base_dir)
        except Exception as e:
            dolog("Exception in running themis: " + str(e))
    repo.update_ontology_status(ontology=changed_file, status='finished')
    repo.save()