{"id":16741364,"url":"https://github.com/metaodi/museumpy","last_synced_at":"2025-03-21T22:31:34.828Z","repository":{"id":46723018,"uuid":"406148263","full_name":"metaodi/museumpy","owner":"metaodi","description":"MuseumPlus client for Python","archived":false,"fork":false,"pushed_at":"2023-07-11T16:47:38.000Z","size":69,"stargazers_count":2,"open_issues_count":8,"forks_count":0,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-03-18T05:34:57.573Z","etag":null,"topics":["glam","museum","museumplus"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metaodi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-13T22:31:04.000Z","updated_at":"2022-11-30T09:40:45.000Z","dependencies_parsed_at":"2024-10-13T01:01:30.269Z","dependency_job_id":"fdecc484-3015-4a00-b553-22e6028e1120","html_url":"https://github.com/metaodi/museumpy","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.30000000000000004","last_synced_commit":"586fcf14fc5b274168e795e7bb987d221f34d4df"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metaodi%2Fmuseumpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metaodi%2Fmuseumpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metaodi%2Fmuseumpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metaodi%2Fmuseumpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metaodi","download_url":"https://codeload.github.com/metaodi/museumpy/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880229,"owners_count":20525505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["glam","museum","museumplus"],"created_at":"2024-10-13T01:01:20.725Z","updated_at":"2025-03-21T22:31:34.261Z","avatar_url":"https://github.com/metaodi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# museumpy\n\n**museum**py is a client for python to get data from [Zetcom MuseumPlus](https://www.zetcom.com/en/museumplus-en/) instances using its [API](http://docs.zetcom.com/framework-public/ws/ws-api-module.html).\n\n## Table of Contents\n\n* [Installation](#installation)\n* [Usage](#usage)\n    * [`search`](#search)\n    * [`fulltext_search`](#fulltext_search)\n* [Advanced Usage](#advanced-usage)\n    * [`module_item`](#module_item)\n    * [`download_attachement`](#download_attachement)\n    * [Custom mapping of fields](#custom-mapping-of-fields)\n* [Release](#release)\n\n## Installation\n\n[museumpy is available on PyPI](https://pypi.org/project/museumpy/), so to install it simply use:\n\n```\n$ pip install museumpy\n```\n\n## Usage\n\nSee the [`examples` directory](/examples) for more scripts.\n\n### `search`\n\n```python\nimport museumpy\n\nrecords = museumpy.search(\n    base_url='https://mpzurichrietberg.zetcom.com/MpWeb-mpZurichRietberg',\n    field='ObjObjectNumberTxt',\n    value='2019.184',\n)\n\n\nfor record in records:\n    print(record)\n```\n\n\nThe return value of `search` is iterable, so you can easily loop over it. Or you can use indices to access elements, e.g. `records[1]` to get the second element, or `records[-1]` to get the last one.\n\nEven [slicing](https://python-reference.readthedocs.io/en/latest/docs/brackets/slicing.html) is supported, so you can do things like only iterate over the first 5 elements using\n\n```python\nfor records in records[:5]:\n   print(record)\n```\n\n### `fulltext_search`\n```python\nimport museumpy\n\nrecords = museumpy.fulltext_search(\n    base_url='https://test.zetcom.com/MpWeb-mpTest',\n    query='Patolu',\n)\n\n\nfor record in records:\n    print(record)\n```\n\n## Advanced usage\n\nFor more advanced usage of this library, it is recommened to first create a client instance and then use this to request data:\n\n```python\nimport museumpy\nimport requests\n\ns = requests.Session()\ns.auth = ('user', 'pass')\ns.headers.update({'Accept-Language': 'de'})\n\nclient = museumpy.MuseumPlusClient(\n    base_url='https://test.zetcom.com/MpWeb-mpTest',\n    session=s\n)\n\n```\n\n\n### `module_item`\n```python\nimport museumpy\n\nid = '98977'\nmodule = 'Multimedia'\nitem = client.module_item(id, module)\n```\n\n### `download_attachement`\n```python\nimport museumpy\n\nid = '98977'\nmodule = 'Multimedia'\n# download attachment to a directory called `files`\nattachment_path = client.download_attachment(id, module, 'files')\nprint(attachment_path)\n```\n\n### Custom mapping of fields\n\nThere are most likely custom fields on the MuseumPlus Instance you want to query.\nThe returned XML is converted to a python `dict` using the [`xmltodict` library](https://pypi.org/project/xmltodict/).\nThe raw dict is returned on the `raw` key of the result:\n\n```python\nimport museumpy\n\nrecords = museumpy.search(\n    base_url='https://test.zetcom.com/MpWeb-mpTest',\n    query='Patolu',\n)\nfor record in records:\n    print(record['raw'])\n```\n\nFor convenience a default mapping is provided to access some fields more easily:\n\n\n```python\nfor record in records:\n    print(record['hasAttachments'])\n    print(record['ObjObjectNumberTxt'])\n```\n\nIf you want to customize this mapping, you can pass a `map_function` to the client, which is then used on all subsequent calls to `search` and `fulltext_search`:\n\n\n```python\nimport museumpy\n\ndef my_custom_map(record, xml_rec):\n    NS = \"http://www.zetcom.com/ria/ws/module\"\n    ID_XPATH = f\".//{{{NS}}}dataField[@name='ObjObjectNumberTxt']/{{{NS}}}value\"\n    TITLE_XPATH = f\".//{{{NS}}}repeatableGroup[@name='ObjObjectTitleGrp']//{{{NS}}}dataField[@name='TitleTxt']//{{{NS}}}value\"\n\n    xml_parser = museumpy.xmlparse.XMLParser()\n    my_new_record = {\n        'my_id': xml_parser.find(xml_rec, ID_XPATH).text,\n        'my_title': xml_parser.find(xml_rec, TITLE_XPATH).text \n    }\n    return my_new_record\n\n\nclient = museumpy.MuseumPlusClient(\n    base_url='https://test.zetcom.com/MpWeb-mpTest',\n    map_function=my_custom_map,\n)\n\nrecords = client.search(\n    base_url='https://test.zetcom.com/MpWeb-mpTest',\n    query='Patolu',\n)\nfor record in records:\n    print(record['my_id'])\n    print(record['my_title'])\n\n```\n\n## Release\n\nTo create a new release, follow these steps (please respect [Semantic Versioning](http://semver.org/)):\n\n1. Adapt the version number in `museumpy/__init__.py`\n1. Update the CHANGELOG with the version\n1. Create a [pull request to merge `develop` into `main`](https://github.com/metaodi/museumpy/compare/main...develop?expand=1) (make sure the tests pass!)\n1. Create a [new release/tag on GitHub](https://github.com/metaodi/museumpy/releases) (on the main branch)\n1. The [publication on PyPI](https://pypi.python.org/pypi/museumpy) happens via [GitHub Actions](https://github.com/metaodi/museumpy/actions?query=workflow%3A%22Upload+Python+Package%22) on every tagged commit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetaodi%2Fmuseumpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetaodi%2Fmuseumpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetaodi%2Fmuseumpy/lists"}