Skip to main content

Toolbelt to export metadata from the Isogeo REST API into Microsoft Word documents (.docx).

Project description

Isogeo - DOCX Exporter

PyPI PyPI - Python Version

Build Status Azure DevOps coverage

Documentation Status Code style: black

Python package to export Isogeo metadata into Word documents using the Python SDK and docxtpl.

Usage in a nutshell

  1. Install:

    pip install isogeo-export-docx
    
  2. 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()
    
  3. Make a search:

    search = isogeo.search(include="all",)
    # close session
    isogeo.close()
    
  4. 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.0.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

isogeo_export_docx-1.0.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file isogeo-export-docx-1.0.0.tar.gz.

File metadata

  • Download URL: isogeo-export-docx-1.0.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for isogeo-export-docx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1cc89aead4e38d63f2e638b8aa354d22e20abf40ea1289331b2f054c252351ff
MD5 c12c1638059eca01fd4cd17544c9ffcb
BLAKE2b-256 d52c0876dd61afc954d930b6bd0d00cca02c170020bf4989e7250e62933f4023

See more details on using hashes here.

File details

Details for the file isogeo_export_docx-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: isogeo_export_docx-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for isogeo_export_docx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ae0d02981b9ee11f6d828b2ac7deb05ae0e5a933e6a64d6f800a0f4a304af6b
MD5 f5b4d7b77d841a32adbce42425bc0a58
BLAKE2b-256 3840b9dcf2166c04129c9bcb97efd9b021d067fba533eeb9d32d5f9badb3840b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page