View Single Post
Old 09-09-2022, 06:36 PM   #4
un_pogaz
Chalut o/
un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.
 
un_pogaz's Avatar
 
Posts: 443
Karma: 672378
Join Date: Dec 2017
Device: Kobo
Meh, too bad, but predictable.
For information, here is my code for the strcase function (more consistent with Calibre standards)

strcase(x, y, lt, eq, gt)
Code:
def evaluate(self, formatter, kwargs, mi, locals, x, y, lt, eq, gt):
    from calibre.utils.icu import case_sensitive_strcmp as strcmp
    v = strcmp(x, y)
    if v < 0:
        return lt
    if v == 0:
        return eq
    return gt
Quote:
strcase(x, y, lt, eq, gt) -- does a case-sensitive comparison of x and y as strings. Returns lt if x < y. Returns eq if x == y. Otherwise returns gt.
Note, I'm thinking if I commit this to Calibre. Literals operator are unnecessary for a such marginal case, but providing a build-in function would be useful, so you don't have to look up how to do it if you ever need it.

Last edited by un_pogaz; 09-09-2022 at 06:49 PM.
un_pogaz is offline   Reply With Quote