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

Uploaded Python 3

File details

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

File metadata

  • Download URL: isogeo-export-docx-1.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 762e65fd9538a715ea1a090d38cdc0965a77e4a44d11b3cc01e40ccb24a64fa8
MD5 4c7c9422094765007309b14b720465db
BLAKE2b-256 be1ceea91b3dbb2f4ab0979f237b3057a1ba7cf2bb994c8945b00f1262d22d78

See more details on using hashes here.

File details

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

File metadata

  • Download URL: isogeo_export_docx-1.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 103068fe7521beafff80268b96b0e8de20108740305463f4b36f8015763a3a9b
MD5 f7876fb5241c048b9520b81592d07d69
BLAKE2b-256 aba27d8ce3ac3b25ac01d199f3dc800c7ddaa3297cd7d50182f6840cb10afd1a

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