Package: quickstatements-client
QuickStatements ClientA data model and client for WikidataQuickStatements.💪 Getting StartedHere's how to quickly construct some QuickStatementsimportdatetimefromquickstatements_clientimportDateQualifier,EntityQualifier,TextQualifier,EntityLinesubject_qid="Q47475003"# Charles Tapley Hoytsubject_orcid="0000-0003-4423-4370"reference_url_qualifier=TextQualifier(predicate="S854",target=f"https://orcid.org/0000-0003-4423-4370")start_date=datetime.datetime(year=2021,day=15,month=2)start_date_qualifier=DateQualifier.start_time(start_date)position_held_qualifier=EntityQualifier(predicate="P39",target="Q1706722")employment_line=EntityLine(subject=subject_qid,predicate="P108",# employertarget="Q49121",# Harvard medical schoolqualifiers=[reference_url_qualifier,start_date_qualifier,position_held_qualifier],)>>>employment_line.get_line()'Q47475003|P108|Q49121|S854|"https://orcid.org/0000-0003-4423-4370"|P580|+2021-02-15T00:00:00Z/11|P39|Q1706722',How to send some QuickStatements to the API:fromquickstatements_clientimportQuickStatementsClientlines=[employment_line,...]client=QuickStatementsClient(token=...,username=...)res=client.post(lines,batch_name="Test Batch")# see also res.batch_idimportwebbrowserwebbrowser.open_new_tab(res.batch_url)Note:tokenandusernameare automatically looked up withpystowif they aren't given.
Specifically, usingpystow.get_config("quickstatements", "token)andpystow.get_config("quickstatements", "username").🚀 InstallationThe most recent release can be installed fromPyPIwith:$pipinstallquickstatements_clientThe most recent code and data can be installed directly from GitHub with:$pipinstallgit+https://github.com/cthoyt/quickstatements-client.git👐 ContributingContributions, whether filing an issue, making a pull request, or forking, are appreciated. SeeCONTRIBUTING.mdfor more information on getting involved.👋 AttributionThis code was originally written as a contribution toPyORCIDator.
Special thanks to Tiago Lubiana [@lubianat] and João Vitor [@jvfe] for discussions and testing.⚖️ LicenseThe code in this package is licensed under the MIT License.🍪 CookiecutterThis package was created with@audreyfeldroy'scookiecutterpackage using@cthoyt'scookiecutter-snekpacktemplate.🛠️ For DevelopersSee developer instructionsThe final section of the README is for if you want to get involved by making a code contribution.Development InstallationTo install in development mode, use the following:$gitclonegit+https://github.com/cthoyt/quickstatements-client.git
$cdquickstatements-client
$pipinstall-e.🥼 TestingAfter cloning the repository and installingtoxwithpip install tox, the unit tests in thetests/folder can be
run reproducibly with:$toxAdditionally, these tests are automatically re-run with each commit in aGitHub Action.📖 Building the DocumentationThe documentation can be built locally using the following:$gitclonegit+https://github.com/cthoyt/quickstatements-client.git
$cdquickstatements-client
$tox-edocs
$opendocs/build/html/index.htmlThe documentation automatically installs the package as well as thedocsextra specified in thesetup.cfg.sphinxplugins
liketexextcan be added there. Additionally, they need to be added to theextensionslist indocs/source/conf.py.📦 Making a ReleaseAfter installing the package in development mode and installingtoxwithpip install tox, the commands for making a new release are contained within thefinishenvironment
intox.ini. Run the following from the shell:$tox-efinishThis script does the following:UsesBump2Versionto switch the version number in thesetup.cfg,src/quickstatements_client/version.py, anddocs/source/conf.pyto not have the-devsuffixPackages the code in both a tar archive and a wheel usingbuildUploads to PyPI usingtwine. Be sure to have a.pypircfile configured to avoid the need for manual input at this
stepPush to GitHub. You'll need to make a release going with the commit where the version was bumped.Bump the version to the next patch. If you made big changes and want to bump the version by minor, you can
usetox -e bumpversion -- minorafter.