philoch-bib-sdk 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl
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/adapters/tabular_data/read_journal_volume_number_index.py +19 -9
- philoch_bib_sdk/converters/plaintext/bibitem/bibkey_parser.py +14 -0
- philoch_bib_sdk/logic/functions/journal_article_matcher.py +5 -3
- {philoch_bib_sdk-0.1.4.dist-info → philoch_bib_sdk-0.1.5.dist-info}/METADATA +1 -1
- {philoch_bib_sdk-0.1.4.dist-info → philoch_bib_sdk-0.1.5.dist-info}/RECORD +8 -8
- {philoch_bib_sdk-0.1.4.dist-info → philoch_bib_sdk-0.1.5.dist-info}/LICENSE +0 -0
- {philoch_bib_sdk-0.1.4.dist-info → philoch_bib_sdk-0.1.5.dist-info}/WHEEL +0 -0
- {philoch_bib_sdk-0.1.4.dist-info → philoch_bib_sdk-0.1.5.dist-info}/entry_points.txt +0 -0
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
from functools import partial
|
|
2
2
|
from typing import Callable, NamedTuple
|
|
3
3
|
|
|
4
|
+
from philoch_bib_sdk.converters.plaintext.bibitem.bibkey_parser import hard_parse_bibkey, parse_bibkey
|
|
4
5
|
from philoch_bib_sdk.logic.functions.journal_article_matcher import (
|
|
5
|
-
TBibkey,
|
|
6
6
|
TJournalBibkeyIndex,
|
|
7
|
-
TJournalName,
|
|
8
|
-
TNumber,
|
|
9
7
|
TReadIndex,
|
|
10
|
-
TVolume,
|
|
11
8
|
)
|
|
12
9
|
|
|
10
|
+
from aletk.ResultMonad import Err
|
|
11
|
+
|
|
13
12
|
|
|
14
13
|
class ColumnNames(NamedTuple):
|
|
15
|
-
bibkey:
|
|
16
|
-
journal:
|
|
17
|
-
volume:
|
|
18
|
-
number:
|
|
14
|
+
bibkey: str
|
|
15
|
+
journal: str
|
|
16
|
+
volume: str
|
|
17
|
+
number: str
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
def _read_from_ods(
|
|
@@ -49,8 +48,19 @@ def _read_from_ods(
|
|
|
49
48
|
f"Tabular data at '{file_path}' is empty or does not contain the expected columns: {column_names}"
|
|
50
49
|
)
|
|
51
50
|
|
|
51
|
+
bibkeys_parsed = (parse_bibkey(str(row[column_names.bibkey])) for row in df.to_dicts())
|
|
52
|
+
|
|
53
|
+
bibkey_errors = [bibkey for bibkey in bibkeys_parsed if isinstance(bibkey, Err)]
|
|
54
|
+
|
|
55
|
+
if bibkey_errors != []:
|
|
56
|
+
raise ValueError(
|
|
57
|
+
f"Failed to parse bibkeys in the ODS file at '{file_path}': {' --- '.join(str(bibkey_errors))}"
|
|
58
|
+
)
|
|
59
|
+
|
|
52
60
|
return {
|
|
53
|
-
(row[column_names.journal], row[column_names.volume], row[column_names.number]):
|
|
61
|
+
(row[column_names.journal], row[column_names.volume], row[column_names.number]): hard_parse_bibkey(
|
|
62
|
+
row[column_names.bibkey]
|
|
63
|
+
)
|
|
54
64
|
for row in df.to_dicts()
|
|
55
65
|
}
|
|
56
66
|
|
|
@@ -142,3 +142,17 @@ def parse_bibkey(text: str) -> Ok[BibKeyAttr] | Err:
|
|
|
142
142
|
error_type="BibkeyError",
|
|
143
143
|
error_trace=f"{traceback.format_exc()}",
|
|
144
144
|
)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def hard_parse_bibkey(text: str) -> BibKeyAttr:
|
|
148
|
+
"""
|
|
149
|
+
Hard parse a bibkey, without any error handling.
|
|
150
|
+
This is used for testing purposes only.
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
bibkey_parsed = parse_bibkey(text)
|
|
154
|
+
|
|
155
|
+
if isinstance(bibkey_parsed, Err):
|
|
156
|
+
raise ValueError(f"Could not hard parse '{text}' as bibkey: {bibkey_parsed.message}")
|
|
157
|
+
|
|
158
|
+
return bibkey_parsed.out
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import Callable, Dict, Tuple
|
|
2
2
|
from philoch_bib_sdk.converters.plaintext.journal.formatter import format_journal
|
|
3
|
-
from philoch_bib_sdk.logic.models import BibItem
|
|
3
|
+
from philoch_bib_sdk.logic.models import BibItem, BibKeyAttr
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
type TJournalName = str
|
|
@@ -12,10 +12,12 @@ type TNumber = str
|
|
|
12
12
|
type TBibkey = str
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
type TJournalBibkeyIndex = Dict[
|
|
15
|
+
type TJournalBibkeyIndex = Dict[
|
|
16
|
+
Tuple[TJournalName, TVolume, TNumber], BibKeyAttr
|
|
17
|
+
] # (journal, volume, number) # bibkey
|
|
16
18
|
|
|
17
19
|
|
|
18
|
-
def get_bibkey_by_journal_volume_number(index: TJournalBibkeyIndex, subject: BibItem) ->
|
|
20
|
+
def get_bibkey_by_journal_volume_number(index: TJournalBibkeyIndex, subject: BibItem) -> BibKeyAttr:
|
|
19
21
|
"""
|
|
20
22
|
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
23
|
"""
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
philoch_bib_sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
philoch_bib_sdk/adapters/tabular_data/read_journal_volume_number_index.py,sha256=
|
|
2
|
+
philoch_bib_sdk/adapters/tabular_data/read_journal_volume_number_index.py,sha256=6ocGGl9nZXqyHkPxJp5GH1NIfb-BUMTYqr84QwZOPd8,2210
|
|
3
3
|
philoch_bib_sdk/converters/latex.py,sha256=LuAKLrClECuBeaDQYJc7tIJECEV4h0kt0VE_ssv3s0o,236
|
|
4
4
|
philoch_bib_sdk/converters/plaintext/author/formatter.py,sha256=hsqKUyNhIZeqisnEQU43DokAfEfG78rgQ8POTjYnToM,965
|
|
5
5
|
philoch_bib_sdk/converters/plaintext/author/parser.py,sha256=LL12mtgN59eJCv551c6s7YfMTjfJAJqm-jRQkdntmIg,2514
|
|
6
6
|
philoch_bib_sdk/converters/plaintext/bib_string_formatter.py,sha256=5Z97u5GryHUgZcPhWE41thgWCB4wYu22pZ9et6nakmw,329
|
|
7
7
|
philoch_bib_sdk/converters/plaintext/bibitem/bibkey_formatter.py,sha256=YivsY0gblKJdC4yKYZ3tvWmKIvFXW4iNht9zhz8oFUs,565
|
|
8
|
-
philoch_bib_sdk/converters/plaintext/bibitem/bibkey_parser.py,sha256=
|
|
8
|
+
philoch_bib_sdk/converters/plaintext/bibitem/bibkey_parser.py,sha256=TKHFQ9QeZ2Jgm3sFCjTqz_PDfous0amvz3DB0AJA51E,4991
|
|
9
9
|
philoch_bib_sdk/converters/plaintext/bibitem/date_formatter.py,sha256=G2mbaJidDg8avKBbro1rVcEznPC92XVTDQ4fSdmvhJo,1480
|
|
10
10
|
philoch_bib_sdk/converters/plaintext/bibitem/date_parser.py,sha256=3ZYGhhGqILzrvnwOvG4NPAjErLwVva0dfsN0B9eFomg,2242
|
|
11
11
|
philoch_bib_sdk/converters/plaintext/bibitem/formatter.py,sha256=EjSwHYAPn0YRjeLGK_rCi26Wtug6X5x5DFEKPjStn30,6298
|
|
@@ -17,12 +17,12 @@ philoch_bib_sdk/converters/plaintext/journal/parser.py,sha256=kT1YHwc9Am82WHRhaS
|
|
|
17
17
|
philoch_bib_sdk/converters/plaintext/shared/renderable_formatter.py,sha256=oS5u8RJpkRXaDTmauVqZi-uuXsyG-UQZMK2pgzSk-qo,686
|
|
18
18
|
philoch_bib_sdk/logic/default_models.py,sha256=cHHKSFmNR29qBxQkPwelQ09sx66isHlAIr1PiIHAvH4,10467
|
|
19
19
|
philoch_bib_sdk/logic/functions/comparator.py,sha256=4G5EUEVf8v6URt1v1Fqk1pjqni6fxUs_Goh4EQ4RBJY,4034
|
|
20
|
-
philoch_bib_sdk/logic/functions/journal_article_matcher.py,sha256=
|
|
20
|
+
philoch_bib_sdk/logic/functions/journal_article_matcher.py,sha256=IcnTv07Gk68M1LGB0Y9Z2DZsLYsWRzJCeL_c1r29bqg,1219
|
|
21
21
|
philoch_bib_sdk/logic/literals.py,sha256=_9poyFdSqbMWNg686xaexvkZTIrpCbQqPNTCVi0PlFc,1573
|
|
22
22
|
philoch_bib_sdk/logic/models.py,sha256=xHCQWFq_rEcX967icALD4oOQjM8AlLKLzXQ8SP-YNis,8681
|
|
23
23
|
philoch_bib_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
-
philoch_bib_sdk-0.1.
|
|
25
|
-
philoch_bib_sdk-0.1.
|
|
26
|
-
philoch_bib_sdk-0.1.
|
|
27
|
-
philoch_bib_sdk-0.1.
|
|
28
|
-
philoch_bib_sdk-0.1.
|
|
24
|
+
philoch_bib_sdk-0.1.5.dist-info/LICENSE,sha256=nplGobji9gkYmJxDBbBz2SKjZY27SUaqhqKkpUB-C30,1070
|
|
25
|
+
philoch_bib_sdk-0.1.5.dist-info/METADATA,sha256=wGBNDCmurQsZbrDFiO9PrTHUfp0B3dLeLOLre7Io6Ns,816
|
|
26
|
+
philoch_bib_sdk-0.1.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
27
|
+
philoch_bib_sdk-0.1.5.dist-info/entry_points.txt,sha256=5PDcoKK00cdaL0CabioRUz08ZJeXLa94Ca-C0umGPTU,46
|
|
28
|
+
philoch_bib_sdk-0.1.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|