Export metadata from the Isogeo REST API into Microsoft Word documents (.docx).
Project description
Isogeo - DOCX Exporter
Python package to export Isogeo metadata into Word documents using the Python SDK and docxtpl.
Usage in a nutshell
-
Install:
pip install isogeo-export-docx
-
Authenticate
# import from isogeo_pysdk import Isogeo # API client isogeo = Isogeo( auth_mode="group", client_id=ISOGEO_API_GROUP_CLIENT_ID, client_secret=ISOGEO_API_GROUP_CLIENT_SECRET, auto_refresh_url="{}/oauth/token".format(ISOGEO_ID_URL), platform=ISOGEO_PLATFORM, ) # getting a token isogeo.connect()
-
Make a search:
search = isogeo.search(include="all",) # close session isogeo.close()
-
Export:
# import from isogeotodocx import Isogeo2docx # output folder Path("_output/").mkdir(exist_ok=True) # template template_path = Path(r"tests\fixtures\template_Isogeo.docx") # instanciate toDocx = Isogeo2docx() # parse results and export it for md in search_results.results: # load metadata as object metadata = Metadata.clean_attributes(md) # prepare the template tpl = DocxTemplate(template_path.resolve()) # fill the template toDocx.md2docx(docx_template=tpl, md=metadata) # filename md_name = metadata.title_or_name(slugged=1) uuid = "{}".format(metadata._id[:5]) out_docx_filename = "_output/{}_{}.docx".format(md_name, uuid) # save it tpl.save(out_docx_filename) # delete template object del tpl
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
isogeo-export-docx-1.1.3.tar.gz
(10.5 kB
view hashes)
Built Distribution
Close
Hashes for isogeo_export_docx-1.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e527e4542b37b3901d91db830208cb1789e1c71a6a2535c7fc807ca26d3c73df |
|
MD5 | 2fc93d171680da2fb80e73dc6dedb1e5 |
|
BLAKE2b-256 | c130bb0bf5fd55b8f0c10b03acdc296814ba307b0e4c11b5a0c2980a9ccd5bac |