Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if outputpath:
if not(os.path.exists(outputpath)) or not (os.path.isdir(outputpath)):
click.secho("WARNING: the -o option must include a valid directory path.", fg="red")
sys.exit(0)
else:
from os.path import expanduser
home = expanduser("~")
outputpath = os.path.join(home, "ontospy-viz-multi")
if source:
click.secho("WARNING: not implemented yet. Only local repo can be exported.", fg="red")
sys.exit(0)
else:
click.secho("Exporting the local library: '%s'" % get_home_location(), fg="green")
report_pages = []
for onto_name in get_localontologies():
full_uri = os.path.join(get_home_location(), onto_name)
if theme=="random":
_theme = random_theme()
else:
_theme = theme
click.secho("Onto: <%s> Theme: '%s'" % (onto_name, _theme), fg="green")
printDebug("Loading graph...", dim=True)
g = Ontospy(os.path.join(get_home_location(), onto_name), verbose=verbose)
printDebug("Building visualization...", dim=True)
else:
from os.path import expanduser
home = expanduser("~")
outputpath = os.path.join(home, "ontospy-viz-multi")
if source:
click.secho("WARNING: not implemented yet. Only local repo can be exported.", fg="red")
sys.exit(0)
else:
click.secho("Exporting the local library: '%s'" % get_home_location(), fg="green")
report_pages = []
for onto_name in get_localontologies():
full_uri = os.path.join(get_home_location(), onto_name)
if theme=="random":
_theme = random_theme()
else:
_theme = theme
click.secho("Onto: <%s> Theme: '%s'" % (onto_name, _theme), fg="green")
printDebug("Loading graph...", dim=True)
g = Ontospy(os.path.join(get_home_location(), onto_name), verbose=verbose)
printDebug("Building visualization...", dim=True)
onto_name_safe = slugify(unicode(onto_name))
onto_outputpath = os.path.join(outputpath, onto_name_safe )
# note: single static files output path
static_outputpath = os.path.join(outputpath, "static" )
# v = KompleteViz(g, theme=_theme)
v = KompleteVizMultiModel(g, theme=_theme, static_url="../static/", output_path_static=static_outputpath)
from .builder import random_theme
theme = random_theme()
if outputpath:
if not(os.path.exists(outputpath)) or not (os.path.isdir(outputpath)):
click.secho("WARNING: the -o option must include a valid directory path.", fg="red")
sys.exit(0)
if not library and not source:
# ctx.get_help()
# ctx.invoke(get_help) how to???
click.secho("WARNING: not enough options. Use -h for help.", fg="red")
sys.exit(0)
if library:
click.secho("Showing the local library: '%s'" % get_home_location(), fg='red')
if source and len(source) > 1:
click.secho('Note: currently only one argument can be passed', fg='red')
url = action_visualize(source, fromshell=False, path=outputpath, title=title, theme=theme, verbose=verbose)
if url:# open browser
import webbrowser
webbrowser.open(url)
# continue and print(timing at bottom )
raise SystemExit(1)
def __init__(self, uri=None):
"""
self.current = {'file' : filename, 'fullpath' : fullpath, 'graph': g}
self.currentEntity = {'name' : obj.locale or obj.uri, 'object' : obj, 'type' : 'class'}
# or 'property' or 'concept'
"""
# init repo if necessary
manager.get_or_create_home_repo()
# useful vars
self.LOCAL = ONTOSPY_LOCAL
self.LOCAL_MODELS = manager.get_home_location()
self.all_ontologies = manager.get_localontologies()
self.current = None
self.currentEntity = None
if uri:
self._load_ontology(uri, preview_mode=True)
cmd.Cmd.__init__(self)
viztype = ask_visualization()
if viztype == "":
return None
# raise SystemExit, 1
# 2017-01-23: bypass pickled stuff as it has wrong counts etc..
USE_CACHE = False
# get ontospy graph
if islocal and USE_CACHE:
g = get_pickled_ontology(ontouri)
if not g:
g = do_pickle_ontology(ontouri)
else:
printDebug("Loading graph...", dim=True)
if islocal:
g = Ontospy(os.path.join(ontospy_manager.get_home_location(), ontouri), verbose=verbose)
else:
g = Ontospy(ontouri, verbose=verbose)
# put in home folder by default: //files..
if not path:
from os.path import expanduser
home = expanduser("~")
onto_path = slugify(unicode(ontouri))
viz_path = slugify(unicode(VISUALIZATIONS_LIST[viztype]['Title']))
path = os.path.join(home, "ontospy-viz/" + onto_path + "/" + viz_path )
if not os.path.exists(path):
os.makedirs(path)
# url = build_viz(ontouri, g, viztype, path)
printDebug("Building visualization...", dim=True)
url = build_visualization(ontouri, g, viztype, path, title, theme)