piffle


Namepiffle JSON
Version 0.5.0 PyPI version JSON
download
home_page
SummaryPython library for working with IIIF Image and Presentation APIs
upload_time2023-10-05 20:27:28
maintainer
docs_urlNone
author
requires_python>=3.8
licenseApache License, Version 2.0
keywords iiif
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # piffle

Python library for generating and parsing [IIIF Image API](http://iiif.io/api/image/2.1/) URLs in an
object-oriented, pythonic fashion.

[![Unit Test Status](https://github.com/Princeton-CDH/piffle/workflows/unit_tests/badge.svg)](https://github.com/Princeton-CDH/piffle/actions?query=workflow%3Aunit_tests)
[![codecov](https://codecov.io/gh/Princeton-CDH/piffle/branch/main/graph/badge.svg)](https://codecov.io/gh/Princeton-CDH/piffle)
[![Maintainability](https://api.codeclimate.com/v1/badges/d37850d90592f9d628df/maintainability)](https://codeclimate.com/github/Princeton-CDH/piffle/maintainability)


Piffle is tested on Python 3.8—3.11.

Piffle was originally developed by Rebecca Sutton Koeser at Emory University as a part of [Readux](https://github.com/ecds/readux) and forked as a separate project under [emory-lits-labs](https://github.com/emory-lits-labs/). It was later transferred to Rebecca Sutton Koeser at the Center for Digital Humanities at Princeton.

## Installation and example use:

`pip install piffle`

Example use for generating an IIIF image url:

```
>>> from piffle.image import IIIFImageClient
>>> myimg = IIIFImageClient('http://image.server/path/', 'myimgid')
>>> print myimg
http://image.server/path/myimgid/full/full/0/default.jpg
>>> print myimg.info()
http://image.server/path/myimgid/info.json"
>>> print myimg.size(width=120).format('png')
http://image.server/path/myimgid/full/120,/0/default.png
```

Example use for parsing an IIIF image url:

```
>>> from piffle.image import IIIFImageClient
>>> myimg = IIIFImageClient.init_from_url('http://www.example.org/image-service/abcd1234/full/full/0/default.jpg')
>>> print myimg
http://www.example.org/image-service/abcd1234/full/full/0/default.jpg
>>> print myimg.info()
http://www.example.org/image-service/abcd1234/info.json
>>> myimg.as_dict()['size']['full']
True
>>> myimg.as_dict()['size']['exact']
False
>>> myimg.as_dict()['rotation']['degrees']
0.0
```

Example use for reading a IIIF manifest:

```
>>> from piffle.image import IIIFImageClient
>>> from piffle.presentation import IIIFPresentation
>>>  manifest = IIIFPresentation.from_url('https://iiif.bodleian.ox.ac.uk/iiif/manifest/60834383-7146-41ab-bfe1-48ee97bc04be.json')
>>> manifest.label
'Bodleian Library MS. Bodl. 264'
>>> manifest.id
'https://iiif.bodleian.ox.ac.uk/iiif/manifest/60834383-7146-41ab-bfe1-48ee97bc04be.json'
>>> manifest.type
'sc:Manifest'
>>> for canvas in manifest.sequences[0].canvases[:5]:
...     image_id = canvas.images[0].resource.id
...     iiif_img = IIIFImageClient(*image_id.rsplit('/', 1))
...     print(str(iiif_img.size(height=250)))
...
https://iiif.bodleian.ox.ac.uk/iiif/image/90701d49-5e0c-4fb5-9c7d-45af96565468/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/e878cc78-acd3-43ca-ba6e-90a392f15891/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/0f1ed064-a972-4215-b884-d8d658acefc5/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/6fe52b9a-5bb7-4b5b-bbcd-ad0489fcad2a/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/483ff8ec-347d-4070-8442-dbc15bc7b4de/full/,250/0/default.jpg
```

## Development and Testing

This project uses [git-flow](https://github.com/nvie/gitflow) branching conventions.

Install locally for development (the use of a python virtualenv is recommended):

`pip install -e .`

Install test dependencies:

`pip install -e ".[dev]"`

Run unit tests: `py.test` or `python setup.py test`

### Install pre-commit hooks

Anyone who wants to contribute to this codebase should install the configured pre-commit hooks:

```
pre-commit install
```

This will configure a pre-commit hooks to automatically lint and format python code with [ruff](https://github.com/astral-sh/ruff) and [black](https://github.com/psf/black).

Pre-commit hooks and formatting conventions were added at version 0.5, so ``git blame`` may not reflect the true author of a given change. To make ``git blame`` more accurate, ignore formatting revisions:

```
git blame <FILE> --ignore-revs-file .git-blame-ignore-revs
```

Or configure your git to always ignore styling revision commits:
```
git config blame.ignoreRevsFile .git-blame-ignore-revs
```

## Publishing python packages

A new python packages is automatically built and published to [PyPI](https://pypi.python.org/pypi) using a GitHub Actions workflow when a new release is created on GitHub.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "piffle",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "iiif",
    "author": "",
    "author_email": "The Center for Digital Humanities at Princeton <cdhdevteam@princeton.edu>",
    "download_url": "https://files.pythonhosted.org/packages/41/8b/3d3ca75ae350da1ea86ab0cb6fed598a9e1864a50f320b6284d29daefaa5/piffle-0.5.0.tar.gz",
    "platform": null,
    "description": "# piffle\n\nPython library for generating and parsing [IIIF Image API](http://iiif.io/api/image/2.1/) URLs in an\nobject-oriented, pythonic fashion.\n\n[![Unit Test Status](https://github.com/Princeton-CDH/piffle/workflows/unit_tests/badge.svg)](https://github.com/Princeton-CDH/piffle/actions?query=workflow%3Aunit_tests)\n[![codecov](https://codecov.io/gh/Princeton-CDH/piffle/branch/main/graph/badge.svg)](https://codecov.io/gh/Princeton-CDH/piffle)\n[![Maintainability](https://api.codeclimate.com/v1/badges/d37850d90592f9d628df/maintainability)](https://codeclimate.com/github/Princeton-CDH/piffle/maintainability)\n\n\nPiffle is tested on Python 3.8\u20143.11.\n\nPiffle was originally developed by Rebecca Sutton Koeser at Emory University as a part of [Readux](https://github.com/ecds/readux) and forked as a separate project under [emory-lits-labs](https://github.com/emory-lits-labs/). It was later transferred to Rebecca Sutton Koeser at the Center for Digital Humanities at Princeton.\n\n## Installation and example use:\n\n`pip install piffle`\n\nExample use for generating an IIIF image url:\n\n```\n>>> from piffle.image import IIIFImageClient\n>>> myimg = IIIFImageClient('http://image.server/path/', 'myimgid')\n>>> print myimg\nhttp://image.server/path/myimgid/full/full/0/default.jpg\n>>> print myimg.info()\nhttp://image.server/path/myimgid/info.json\"\n>>> print myimg.size(width=120).format('png')\nhttp://image.server/path/myimgid/full/120,/0/default.png\n```\n\nExample use for parsing an IIIF image url:\n\n```\n>>> from piffle.image import IIIFImageClient\n>>> myimg = IIIFImageClient.init_from_url('http://www.example.org/image-service/abcd1234/full/full/0/default.jpg')\n>>> print myimg\nhttp://www.example.org/image-service/abcd1234/full/full/0/default.jpg\n>>> print myimg.info()\nhttp://www.example.org/image-service/abcd1234/info.json\n>>> myimg.as_dict()['size']['full']\nTrue\n>>> myimg.as_dict()['size']['exact']\nFalse\n>>> myimg.as_dict()['rotation']['degrees']\n0.0\n```\n\nExample use for reading a IIIF manifest:\n\n```\n>>> from piffle.image import IIIFImageClient\n>>> from piffle.presentation import IIIFPresentation\n>>>  manifest = IIIFPresentation.from_url('https://iiif.bodleian.ox.ac.uk/iiif/manifest/60834383-7146-41ab-bfe1-48ee97bc04be.json')\n>>> manifest.label\n'Bodleian Library MS. Bodl. 264'\n>>> manifest.id\n'https://iiif.bodleian.ox.ac.uk/iiif/manifest/60834383-7146-41ab-bfe1-48ee97bc04be.json'\n>>> manifest.type\n'sc:Manifest'\n>>> for canvas in manifest.sequences[0].canvases[:5]:\n...     image_id = canvas.images[0].resource.id\n...     iiif_img = IIIFImageClient(*image_id.rsplit('/', 1))\n...     print(str(iiif_img.size(height=250)))\n...\nhttps://iiif.bodleian.ox.ac.uk/iiif/image/90701d49-5e0c-4fb5-9c7d-45af96565468/full/,250/0/default.jpg\nhttps://iiif.bodleian.ox.ac.uk/iiif/image/e878cc78-acd3-43ca-ba6e-90a392f15891/full/,250/0/default.jpg\nhttps://iiif.bodleian.ox.ac.uk/iiif/image/0f1ed064-a972-4215-b884-d8d658acefc5/full/,250/0/default.jpg\nhttps://iiif.bodleian.ox.ac.uk/iiif/image/6fe52b9a-5bb7-4b5b-bbcd-ad0489fcad2a/full/,250/0/default.jpg\nhttps://iiif.bodleian.ox.ac.uk/iiif/image/483ff8ec-347d-4070-8442-dbc15bc7b4de/full/,250/0/default.jpg\n```\n\n## Development and Testing\n\nThis project uses [git-flow](https://github.com/nvie/gitflow) branching conventions.\n\nInstall locally for development (the use of a python virtualenv is recommended):\n\n`pip install -e .`\n\nInstall test dependencies:\n\n`pip install -e \".[dev]\"`\n\nRun unit tests: `py.test` or `python setup.py test`\n\n### Install pre-commit hooks\n\nAnyone who wants to contribute to this codebase should install the configured pre-commit hooks:\n\n```\npre-commit install\n```\n\nThis will configure a pre-commit hooks to automatically lint and format python code with [ruff](https://github.com/astral-sh/ruff) and [black](https://github.com/psf/black).\n\nPre-commit hooks and formatting conventions were added at version 0.5, so ``git blame`` may not reflect the true author of a given change. To make ``git blame`` more accurate, ignore formatting revisions:\n\n```\ngit blame <FILE> --ignore-revs-file .git-blame-ignore-revs\n```\n\nOr configure your git to always ignore styling revision commits:\n```\ngit config blame.ignoreRevsFile .git-blame-ignore-revs\n```\n\n## Publishing python packages\n\nA new python packages is automatically built and published to [PyPI](https://pypi.python.org/pypi) using a GitHub Actions workflow when a new release is created on GitHub.\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "Python library for working with IIIF Image and Presentation APIs",
    "version": "0.5.0",
    "project_urls": {
        "homepage": "https://github.com/princeton-cdh/piffle",
        "repository": "https://github.com/princeton-cdh/piffle"
    },
    "split_keywords": [
        "iiif"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9496a6aca092b8d9b19ca007eca59abdf39eb2067663632ddd6130fca2e0af1",
                "md5": "2cbc4e2919973f6d2ab320f934f5572d",
                "sha256": "48b6f2d8d4b5a6a2d246f637014cb5e77248e8cfa9e61281e3a067c67be92860"
            },
            "downloads": -1,
            "filename": "piffle-0.5.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2cbc4e2919973f6d2ab320f934f5572d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 15912,
            "upload_time": "2023-10-05T20:27:27",
            "upload_time_iso_8601": "2023-10-05T20:27:27.074002Z",
            "url": "https://files.pythonhosted.org/packages/c9/49/6a6aca092b8d9b19ca007eca59abdf39eb2067663632ddd6130fca2e0af1/piffle-0.5.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "418b3d3ca75ae350da1ea86ab0cb6fed598a9e1864a50f320b6284d29daefaa5",
                "md5": "6072faa7029ea1ee43fe95ed568735d2",
                "sha256": "09bcc3a5ea0388a0169490cf774dc30b04dbcc5d7d2bcca792b32c39b3d56b5c"
            },
            "downloads": -1,
            "filename": "piffle-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6072faa7029ea1ee43fe95ed568735d2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 28555,
            "upload_time": "2023-10-05T20:27:28",
            "upload_time_iso_8601": "2023-10-05T20:27:28.613983Z",
            "url": "https://files.pythonhosted.org/packages/41/8b/3d3ca75ae350da1ea86ab0cb6fed598a9e1864a50f320b6284d29daefaa5/piffle-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-05 20:27:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "princeton-cdh",
    "github_project": "piffle",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "piffle"
}
        
Elapsed time: 0.12170s