def run_from_terminal(): """Run ontology2dot from the terminal.""" # Parse the user arguments parser = argparse.ArgumentParser( description="Convert an ontology in OWL format to " "an ontology in YAML format." ) parser.add_argument("to_plot", metavar="to_plot", type=str, nargs="+", help="Either installed namespaces or paths " "to yaml ontology files") parser.add_argument("--output-filename", "-o", type=os.path.abspath, default=None, help="The name of the output file") parser.add_argument("--group", "-g", action="store_true", help="Whether to organize each namespace in a " "separate cluster") args = parser.parse_args() namespaces = list() parser = Parser(_namespace_registry._graph) for x in args.to_plot: if x in _namespace_registry: namespaces.append(x) continue for n in Parser.get_namespace_names(x): if n in _namespace_registry: logger.warning("Using installed version of namespace %s" % n) namespaces.append(_namespace_registry[n]) else: parser.parse(x) _namespace_registry.update_namespaces() namespaces.append(_namespace_registry[n]) # Convert the ontology to dot converter = Ontology2Dot( namespaces=namespaces, output_filename=args.output_filename, group=args.group ) converter.render()
from osp.core.session import DbWrapperSession from osp.core.session.transport.transport_session_server import \ TransportSessionServer try: from tests.test_sqlite_city import check_state except ImportError: from test_sqlite_city import check_state try: from osp.core.namespaces import city except ImportError: from osp.core.ontology import Parser from osp.core.namespaces import _namespace_registry Parser(_namespace_registry._graph).parse("city") _namespace_registry.update_namespaces() city = _namespace_registry.city HOST = "127.0.0.1" PORT = 8681 URI = f"ws://{HOST}:{PORT}" DB = "dataspace.db" class TestDataspaceWrapper(unittest.TestCase): """Test the DataspaceWrapper.""" SERVER_STARTED = False @classmethod def setUpClass(cls):
ch.setFormatter(formatter) logger.addHandler(ch) logging.getLogger("osp.wrappers").addHandler(ch) try: from osp.core.packageinfo import VERSION as __version__ except ModuleNotFoundError: __version__ = None logger.critical( "Error determining version of osp-core. If you installed from source, " "try the follwing: \n" "\t- If you want to import osp-core with the osp-core repo as cwd, " "please reinstall using `pip install -e <path/to/osp-core/repo>`. \n" "\t- Otherwise you can reinstall using " "`pip install <path/to/osp-core/repo>`.") def __getattr__(name): if name != "load_tests": logger.warning(f"osp.core.{name} is deprecated. " f"Use osp.core.namespaces.{name} instead.") return getattr(osp.core.namespaces, name) if (sys.version_info.major, sys.version_info.minor) <= (3, 6): logger.info("We recommend using a python version of at least 3.7") logger.info(f"osp.core.<namespace> is deprecated. " f"Use osp.core.namespaces.<namespace> instead.") _namespace_registry.update_namespaces( modules=[sys.modules[__name__], namespaces])