flickr-sdc


Nameflickr-sdc JSON
Version 1.0.0 PyPI version JSON
download
home_page
SummaryStructured data definitions for Flickr photos on Wikimedia Commons
upload_time2023-11-12 15:59:13
maintainer
docs_urlNone
author
requires_python>=3.2
license
keywords flickr wikimedia_commons
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # flickr-sdc

This library contains structured data definitions for Flickr photos on Wikimedia Commons.

It also contains some utilities for working with structured data on Wikimedia files, including a Wikimedia API client with structured data-related methods, and a set of Python types for the Wikidata data model.

These definitions are used by [Flickypedia](https://github.com/Flickr-Foundation/flickypedia) and [Flickypedia Backfillr Bot](https://github.com/Flickr-Foundation/flickypedia-backfillr-bot), and are published here

## Naming things

SDC stands for "Structured Data on (Wikimedia) Commons".

I'm using "statement" and "claim" somewhat interchangeably, but that might be wrong in some places.
I've read [Commons:Statements](https://commons.wikimedia.org/wiki/Commons:Statements), but I still don't really understand the distinction.

## Usage

There are three parts of this library that might be useful:

1.  **The `create_sdc_claims_for_flickr_photo()` function.**
    This creates a complete set of SDC statements for a Flickr photo.

    It takes a `SinglePhoto` as an argument, which comes from the [flickr-photos-api](https://github.com/Flickr-Foundation/flickr-photos-api) library.
    For example:
    
    ```pycon
    >>> from flickr_photos_api import FlickrPhotosApi
    >>> from flickr_sdc import create_sdc_claims_for_flickr_photo
    >>> sdc = create_sdc_claims_for_flickr_photo(
    ...     photo = FlickrPhotosApi(…).get_single_photo(photo_id="14898030836")
    ... )
    >>> sdc
    {'claims': [{'mainsnak': {'snaktype': 'somevalue', 'property': 'P170'}...
    ```
    
    This returns a Python dictionary which can be JSON-ified and passed directly to Wikimedia's [`wbeditentity` API](https://www.wikidata.org/w/api.php?modules=wbeditentity&action=help).
    
    See [structured_data.py](https://github.com/Flickr-Foundation/flickr-sdc/blob/main/src/flickr_sdc/structured_data.py) for the complete set of structured data definitions.

2.  **The WikimediaSdcApi client.**
    This has some methods for doing stuff with structured data on Wikimedia files, including:
    
    *   Retrieving the structured data for a file using `WikimediaSdcApi.get_structured_data(page_id: str)`
    *   Upating a single statement for a file on Commons using `WikimediaSdcApi.update_statement()`
    
    This is defined in [wikimedia.py](https://github.com/Flickr-Foundation/flickr-sdc/blob/main/src/flickr_sdc/wikimedia.py), and you can see the docstrings on the individual functions for more usage information.

3.  **The Python types for the Wikidata data model in <a href="https://github.com/Flickr-Foundation/flickr-sdc/blob/main/src/flickr_sdc/_types.py">_types.py</a>.**
    These are all exported as part of the top-level module (e.g. `from flickr_sdc import NewStatement`) and can be used with Python type checkers like mypy.
    I found them very useful for writing type-checked code.

## Development

You can set up a local development environment by cloning the repo and installing dependencies:

```console
$ git clone https://github.com/Flickr-Foundation/flickr-sdc.git
$ cd flickr-sdc
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -e .
```

If you want to run tests, install the dev dependencies and run py.test:

```console
$ source .venv/bin/activate
$ pip install -r dev_requirements.txt
$ coverage run -m pytest tests
$ coverage report
```

To make changes to the library:

1.  Create a new branch
2.  Push your changes to GitHub
3.  Open a pull request
4.  Fix any issues flagged by GitHub Actions (including tests, code linting, and type checking)
5.  Ask somebody to review your change
6.  Merge it!

To create a new version on PyPI:

1.  Update the version in `src/flickr_sdc/__init__.py`
2.  Add release notes in `CHANGELOG.md` and push a new tag to GitHub
3.  Deploy the release using twine:

    ```console
    $ python3 -m build
    $ python3 -m twine upload dist/* --username=__token__
    ```
    
    You will need [a PyPI API token](https://pypi.org/help/#apitoken) to publish packages.
    This token is stored in 1Password.

## License

This project is dual-licensed as Apache-2.0 and MIT.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "flickr-sdc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.2",
    "maintainer_email": "Alex Chan <alex@flickr.org>",
    "keywords": "flickr,wikimedia_commons",
    "author": "",
    "author_email": "Flickr Foundation <hello@flickr.org>",
    "download_url": "https://files.pythonhosted.org/packages/ce/f1/9c8e63857fb589954662b580a0ee582b82b5af7b3f8daa4ab22817c83921/flickr-sdc-1.0.0.tar.gz",
    "platform": null,
    "description": "# flickr-sdc\n\nThis library contains structured data definitions for Flickr photos on Wikimedia Commons.\n\nIt also contains some utilities for working with structured data on Wikimedia files, including a Wikimedia API client with structured data-related methods, and a set of Python types for the Wikidata data model.\n\nThese definitions are used by [Flickypedia](https://github.com/Flickr-Foundation/flickypedia) and [Flickypedia Backfillr Bot](https://github.com/Flickr-Foundation/flickypedia-backfillr-bot), and are published here\n\n## Naming things\n\nSDC stands for \"Structured Data on (Wikimedia) Commons\".\n\nI'm using \"statement\" and \"claim\" somewhat interchangeably, but that might be wrong in some places.\nI've read [Commons:Statements](https://commons.wikimedia.org/wiki/Commons:Statements), but I still don't really understand the distinction.\n\n## Usage\n\nThere are three parts of this library that might be useful:\n\n1.  **The `create_sdc_claims_for_flickr_photo()` function.**\n    This creates a complete set of SDC statements for a Flickr photo.\n\n    It takes a `SinglePhoto` as an argument, which comes from the [flickr-photos-api](https://github.com/Flickr-Foundation/flickr-photos-api) library.\n    For example:\n    \n    ```pycon\n    >>> from flickr_photos_api import FlickrPhotosApi\n    >>> from flickr_sdc import create_sdc_claims_for_flickr_photo\n    >>> sdc = create_sdc_claims_for_flickr_photo(\n    ...     photo = FlickrPhotosApi(\u2026).get_single_photo(photo_id=\"14898030836\")\n    ... )\n    >>> sdc\n    {'claims': [{'mainsnak': {'snaktype': 'somevalue', 'property': 'P170'}...\n    ```\n    \n    This returns a Python dictionary which can be JSON-ified and passed directly to Wikimedia's [`wbeditentity` API](https://www.wikidata.org/w/api.php?modules=wbeditentity&action=help).\n    \n    See [structured_data.py](https://github.com/Flickr-Foundation/flickr-sdc/blob/main/src/flickr_sdc/structured_data.py) for the complete set of structured data definitions.\n\n2.  **The WikimediaSdcApi client.**\n    This has some methods for doing stuff with structured data on Wikimedia files, including:\n    \n    *   Retrieving the structured data for a file using `WikimediaSdcApi.get_structured_data(page_id: str)`\n    *   Upating a single statement for a file on Commons using `WikimediaSdcApi.update_statement()`\n    \n    This is defined in [wikimedia.py](https://github.com/Flickr-Foundation/flickr-sdc/blob/main/src/flickr_sdc/wikimedia.py), and you can see the docstrings on the individual functions for more usage information.\n\n3.  **The Python types for the Wikidata data model in <a href=\"https://github.com/Flickr-Foundation/flickr-sdc/blob/main/src/flickr_sdc/_types.py\">_types.py</a>.**\n    These are all exported as part of the top-level module (e.g. `from flickr_sdc import NewStatement`) and can be used with Python type checkers like mypy.\n    I found them very useful for writing type-checked code.\n\n## Development\n\nYou can set up a local development environment by cloning the repo and installing dependencies:\n\n```console\n$ git clone https://github.com/Flickr-Foundation/flickr-sdc.git\n$ cd flickr-sdc\n$ python3 -m venv .venv\n$ source .venv/bin/activate\n$ pip install -e .\n```\n\nIf you want to run tests, install the dev dependencies and run py.test:\n\n```console\n$ source .venv/bin/activate\n$ pip install -r dev_requirements.txt\n$ coverage run -m pytest tests\n$ coverage report\n```\n\nTo make changes to the library:\n\n1.  Create a new branch\n2.  Push your changes to GitHub\n3.  Open a pull request\n4.  Fix any issues flagged by GitHub Actions (including tests, code linting, and type checking)\n5.  Ask somebody to review your change\n6.  Merge it!\n\nTo create a new version on PyPI:\n\n1.  Update the version in `src/flickr_sdc/__init__.py`\n2.  Add release notes in `CHANGELOG.md` and push a new tag to GitHub\n3.  Deploy the release using twine:\n\n    ```console\n    $ python3 -m build\n    $ python3 -m twine upload dist/* --username=__token__\n    ```\n    \n    You will need [a PyPI API token](https://pypi.org/help/#apitoken) to publish packages.\n    This token is stored in 1Password.\n\n## License\n\nThis project is dual-licensed as Apache-2.0 and MIT.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Structured data definitions for Flickr photos on Wikimedia Commons",
    "version": "1.0.0",
    "project_urls": {
        "Changelog": "https://github.com/Flickr-Foundation/flickr-sdc/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/Flickr-Foundation/flickr-sdc"
    },
    "split_keywords": [
        "flickr",
        "wikimedia_commons"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fedcbaa46ca8873236f0e96f8cd84a04b10d997fe0aab76b80cb34faf015e2c8",
                "md5": "50cc767ec6df6422f011b0807e0ca116",
                "sha256": "ce08cb1627efef4bdb7baad89ea14b9b5ebc82afa50231cf629cd83fda38ffef"
            },
            "downloads": -1,
            "filename": "flickr_sdc-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "50cc767ec6df6422f011b0807e0ca116",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.2",
            "size": 19693,
            "upload_time": "2023-11-12T15:59:11",
            "upload_time_iso_8601": "2023-11-12T15:59:11.556728Z",
            "url": "https://files.pythonhosted.org/packages/fe/dc/baa46ca8873236f0e96f8cd84a04b10d997fe0aab76b80cb34faf015e2c8/flickr_sdc-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cef19c8e63857fb589954662b580a0ee582b82b5af7b3f8daa4ab22817c83921",
                "md5": "0d42c8eb7ba9e4826970f5386cd887c2",
                "sha256": "6891ee4e4b00eb1f928fe86d2663c374ba56ca6dabecfd649c4cf4908e5ac41d"
            },
            "downloads": -1,
            "filename": "flickr-sdc-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0d42c8eb7ba9e4826970f5386cd887c2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.2",
            "size": 23060,
            "upload_time": "2023-11-12T15:59:13",
            "upload_time_iso_8601": "2023-11-12T15:59:13.279489Z",
            "url": "https://files.pythonhosted.org/packages/ce/f1/9c8e63857fb589954662b580a0ee582b82b5af7b3f8daa4ab22817c83921/flickr-sdc-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-12 15:59:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Flickr-Foundation",
    "github_project": "flickr-sdc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "flickr-sdc"
}
        
Elapsed time: 0.14612s