rdfframework.utilities package¶
Submodules¶
rdfframework.utilities.codetimer module¶
Simple timer module for timing code execution
rdfframework.utilities.debug module¶
utilities for debuging code
rdfframework.utilities.frameworkutilities module¶
-
class
rdfframework.utilities.frameworkutilities.DeleteProperty[source]¶ Bases:
objectdummy class for tagging items to be deleted. This will prevent passed in data ever being confused with marking a property for deletion.
-
class
rdfframework.utilities.frameworkutilities.NotInFormClass[source]¶ Bases:
objectdummy class for tagging properties that were never in a form. This will prevent passed in data ever being confused with a property that was never in the form.
-
rdfframework.utilities.frameworkutilities.cbool(value, strict=True)[source]¶ converts a value to true or false. Python’s default bool() function does not handle ‘true’ of ‘false’ strings
-
rdfframework.utilities.frameworkutilities.clean_iri(uri_string)[source]¶ removes the <> signs from a string start and end
-
rdfframework.utilities.frameworkutilities.convert_spo_to_dict(data, mode='subject', option='string')[source]¶ Takes the SPAQRL query results and converts them to a python Dict
mode: subject –> groups based on subject
-
rdfframework.utilities.frameworkutilities.copy_obj(obj)[source]¶ does a deepcopy of an object, but does not copy a class i.e. x = {“key”:[<classInstance1>,<classInstance2>,<classInstance3>]} y = copy_obj(x) y –> {“key”:[<classInstance1>,<classInstance2>,<classInstance3>]} del y[‘key’][0] y –> {“key”:[<classInstance2>,<classInstance3>]} x –> {“key”:[<classInstance1>,<classInstance2>,<classInstance3>]} *** this is to overcome a dictionary object that lists with classes
as the list items.
-
rdfframework.utilities.frameworkutilities.fw_config(**kwargs)[source]¶ function returns the application configuration information
-
rdfframework.utilities.frameworkutilities.get_app_ns_uri(value)[source]¶ looks in the framework for the namespace uri
-
rdfframework.utilities.frameworkutilities.get_attr(item, name, default=None)[source]¶ similar to getattr and get but will test for class or dict
-
rdfframework.utilities.frameworkutilities.iri(uri_string)[source]¶ converts a string to an IRI or returns an IRI if already formated
-
rdfframework.utilities.frameworkutilities.is_not_null(value)[source]¶ test for None and empty string
-
rdfframework.utilities.frameworkutilities.is_valid_object(uri_string)[source]¶ Test to see if the string is a object store
-
rdfframework.utilities.frameworkutilities.make_list(value)[source]¶ Takes a value and turns it into a list if it is not one
!!!!! This is important becouse list(value) if perfomed on an dictionary will return the keys of the dictionary in a list and not the dictionay as an element in the list. i.e.
x = {“first”:1, “second”:2} list(x) = [“first”, “second”] or use this [x,] make_list(x) =[{“first”:1, “second”:2}]
-
rdfframework.utilities.frameworkutilities.make_set(value)[source]¶ Takes a value and turns it into a set
!!!! This is important because set(string) will parse a string to individual characters vs. adding the string as an element of the set i.e.
x = ‘setvalue’ set(x) = {‘t’, ‘a’, ‘e’, ‘v’, ‘u’, ‘s’, ‘l’} make_set(x) = {‘setvalue’} or use set([x,]) by adding string as first item in list.
-
rdfframework.utilities.frameworkutilities.make_triple(sub, pred, obj)[source]¶ - Takes a subject predicate and object and joins them with a space
- in between
- Args:
- sub – Subject pred – Predicate obj – Object
- Returns
- str
-
rdfframework.utilities.frameworkutilities.nz(value, none_value, strict=True)[source]¶ This function is named after an old VBA function. It returns a default value if the passed in value is None. If strict is False it will treat an empty string as None as well.
example: x = None nz(x,”hello”) –> “hello” nz(x,””) –> “” y = “” nz(y,”hello”) –> “” nz(y,”hello”, False) –> “hello”
-
rdfframework.utilities.frameworkutilities.remove_null(obj)[source]¶ reads through a list or set and strips any null values
-
rdfframework.utilities.frameworkutilities.render_without_request(template_name, **template_vars)[source]¶ Usage is the same as flask.render_template:
render_without_request(‘my_template.html’, var1=’foo’, var2=’bar’)
rdfframework.utilities.uriconvertor module¶
contains functions for converting objects to namespace prefixes
-
rdfframework.utilities.uriconvertor.convert_obj_to_rdf_namespace(obj, ns_obj=None)[source]¶ This function takes rdf json definitions and converts all of the uri strings to a ns_value format
-
rdfframework.utilities.uriconvertor.convert_to_ns(value, ns_obj=None)[source]¶ converts a value to the prefixed rdf ns equivalent. If not found returns the value as is
-
rdfframework.utilities.uriconvertor.convert_to_ttl(value, ns_obj=None)[source]¶ converts a value to the prefixed rdf ns equivalent. If not found returns the value as is
-
rdfframework.utilities.uriconvertor.convert_to_uri(value, ns_obj=None, strip_iri=False)[source]¶ converts a prefixed rdf ns equivalent value to its uri form. If not found returns the value as is
-
rdfframework.utilities.uriconvertor.create_namespace_obj(obj)[source]¶ takes initial rdf application definitions and reads the namespaces
-
rdfframework.utilities.uriconvertor.pyuri(value)[source]¶ converts an iri to the app defined rdf namespaces in the framework in a python accessable format. i.e. schema:name or http:schema.org/name –> schema_name
-
rdfframework.utilities.uriconvertor.ttluri(value)[source]¶ converts an iri to the app defined rdf namespaces in the framework in a turtle accessable format. i.e. schema_name or http:schema.org/name –> schema:name