The Devel class¶
- class ferenda.Devel(config=None, **kwargs)¶
Collection of utility commands for developing docrepos.
This module acts as a docrepo (and as such is easily callable from ferenda-manager.py), but instead of download, parse, generate et al, contains various tool commands that is useful for developing and debugging your own docrepo classes.
Use it by first enabling it:
./ferenda-build.py ferenda.Devel enable
And then run individual tools like:
./ferenda-build.py devel dumprdf path/to/xhtml/rdfa.xhtml
- alias = 'devel'¶
- dumprdf(filename, format='turtle')¶
Extract all RDF data from a parsed file and dump it to stdout.
Parameters: - filename (str) – Full path of the parsed XHTML+RDFa file.
- format (str) – The serialization format for RDF data (same as for rdflib.graph.Graph.serialize())
Example:
./ferenda-build.py devel dumprdf path/to/xhtml/rdfa.xhtml nt
- dumpstore(format='turtle')¶
Extract all RDF data from the system triplestore and dump it to stdout using the specified format.
Parameters: format (str) – The serialization format for RDF data (same as for ferenda.TripleStore.get_serialized()). Example:
./ferenda-build.py devel dumpstore nt > alltriples.nt
- csvinventory(alias)¶
Create an inventory of documents, as a CSV file. Only documents that have been parsed and yielded some minimum amount of RDF metadata will be included.
Parameters: alias (str) – Docrepo alias
- mkpatch(alias, basefile, description)¶
Create a patch file from downloaded or intermediate files. Before running this tool, you should hand-edit the intermediate file. If your docrepo doesn’t use intermediate files, you should hand-edit the downloaded file instead. The tool will first stash away the intermediate (or downloaded) file, then re-run parse() (or download_single()) in order to get a new intermediate (or downloaded) file. It will then calculate the diff between these two versions and save it as a patch file in it’s proper place (as determined by config.patchdir), where it will be picked up automatically by patch_if_needed().
Parameters: Example:
./ferenda-build.py devel mkpatch myrepo basefile1 "Removed sensitive personal information"
- parsestring(string, citationpattern, uriformatter=None)¶
Parse a string using a named citationpattern and print parse tree and optionally formatted uri(s) on stdout.
Parameters: Note
This is not implemented yet
Example:
./ferenda-build.py devel parsestring \ "According to direktiv 2007/42/EU, ..." \ ferenda.citationpatterns.eulaw
- fsmparse(functionname, source)¶
Parse a list of text chunks using a named fsm parser and output the parse tree and final result to stdout.
Parameters:
- queryindex(querystring)¶
Query the system fulltext index and return the IDs/URIs for matching documents.
Parameters: querystring (str) – The query
- construct(template, uri, format='turtle')¶
- select(template, uri, format='json')¶
- destroyindex()¶
- documentstore_class¶
alias of DummyStore
- downloaded_suffix = '.html'¶
- storage_policy = 'file'¶
- get_default_options()¶
- download()¶
- parse(basefile)¶
- relate(basefile)¶
- generate(basefile)¶
- toc(otherrepos)¶
- news(otherrepos)¶
- status()¶
- classmethod setup(action, config)¶
- classmethod teardown(action, config)¶