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.2.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.2-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: isogeo-export-docx-1.1.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for isogeo-export-docx-1.1.2.tar.gz
Algorithm Hash digest
SHA256 e85a3cf2d188f3d06eed85602b91e6b80512fd1b4e60987d8ce4e6c8c4f74ecf
MD5 0164661a22206c117cd814f92955e6f0
BLAKE2b-256 8d7851197a8a98aa8f6eb214d1249bb4b3594020d49a86396565fe61095e425b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: isogeo_export_docx-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for isogeo_export_docx-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fcf2b0eae9e649f4516c711bb944808a6f52a0a08a8ff583497acea88d5e2c40
MD5 0ade6d6b46c92bbd3a02614b9275dacd
BLAKE2b-256 ebbac94eaf8c096aad9d49464cc2ecbf3f6241de5b88b8fed2638ae5ca6ef808

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