Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, "3.10", 3.11, 3.12]
python-version: ["3.10", 3.11, 3.12, 3.13, 3.14]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## unreleased

- Support parsing GRAID annotations.
- Drop py3.8 compat.
- Removed the `Corpus.write_app` method.


## [2.2.0] - 2025-01-15
Expand Down
4 changes: 4 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ tox -r
```shell
flake8 src
```
- Make sure pylint passes with a score of 10:
```shell
pylint src
```

- Make sure docs can be created:
```shell
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ package_dir =
= src
python_requires = >=3.8
install_requires =
attrs
csvw
clldutils
pycldf
segments>=2.0.0
tabulate
include_package_data = True

[options.packages.find]
Expand Down
3 changes: 3 additions & 0 deletions src/pyigt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Functionality to read and write interlinear glossed text.
"""
from .igt import Corpus, IGT, LGRConformance, Example # noqa: F401
from .lgrmorphemes import GlossedWord, GlossedMorpheme # noqa: F401

Expand Down
5 changes: 4 additions & 1 deletion src/pyigt/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
CLI for the pyigt package.
"""
import sys
import contextlib

Expand All @@ -7,7 +10,7 @@
import pyigt.commands


def main(args=None, catch_all=False, parsed_args=None):
def main(args=None, catch_all=False, parsed_args=None): # pylint: disable=C0116
parser, subparsers = get_parser_and_subparsers('igt')
register_subcommands(subparsers, pyigt.commands)

Expand Down
10 changes: 8 additions & 2 deletions src/pyigt/cli_util.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
"""
Helpers for the `pyigt` CLI.
"""
import sys
import argparse

from clldutils.clilib import PathType

from pyigt import Corpus


def add_corpus(parser):
def add_corpus(parser: argparse.ArgumentParser):
"""Add an argument to specify a CLDF Dataset."""
parser.add_argument(
'dataset',
type=PathType(type='file', must_exist=False),
help="Either a CLDF dataset specified by its metadata file or a CLDF ExampleTable"
"as CSV file or '-' to read from <stdin>.")


def get_corpus(args):
def get_corpus(args: argparse.Namespace) -> Corpus:
"""Retrieve a Corpus according to the input from the CLI. Works in tandem with `add_corpus`."""
if args.dataset.name == '-':
return Corpus.from_stream(sys.stdin)
return Corpus.from_path(args.dataset)
8 changes: 4 additions & 4 deletions src/pyigt/commands/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pyigt.cli_util import add_corpus, get_corpus


def register(parser):
def register(parser): # pylint: disable=C0116
add_corpus(parser)
parser.add_argument(
'filter',
Expand All @@ -23,7 +23,7 @@ def register(parser):
)


def run(args):
def run(args): # pylint: disable=C0116
corpus = get_corpus(args)
filters = [f.split('=', maxsplit=1) for f in args.filter]

Expand All @@ -42,9 +42,9 @@ def match(igt, c, p):

for igt in corpus:
if (not filters) or all(match(igt, c, p) for c, p in filters):
print('Example {0}:'.format(igt.id))
print(f'Example {igt.id}:')
print(igt)
print()

if corpus.fname:
print('IGT corpus at {0}'.format(corpus.fname))
print(f'IGT corpus at {corpus.fname}')
9 changes: 5 additions & 4 deletions src/pyigt/commands/stats.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
"""
Describe the IGTs in a CLDF dataset
"""
from clldutils.clilib import Table
from clldutils.clilib import Table, add_format

from pyigt.cli_util import add_corpus, get_corpus


def register(parser):
def register(parser): # pylint: disable=C0116
add_corpus(parser)
add_format(parser)
parser.add_argument('--verbose', action='store_true', default=False)


def run(args):
def run(args): # pylint: disable=C0116
corpus = get_corpus(args)

with Table('type', 'count') as t:
with Table(args, 'type', 'count') as t:
e, w, m = corpus.get_stats()
t.append(['example', e])
t.append(['word', w])
Expand Down
Loading