Skip to main content

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.1.1.tar.gz (10.5 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.1.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: isogeo-export-docx-1.1.1.tar.gz
  • Upload date:
  • Size: 10.5 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.1.1.tar.gz
Algorithm Hash digest
SHA256 62bf5fe3f67c1af508d41e4efed78d8338799ede883fb1e02edbf6ea5d844c1c
MD5 c5010d0a2092b4a7c7ae90b9af3a3559
BLAKE2b-256 6215571287d9bc4fdaf36f0f02227a9785f55204bdcabdd850f000bcbcc031c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: isogeo_export_docx-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.6 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2fd7cc1be3b6979b9a09f9a0a0825e09a17c4bec7189aa589fb1776276b0847
MD5 512fa93028fc468abb722ede1a4d4d22
BLAKE2b-256 0191c2054b53c41a64b89aca38ed65e4daaf48a0c94bd421681946ef4a9d612f

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