philoch-bib-sdk 0.1.3__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/PKG-INFO +2 -1
- philoch_bib_sdk-0.1.4/philoch_bib_sdk/adapters/tabular_data/read_journal_volume_number_index.py +59 -0
- philoch_bib_sdk-0.1.4/philoch_bib_sdk/logic/default_models.py +315 -0
- philoch_bib_sdk-0.1.4/philoch_bib_sdk/logic/functions/journal_article_matcher.py +40 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/pyproject.toml +5 -1
- philoch_bib_sdk-0.1.3/philoch_bib_sdk/logic/default_models.py +0 -120
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/LICENSE +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/README.md +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/__init__.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/latex.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/author/formatter.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/author/parser.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/bib_string_formatter.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/bibitem/bibkey_formatter.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/bibitem/bibkey_parser.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/bibitem/date_formatter.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/bibitem/date_parser.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/bibitem/formatter.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/bibitem/pages_formatter.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/bibitem/pages_parser.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/bibitem/parser.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/journal/formatter.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/journal/parser.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/converters/plaintext/shared/renderable_formatter.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/logic/functions/comparator.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/logic/literals.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/logic/models.py +0 -0
- {philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: philoch-bib-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Standard development kit for the Philosophie Bibliography project
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Luis Alejandro Bordo García
|
|
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
14
|
Requires-Dist: aletk (>=0.1.6,<0.2.0)
|
|
15
15
|
Requires-Dist: attrs (>=25.3.0,<26.0.0)
|
|
16
|
+
Requires-Dist: polars (>=1.32.3,<2.0.0)
|
|
16
17
|
Description-Content-Type: text/markdown
|
|
17
18
|
|
|
18
19
|
# Philosophie.ch Bibliography SDK
|
philoch_bib_sdk-0.1.4/philoch_bib_sdk/adapters/tabular_data/read_journal_volume_number_index.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from functools import partial
|
|
2
|
+
from typing import Callable, NamedTuple
|
|
3
|
+
|
|
4
|
+
from philoch_bib_sdk.logic.functions.journal_article_matcher import (
|
|
5
|
+
TBibkey,
|
|
6
|
+
TJournalBibkeyIndex,
|
|
7
|
+
TJournalName,
|
|
8
|
+
TNumber,
|
|
9
|
+
TReadIndex,
|
|
10
|
+
TVolume,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ColumnNames(NamedTuple):
|
|
15
|
+
bibkey: TBibkey
|
|
16
|
+
journal: TJournalName
|
|
17
|
+
volume: TVolume
|
|
18
|
+
number: TNumber
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _read_from_ods(
|
|
22
|
+
column_names: ColumnNames,
|
|
23
|
+
file_path: str,
|
|
24
|
+
) -> TJournalBibkeyIndex:
|
|
25
|
+
"""
|
|
26
|
+
Reads the specified columns from an ODS file and returns a TJournalBibkeyIndex dictionary.
|
|
27
|
+
Args:
|
|
28
|
+
column_names (ColumnNames): The names of the columns to read (journal, volume, number, bibkey).
|
|
29
|
+
file_path (str): The path to the ODS file.
|
|
30
|
+
Returns:
|
|
31
|
+
TJournalBibkeyIndex: A dictionary mapping (journal, volume, number) tuples to bibkey values.
|
|
32
|
+
"""
|
|
33
|
+
import polars as pl
|
|
34
|
+
|
|
35
|
+
df = pl.read_ods(
|
|
36
|
+
source=file_path,
|
|
37
|
+
has_header=True,
|
|
38
|
+
columns=[column_names.journal, column_names.volume, column_names.number, column_names.bibkey],
|
|
39
|
+
schema_overrides={
|
|
40
|
+
column_names.journal: pl.Utf8,
|
|
41
|
+
column_names.volume: pl.Utf8,
|
|
42
|
+
column_names.number: pl.Utf8,
|
|
43
|
+
column_names.bibkey: pl.Utf8,
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
if df.is_empty():
|
|
48
|
+
raise ValueError(
|
|
49
|
+
f"Tabular data at '{file_path}' is empty or does not contain the expected columns: {column_names}"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
(row[column_names.journal], row[column_names.volume], row[column_names.number]): row[column_names.bibkey]
|
|
54
|
+
for row in df.to_dicts()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
type THOFReadFromOds = Callable[[ColumnNames], TReadIndex]
|
|
59
|
+
hof_read_from_ods: THOFReadFromOds = lambda column_names: partial(_read_from_ods, column_names)
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
from typing import Tuple, TypedDict, Unpack, Literal
|
|
2
|
+
from philoch_bib_sdk.logic.models import BibItem, PageAttr, KeywordsAttr, BibItemDateAttr, BibKeyAttr, Keyword
|
|
3
|
+
|
|
4
|
+
from philoch_bib_sdk.logic.literals import TBasicPubState, TBibTeXEntryType, TEpoch, TLanguageID, TPubState
|
|
5
|
+
from philoch_bib_sdk.logic.models import (
|
|
6
|
+
Author,
|
|
7
|
+
BaseNamedRenderable,
|
|
8
|
+
BaseRenderable,
|
|
9
|
+
BibItem,
|
|
10
|
+
BibStringAttr,
|
|
11
|
+
Journal,
|
|
12
|
+
Keyword,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class BibStringArgs(TypedDict, total=False):
|
|
17
|
+
latex: str
|
|
18
|
+
unicode: str
|
|
19
|
+
simplified: str
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def default_bib_string(**kwargs: Unpack[BibStringArgs]) -> BibStringAttr:
|
|
23
|
+
"""
|
|
24
|
+
Create a default BibString object, given a dictionary with any (or None) of its attributes. Defaults to empty strings if not provided.
|
|
25
|
+
"""
|
|
26
|
+
return BibStringAttr(
|
|
27
|
+
latex=kwargs.get("latex", ""),
|
|
28
|
+
unicode=kwargs.get("unicode", ""),
|
|
29
|
+
simplified=kwargs.get("simplified", ""),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
############
|
|
34
|
+
# Base Renderables
|
|
35
|
+
############
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class BaseRenderableArgs(TypedDict, total=False):
|
|
39
|
+
text: BibStringArgs
|
|
40
|
+
id: int | None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def default_base_renderable(**kwargs: Unpack[BaseRenderableArgs]) -> BaseRenderable:
|
|
44
|
+
"""
|
|
45
|
+
Create a default BaseRenderable object, given a dictionary with any (or None) of its attributes. Defaults to empty strings if not provided.
|
|
46
|
+
"""
|
|
47
|
+
return BaseRenderable(
|
|
48
|
+
text=default_bib_string(**kwargs.get("text", {})),
|
|
49
|
+
id=kwargs.get("id", None),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class BaseNamedRenderableArgs(TypedDict, total=False):
|
|
54
|
+
name: BibStringArgs
|
|
55
|
+
id: int | None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def default_base_named_renderable(**kwargs: Unpack[BaseNamedRenderableArgs]) -> BaseNamedRenderable:
|
|
59
|
+
"""
|
|
60
|
+
Create a default BaseNamedRenderable object, given a dictionary with any (or None) of its attributes. Defaults to empty strings if not provided.
|
|
61
|
+
"""
|
|
62
|
+
return BaseNamedRenderable(
|
|
63
|
+
name=default_bib_string(**kwargs.get("name", {})),
|
|
64
|
+
id=kwargs.get("id", None),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
############
|
|
69
|
+
# Author
|
|
70
|
+
############
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class AuthorArgs(TypedDict, total=False):
|
|
74
|
+
given_name: BibStringArgs
|
|
75
|
+
family_name: BibStringArgs
|
|
76
|
+
mononym: BibStringArgs
|
|
77
|
+
shorthand: BibStringArgs
|
|
78
|
+
famous_name: BibStringArgs
|
|
79
|
+
publications: Tuple[BibItem, ...]
|
|
80
|
+
id: int | None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def default_author(**kwargs: Unpack[AuthorArgs]) -> Author:
|
|
84
|
+
"""
|
|
85
|
+
Create a default Author object, given a dictionary with any (or None) of its attributes. Defaults to empty strings and an empty tuple for publications if not provided.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
return Author(
|
|
89
|
+
given_name=default_bib_string(**kwargs.get("given_name", {})),
|
|
90
|
+
family_name=default_bib_string(**kwargs.get("family_name", {})),
|
|
91
|
+
mononym=default_bib_string(**kwargs.get("mononym", {})),
|
|
92
|
+
shorthand=default_bib_string(**kwargs.get("shorthand", {})),
|
|
93
|
+
famous_name=default_bib_string(**kwargs.get("famous_name", {})),
|
|
94
|
+
publications=kwargs.get("publications", ()),
|
|
95
|
+
id=kwargs.get("id", None),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
############
|
|
100
|
+
# Journal
|
|
101
|
+
############
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class JournalArgs(TypedDict, total=False):
|
|
105
|
+
name: BibStringArgs
|
|
106
|
+
issn_print: str
|
|
107
|
+
issn_electronic: str
|
|
108
|
+
id: int | None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def default_journal(**kwargs: Unpack[JournalArgs]) -> Journal | None:
|
|
112
|
+
"""
|
|
113
|
+
Create a default Journal object, given a dictionary with any (or None) of its attributes. Defaults to empty strings if not provided.
|
|
114
|
+
"""
|
|
115
|
+
if kwargs == {}:
|
|
116
|
+
return None
|
|
117
|
+
|
|
118
|
+
return Journal(
|
|
119
|
+
name=default_bib_string(**kwargs.get("name", {})),
|
|
120
|
+
issn_print=kwargs.get("issn_print", ""),
|
|
121
|
+
issn_electronic=kwargs.get("issn_electronic", ""),
|
|
122
|
+
id=kwargs.get("id", None),
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
############
|
|
127
|
+
# Support Args
|
|
128
|
+
############
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class PageArgs(TypedDict, total=False):
|
|
132
|
+
start: str
|
|
133
|
+
end: str
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def default_page(**kwargs: Unpack[PageArgs]) -> PageAttr:
|
|
137
|
+
return PageAttr(
|
|
138
|
+
start=kwargs.get("start", ""),
|
|
139
|
+
end=kwargs.get("end", ""),
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class KeywordsArgs(TypedDict, total=False):
|
|
144
|
+
level_1: str
|
|
145
|
+
level_2: str
|
|
146
|
+
level_3: str
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def default_keywords(**kwargs: Unpack[KeywordsArgs]) -> KeywordsAttr:
|
|
150
|
+
return KeywordsAttr(
|
|
151
|
+
level_1=Keyword(name=kwargs.get("level_1", "")),
|
|
152
|
+
level_2=Keyword(name=kwargs.get("level_2", "")),
|
|
153
|
+
level_3=Keyword(name=kwargs.get("level_3", "")),
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class BibItemDateArgs(TypedDict, total=False):
|
|
158
|
+
year: int
|
|
159
|
+
year_part_2_hyphen: int | None
|
|
160
|
+
year_part_2_slash: int | None
|
|
161
|
+
month: int | None
|
|
162
|
+
day: int | None
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def default_bib_item_date(**kwargs: Unpack[BibItemDateArgs]) -> BibItemDateAttr:
|
|
166
|
+
return BibItemDateAttr(
|
|
167
|
+
year=kwargs.get("year", 0),
|
|
168
|
+
year_part_2_hyphen=kwargs.get("year_part_2_hyphen"),
|
|
169
|
+
year_part_2_slash=kwargs.get("year_part_2_slash"),
|
|
170
|
+
month=kwargs.get("month"),
|
|
171
|
+
day=kwargs.get("day"),
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def parse_date(date: BibItemDateArgs | Literal["no date"]) -> BibItemDateAttr | Literal["no date"]:
|
|
176
|
+
if isinstance(date, dict):
|
|
177
|
+
return default_bib_item_date(**date)
|
|
178
|
+
else:
|
|
179
|
+
return "no date"
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class BibKeyArgs(TypedDict, total=False):
|
|
183
|
+
first_author: str
|
|
184
|
+
other_authors: str
|
|
185
|
+
date: int | TBasicPubState
|
|
186
|
+
date_suffix: str
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def default_bib_key(**kwargs: Unpack[BibKeyArgs]) -> BibKeyAttr:
|
|
190
|
+
# Then pass to BibKeyAttr
|
|
191
|
+
return BibKeyAttr(
|
|
192
|
+
first_author=kwargs.get("first_author", ""),
|
|
193
|
+
other_authors=kwargs.get("other_authors", ""),
|
|
194
|
+
date=kwargs.get("date", ""),
|
|
195
|
+
date_suffix=kwargs.get("date_suffix", ""),
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
############
|
|
200
|
+
# BibItem Args
|
|
201
|
+
############
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class BibItemArgs(TypedDict, total=False):
|
|
205
|
+
_to_do_general: str
|
|
206
|
+
_change_request: str
|
|
207
|
+
entry_type: TBibTeXEntryType
|
|
208
|
+
bibkey: BibKeyArgs
|
|
209
|
+
author: Tuple[AuthorArgs, ...]
|
|
210
|
+
editor: Tuple[AuthorArgs, ...]
|
|
211
|
+
options: Tuple[str, ...]
|
|
212
|
+
date: BibItemDateArgs | Literal["no date"]
|
|
213
|
+
pubstate: TPubState
|
|
214
|
+
title: BibStringArgs
|
|
215
|
+
booktitle: BibStringArgs
|
|
216
|
+
# crossref: dict
|
|
217
|
+
journal: JournalArgs
|
|
218
|
+
volume: str
|
|
219
|
+
number: str
|
|
220
|
+
pages: Tuple[PageArgs, ...]
|
|
221
|
+
eid: str
|
|
222
|
+
series: BaseNamedRenderableArgs
|
|
223
|
+
address: BibStringArgs
|
|
224
|
+
institution: BibStringArgs
|
|
225
|
+
school: BibStringArgs
|
|
226
|
+
publisher: BibStringArgs
|
|
227
|
+
type: BibStringArgs
|
|
228
|
+
edition: int
|
|
229
|
+
note: BibStringArgs
|
|
230
|
+
issuetitle: BibStringArgs
|
|
231
|
+
_guesteditor: Tuple[AuthorArgs, ...]
|
|
232
|
+
_extra_note: BibStringArgs
|
|
233
|
+
urn: str
|
|
234
|
+
eprint: str
|
|
235
|
+
doi: str
|
|
236
|
+
url: str
|
|
237
|
+
_kws: KeywordsArgs
|
|
238
|
+
_epoch: TEpoch
|
|
239
|
+
_person: AuthorArgs
|
|
240
|
+
_comm_for_profile_bib: str
|
|
241
|
+
_langid: TLanguageID
|
|
242
|
+
_lang_der: str
|
|
243
|
+
_further_refs: Tuple[BibKeyArgs, ...]
|
|
244
|
+
_depends_on: Tuple[BibKeyArgs, ...]
|
|
245
|
+
_dltc_num: int
|
|
246
|
+
_spec_interest: str
|
|
247
|
+
_note_perso: str
|
|
248
|
+
_note_stock: str
|
|
249
|
+
_note_status: str
|
|
250
|
+
_num_inwork_coll: int
|
|
251
|
+
_num_inwork: str
|
|
252
|
+
_num_coll: int
|
|
253
|
+
_dltc_copyediting_note: str
|
|
254
|
+
_note_missing: str
|
|
255
|
+
_num_sort: int
|
|
256
|
+
id: int
|
|
257
|
+
_bib_info_source: str
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def default_bib_item(**kwargs: Unpack[BibItemArgs]) -> BibItem:
|
|
261
|
+
return BibItem(
|
|
262
|
+
to_do_general=kwargs.get("_to_do_general", ""),
|
|
263
|
+
change_request=kwargs.get("_change_request", ""),
|
|
264
|
+
entry_type=kwargs.get("entry_type", "UNKNOWN"),
|
|
265
|
+
bibkey=default_bib_key(**kwargs.get("bibkey", {})) if "bibkey" in kwargs else "",
|
|
266
|
+
author=tuple(default_author(**a) for a in kwargs.get("author", ())),
|
|
267
|
+
editor=tuple(default_author(**e) for e in kwargs.get("editor", ())),
|
|
268
|
+
options=kwargs.get("options", ()),
|
|
269
|
+
date=parse_date(kwargs.get("date", "no date")),
|
|
270
|
+
pubstate=kwargs.get("pubstate", ""),
|
|
271
|
+
title=default_bib_string(**kwargs.get("title", {})) if "title" in kwargs else "",
|
|
272
|
+
booktitle=default_bib_string(**kwargs.get("booktitle", {})) if "booktitle" in kwargs else "",
|
|
273
|
+
crossref="", # Crossref is not defined in the provided context, so we leave it as an empty string
|
|
274
|
+
journal=default_journal(**kwargs.get("journal", {})) if "journal" in kwargs else None,
|
|
275
|
+
volume=kwargs.get("volume", ""),
|
|
276
|
+
number=kwargs.get("number", ""),
|
|
277
|
+
pages=tuple(default_page(**p) for p in kwargs.get("pages", ())),
|
|
278
|
+
eid=kwargs.get("eid", ""),
|
|
279
|
+
series=default_base_named_renderable(**kwargs.get("series", {})) if "series" in kwargs else "",
|
|
280
|
+
address=default_bib_string(**kwargs.get("address", {})) if "address" in kwargs else "",
|
|
281
|
+
institution=default_bib_string(**kwargs.get("institution", {})) if "institution" in kwargs else "",
|
|
282
|
+
school=default_bib_string(**kwargs.get("school", {})) if "school" in kwargs else "",
|
|
283
|
+
publisher=default_bib_string(**kwargs.get("publisher", {})) if "publisher" in kwargs else "",
|
|
284
|
+
type=default_bib_string(**kwargs.get("type", {})) if "type" in kwargs else "",
|
|
285
|
+
edition=kwargs.get("edition"),
|
|
286
|
+
note=default_bib_string(**kwargs.get("note", {})) if "note" in kwargs else "",
|
|
287
|
+
issuetitle=default_bib_string(**kwargs.get("issuetitle", {})) if "issuetitle" in kwargs else "",
|
|
288
|
+
guesteditor=tuple(default_author(**a) for a in kwargs.get("_guesteditor", ())),
|
|
289
|
+
extra_note=default_bib_string(**kwargs.get("_extra_note", {})) if "_extra_note" in kwargs else "",
|
|
290
|
+
urn=kwargs.get("urn", ""),
|
|
291
|
+
eprint=kwargs.get("eprint", ""),
|
|
292
|
+
doi=kwargs.get("doi", ""),
|
|
293
|
+
url=kwargs.get("url", ""),
|
|
294
|
+
kws=default_keywords(**kwargs.get("_kws", {})) if "_kws" in kwargs else "",
|
|
295
|
+
epoch=kwargs.get("_epoch", ""),
|
|
296
|
+
person=default_author(**kwargs.get("_person", {})) if "_person" in kwargs else "",
|
|
297
|
+
comm_for_profile_bib=kwargs.get("_comm_for_profile_bib", ""),
|
|
298
|
+
langid=kwargs.get("_langid", ""),
|
|
299
|
+
lang_der=kwargs.get("_lang_der", ""),
|
|
300
|
+
further_refs=tuple(default_bib_key(**b) for b in kwargs.get("_further_refs", ())),
|
|
301
|
+
depends_on=tuple(default_bib_key(**b) for b in kwargs.get("_depends_on", ())),
|
|
302
|
+
dltc_num=kwargs.get("_dltc_num"),
|
|
303
|
+
spec_interest=kwargs.get("_spec_interest", ""),
|
|
304
|
+
note_perso=kwargs.get("_note_perso", ""),
|
|
305
|
+
note_stock=kwargs.get("_note_stock", ""),
|
|
306
|
+
note_status=kwargs.get("_note_status", ""),
|
|
307
|
+
num_inwork_coll=kwargs.get("_num_inwork_coll"),
|
|
308
|
+
num_inwork=kwargs.get("_num_inwork", ""),
|
|
309
|
+
num_coll=kwargs.get("_num_coll"),
|
|
310
|
+
dltc_copyediting_note=kwargs.get("_dltc_copyediting_note", ""),
|
|
311
|
+
note_missing=kwargs.get("_note_missing", ""),
|
|
312
|
+
num_sort=kwargs.get("_num_sort"),
|
|
313
|
+
id=kwargs.get("id"),
|
|
314
|
+
bib_info_source=kwargs.get("_bib_info_source", ""),
|
|
315
|
+
)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from typing import Callable, Dict, Tuple
|
|
2
|
+
from philoch_bib_sdk.converters.plaintext.journal.formatter import format_journal
|
|
3
|
+
from philoch_bib_sdk.logic.models import BibItem
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
type TJournalName = str
|
|
7
|
+
|
|
8
|
+
type TVolume = str
|
|
9
|
+
|
|
10
|
+
type TNumber = str
|
|
11
|
+
|
|
12
|
+
type TBibkey = str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
type TJournalBibkeyIndex = Dict[Tuple[TJournalName, TVolume, TNumber], TBibkey] # (journal, volume, number) # bibkey
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_bibkey_by_journal_volume_number(index: TJournalBibkeyIndex, subject: BibItem) -> TBibkey:
|
|
19
|
+
"""
|
|
20
|
+
Simple lookup of a Bibitem on an index for its bibkey, via the combination (journal_name, volume, number). Fails if any of the three fields are missing.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
journal = format_journal(subject.journal, bibstring_type="latex")
|
|
24
|
+
volume = subject.volume
|
|
25
|
+
number = subject.number
|
|
26
|
+
|
|
27
|
+
if any((journal == "", volume == "", number == "")):
|
|
28
|
+
raise ValueError(
|
|
29
|
+
f"Expected subject bibitem journal with non-empty journal, volume, and number. Found [[ journal: {journal}; volume: {volume}; number: {number} ]] instead."
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return index[(journal, volume, number)]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
type TReadIndex = Callable[
|
|
36
|
+
[
|
|
37
|
+
str, # path to the index file
|
|
38
|
+
],
|
|
39
|
+
TJournalBibkeyIndex,
|
|
40
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "philoch-bib-sdk"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.4"
|
|
4
4
|
description = "Standard development kit for the Philosophie Bibliography project"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Luis Alejandro Bordo García", email = "luis.bordo@philosophie.ch"}
|
|
@@ -19,6 +19,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
19
19
|
[tool.poetry.dependencies]
|
|
20
20
|
aletk = "^0.1.6"
|
|
21
21
|
attrs = "^25.3.0"
|
|
22
|
+
polars = "^1.32.3"
|
|
22
23
|
|
|
23
24
|
[tool.poetry.group.dev.dependencies]
|
|
24
25
|
pytest = "^8.3.5"
|
|
@@ -27,6 +28,8 @@ black = {extras = ["jupyter"], version = "^25.1.0"}
|
|
|
27
28
|
jupyter = "^1.1.1"
|
|
28
29
|
pytest-env = "^1.1.5"
|
|
29
30
|
autoflake = "^2.3.1"
|
|
31
|
+
odswriter = "^0.4.0"
|
|
32
|
+
fastexcel = "^0.14.0"
|
|
30
33
|
|
|
31
34
|
[tool.poetry.group.experimental.dependencies]
|
|
32
35
|
cytoolz = "^1.0.1"
|
|
@@ -52,6 +55,7 @@ env = [
|
|
|
52
55
|
[[tool.mypy.overrides]]
|
|
53
56
|
module = [
|
|
54
57
|
"cytoolz",
|
|
58
|
+
"odswriter",
|
|
55
59
|
]
|
|
56
60
|
ignore_missing_imports = true
|
|
57
61
|
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
from typing import Tuple, TypedDict, Unpack
|
|
2
|
-
|
|
3
|
-
from philoch_bib_sdk.logic.models import (
|
|
4
|
-
Author,
|
|
5
|
-
BaseNamedRenderable,
|
|
6
|
-
BaseRenderable,
|
|
7
|
-
BibItem,
|
|
8
|
-
BibStringAttr,
|
|
9
|
-
Journal,
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class BibStringArgs(TypedDict, total=False):
|
|
14
|
-
latex: str
|
|
15
|
-
unicode: str
|
|
16
|
-
simplified: str
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def default_bib_string(**kwargs: Unpack[BibStringArgs]) -> BibStringAttr:
|
|
20
|
-
"""
|
|
21
|
-
Create a default BibString object, given a dictionary with any (or None) of its attributes. Defaults to empty strings if not provided.
|
|
22
|
-
"""
|
|
23
|
-
return BibStringAttr(
|
|
24
|
-
latex=kwargs.get("latex", ""),
|
|
25
|
-
unicode=kwargs.get("unicode", ""),
|
|
26
|
-
simplified=kwargs.get("simplified", ""),
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
############
|
|
31
|
-
# Base Renderables
|
|
32
|
-
############
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class BaseRenderableArgs(TypedDict, total=False):
|
|
36
|
-
text: BibStringArgs
|
|
37
|
-
id: int | None
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def default_base_renderable(**kwargs: Unpack[BaseRenderableArgs]) -> BaseRenderable:
|
|
41
|
-
"""
|
|
42
|
-
Create a default BaseRenderable object, given a dictionary with any (or None) of its attributes. Defaults to empty strings if not provided.
|
|
43
|
-
"""
|
|
44
|
-
return BaseRenderable(
|
|
45
|
-
text=default_bib_string(**kwargs.get("text", {})),
|
|
46
|
-
id=kwargs.get("id", None),
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class BaseNamedRenderableArgs(TypedDict, total=False):
|
|
51
|
-
name: BibStringArgs
|
|
52
|
-
id: int | None
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def default_base_named_renderable(**kwargs: Unpack[BaseNamedRenderableArgs]) -> BaseNamedRenderable:
|
|
56
|
-
"""
|
|
57
|
-
Create a default BaseNamedRenderable object, given a dictionary with any (or None) of its attributes. Defaults to empty strings if not provided.
|
|
58
|
-
"""
|
|
59
|
-
return BaseNamedRenderable(
|
|
60
|
-
name=default_bib_string(**kwargs.get("name", {})),
|
|
61
|
-
id=kwargs.get("id", None),
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
############
|
|
66
|
-
# Author
|
|
67
|
-
############
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
class AuthorArgs(TypedDict, total=False):
|
|
71
|
-
given_name: BibStringArgs
|
|
72
|
-
family_name: BibStringArgs
|
|
73
|
-
mononym: BibStringArgs
|
|
74
|
-
shorthand: BibStringArgs
|
|
75
|
-
famous_name: BibStringArgs
|
|
76
|
-
publications: Tuple[BibItem, ...]
|
|
77
|
-
id: int | None
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def default_author(**kwargs: Unpack[AuthorArgs]) -> Author:
|
|
81
|
-
"""
|
|
82
|
-
Create a default Author object, given a dictionary with any (or None) of its attributes. Defaults to empty strings and an empty tuple for publications if not provided.
|
|
83
|
-
"""
|
|
84
|
-
|
|
85
|
-
return Author(
|
|
86
|
-
given_name=default_bib_string(**kwargs.get("given_name", {})),
|
|
87
|
-
family_name=default_bib_string(**kwargs.get("family_name", {})),
|
|
88
|
-
mononym=default_bib_string(**kwargs.get("mononym", {})),
|
|
89
|
-
shorthand=default_bib_string(**kwargs.get("shorthand", {})),
|
|
90
|
-
famous_name=default_bib_string(**kwargs.get("famous_name", {})),
|
|
91
|
-
publications=kwargs.get("publications", ()),
|
|
92
|
-
id=kwargs.get("id", None),
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
############
|
|
97
|
-
# Journal
|
|
98
|
-
############
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class JournalArgs(TypedDict, total=False):
|
|
102
|
-
name: BibStringArgs
|
|
103
|
-
issn_print: str
|
|
104
|
-
issn_electronic: str
|
|
105
|
-
id: int | None
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def default_journal(**kwargs: Unpack[JournalArgs]) -> Journal | None:
|
|
109
|
-
"""
|
|
110
|
-
Create a default Journal object, given a dictionary with any (or None) of its attributes. Defaults to empty strings if not provided.
|
|
111
|
-
"""
|
|
112
|
-
if kwargs == {}:
|
|
113
|
-
return None
|
|
114
|
-
|
|
115
|
-
return Journal(
|
|
116
|
-
name=default_bib_string(**kwargs.get("name", {})),
|
|
117
|
-
issn_print=kwargs.get("issn_print", ""),
|
|
118
|
-
issn_electronic=kwargs.get("issn_electronic", ""),
|
|
119
|
-
id=kwargs.get("id", None),
|
|
120
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{philoch_bib_sdk-0.1.3 → philoch_bib_sdk-0.1.4}/philoch_bib_sdk/logic/functions/comparator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|