How to use the ontospy.ontospy function in ontospy

To help you get started, we’ve selected a few ontospy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lambdamusic / Ontospy / ontospy / extras / import_web.py View on Github external
def parse_options():
	"""
	parse_options() -> opts, args

	Parse any command-line options given returning both
	the parsed options and arguments.

	https://docs.python.org/2/library/optparse.html

	"""

	parser = optparse.OptionParser(usage=USAGE, version=ontospy.VERSION)

	parser.add_option("-a", "--all",
			action="store_true", default=False, dest="all",
			help="Show all entries found by querying http://prefix.cc/popular/all.")

	parser.add_option("-q", "",
			action="store", type="string", default="", dest="query",
			help="A query string used to match the catalog entries.")

	opts, args = parser.parse_args()

	if not opts.all and not opts.query:
		parser.print_help()
		# sys.exit(0)

	return opts, args
github lambdamusic / Ontospy / ontospy / extras / exporter.py View on Github external
import json
# django loading requires different steps based on version
# https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
import django
if django.get_version() > '1.7':
	from django.conf import settings
	from django.template import Context, Template
	settings.configure()
	django.setup()
	settings.TEMPLATES = [
	    {
	        'BACKEND': 'django.template.backends.django.DjangoTemplates',
	        'DIRS': [
	            # insert your TEMPLATE_DIRS here
	            ontospy.ONTOSPY_LOCAL_TEMPLATES + "components",
	        ],
	        'APP_DIRS': True,
	        'OPTIONS': {
	            'context_processors': [
	                # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
	                # list if you haven't customized them:
	                'django.contrib.auth.context_processors.auth',
	                'django.template.context_processors.debug',
	                'django.template.context_processors.i18n',
	                'django.template.context_processors.media',
	                'django.template.context_processors.static',
	                'django.template.context_processors.tz',
	                'django.contrib.messages.context_processors.messages',
	            ],
	        },
	    },
github lambdamusic / Ontospy / ontospy / extras / import_web.py View on Github external
def main():
	""" command line script """

	print("OntoSpy " + ontospy.VERSION)
	ontospy.get_or_create_home_repo()

	opts, args = parse_options()

	sTime = time.time()

	# _list = getCatalog(query=opts.query)
	# action_webimport(_list)

	d = get_LOV_vocabularies()
	print_LOV_data(d)


	# finally:
	# print(some stats....)
	eTime = time.time()
github lambdamusic / Ontospy / ontospy / extras / import_web.py View on Github external
counter = 1
	for x in options:
		print(Fore.BLUE + Style.BRIGHT + "[%d]" % counter, Style.RESET_ALL + x[0] + " ==> ", Fore.RED +	 x[1], Style.RESET_ALL)
		# print(Fore.BLUE + x[0], " ==> ", x[1])
		counter += 1

	while True:
		var = raw_input(Style.BRIGHT + "=====\nSelect ID to import: (q=quit)\n" + Style.RESET_ALL)
		if var == "q":
			break
		else:
			try:
				_id = int(var)
				ontouri = options[_id - 1][1]
				print(Fore.RED + "\n---------\n" + ontouri + "\n---------" + Style.RESET_ALL)
				ontospy.action_import(ontouri)
			except:
				print("Error retrieving file. Import failed.")
				continue
github lambdamusic / Ontospy / ontospy / extras / _render.py View on Github external
Django templates API: https://docs.djangoproject.com/en/dev/ref/templates/api/
	
	output = string

	2016-02-24: added 
	"""

	try:
		ontology = graph.ontologies[0]
		uri = ontology.uri
	except:
		ontology = None
		uri = graph.graphuri

	# ontotemplate = open("template.html", "r")
	ontotemplate = open(ontospy.ONTOSPY_LOCAL_TEMPLATES + "html/index.html", "r")
	
	t = Template(ontotemplate.read())

	
	c = Context({	
					"ontology": ontology,
					"main_uri" : uri,
					"classes": graph.classes,
					"objproperties": graph.objectProperties,
					"dataproperties": graph.datatypeProperties,
					"annotationproperties": graph.annotationProperties,
					"skosConcepts": graph.skosConcepts,
					"instances": []
				})
	
	rnd = t.render(c) 
github lambdamusic / Ontospy / ontospy / viz / viz_html.py View on Github external
Django templates API: https://docs.djangoproject.com/en/dev/ref/templates/api/

	output = string

	2016-02-24: added 
	"""

	try:
		ontology = graph.ontologies[0]
		uri = ontology.uri
	except:
		ontology = None
		uri = graph.graphuri

	# ontotemplate = open("template.html", "r")
	ontotemplate = open(ontospy.ONTOSPY_VIZ_TEMPLATES + "javadoc.html", "r")

	t = Template(ontotemplate.read())


	c = Context({
					"ontology": ontology,
					"main_uri" : uri,
					"classes": graph.classes,
					"objproperties": graph.objectProperties,
					"dataproperties": graph.datatypeProperties,
					"annotationproperties": graph.annotationProperties,
					"skosConcepts": graph.skosConcepts,
					"instances": []
				})

	rnd = t.render(c)
github lambdamusic / Ontospy / ontospy / extras / _render.py View on Github external
import json
# django loading requires different steps based on version
# https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
import django
if django.get_version() > '1.7':	
	from django.conf import settings
	from django.template import Context, Template
	settings.configure()
	django.setup()
	settings.TEMPLATES = [
	    {
	        'BACKEND': 'django.template.backends.django.DjangoTemplates',
	        'DIRS': [
	            # insert your TEMPLATE_DIRS here
	            ontospy.ONTOSPY_LOCAL_TEMPLATES + "components",
	        ],
	        'APP_DIRS': True,
	        'OPTIONS': {
	            'context_processors': [
	                # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
	                # list if you haven't customized them:
	                'django.contrib.auth.context_processors.auth',
	                'django.template.context_processors.debug',
	                'django.template.context_processors.i18n',
	                'django.template.context_processors.media',
	                'django.template.context_processors.static',
	                'django.template.context_processors.tz',
	                'django.contrib.messages.context_processors.messages',
	            ],
	        },
	    },