Skip to content

Commit

Permalink
Edit book: Saved searches: Fix incorrect import in generated source c…
Browse files Browse the repository at this point in the history
…ode for some builtin functions
  • Loading branch information
kovidgoyal committed Aug 11, 2023
1 parent 3767147 commit 45d6c28
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/calibre/utils/icu.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def two_args(a, b):
return two_args


def make_change_case_func(which):
def make_change_case_func(which, name):

def change_case(x):
try:
Expand All @@ -201,6 +201,7 @@ def change_case(x):
return x
return _icu.change_case(x, which, _locale)
raise
change_case.__name__ = name
return change_case
# }}}

Expand All @@ -216,9 +217,9 @@ def change_case(x):
strcmp = make_two_arg_func(sort_collator)
case_sensitive_strcmp = make_two_arg_func(case_sensitive_collator)
primary_strcmp = make_two_arg_func(primary_collator)
upper = make_change_case_func(_icu.UPPER_CASE)
lower = make_change_case_func(_icu.LOWER_CASE)
title_case = make_change_case_func(_icu.TITLE_CASE)
upper = make_change_case_func(_icu.UPPER_CASE, 'upper')
lower = make_change_case_func(_icu.LOWER_CASE, 'lower')
title_case = make_change_case_func(_icu.TITLE_CASE, 'title_case')


def capitalize(x):
Expand All @@ -228,11 +229,7 @@ def capitalize(x):
return x


try:
swapcase = _icu.swap_case
except AttributeError: # For people running from source
def swapcase(x):
return x.swapcase()
swapcase = swap_case = _icu.swap_case

find = make_two_arg_func(collator, 'find')
primary_find = make_two_arg_func(primary_collator, 'find')
Expand Down

0 comments on commit 45d6c28

Please sign in to comment.