Readers

Jangle provides readers for commonly-used resources such as SIL ISO 639-3 tables and IANA registries. A record-jar parser is also available for the latter.

class jangle.readers.Record[source]

Used for working with record-jar records.

add(key: str, val: str) None[source]

Adds a value to a field.

one(key: str) str[source]

Return a single value from a field.

Raises

ValueError

If the field has multiple values.

KeyError

If the field has no values.

get_one(key: str, default: T = None) Union[str, T][source]

Return a single value from a field, or default.

Raises

ValueError

If the field has multiple values.

jangle.readers.parse_record_jar(lines: Iterable[str], indent='\t', multiline_separator='\r\n') Generator[Record, None, None][source]

Yields records from a set of lines. See https://datatracker.ietf.org/doc/pdf/draft-phillips-record-jar-02.

class jangle.readers.SilTableReader(fn: str, zf: Optional[ZipFile] = None)[source]

Uses csv.DictReader to read tab-delimited data from https://iso639-3.sil.org/sites/iso639-3/files/downloads/, or a ZipFile to minimize requests.

More information is available at https://iso639-3.sil.org/code_tables/download_tables.

chunk_size = 512
close() None[source]
class jangle.readers.IANARegistryReader(fn: str)[source]

Provides a file date and an iterable of records from an IANA registry.

chunk_size = 512
records: Generator[Record, None, None]
file_date: str
class jangle.readers.IANASubtagRegistryReader[source]

Reads https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry.

class jangle.readers.IANAExtensionsRegistryReader[source]