Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 36 additions & 14 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,44 @@ name: Run tests
on: [push, pull_request]

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: false
matrix:
python-version: [2.7, 3.6, 3.7, 3.8]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --all-extras --python ${{ matrix.python-version }}

- name: Run tests
run: uv run --python ${{ matrix.python-version }} pytest

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Set up Python
run: uv python install 3.13

- name: Install dependencies
run: uv sync --all-extras

- name: Lint with ruff
run: uv run ruff check . || true

- name: Check formatting with ruff
run: uv run ruff format --check . || true
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,32 @@ develop-eggs
parts
src/pyoai.egg-info
.tox

# Python
__pycache__/
*.py[cod]
*$py.class
*.egg-info/
dist/
build/
.eggs/
*.egg

# Virtual environments
.venv/
venv/
ENV/

# uv (library - do not commit lockfile)
uv.lock

# IDE
.idea/
.vscode/
*.swp
*.swo

# Testing
.pytest_cache/
.coverage
htmlcov/
5 changes: 0 additions & 5 deletions .hgignore

This file was deleted.

21 changes: 0 additions & 21 deletions .hgtags

This file was deleted.

16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.0
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
28 changes: 0 additions & 28 deletions INSTALL.txt

This file was deleted.

3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

75 changes: 55 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,33 +1,68 @@
======
OAIPMH
pyoai
======

.. image:: https://img.shields.io/pypi/v/pyoai.svg
:target: https://pypi.python.org/pypi/pyoai

.. image:: https://github.com/infrae/pyoai/workflows/Run%20tests/badge.svg
:target: https://github.com/infrae/pyoai/actions?query=workflow%3A%22Run+tests%22

The oaipmh module is a Python implementation of an "Open Archives
Initiative Protocol for Metadata Harvesting" (version 2) client and
server. The protocol is described here:
.. image:: https://github.com/mpasternak/pyoai/actions/workflows/run_tests.yml/badge.svg
:target: https://github.com/mpasternak/pyoai/actions/workflows/run_tests.yml

http://www.openarchives.org/OAI/openarchivesprotocol.html
.. image:: https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12%20|%203.13-blue
:target: https://www.python.org/

Below is a simple implementation of an OAIPMH client:
The ``oaipmh`` module is a Python implementation of the
`Open Archives Initiative Protocol for Metadata Harvesting`_ (version 2)
client and server.

>>> from oaipmh.client import Client
>>> from oaipmh.metadata import MetadataRegistry, oai_dc_reader
.. _Open Archives Initiative Protocol for Metadata Harvesting: http://www.openarchives.org/OAI/openarchivesprotocol.html

>>> URL = 'http://uni.edu/ir/oaipmh'
Installation
============

>>> registry = MetadataRegistry()
>>> registry.registerReader('oai_dc', oai_dc_reader)
>>> client = Client(URL, registry)
.. code-block:: bash

>>> for record in client.listRecords(metadataPrefix='oai_dc'):
>>> print record
pip install pyoai

Or with `uv`_::

The pyoai package also contains a generic server implementation of the
OAIPMH protocol, this is used as the foundation of the `MOAI Server Platform`_
uv add pyoai

.. _MOAI Server Platform: http://pypi.python.org/pypi/MOAI
.. _uv: https://docs.astral.sh/uv/

Requirements
============

* Python 3.10+
* `lxml <https://lxml.de/>`_

Example
=======

A simple OAI-PMH client:

.. code-block:: python

from oaipmh.client import Client
from oaipmh.metadata import MetadataRegistry, oai_dc_reader

URL = 'http://uni.edu/ir/oaipmh'

registry = MetadataRegistry()
registry.registerReader('oai_dc', oai_dc_reader)
client = Client(URL, registry)

for record in client.listRecords(metadataPrefix='oai_dc'):
print(record)

The pyoai package also contains a generic server implementation of the
OAI-PMH protocol. It is used as the foundation of the
`MOAI Server Platform <http://pypi.python.org/pypi/MOAI>`_.

Development
===========

.. code-block:: bash

uv sync --all-extras
uv run pytest
14 changes: 0 additions & 14 deletions buildout.cfg

This file was deleted.

71 changes: 71 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[build-system]
requires = ["setuptools>=75.0"]
build-backend = "setuptools.build_meta"

[project]
name = "pyoai"
version = "2.5.2"
description = "The oaipmh module is a Python implementation of an \"Open Archives Initiative Protocol for Metadata Harvesting\" (version 2) client and server."
readme = "README.rst"
requires-python = ">=3.10"
license = "BSD-3-Clause"
authors = [
{name = "Infrae", email = "info@infrae.com"},
]
keywords = ["OAI-PMH", "xml", "archive"]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries :: Python Modules",
"Environment :: Web Environment",
]
dependencies = [
"lxml",
]

[project.urls]
Homepage = "http://www.infrae.com/download/oaipmh"
Repository = "https://github.com/infrae/pyoai"

[project.optional-dependencies]
dev = [
"pytest",
"pre-commit",
"ruff",
"bumpver",
]

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-dir]
"" = "src"

[tool.ruff]
target-version = "py310"

[tool.ruff.lint]
select = ["E", "F", "W"]

[tool.pytest.ini_options]
testpaths = ["src/oaipmh/tests"]
python_classes = ["*TestCase"]

[tool.bumpver]
current_version = "2.5.2"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "Bump version {old_version} -> {new_version}"
commit = true
tag = true
push = false

[tool.bumpver.file_patterns]
"pyproject.toml" = [
'current_version = "{version}"',
'version = "{version}"',
]
26 changes: 0 additions & 26 deletions setup.py

This file was deleted.

Loading
Loading