{ "info": { "author": "Simon Johnston", "author_email": "johnstonskj@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Build Tools", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# RDF Tools\n\nThis package consists of a set of command-line tools that do interesting things with RDF and SPARQL.\n\nThe functionality is provided by RDFLib, and while that provides a set of commands those provided here are somewhat more extensive and also based upon a common command framework that can be extended easily for more cases.\n\n[![Travis Status](https://travis-ci.org/johnstonskj/rdftools.svg?branch=master)](https://travis-ci.org/johnstonskj/rdftools)\n[![Coverage Status](https://coveralls.io/repos/github/johnstonskj/rdftools/badge.svg?branch=master)](https://coveralls.io/github/johnstonskj/rdftools?branch=master)\n[![Maintainability](https://api.codeclimate.com/v1/badges/713dc63ecf8f8efa44d7/maintainability)](https://codeclimate.com/github/johnstonskj/rdftools/maintainability)\n[![Requirements](https://requires.io/github/johnstonskj/rdftools/requirements.svg?branch=master)](https://requires.io/github/johnstonskj/rdftools/requirements/?branch=master)\n\n[![GitHub stars](https://img.shields.io/github/stars/johnstonskj/rdftools.svg)](https://github.com/johnstonskj/rdftools/stargazers)\n[![Current Version](https://img.shields.io/pypi/v/rdftools.svg)](https://pypi.python.org/pypi/rdftools)\n[![Python Versions](https://img.shields.io/pypi/pyversions/rdftools.svg)](https://pypi.python.org/pypi/rdftools)\n[![Python Implementations](https://img.shields.io/pypi/implementation/rdftools.svg)](https://pypi.python.org/pypi/tdftools)\n\n## Usage\n\nThe tooling uses a common starting command, `rdf`, that then executes sub-commands. As expected, the command has a help function and lists the supported sub-commands as _positional arguments_. These sub-commands also have their own help.\n\n```\n$ rdf -h\nusage: rdf [-h] [-v] {validate,convert,select,query} ...\n\nRDF tool\n\npositional arguments:\n {validate,convert,select,shell,query}\n subargs\n\noptional arguments:\n -h, --help show this help message and exit\n -v, --verbose\n```\n\nThe currently supported sub-commands are as follows.\n\n* `convert` - convert files between different RDF representations (NTriples, Notation3, XML, ...).\n* `query` - execute SPARQL queries over RDF files.\n* `select` - simple projections from RDF files.\n* `shell` - run an interactive shell session.\n* `validate` - validate an RDF file.\n\nAn example, running a SPARQL query over a downloaded file is shown below.\n\n```\n$ rdf query -i ~/social.n3 -r n3 -q \"SELECT DISTINCT ?person ?topic WHERE { ?person ?topic. }\"\nperson topic\n============================================== =============================================\nhttp://amazon.com/cprm/customers/1.0/Alice http://amazon.com/cprm/entities/1.0/Diving\nhttp://amazon.com/cprm/customers/1.0/Bob http://amazon.com/cprm/entities/1.0/Diving\nhttp://amazon.com/cprm/customers/1.0/Alice http://amazon.com/cprm/entities/1.0/Shoes\n3 rows returned in 1.629622 seconds.\n```\n\n## Debugging\n\nThe `-v` parameter to either `rdf` or one of the sub-commands controls the standard Python logging level. It can be stated multiple times to increase the logging; `-v` for warnings, `-vv` for informational, `-vvv` for debug.\n\n## Interactive Shell\n\nFor a more interactive exploration of RDF data you can run `rdf shell` which gives you access to a lot of the same functions in the separate tools. The shell has a single common graph into which you can load data from external files (and stores in the future), and run SPARQL queries. The shell also has a default initialization file, so commonly used prefixes, common data, etc. can be loaded before you start your session.\n\n```\n$ rdf shell\nRDF Shell, v0.1.0.\nreading commands from file /Users/simonjo/.rdfshrc\nGraph updated with 40 statements.\n>\n```\n\nAs you might expect, the shell supports a `help` function and command completion as well as a persistent history.\n\n### Initialization File\n\nThe default location for this is `~/.rdfshrc`, all commands are read as if you typed them into the shell.\n\n### History File\n\nThe default location for this is `~/.rdfsh_hist`, it will be read at startup and updated on closing the shell.\n\n## Extending\n\nNew commands are added as modules in the `rdftools/scripts` folder and have the following structure.\n\n```python\nimport rdftools\n\ndef main():\n (LOG, cmd) = rdftools.startup('Tool description.', add_args=None)\n\n ...\n```\n\nThe `add_args` parameter is used to add additional command-line arguments to the common `argparse` structure. The function, if required, takes in a parser object and returns it. The common command line arguments include verbosity, help, and reading files.\n\n```python\ndef add_args(parser):\n return parser\n\n```\n\nThe results from `startup` are a standard logger and an (`ArgumentParser`) `Namespace` object. The tool can then use the functions `read`, `read_into`, `read_all`, `write`, and `query` to perform common operations on RDF files.\n\nExtending the shell is also pretty simple, you add a function of the following form, it always takes a context object first, and the doc string will be used by default as the displayed help for your command. Arguments may be parsed for more structure, and `print()` is used extensively for user feedback. Note that you must always return the context, whether you updated it or not. The `add_command` function will install it into the shell, enabling help and command completion.\n\n```python\ndef echo(context, args):\n \"\"\" echo text\n Echo back the following text.\"\"\"\n print(args)\n return context\nadd_command(echo)\n```\n\n## References\n\n* [RDF Working Group](https://www.w3.org/2011/rdf-wg/wiki/Main_Page)\n* [SPARQL Overview](https://www.w3.org/TR/sparql11-overview/)\n* [RDFLib](https://github.com/RDFLib/rdflib)\n* [Travis Project](https://travis-ci.org/johnstonskj/rdftools)\n* [Coveralls Project](https://coveralls.io/github/johnstonskj/rdftools)\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/johnstonskj/rdftools", "keywords": "development,RDF", "license": "", "maintainer": "", "maintainer_email": "", "name": "rdftools", "package_url": "https://pypi.org/project/rdftools/", "platform": "", "project_url": "https://pypi.org/project/rdftools/", "project_urls": { "Homepage": "https://github.com/johnstonskj/rdftools" }, "release_url": "https://pypi.org/project/rdftools/0.2.0/", "requires_dist": [ "python-i18n (>=0.3)", "pyyaml (>=3.10)", "rdflib (>=4.2)" ], "requires_python": ">=3.3", "summary": "Command-line tools for RDF", "version": "0.2.0" }, "last_serial": 3648739, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "23dcce46dda59f3b7c730ab27fb2257a", "sha256": "555d3be5181c65c833a77d43d1b57a7814d03a3e044af86cc4948d16e4094d86" }, "downloads": -1, "filename": "rdftools-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "23dcce46dda59f3b7c730ab27fb2257a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.3", "size": 14386, "upload_time": "2018-03-06T00:02:11", "url": "https://files.pythonhosted.org/packages/ac/72/a33d24da939548cf893bb796ba2ffee6414b7eee6581fde0914a07c5b9b7/rdftools-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1e4634418d945d31e376ea7f0c43d79c", "sha256": "160d64da0a0806971603eaf342e483872f3fa2b48a7556e5baeab2edd69afafb" }, "downloads": -1, "filename": "rdftools-0.1.0.tar.gz", "has_sig": false, "md5_digest": "1e4634418d945d31e376ea7f0c43d79c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.3", "size": 11959, "upload_time": "2018-03-06T00:02:14", "url": "https://files.pythonhosted.org/packages/0b/bf/4373971b8401b9bc34c5c1ae9e2ab8098fcba68793a98187c55957b0b7ac/rdftools-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "07f09b61edba2ca540121a78854353f9", "sha256": "e2439008929ee3acb5c7bb8eecfd5b9eb96173887695592168be33ef7b235898" }, "downloads": -1, "filename": "rdftools-0.2.0a-py3-none-any.whl", "has_sig": false, "md5_digest": "07f09b61edba2ca540121a78854353f9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.3", "size": 14607, "upload_time": "2018-03-07T19:07:59", "url": "https://files.pythonhosted.org/packages/e4/64/9c721450cfca13795d8412595cd37cae0cd8b55a667bbcaa89b596e2e9bf/rdftools-0.2.0a-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "46877ab24856bef34ac2c95d07599cd5", "sha256": "0c398154c86de1e29fe3916dd26397ebbd7101c05672459b13124e6bc4e674b1" }, "downloads": -1, "filename": "rdftools-0.2.0a.tar.gz", "has_sig": false, "md5_digest": "46877ab24856bef34ac2c95d07599cd5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.3", "size": 13908, "upload_time": "2018-03-07T19:08:00", "url": "https://files.pythonhosted.org/packages/49/6e/61bc38e3016108628895b7eaaab2f6690b8bf97d8e6a9b5af9d3117e4cc5/rdftools-0.2.0a.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "07f09b61edba2ca540121a78854353f9", "sha256": "e2439008929ee3acb5c7bb8eecfd5b9eb96173887695592168be33ef7b235898" }, "downloads": -1, "filename": "rdftools-0.2.0a-py3-none-any.whl", "has_sig": false, "md5_digest": "07f09b61edba2ca540121a78854353f9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.3", "size": 14607, "upload_time": "2018-03-07T19:07:59", "url": "https://files.pythonhosted.org/packages/e4/64/9c721450cfca13795d8412595cd37cae0cd8b55a667bbcaa89b596e2e9bf/rdftools-0.2.0a-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "46877ab24856bef34ac2c95d07599cd5", "sha256": "0c398154c86de1e29fe3916dd26397ebbd7101c05672459b13124e6bc4e674b1" }, "downloads": -1, "filename": "rdftools-0.2.0a.tar.gz", "has_sig": false, "md5_digest": "46877ab24856bef34ac2c95d07599cd5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.3", "size": 13908, "upload_time": "2018-03-07T19:08:00", "url": "https://files.pythonhosted.org/packages/49/6e/61bc38e3016108628895b7eaaab2f6690b8bf97d8e6a9b5af9d3117e4cc5/rdftools-0.2.0a.tar.gz" } ] }