Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 08-10-2023, 01:16 PM   #1
MerlinMama
Evangelist
MerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beauty
 
MerlinMama's Avatar
 
Posts: 487
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Libra Colour
Error in built-in RegEx function

I was looking to create a RegEx function and wanted to see how one of the others was set up, so I opened one (clicked the 'Create/Edit' button on Lower-Case Text)

Without changing anything, as I just wanted to see how it was set up, I clicked 'OK' and I got the following error message:

Spoiler:
calibre, version 6.24.0
ERROR: Invalid Python code: The code you created is not valid Python code, with error: cannot import name 'change_case' from 'calibre.utils.icu' (C:\Program Files\Calibre2\app\bin\python-lib.bypy.frozen\calibre\utils\icu.pyc)


I realize that perhaps while I was checking this out I might have inadvertently changed something, I wasn't really paying attention, so I checked 'Upper-case text'. This time I definitely touched only the 'OK' button and got the same error message.

I checked 'Title-case text', and this one does NOT give me the error message.

Here is what is in the Function:

Spoiler:
Code:
from calibre.utils.icu import change_case
from calibre.ebooks.oeb.polish.utils import apply_func_to_match_groups

def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    '''Make matched text lower case. If the regular expression contains groups,
    only the text in the groups will be changed, otherwise the entire text is
    changed.'''
    return apply_func_to_match_groups(match, lower)
MerlinMama is offline   Reply With Quote
Old 08-10-2023, 10:11 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,994
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://github.com/kovidgoyal/calibr...12936f7a6cd1c7
kovidgoyal is offline   Reply With Quote
Advert
Old 08-10-2023, 10:15 PM   #3
MerlinMama
Evangelist
MerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beauty
 
MerlinMama's Avatar
 
Posts: 487
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Libra Colour
Ok. Thank you. I was almost convinced I did something, even though I was also sure I didn't
MerlinMama is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with S&R RegEx Function MerlinMama Editor 5 05-29-2022 02:23 AM
Help creating possible Regex-Function MerlinMama Editor 14 03-03-2020 05:53 AM
Predefined regex for Regex-function sherman Editor 3 01-19-2020 05:32 AM
regex function replacement The_book Sigil 5 12-09-2019 09:45 AM
Regex Function about «» and “” senhal Editor 8 04-06-2016 02:12 AM


All times are GMT -4. The time now is 12:58 AM.


MobileRead.com is a privately owned, operated and funded community.