Skip to content

Commit a5531d0

Browse files
committed
Fix capitalization function calls.
1 parent 3135e24 commit a5531d0

2 files changed

Lines changed: 22 additions & 27 deletions

File tree

scriptshifter/hooks/hebrew/dicta_api.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from requests import post
44

55
from scriptshifter.exceptions import BREAK, UpstreamError
6-
from scriptshifter.tools import capitalize
6+
from scriptshifter.hooks.general import capitalize_post_assembly
77

88
EP = environ.get("TXL_DICTA_EP")
99
DEFAULT_GENRE = "rabbinic"
@@ -25,16 +25,8 @@ def s2r_post_config(ctx):
2525
except Exception:
2626
raise UpstreamError("Error received from Dicta service.")
2727

28-
rom = rsp.json().get("transliteration")
29-
30-
if rom:
31-
if ctx.options["capitalize"] == "all":
32-
rom = capitalize(rom)
33-
elif ctx.options["capitalize"] == "first":
34-
rom = rom[0].upper() + rom[1:]
35-
else:
36-
ctx.warnings.append("Upstream service returned empty result.")
37-
38-
ctx.dest = rom
28+
ctx.dest = rsp.json().get("transliteration")
29+
if ctx.dest:
30+
ctx.dest = capitalize_post_assembly(ctx)
3931

4032
return BREAK

scriptshifter/hooks/korean/romanizer.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from scriptshifter.exceptions import BREAK
3030
from scriptshifter.hooks.korean import KCONF
31-
from scriptshifter.tools import capitalize
31+
from scriptshifter.hooks.general import capitalize_post_assembly
3232

3333

3434
PWD = path.dirname(path.realpath(__file__))
@@ -62,6 +62,12 @@ def s2r_nonames_post_config(ctx):
6262
ctx.dest, ctx.warnings = _romanize_nonames(
6363
ctx.src, ctx.options)
6464

65+
if ctx.dest:
66+
# FKR042: Capitalize all first letters
67+
# FKR043: Capitalize the first letter
68+
logger.debug(f"Before capitalization: {ctx.dest}")
69+
ctx.dest = capitalize_post_assembly(ctx)
70+
6571
return BREAK
6672

6773

@@ -74,6 +80,12 @@ def s2r_names_post_config(ctx):
7480
"""
7581
ctx.dest, ctx.warnings = _romanize_names(ctx.src, ctx.options)
7682

83+
if ctx.dest:
84+
# FKR042: Capitalize all first letters
85+
# FKR043: Capitalize the first letter
86+
logger.debug(f"Before capitalization: {ctx.dest}")
87+
ctx.dest = capitalize_post_assembly(ctx)
88+
7789
return BREAK
7890

7991

@@ -105,19 +117,9 @@ def _romanize_nonames(src, options):
105117

106118
rom = _romanize_oclc_auto(kor)
107119

108-
logger.debug(f"Before capitalization: {rom}")
109-
# FKR042: Capitalize all first letters
110-
if options["capitalize"] == "all":
111-
rom = capitalize(rom)
112-
# FKR043: Capitalize the first letter
113-
elif options["capitalize"] == "first":
114-
rom = rom[0].upper() + rom[1:]
115-
116120
# FKR044: Ambiguities
117121
ambi = re.sub("[,.\";: ]+", " ", rom)
118122

119-
# TODO Decide what to do with these. There is no facility for outputting
120-
# warnings or notes to the user yet.
121123
warnings = []
122124
_fkr_log(45)
123125
for exp, warn in KCONF["fkr045"].items():
@@ -308,10 +310,11 @@ def _kor_corp_name_rom(src):
308310
src = src[:-4]
309311
yu = "R"
310312

311-
rom_tok = []
312-
for tok in src.split(" "):
313-
rom_tok.append(_romanize_oclc_auto(tok))
314-
rom = capitalize(" ".join(rom_tok))
313+
rom_tok = [
314+
_romanize_oclc_auto(tok)
315+
for tok in src.split(" ")
316+
]
317+
rom = " ".join(rom_tok)
315318

316319
if chu == "L":
317320
rom = "(Chu) " + rom

0 commit comments

Comments
 (0)