Skip to content

itu_t_documents

itu_t_documents package.

Access the documents of ITU-T study group meetings. The package offers a Python API, a command line interface and an MCP server on top of the same metadata store and document cache.

Modules:

  • api –

    High level API for ITU-T meeting documents.

  • api_queries –

    The stored-document queries of the high level API.

  • api_sync –

    The synchronisation methods of the high level API.

  • auth –

    Authentication against the ITU-T document management system.

  • catalogue –

    The catalogue of the ITU-T study groups.

  • catalogue_search –

    Search in the ITU-T catalogue.

  • cli –

    CLI module for ITU-T Documents.

  • config –

    Configuration of the ITU-T documents.

  • downloads –

    Download the file of a document.

  • errors –

    The errors the package raises.

  • fetching –

    Read the ITU-T web site.

  • http –

    HTTP access to the ITU-T document management system.

  • interfaces –

    The contracts the parts of the package agree on.

  • mcp –

    The MCP server of ITU-T Documents.

  • models –

    Domain model of the ITU-T documents.

  • scraping –

    Scrapers for the ITU-T meeting document pages.

  • storage –

    Local storage of document metadata and files.

  • urls –

    URL builders for the ITU-T document management system.

Classes:

  • AccessDeniedError –

    Raised when the TIES account may not see the requested document.

  • AuthenticationError –

    Raised when the TIES authentication could not be completed.

  • CatalogueEntry –

    One entry of a search in the catalogue.

  • DocFormat –

    File formats offered by the ITU-T DMS for a document.

  • DocLanguage –

    Languages a document can be published in.

  • DocType –

    Document type codes as they appear in ITU-T document identifiers.

  • DocVisibility –

    Access level of a document in the ITU-T DMS.

  • DocumentFile –

    One downloadable rendition of a document.

  • DocumentMetadata –

    Metadata scraped for a document from the ITU-T DMS listing and detail pages.

  • DocumentRecord –

    A document as stored in the metadata database.

  • DocumentRef –

    The identity of a single ITU-T document.

  • FileCache –

    Stores downloaded documents in the per-user cache directory.

  • IncompleteListingError –

    Raised when a document listing holds fewer documents than it reports.

  • ItuCatalogue –

    The structure of the ITU-T study groups.

  • ItuDocuments –

    High level access to the documents of ITU-T study group meetings.

  • ItuError –

    Base class of the errors the package raises.

  • MeetingId –

    Identifies an ITU-T meeting by its start date.

  • MetadataStore –

    The SQLite metadata store of the ITU-T documents.

  • Person –

    A person holding a role for a question under study.

  • Question –

    A question under study of an ITU-T study group.

  • Role –

    Roles a person can hold for a question under study.

  • ScrapingError –

    Raised when a page of the ITU-T cannot be read.

  • Settings –

    Runtime configuration of the ITU-T documents.

  • SourceCount –

    The number of documents a single source submitted.

  • StructureGroup –

    A group of a study group that is neither a question nor a working group.

  • StudyGroup –

    An ITU-T study group of a study period.

  • StudyGroupStructure –

    The structure of an ITU-T study group in a study period.

  • StudyPeriod –

    An ITU-T study period, e.g. 2025-2028.

  • UnknownEntityError –

    Raised when an entity of the ITU-T structure does not exist.

  • WorkingGroup –

    A working group of a study group, or the plenary itself.

AccessDeniedError

Bases: ItuError

Raised when the TIES account may not see the requested document.

A TIES account is valid for the whole ITU-T, but its membership covers only the study groups the account belongs to. The ITU-T answers a document outside the membership with a status of 401 and a page that blames invalid credentials, which is not what happened.

AuthenticationError

Bases: ItuError

Raised when the TIES authentication could not be completed.

CatalogueEntry dataclass

CatalogueEntry(kind: str, code: str, title: str, study_group: int, period: str)

One entry of a search in the catalogue.

Attributes:

  • label (str) –

    The entry as it is shown to a user.

label property

label: str

The entry as it is shown to a user.

DocFormat

Bases: StrEnum

File formats offered by the ITU-T DMS for a document.

The member value is the code used in the !!<FORMAT>-<LANGUAGE> suffix of a download URL.

Methods:

  • parse –

    Return the member for code or None when the code is unknown.

parse classmethod

parse(code: str) -> DocFormat | None

Return the member for code or None when the code is unknown.

Source code in src/itu_t_documents/models/enums.py
28
29
30
31
32
33
34
@classmethod
def parse(cls, code: str) -> DocFormat | None:
    """Return the member for ``code`` or ``None`` when the code is unknown."""
    try:
        return cls(code.strip().upper())
    except ValueError:
        return None

DocLanguage

Bases: StrEnum

Languages a document can be published in.

The member value is the code used in the !!<FORMAT>-<LANGUAGE> suffix of a download URL.

Methods:

  • parse –

    Return the member for code or None when the code is unknown.

parse classmethod

parse(code: str) -> DocLanguage | None

Return the member for code or None when the code is unknown.

Source code in src/itu_t_documents/models/enums.py
51
52
53
54
55
56
57
@classmethod
def parse(cls, code: str) -> DocLanguage | None:
    """Return the member for ``code`` or ``None`` when the code is unknown."""
    try:
        return cls(code.strip().upper())
    except ValueError:
        return None

DocType

Bases: StrEnum

Document type codes as they appear in ITU-T document identifiers.

C Contribution submitted to a study group. TD Temporary document produced during a meeting. COL Collective letter (circular) issued by a study group. R Report produced by a study group.

DocVisibility

Bases: StrEnum

Access level of a document in the ITU-T DMS.

The ITU-T DMS exposes documents under three different path prefixes. The member value is the path segment used by the ITU-T download URLs.

PUBLIC is the access level of the metadata: the number, the title and the sources of a collective letter are readable without an account. The download itself goes through the access policy of the DMS and needs a TIES session, also for a collective letter — the package authenticates for every download.

DocumentFile

Bases: BaseModel

One downloadable rendition of a document.

Attributes:

  • extension (str) –

    The file name extension of the rendition.

  • file_format (DocFormat | None) –

    The parsed format code, or None when the DMS uses an unknown code.

  • language (DocLanguage | None) –

    The parsed language code, or None when the DMS uses an unknown code.

extension property

extension: str

The file name extension of the rendition.

The DMS publishes a document in the format it was submitted in, so the extension of the download URL is the authoritative one and the default of the format is only used as a fallback.

file_format property

file_format: DocFormat | None

The parsed format code, or None when the DMS uses an unknown code.

language property

language: DocLanguage | None

The parsed language code, or None when the DMS uses an unknown code.

DocumentMetadata

Bases: BaseModel

Metadata scraped for a document from the ITU-T DMS listing and detail pages.

Attributes:

document_id property

document_id: str

The DMS identifier of the described document.

DocumentRecord dataclass

DocumentRecord(document_id: str, doc_type: DocType, number: int, subtype: str | None, title: str, sources: tuple[str, ...] = (), questions: tuple[int, ...] = (), posted: date | None = None, revision: int | None = None, study_group: int = 0, study_period: str = '', meeting_code: str | None = None, detail_url: str = '')

A document as stored in the metadata database.

DocumentRef

Bases: BaseModel

The identity of a single ITU-T document.

Methods:

  • detail_url –

    Build the URL of the DMS detail page for this document.

  • download_url –

    Build the DMS download URL for one rendition of this document.

  • parse –

    Parse a DMS document identifier such as T25-SG12-261015-TD-GEN-0520.

Attributes:

display_number property

display_number: str

The number as shown by the ITU-T web interface, e.g. 520-GEN.

document_id property

document_id: str

The DMS identifier of this document.

study_group_code property

study_group_code: str

The study group part of a DMS identifier, e.g. SG05.

The ITU-T writes single digit study groups with a leading zero, so study group 5 becomes SG05.

visibility property

visibility: DocVisibility

The access level of this document type in the DMS.

detail_url

detail_url() -> str

Build the URL of the DMS detail page for this document.

Source code in src/itu_t_documents/models/documents.py
162
163
164
def detail_url(self) -> str:
    """Build the URL of the DMS detail page for this document."""
    return detail_url(self.document_id)

download_url

download_url(file_format: DocFormat, language: DocLanguage, revision: int | None = None, extension: str | None = None) -> str

Build the DMS download URL for one rendition of this document.

Parameters:

  • file_format

    (DocFormat) –

    The requested file format.

  • language

    (DocLanguage) –

    The requested language.

  • revision

    (int | None, default: None ) –

    The revision of the document. The DMS marks a revision with !R1! instead of the plain !! separator.

  • extension

    (str | None, default: None ) –

    The file name extension. Defaults to the extension the DMS uses for the format.

Returns:

  • str –

    An absolute URL on www.itu.int.

Source code in src/itu_t_documents/models/documents.py
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
def download_url(
    self,
    file_format: DocFormat,
    language: DocLanguage,
    revision: int | None = None,
    extension: str | None = None,
) -> str:
    """Build the DMS download URL for one rendition of this document.

    Args:
        file_format: The requested file format.
        language: The requested language.
        revision: The revision of the document. The DMS marks a revision
            with ``!R1!`` instead of the plain ``!!`` separator.
        extension: The file name extension. Defaults to the extension the
            DMS uses for the format.

    Returns:
        An absolute URL on ``www.itu.int``.
    """
    segment, visibility = _TYPE_PATHS[self.doc_type]
    suffix = extension or default_extension(file_format)
    path = f"/dms_{visibility.value}/itu-t/md/{self.study_period.short_code}/sg{self.study_group:02d}/{segment}"
    if self.doc_type is DocType.TEMPORARY_DOCUMENT:
        if self.meeting is None:
            raise ValueError("temporary documents require a meeting")
        path = f"{path}/{self.meeting.code}/{self.subtype or 'GEN'}"
    marker = "!!" if revision is None else f"!R{revision}!"
    return f"{BASE_URL}{path}/{self.document_id}{marker}{file_format.value}-{language.value}.{suffix}"

parse classmethod

parse(document_id: str) -> DocumentRef

Parse a DMS document identifier such as T25-SG12-261015-TD-GEN-0520.

The period code of the identifier names the first year of the study period, so the period itself is looked up in the registry of the known periods.

Source code in src/itu_t_documents/models/documents.py
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@classmethod
def parse(cls, document_id: str) -> DocumentRef:
    """Parse a DMS document identifier such as ``T25-SG12-261015-TD-GEN-0520``.

    The period code of the identifier names the first year of the study
    period, so the period itself is looked up in the registry of the
    known periods.
    """
    match = _DOCUMENT_ID_RE.match(document_id.strip())
    if match is None:
        raise ValueError(f"cannot parse document identifier from {document_id!r}")
    period = StudyPeriod.parse(f"T{match['period']}")
    meeting = MeetingId.from_code(match["meeting"]) if match["meeting"] else None
    return cls(
        study_period=period,
        study_group=int(match["group"]),
        doc_type=DocType(match["type"]),
        number=int(match["number"]),
        subtype=match["subtype"],
        meeting=meeting,
    )

FileCache

FileCache(settings: Settings | None = None)

Stores downloaded documents in the per-user cache directory.

Parameters:

  • settings

    (Settings | None, default: None ) –

    The configuration to use. Defaults to the resolved environment and configuration file settings.

Methods:

  • find –

    Return the cached rendition of a document, if there is one.

  • has –

    Whether a rendition is already cached.

  • load –

    Read a rendition from the cache.

  • path_for –

    Return the cache path of one rendition of a document.

  • store –

    Store a rendition in the cache.

Source code in src/itu_t_documents/storage/files.py
27
28
29
30
31
32
33
34
35
36
def __init__(self, settings: Settings | None = None) -> None:
    """Open the cache.

    Args:
        settings: The configuration to use. Defaults to the resolved
            environment and configuration file settings.
    """
    self.settings = settings or Settings()
    self.root_dir = self.settings.resolved_cache_dir / FILES_DIRECTORY
    self.root_dir.mkdir(parents=True, exist_ok=True)

find

Return the cached rendition of a document, if there is one.

The original document is preferred over a revision of it.

Parameters:

Returns:

  • Path | None –

    The path of the cached rendition, or None when nothing is

  • Path | None –

    cached for it.

Source code in src/itu_t_documents/storage/files.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def find(self, ref: DocumentRef, file_format: DocFormat, language: DocLanguage) -> Path | None:
    """Return the cached rendition of a document, if there is one.

    The original document is preferred over a revision of it.

    Args:
        ref: The identity of the document.
        file_format: The format of the rendition.
        language: The language of the rendition.

    Returns:
        The path of the cached rendition, or ``None`` when nothing is
        cached for it.
    """
    document_dir = self.root_dir / ref.document_id
    if not document_dir.is_dir():
        return None
    base = f"{file_format.value}-{language.value}"
    matches = [*document_dir.glob(f"{base}.*"), *document_dir.glob(f"{base}-R*.*")]
    if not matches:
        return None
    return sorted(matches, key=_revision_rank)[0]

has

Whether a rendition is already cached.

Parameters:

Returns:

  • bool –

    True when the cached file exists.

Source code in src/itu_t_documents/storage/files.py
87
88
89
90
91
92
93
94
95
96
97
98
def has(self, ref: DocumentRef, file_format: DocFormat, language: DocLanguage) -> bool:
    """Whether a rendition is already cached.

    Args:
        ref: The identity of the document.
        file_format: The format of the rendition.
        language: The language of the rendition.

    Returns:
        ``True`` when the cached file exists.
    """
    return self.find(ref, file_format, language) is not None

load

Read a rendition from the cache.

Parameters:

Returns:

  • bytes | None –

    The bytes of the document, or None when it is not cached.

Source code in src/itu_t_documents/storage/files.py
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
def load(self, ref: DocumentRef, file_format: DocFormat, language: DocLanguage) -> bytes | None:
    """Read a rendition from the cache.

    Args:
        ref: The identity of the document.
        file_format: The format of the rendition.
        language: The language of the rendition.

    Returns:
        The bytes of the document, or ``None`` when it is not cached.
    """
    path_file = self.find(ref, file_format, language)
    if path_file is None:
        return None
    return path_file.read_bytes()

path_for

path_for(ref: DocumentRef, file_format: DocFormat, language: DocLanguage, revision: int | None = None, extension: str | None = None) -> Path

Return the cache path of one rendition of a document.

Parameters:

  • ref

    (DocumentRef) –

    The identity of the document.

  • file_format

    (DocFormat) –

    The format of the rendition.

  • language

    (DocLanguage) –

    The language of the rendition.

  • revision

    (int | None, default: None ) –

    The revision of the rendition. A revision is kept beside the original document.

  • extension

    (str | None, default: None ) –

    The file name extension of the rendition. Defaults to the extension the DMS uses for the format.

Returns:

  • Path –

    The path the rendition is cached at.

Source code in src/itu_t_documents/storage/files.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def path_for(
    self,
    ref: DocumentRef,
    file_format: DocFormat,
    language: DocLanguage,
    revision: int | None = None,
    extension: str | None = None,
) -> Path:
    """Return the cache path of one rendition of a document.

    Args:
        ref: The identity of the document.
        file_format: The format of the rendition.
        language: The language of the rendition.
        revision: The revision of the rendition. A revision is kept
            beside the original document.
        extension: The file name extension of the rendition. Defaults to
            the extension the DMS uses for the format.

    Returns:
        The path the rendition is cached at.
    """
    suffix = "" if revision is None else f"-R{revision}"
    name = f"{file_format.value}-{language.value}{suffix}.{extension or default_extension(file_format)}"
    return self.root_dir / ref.document_id / name

store

store(ref: DocumentRef, file_format: DocFormat, language: DocLanguage, content: bytes, *, revision: int | None = None, extension: str | None = None) -> Path

Store a rendition in the cache.

Parameters:

  • ref

    (DocumentRef) –

    The identity of the document.

  • file_format

    (DocFormat) –

    The format of the rendition.

  • language

    (DocLanguage) –

    The language of the rendition.

  • content

    (bytes) –

    The bytes of the document.

  • revision

    (int | None, default: None ) –

    The revision of the rendition.

  • extension

    (str | None, default: None ) –

    The file name extension of the rendition.

Returns:

  • Path –

    The path the rendition was written to.

Source code in src/itu_t_documents/storage/files.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def store(
    self,
    ref: DocumentRef,
    file_format: DocFormat,
    language: DocLanguage,
    content: bytes,
    *,
    revision: int | None = None,
    extension: str | None = None,
) -> Path:
    """Store a rendition in the cache.

    Args:
        ref: The identity of the document.
        file_format: The format of the rendition.
        language: The language of the rendition.
        content: The bytes of the document.
        revision: The revision of the rendition.
        extension: The file name extension of the rendition.

    Returns:
        The path the rendition was written to.
    """
    path_file = self.path_for(ref, file_format, language, revision=revision, extension=extension)
    path_file.parent.mkdir(parents=True, exist_ok=True)
    path_file.write_bytes(content)
    return path_file

IncompleteListingError

Bases: ItuError

Raised when a document listing holds fewer documents than it reports.

Every page of a listing is read, so a listing that still holds fewer documents than it reports means that the site changed and the documents of the listing would be lost silently.

ItuCatalogue

ItuCatalogue(settings: Settings | None = None, *, client: ItuClient | None = None)

Bases: SearchOperations

The structure of the ITU-T study groups.

Parameters:

  • settings

    (Settings | None, default: None ) –

    The configuration to use. Defaults to the resolved environment and configuration file settings.

  • client

    (ItuClient | None, default: None ) –

    The HTTP client to use. Defaults to a new one.

Methods:

  • close –

    Release the resources owned by this catalogue.

  • current_period –

    Return the study period of the current year.

  • find_question –

    Return a question under study of a study group.

  • find_study_group –

    Return a study group of a study period.

  • find_working_group –

    Return a working group of a study group.

  • periods –

    Return every study period the ITU-T knows, oldest first.

  • search –

    Search the catalogue for the entities that mention the given text.

  • structure –

    Return the structure of a study group.

  • study_groups –

    Return the study groups of a study period.

Source code in src/itu_t_documents/catalogue.py
34
35
36
37
38
39
40
41
42
43
44
def __init__(self, settings: Settings | None = None, *, client: ItuClient | None = None) -> None:
    """Create the catalogue.

    Args:
        settings: The configuration to use. Defaults to the resolved
            environment and configuration file settings.
        client: The HTTP client to use. Defaults to a new one.
    """
    self.settings = settings or Settings()
    self.client = client or ItuHttpClient(self.settings)
    self._owns_client = client is None

close

close() -> None

Release the resources owned by this catalogue.

Source code in src/itu_t_documents/catalogue.py
46
47
48
49
def close(self) -> None:
    """Release the resources owned by this catalogue."""
    if self._owns_client:
        self.client.close()

current_period staticmethod

current_period() -> StudyPeriod

Return the study period of the current year.

Source code in src/itu_t_documents/catalogue.py
163
164
165
166
@staticmethod
def current_period() -> StudyPeriod:
    """Return the study period of the current year."""
    return StudyPeriod.current()

find_question

find_question(number: int, period: StudyPeriod, study_group: int | None = None) -> Question

Return a question under study of a study group.

A question number is only unique inside a study group, so the study group may be named. Without it every study group of the period is searched.

Parameters:

  • number

    (int) –

    The number of the question, e.g. 5 for Q5/12.

  • period

    (StudyPeriod) –

    The study period.

  • study_group

    (int | None, default: None ) –

    The number of the study group, e.g. 12.

Returns:

Raises:

Source code in src/itu_t_documents/catalogue.py
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
def find_question(self, number: int, period: StudyPeriod, study_group: int | None = None) -> Question:
    """Return a question under study of a study group.

    A question number is only unique inside a study group, so the study
    group may be named. Without it every study group of the period is
    searched.

    Args:
        number: The number of the question, e.g. 5 for ``Q5/12``.
        period: The study period.
        study_group: The number of the study group, e.g. 12.

    Returns:
        The question.

    Raises:
        UnknownEntityError: When no study group of the period has such a
            question.
    """
    groups = [group for group in self.study_groups(period) if study_group is None or group.number == study_group]
    for group in groups:
        for question in self.structure(group.number, period).questions:
            if question.number == number:
                return question
    raise UnknownEntityError(f"no study group of {period.label} has a question Q{number}")

find_study_group

find_study_group(number: int, period: StudyPeriod) -> StudyGroup

Return a study group of a study period.

Parameters:

  • number

    (int) –

    The number of the study group, e.g. 12.

  • period

    (StudyPeriod) –

    The study period.

Returns:

Raises:

Source code in src/itu_t_documents/catalogue.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
def find_study_group(self, number: int, period: StudyPeriod) -> StudyGroup:
    """Return a study group of a study period.

    Args:
        number: The number of the study group, e.g. 12.
        period: The study period.

    Returns:
        The study group.

    Raises:
        UnknownEntityError: When the period has no such study group.
    """
    study_groups = self.study_groups(period)
    for study_group in study_groups:
        if study_group.number == number:
            return study_group
    known = ", ".join(group.code for group in study_groups)
    raise UnknownEntityError(f"{period.label} has no study group SG{number:02d}; its study groups are {known}")

find_working_group

find_working_group(code: str, period: StudyPeriod) -> WorkingGroup

Return a working group of a study group.

The study group is taken from the code, e.g. WP1/12.

Parameters:

  • code

    (str) –

    The code of the working group, e.g. WP1/12.

  • period

    (StudyPeriod) –

    The study period.

Returns:

Raises:

  • UnknownEntityError –

    When the code names no working group, or the study group of the code has no such working group.

Source code in src/itu_t_documents/catalogue.py
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
def find_working_group(self, code: str, period: StudyPeriod) -> WorkingGroup:
    """Return a working group of a study group.

    The study group is taken from the code, e.g. ``WP1/12``.

    Args:
        code: The code of the working group, e.g. ``WP1/12``.
        period: The study period.

    Returns:
        The working group.

    Raises:
        UnknownEntityError: When the code names no working group, or the
            study group of the code has no such working group.
    """
    number = _study_group_of(code, "working group")
    for working_group in self.structure(number, period).working_groups:
        if working_group.code == code.strip().upper():
            return working_group
    raise UnknownEntityError(f"SG{number:02d} has no working group {code.strip().upper()}")

periods staticmethod

periods() -> list[StudyPeriod]

Return every study period the ITU-T knows, oldest first.

Source code in src/itu_t_documents/catalogue.py
158
159
160
161
@staticmethod
def periods() -> list[StudyPeriod]:
    """Return every study period the ITU-T knows, oldest first."""
    return StudyPeriod.all()

search

search(text: str, period: StudyPeriod | None = None) -> list[CatalogueEntry]

Search the catalogue for the entities that mention the given text.

The study groups, the working groups, the questions under study and the other groups of every study group of the period are searched.

Parameters:

  • text

    (str) –

    The text to look for, e.g. speech or Q5.

  • period

    (StudyPeriod | None, default: None ) –

    The study period to search in. Defaults to the current study period.

Returns:

Source code in src/itu_t_documents/catalogue_search.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def search(self, text: str, period: StudyPeriod | None = None) -> list[CatalogueEntry]:
    """Search the catalogue for the entities that mention the given text.

    The study groups, the working groups, the questions under study and
    the other groups of every study group of the period are searched.

    Args:
        text: The text to look for, e.g. ``speech`` or ``Q5``.
        period: The study period to search in. Defaults to the current
            study period.

    Returns:
        The matching entries, ordered by their kind and their code.
    """
    wanted = text.strip().lower()
    if not wanted:
        return []
    period = period or self.current_period()
    entries: list[CatalogueEntry] = []
    for study_group in self.study_groups(period):
        entries.extend(self._search_study_group(study_group, wanted))
    return sorted(entries, key=lambda entry: (entry.kind, entry.code))

structure

Return the structure of a study group.

Parameters:

  • study_group

    (int) –

    The number of the study group, e.g. 12.

  • period

    (StudyPeriod) –

    The study period.

Returns:

Raises:

Source code in src/itu_t_documents/catalogue.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
def structure(self, study_group: int, period: StudyPeriod) -> StudyGroupStructure:
    """Return the structure of a study group.

    Args:
        study_group: The number of the study group, e.g. 12.
        period: The study period.

    Returns:
        The plenary, the working groups, the questions under study and
        the other groups of the study group.

    Raises:
        UnknownEntityError: When the period has no such study group.
    """
    group = self.find_study_group(study_group, period)
    page = self.client.get_text(structure_url(study_group, period_index(period)))
    return catalogue_scraper.parse_structure(page, group)

study_groups

study_groups(period: StudyPeriod) -> list[StudyGroup]

Return the study groups of a study period.

The study groups change from period to period, so they are read from the index page of the period.

Parameters:

Returns:

  • list[StudyGroup] –

    The study groups of the period, ordered by their number.

Source code in src/itu_t_documents/catalogue.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def study_groups(self, period: StudyPeriod) -> list[StudyGroup]:
    """Return the study groups of a study period.

    The study groups change from period to period, so they are read from
    the index page of the period.

    Args:
        period: The study period.

    Returns:
        The study groups of the period, ordered by their number.
    """
    page = self.client.get_text(study_groups_index_url(period))
    return catalogue_scraper.parse_study_groups(page, period)

ItuDocuments

ItuDocuments(settings: Settings | None = None, *, client: ItuClient | None = None, store: MetadataStore | None = None, cache: FileCache | None = None)

Bases: SyncOperations, QueryOperations

High level access to the documents of ITU-T study group meetings.

Parameters:

  • settings

    (Settings | None, default: None ) –

    The configuration to use. Defaults to the resolved environment and configuration file settings.

  • client

    (ItuClient | None, default: None ) –

    The HTTP client to use. Defaults to a new one.

  • store

    (MetadataStore | None, default: None ) –

    The metadata store to use. Defaults to a new one.

  • cache

    (FileCache | None, default: None ) –

    The file cache to use. Defaults to a new one.

Methods:

  • close –

    Release the resources owned by this API.

  • contributions_by_source –

    List the contributions submitted by an organisation.

  • documents_for_question –

    List the documents handled in a question.

  • download –

    Download a document, reusing the cached copy when possible.

  • fetch_document_detail –

    Fetch the detail page of a document, which names its renditions.

  • fetch_documents –

    Fetch a document listing, every page of it, without storing it.

  • find_documents –

    Search the stored documents, newest number first.

  • list_meetings –

    List the meetings of a study group, in the order of the ITU-T pages.

  • list_questions –

    List the questions under study of a study group, ordered by number.

  • sync_detail –

    Fetch the renditions of a document and store them.

  • sync_meeting –

    Fetch and store the documents of a meeting.

  • sync_period –

    Fetch and store the period-wide listing of a study group.

  • sync_questions –

    Fetch and store the questions under study of a study group.

  • sync_study_group –

    Fetch and store a study group: every meeting and the period listing.

  • top_sources –

    Count the documents every source submitted, most prolific first.

Source code in src/itu_t_documents/api.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def __init__(
    self,
    settings: Settings | None = None,
    *,
    client: ItuClient | None = None,
    store: MetadataStore | None = None,
    cache: FileCache | None = None,
) -> None:
    """Create the API.

    Args:
        settings: The configuration to use. Defaults to the resolved
            environment and configuration file settings.
        client: The HTTP client to use. Defaults to a new one.
        store: The metadata store to use. Defaults to a new one.
        cache: The file cache to use. Defaults to a new one.
    """
    self.settings = settings or Settings()
    self.client = client or ItuHttpClient(self.settings)
    self.store = store or MetadataStore(self.settings)
    self.cache = cache or FileCache(self.settings)
    self.catalogue = ItuCatalogue(self.settings, client=self.client)
    self._owns_client = client is None
    self._owns_store = store is None

close

close() -> None

Release the resources owned by this API.

Source code in src/itu_t_documents/api.py
73
74
75
76
77
78
def close(self) -> None:
    """Release the resources owned by this API."""
    if self._owns_client:
        self.client.close()
    if self._owns_store:
        self.store.close()

contributions_by_source

contributions_by_source(study_group: int, source: str, study_period: str | None = None) -> list[DocumentRecord]

List the contributions submitted by an organisation.

Reads the metadata store only. source is matched case insensitively and partially; without study_period every stored study period is searched.

Source code in src/itu_t_documents/api_queries.py
 97
 98
 99
100
101
102
103
104
def contributions_by_source(self, study_group: int, source: str, study_period: str | None = None) -> list[DocumentRecord]:
    """List the contributions submitted by an organisation.

    Reads the metadata store only. ``source`` is matched case
    insensitively and partially; without ``study_period`` every stored
    study period is searched.
    """
    return self.find_documents(study_group=study_group, doc_type=DocType.CONTRIBUTION, source=source, study_period=study_period)

documents_for_question

documents_for_question(study_group: int, question: int, meeting: str | None = None, doc_type: DocType | None = None, study_period: str | None = None) -> list[DocumentRecord]

List the documents handled in a question.

Reads the metadata store only. meeting (a DMS code), doc_type and study_period restrict the search; without a study period every stored study period is searched.

Source code in src/itu_t_documents/api_queries.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
def documents_for_question(
    self,
    study_group: int,
    question: int,
    meeting: str | None = None,
    doc_type: DocType | None = None,
    study_period: str | None = None,
) -> list[DocumentRecord]:
    """List the documents handled in a question.

    Reads the metadata store only. ``meeting`` (a DMS code), ``doc_type``
    and ``study_period`` restrict the search; without a study period every
    stored study period is searched.
    """
    return self.find_documents(
        study_group=study_group,
        question=question,
        meeting=meeting,
        doc_type=doc_type,
        study_period=study_period,
    )

download

download(ref: DocumentRef, file_format: DocFormat = PDF, language: DocLanguage = ENGLISH, output_file: Path | None = None) -> Path

Download a document, reusing the cached copy when possible.

Raises :class:FileNotFoundError when the document is not available in the requested format and language, and :class:AccessDeniedError when the TIES account may not see the document. The arguments are documented on :func:itu_t_documents.downloads.download_document.

Source code in src/itu_t_documents/api.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
def download(
    self,
    ref: DocumentRef,
    file_format: DocFormat = DocFormat.PDF,
    language: DocLanguage = DocLanguage.ENGLISH,
    output_file: Path | None = None,
) -> Path:
    """Download a document, reusing the cached copy when possible.

    Raises :class:`FileNotFoundError` when the document is not available
    in the requested format and language, and :class:`AccessDeniedError`
    when the TIES account may not see the document. The arguments are
    documented on :func:`itu_t_documents.downloads.download_document`.
    """
    return download_document(
        self.client,
        self.store,
        self.cache,
        ref,
        file_format=file_format,
        language=language,
        output_file=output_file,
    )

fetch_document_detail

fetch_document_detail(ref: DocumentRef) -> DocumentMetadata

Fetch the detail page of a document, which names its renditions.

Reads the ITU-T web site. The arguments are documented on :func:itu_t_documents.fetching.fetch_document_detail.

Source code in src/itu_t_documents/api.py
112
113
114
115
116
117
118
def fetch_document_detail(self, ref: DocumentRef) -> DocumentMetadata:
    """Fetch the detail page of a document, which names its renditions.

    Reads the ITU-T web site. The arguments are documented on
    :func:`itu_t_documents.fetching.fetch_document_detail`.
    """
    return fetch_document_detail(self.client, ref)

fetch_documents

fetch_documents(study_group: int, doc_type: DocType, study_period: StudyPeriod, meeting: MeetingId | None = None) -> list[DocumentMetadata]

Fetch a document listing, every page of it, without storing it.

Reads the ITU-T web site and raises :class:IncompleteListingError when a listing reports more documents than its pages hold. The arguments are documented on :func:itu_t_documents.fetching.fetch_documents.

Source code in src/itu_t_documents/api.py
102
103
104
105
106
107
108
109
110
def fetch_documents(self, study_group: int, doc_type: DocType, study_period: StudyPeriod, meeting: MeetingId | None = None) -> list[DocumentMetadata]:
    """Fetch a document listing, every page of it, without storing it.

    Reads the ITU-T web site and raises :class:`IncompleteListingError`
    when a listing reports more documents than its pages hold. The
    arguments are documented on
    :func:`itu_t_documents.fetching.fetch_documents`.
    """
    return fetch_documents(self.client, study_group, doc_type, study_period, meeting)

find_documents

find_documents(*, study_group: int | None = None, study_period: str | None = None, doc_type: DocType | None = None, doc_types: tuple[DocType, ...] | None = None, meeting: str | None = None, question: int | None = None, source: str | None = None, limit: int | None = None) -> list[DocumentRecord]

Search the stored documents, newest number first.

Reads the metadata store only; the network is not contacted. The filters are documented on :func:itu_t_documents.storage.queries.find_documents.

Source code in src/itu_t_documents/api_queries.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def find_documents(
    self,
    *,
    study_group: int | None = None,
    study_period: str | None = None,
    doc_type: DocType | None = None,
    doc_types: tuple[DocType, ...] | None = None,
    meeting: str | None = None,
    question: int | None = None,
    source: str | None = None,
    limit: int | None = None,
) -> list[DocumentRecord]:
    """Search the stored documents, newest number first.

    Reads the metadata store only; the network is not contacted. The
    filters are documented on
    :func:`itu_t_documents.storage.queries.find_documents`.
    """
    return find_documents(
        self.store,
        study_group=study_group,
        study_period=study_period,
        doc_type=doc_type,
        doc_types=doc_types,
        meeting=meeting,
        question=question,
        source=source,
        limit=limit,
    )

list_meetings

list_meetings(study_group: int, study_period: StudyPeriod) -> list[MeetingInfo]

List the meetings of a study group, in the order of the ITU-T pages.

Reads the ITU-T web site. The arguments are documented on :func:itu_t_documents.fetching.list_meetings.

Source code in src/itu_t_documents/api.py
86
87
88
89
90
91
92
def list_meetings(self, study_group: int, study_period: StudyPeriod) -> list[meetings_scraper.MeetingInfo]:
    """List the meetings of a study group, in the order of the ITU-T pages.

    Reads the ITU-T web site. The arguments are documented on
    :func:`itu_t_documents.fetching.list_meetings`.
    """
    return list_meetings(self.client, study_group, study_period)

list_questions

list_questions(study_group: int, study_period: StudyPeriod) -> list[Question]

List the questions under study of a study group, ordered by number.

Reads the ITU-T web site. The arguments are documented on :func:itu_t_documents.fetching.list_questions.

Source code in src/itu_t_documents/api.py
 94
 95
 96
 97
 98
 99
100
def list_questions(self, study_group: int, study_period: StudyPeriod) -> list[Question]:
    """List the questions under study of a study group, ordered by number.

    Reads the ITU-T web site. The arguments are documented on
    :func:`itu_t_documents.fetching.list_questions`.
    """
    return list_questions(self.client, study_group, study_period)

sync_detail

sync_detail(ref: DocumentRef) -> DocumentMetadata

Fetch the renditions of a document and store them.

Parameters:

Returns:

Source code in src/itu_t_documents/api_sync.py
134
135
136
137
138
139
140
141
142
143
144
145
def sync_detail(self, ref: DocumentRef) -> DocumentMetadata:
    """Fetch the renditions of a document and store them.

    Args:
        ref: The identity of the document.

    Returns:
        The metadata of the document.
    """
    metadata = self.fetch_document_detail(ref)
    self.store.store_detail(metadata)
    return metadata

sync_meeting

sync_meeting(study_group: int, meeting: MeetingId, study_period: StudyPeriod, doc_types: tuple[DocType, ...] = (CONTRIBUTION, TEMPORARY_DOCUMENT)) -> int

Fetch and store the documents of a meeting.

Parameters:

  • study_group

    (int) –

    The study group number.

  • meeting

    (MeetingId) –

    The meeting.

  • study_period

    (StudyPeriod) –

    The study period.

  • doc_types

    (tuple[DocType, ...], default: (CONTRIBUTION, TEMPORARY_DOCUMENT) ) –

    The document types to fetch.

Returns:

  • int –

    The number of documents stored.

Source code in src/itu_t_documents/api_sync.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def sync_meeting(
    self,
    study_group: int,
    meeting: MeetingId,
    study_period: StudyPeriod,
    doc_types: tuple[DocType, ...] = (DocType.CONTRIBUTION, DocType.TEMPORARY_DOCUMENT),
) -> int:
    """Fetch and store the documents of a meeting.

    Args:
        study_group: The study group number.
        meeting: The meeting.
        study_period: The study period.
        doc_types: The document types to fetch.

    Returns:
        The number of documents stored.
    """
    before = self.store.count_documents()
    for doc_type in doc_types:
        for metadata in self.fetch_documents(study_group, doc_type, study_period, meeting):
            self.store.store_document(metadata)
    return self.store.count_documents() - before

sync_period

sync_period(study_group: int, study_period: StudyPeriod, doc_types: tuple[DocType, ...] = (CONTRIBUTION, TEMPORARY_DOCUMENT)) -> int

Fetch and store the period-wide listing of a study group.

A contribution can be posted between two meetings: the listing of the period names it, while no meeting listing does. The period-wide listing is therefore read as well, and a document it names without a meeting is stored with no meeting.

Parameters:

  • study_group

    (int) –

    The study group number.

  • study_period

    (StudyPeriod) –

    The study period.

  • doc_types

    (tuple[DocType, ...], default: (CONTRIBUTION, TEMPORARY_DOCUMENT) ) –

    The document types to fetch. Temporary documents are previewed by the aggregate listing and are read meeting by meeting instead.

Returns:

  • int –

    The number of documents stored.

Source code in src/itu_t_documents/api_sync.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def sync_period(
    self,
    study_group: int,
    study_period: StudyPeriod,
    doc_types: tuple[DocType, ...] = (DocType.CONTRIBUTION, DocType.TEMPORARY_DOCUMENT),
) -> int:
    """Fetch and store the period-wide listing of a study group.

    A contribution can be posted between two meetings: the listing of the
    period names it, while no meeting listing does. The period-wide
    listing is therefore read as well, and a document it names without a
    meeting is stored with no meeting.

    Args:
        study_group: The study group number.
        study_period: The study period.
        doc_types: The document types to fetch. Temporary documents are
            previewed by the aggregate listing and are read meeting by
            meeting instead.

    Returns:
        The number of documents stored.
    """
    before = self.store.count_documents()
    for doc_type in doc_types:
        if doc_type is DocType.TEMPORARY_DOCUMENT:
            continue
        for metadata in self.fetch_documents(study_group, doc_type, study_period):
            self.store.store_document(metadata)
    return self.store.count_documents() - before

sync_questions

sync_questions(study_group: int, study_period: StudyPeriod) -> int

Fetch and store the questions under study of a study group.

Parameters:

  • study_group

    (int) –

    The study group number.

  • study_period

    (StudyPeriod) –

    The study period.

Returns:

  • int –

    The number of questions stored.

Source code in src/itu_t_documents/api_sync.py
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def sync_questions(self, study_group: int, study_period: StudyPeriod) -> int:
    """Fetch and store the questions under study of a study group.

    Args:
        study_group: The study group number.
        study_period: The study period.

    Returns:
        The number of questions stored.
    """
    questions = self.list_questions(study_group, study_period)
    for question in questions:
        self.store.store_question(question, study_period.label)
    return len(questions)

sync_study_group

sync_study_group(study_group: int, study_period: StudyPeriod, doc_types: tuple[DocType, ...] = (CONTRIBUTION, TEMPORARY_DOCUMENT)) -> SyncReport

Fetch and store a study group: every meeting and the period listing.

Parameters:

  • study_group

    (int) –

    The study group number.

  • study_period

    (StudyPeriod) –

    The study period.

  • doc_types

    (tuple[DocType, ...], default: (CONTRIBUTION, TEMPORARY_DOCUMENT) ) –

    The document types to fetch.

Returns:

  • SyncReport –

    A report of the documents stored per meeting and by the

  • SyncReport –

    period-wide listing alone.

Source code in src/itu_t_documents/api_sync.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def sync_study_group(
    self,
    study_group: int,
    study_period: StudyPeriod,
    doc_types: tuple[DocType, ...] = (DocType.CONTRIBUTION, DocType.TEMPORARY_DOCUMENT),
) -> SyncReport:
    """Fetch and store a study group: every meeting and the period listing.

    Args:
        study_group: The study group number.
        study_period: The study period.
        doc_types: The document types to fetch.

    Returns:
        A report of the documents stored per meeting and by the
        period-wide listing alone.
    """
    meetings: list[tuple[str, int]] = []
    meeting_types = tuple(doc_type for doc_type in doc_types if doc_type in (DocType.CONTRIBUTION, DocType.TEMPORARY_DOCUMENT))
    if meeting_types:
        for meeting in self.list_meetings(study_group, study_period):
            meetings.append((meeting.code, self.sync_meeting(study_group, MeetingId.from_code(meeting.code), study_period, meeting_types)))
    period_only = self.sync_period(study_group, study_period, doc_types)
    return SyncReport(meetings=tuple(meetings), period_only=period_only)

top_sources

top_sources(study_group: int, meetings: tuple[str, ...] | None = None, doc_types: tuple[DocType, ...] = (CONTRIBUTION, TEMPORARY_DOCUMENT), limit: int = 10, *, last_meetings: int | None = None, study_period: StudyPeriod | None = None) -> list[SourceCount]

Count the documents every source submitted, most prolific first.

Reads the metadata store only, so a meeting counts after it was synchronised. last_meetings selects the most recent stored meetings of the study period; meetings names them directly. The arguments are documented on :func:itu_t_documents.storage.queries.top_sources.

Source code in src/itu_t_documents/api_queries.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def top_sources(
    self,
    study_group: int,
    meetings: tuple[str, ...] | None = None,
    doc_types: tuple[DocType, ...] = (DocType.CONTRIBUTION, DocType.TEMPORARY_DOCUMENT),
    limit: int = 10,
    *,
    last_meetings: int | None = None,
    study_period: StudyPeriod | None = None,
) -> list[SourceCount]:
    """Count the documents every source submitted, most prolific first.

    Reads the metadata store only, so a meeting counts after it was
    synchronised. ``last_meetings`` selects the most recent stored
    meetings of the study period; ``meetings`` names them directly. The
    arguments are documented on
    :func:`itu_t_documents.storage.queries.top_sources`.
    """
    if last_meetings is not None:
        meetings = self._recent_meetings(study_group, study_period or StudyPeriod.current(), last_meetings)
    return top_sources(self.store, study_group, meetings, doc_types, limit)

ItuError

MeetingId

Bases: BaseModel

Identifies an ITU-T meeting by its start date.

Methods:

  • from_code –

    Parse a DMS meeting code such as 261015.

Attributes:

  • code (str) –

    The DMS code for this meeting, e.g. 261015.

  • label (str) –

    The human readable meeting date, e.g. 2026-10-15.

code property

code: str

The DMS code for this meeting, e.g. 261015.

label property

label: str

The human readable meeting date, e.g. 2026-10-15.

from_code classmethod

from_code(code: str) -> MeetingId

Parse a DMS meeting code such as 261015.

Source code in src/itu_t_documents/models/documents.py
80
81
82
83
84
85
86
@classmethod
def from_code(cls, code: str) -> MeetingId:
    """Parse a DMS meeting code such as ``261015``."""
    text = code.strip()
    if not (len(text) == 6 and text.isdigit()):
        raise ValueError(f"cannot parse meeting code from {code!r}")
    return cls(start_date=date(2000 + int(text[:2]), int(text[2:4]), int(text[4:])))

MetadataStore

MetadataStore(settings: Settings | None = None)

The SQLite metadata store of the ITU-T documents.

Parameters:

  • settings

    (Settings | None, default: None ) –

    The configuration to use. Defaults to the resolved environment and configuration file settings.

Methods:

  • close –

    Release the database connections held by the store.

  • count_documents –

    Return the number of stored documents.

  • session –

    Return a new database session.

  • store_detail –

    Store what the detail page of a document says.

  • store_document –

    Insert or update a document and its links.

  • store_question –

    Insert or update a question under study and its people.

Source code in src/itu_t_documents/storage/database.py
32
33
34
35
36
37
38
39
40
41
42
43
44
def __init__(self, settings: Settings | None = None) -> None:
    """Open the store.

    Args:
        settings: The configuration to use. Defaults to the resolved
            environment and configuration file settings.
    """
    self.settings = settings or Settings()
    self.cache_dir = self.settings.resolved_cache_dir
    self.cache_dir.mkdir(parents=True, exist_ok=True)
    self.database_path = self.cache_dir / DATABASE_FILE
    self.engine = create_engine(f"sqlite:///{self.database_path}")
    SQLModel.metadata.create_all(self.engine)

close

close() -> None

Release the database connections held by the store.

Source code in src/itu_t_documents/storage/database.py
50
51
52
def close(self) -> None:
    """Release the database connections held by the store."""
    self.engine.dispose()

count_documents

count_documents() -> int

Return the number of stored documents.

Source code in src/itu_t_documents/storage/database.py
94
95
96
97
def count_documents(self) -> int:
    """Return the number of stored documents."""
    with self.session() as session:
        return len(session.exec(select(DocumentRow)).all())

session

session() -> Session

Return a new database session.

Source code in src/itu_t_documents/storage/database.py
46
47
48
def session(self) -> Session:
    """Return a new database session."""
    return Session(self.engine)

store_detail

store_detail(detail: DocumentMetadata) -> DocumentRow

Store what the detail page of a document says.

The detail page gives the title and the renditions of a document. What a listing said — the posting date, the revision, the sources, the questions and the meeting — is unknown to it, so that is kept. A document that no listing told of yet is stored as its detail page describes it.

Parameters:

  • detail

    (DocumentMetadata) –

    The metadata read from the detail page of the document.

Returns:

  • DocumentRow –

    The stored row.

Source code in src/itu_t_documents/storage/database.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
def store_detail(self, detail: DocumentMetadata) -> DocumentRow:
    """Store what the detail page of a document says.

    The detail page gives the title and the renditions of a document. What
    a listing said — the posting date, the revision, the sources, the
    questions and the meeting — is unknown to it, so that is kept. A
    document that no listing told of yet is stored as its detail page
    describes it.

    Args:
        detail: The metadata read from the detail page of the document.

    Returns:
        The stored row.
    """
    with self.session() as session:
        return write_detail(session, detail)

store_document

store_document(metadata: DocumentMetadata) -> DocumentRow

Insert or update a document and its links.

Parameters:

Returns:

  • DocumentRow –

    The stored row.

Source code in src/itu_t_documents/storage/database.py
54
55
56
57
58
59
60
61
62
63
64
def store_document(self, metadata: DocumentMetadata) -> DocumentRow:
    """Insert or update a document and its links.

    Args:
        metadata: The metadata of the document, as a listing tells it.

    Returns:
        The stored row.
    """
    with self.session() as session:
        return write_document(session, metadata)

store_question

store_question(question: Question, period_label: str) -> None

Insert or update a question under study and its people.

Parameters:

  • question

    (Question) –

    The question to store.

  • period_label

    (str) –

    The study period the question belongs to.

Source code in src/itu_t_documents/storage/database.py
84
85
86
87
88
89
90
91
92
def store_question(self, question: Question, period_label: str) -> None:
    """Insert or update a question under study and its people.

    Args:
        question: The question to store.
        period_label: The study period the question belongs to.
    """
    with self.session() as session:
        write_question(session, question, period_label)

Person

Bases: BaseModel

A person holding a role for a question under study.

Question

Bases: BaseModel

A question under study of an ITU-T study group.

Attributes:

co_rapporteurs property

co_rapporteurs: list[Person]

The people holding a co-rapporteur role for this question.

code property

code: str

The ITU-T code of the question, e.g. Q5/12.

rapporteurs property

rapporteurs: list[Person]

The people holding a rapporteur role for this question.

Role

Bases: StrEnum

Roles a person can hold for a question under study.

ScrapingError

Bases: ItuError

Raised when a page of the ITU-T cannot be read.

The text of a page is untrusted input: the ITU-T writes its dates and its labels in its own way, and it changes them. A page that cannot be read is named in the error, together with the text that could not be parsed, so that the failure is a message and not a traceback.

Settings

Bases: BaseSettings

Runtime configuration of the ITU-T documents.

Methods:

Attributes:

config_file property

config_file: Path

Path of the TOML configuration file.

resolved_cache_dir property

resolved_cache_dir: Path

The cache directory with ~ expanded.

has_credentials

has_credentials() -> bool

Whether both a TIES user name and a password are available.

Source code in src/itu_t_documents/config/settings.py
136
137
138
def has_credentials(self) -> bool:
    """Whether both a TIES user name and a password are available."""
    return bool(self.ties_username) and self.ties_password is not None

settings_customise_sources classmethod

settings_customise_sources(settings_cls: type[BaseSettings], init_settings: PydanticBaseSettingsSource, env_settings: PydanticBaseSettingsSource, dotenv_settings: PydanticBaseSettingsSource, file_secret_settings: PydanticBaseSettingsSource) -> tuple[PydanticBaseSettingsSource, ...]

Order the setting sources: manifest, explicit values, environment, TOML file, secretspec.

Source code in src/itu_t_documents/config/settings.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
@classmethod
def settings_customise_sources(
    cls,
    settings_cls: type[BaseSettings],
    init_settings: PydanticBaseSettingsSource,
    env_settings: PydanticBaseSettingsSource,
    dotenv_settings: PydanticBaseSettingsSource,
    file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]:
    """Order the setting sources: manifest, explicit values, environment, TOML file, secretspec."""
    explicit_values = cast(InitSettingsSource, init_settings).init_kwargs
    config_dir = resolve_config_dir(explicit_values.get("config_dir"))
    manifest = resolve_secretspec_manifest(explicit_values.get("secretspec_manifest"), config_dir=config_dir, settings_cls=settings_cls)
    return (
        SecretspecManifestSource(settings_cls, manifest),
        init_settings,
        env_settings,
        TomlConfigSource(settings_cls, config_dir / CONFIG_FILE_NAME),
        file_secret_settings,
        SecretspecConfigSource(settings_cls, manifest=manifest),
    )

SourceCount dataclass

SourceCount(source: str, count: int, contributions: int = 0, temporary_documents: int = 0, meetings: tuple[str, ...] = ())

The number of documents a single source submitted.

StructureGroup

Bases: BaseModel

A group of a study group that is neither a question nor a working group.

Attributes:

is_focus property

is_focus: bool

Whether the group is a focus group.

is_regional property

is_regional: bool

Whether the group is a regional group.

StudyGroup

Bases: BaseModel

An ITU-T study group of a study period.

The study groups change from period to period: SG9 and SG16 existed in 2022-2024 and were replaced by SG21 in 2025-2028. The catalogue knows the study groups of every period.

Attributes:

  • code (str) –

    The ITU-T code of the study group, e.g. SG12.

  • label (str) –

    The study group with its period, e.g. SG12 (2025-2028).

code property

code: str

The ITU-T code of the study group, e.g. SG12.

label property

label: str

The study group with its period, e.g. SG12 (2025-2028).

StudyGroupStructure

Bases: BaseModel

The structure of an ITU-T study group in a study period.

Methods:

  • question –

    Return a question under study of the study group.

  • working_group –

    Return a working group of the study group.

Attributes:

period property

period: StudyPeriod

The study period the structure belongs to.

question

question(number: int) -> Question

Return a question under study of the study group.

Parameters:

  • number

    (int) –

    The number of the question, e.g. 5 for Q5/12.

Returns:

Raises:

Source code in src/itu_t_documents/models/catalogue.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def question(self, number: int) -> Question:
    """Return a question under study of the study group.

    Args:
        number: The number of the question, e.g. 5 for ``Q5/12``.

    Returns:
        The question.

    Raises:
        UnknownEntityError: When the study group has no such question.
    """
    for question in self.questions:
        if question.number == number:
            return question
    raise UnknownEntityError(f"{self.study_group.code} has no question Q{number}/{self.study_group.number}")

working_group

working_group(code: str) -> WorkingGroup

Return a working group of the study group.

Parameters:

  • code

    (str) –

    The code of the working group, e.g. WP1/12.

Returns:

Raises:

Source code in src/itu_t_documents/models/catalogue.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def working_group(self, code: str) -> WorkingGroup:
    """Return a working group of the study group.

    Args:
        code: The code of the working group, e.g. ``WP1/12``.

    Returns:
        The working group.

    Raises:
        UnknownEntityError: When the study group has no such working group.
    """
    wanted = code.strip().upper()
    for working_group in self.working_groups:
        if working_group.code == wanted:
            return working_group
    raise UnknownEntityError(f"{self.study_group.code} has no working group {wanted}")

StudyPeriod

Bases: BaseModel

An ITU-T study period, e.g. 2025-2028.

The ITU-T publishes a fixed set of study periods, so a period that the ITU-T does not know cannot be constructed.

Methods:

  • all –

    Return every study period the ITU-T knows, oldest first.

  • containing –

    Return the study period the given year falls into.

  • current –

    Return the study period of the current year.

  • from_year –

    Return the study period that starts in the given year.

  • parse –

    Parse "2025-2028", "T25" or the start year "2025".

Attributes:

  • code (str) –

    The DMS code for this period, e.g. T25.

  • label (str) –

    The human readable period, e.g. 2025-2028.

  • short_code (str) –

    The two-digit start year used inside DMS download paths, e.g. 25.

code property

code: str

The DMS code for this period, e.g. T25.

label property

label: str

The human readable period, e.g. 2025-2028.

short_code property

short_code: str

The two-digit start year used inside DMS download paths, e.g. 25.

all classmethod

all() -> list[StudyPeriod]

Return every study period the ITU-T knows, oldest first.

Source code in src/itu_t_documents/models/study_periods.py
57
58
59
60
@classmethod
def all(cls) -> list[StudyPeriod]:
    """Return every study period the ITU-T knows, oldest first."""
    return [cls(start_year=start, end_year=end) for start, end in STUDY_PERIODS]

containing classmethod

containing(year: int) -> StudyPeriod

Return the study period the given year falls into.

Parameters:

  • year

    (int) –

    The year, e.g. 2026.

Returns:

Raises:

  • ValueError –

    When no study period covers the given year.

Source code in src/itu_t_documents/models/study_periods.py
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
@classmethod
def containing(cls, year: int) -> StudyPeriod:
    """Return the study period the given year falls into.

    Args:
        year: The year, e.g. 2026.

    Returns:
        The study period, e.g. ``2025-2028``.

    Raises:
        ValueError: When no study period covers the given year.
    """
    for start, end in STUDY_PERIODS:
        if start <= year <= end:
            return cls(start_year=start, end_year=end)
    known = ", ".join(f"{start}-{end}" for start, end in STUDY_PERIODS)
    raise ValueError(f"the year {year} falls into no ITU-T study period; the known periods are {known}")

current classmethod

current() -> StudyPeriod

Return the study period of the current year.

Source code in src/itu_t_documents/models/study_periods.py
101
102
103
104
@classmethod
def current(cls) -> StudyPeriod:
    """Return the study period of the current year."""
    return cls.containing(date.today().year)

from_year classmethod

from_year(year: int) -> StudyPeriod

Return the study period that starts in the given year.

Parameters:

  • year

    (int) –

    The first year of the period, e.g. 2025.

Returns:

Raises:

  • ValueError –

    When the ITU-T has no study period that starts in the given year.

Source code in src/itu_t_documents/models/study_periods.py
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
@classmethod
def from_year(cls, year: int) -> StudyPeriod:
    """Return the study period that starts in the given year.

    Args:
        year: The first year of the period, e.g. 2025.

    Returns:
        The study period, e.g. ``2025-2028``.

    Raises:
        ValueError: When the ITU-T has no study period that starts in the
            given year.
    """
    for start, end in STUDY_PERIODS:
        if start == year:
            return cls(start_year=start, end_year=end)
    known = ", ".join(str(start) for start, _ in STUDY_PERIODS)
    raise ValueError(f"the ITU-T has no study period starting in {year}; the periods start in {known}")

parse classmethod

parse(value: str) -> StudyPeriod

Parse "2025-2028", "T25" or the start year "2025".

Source code in src/itu_t_documents/models/study_periods.py
106
107
108
109
110
111
112
113
114
115
116
117
@classmethod
def parse(cls, value: str) -> StudyPeriod:
    """Parse ``"2025-2028"``, ``"T25"`` or the start year ``"2025"``."""
    text = value.strip()
    if text.upper().startswith("T") and text[1:].isdigit():
        return cls.from_year(2000 + int(text[1:]) if int(text[1:]) < 90 else 1900 + int(text[1:]))
    if text.isdigit():
        return cls.from_year(int(text))
    start_text, _, end_text = text.partition("-")
    if not end_text:
        raise ValueError(f"cannot parse study period from {value!r}")
    return cls(start_year=int(start_text), end_year=int(end_text))

UnknownEntityError

Bases: ItuError

Raised when an entity of the ITU-T structure does not exist.

The study groups of a study period, the working groups of a study group and the questions under study are published by the ITU-T and change from period to period. The catalogue knows them and refuses the ones that do not exist.

WorkingGroup

Bases: BaseModel

A working group of a study group, or the plenary itself.

Methods:

  • parse –

    Parse a working group code such as WP1/12.

Attributes:

  • is_plenary (bool) –

    Whether this working group is the plenary of the study group.

is_plenary property

is_plenary: bool

Whether this working group is the plenary of the study group.

parse classmethod

parse(code: str) -> WorkingGroup

Parse a working group code such as WP1/12.

Source code in src/itu_t_documents/models/questions.py
28
29
30
31
32
33
34
35
36
@classmethod
def parse(cls, code: str) -> WorkingGroup:
    """Parse a working group code such as ``WP1/12``."""
    text = code.strip()
    name: str | None = None
    if "/" in text:
        group, _, number = text.partition("/")
        name = f"{group.upper()} {number}"
    return cls(code=text.upper(), name=name)