for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
"""
Tool to export reified mandos triples.
from typing import Generator, Sequence
from mandos.model.hits import AbstractHit, Triple
def _camelcase(s: str):
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.
return "".join(w.title() if i > 0 else w for i, w in enumerate(s.split("_")))
class Reifier:
def reify(self, hits: Sequence[AbstractHit]) -> Generator[Triple, None, None]:
for hit in hits:
yield from self._reify_one(hit)
def _reify_one(self, hit: AbstractHit) -> Sequence[Triple]:
If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example
class Foo: def some_method(self, x, y): return x + y;
could be written as
class Foo: @classmethod def some_method(cls, x, y): return x + y;
uid = hit.universal_id
state = Triple(uid, "rdf:type", "rdf:statement")
pred = Triple(uid, "rdf:predicate", hit.predicate)
obj = Triple(uid, "rdf:object", hit.object_name)
exclude = {"origin_inchikey", "predicate"}
others = [
Triple(uid, "mandos:" + _camelcase(field), getattr(hit, field))
for field in hit.fields()
if field not in exclude
]
return [state, pred, obj, *others]
__all__ = ["Reifier"]
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.