mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Dont import regex on calibre startup, since importing it seems to fail for unknown reasons on some linux installs
This commit is contained in:
parent
554cdeb746
commit
c572d2436e
@ -9,15 +9,15 @@ from collections import OrderedDict
|
||||
import operator
|
||||
|
||||
from cssutils.css import Property, CSSRule
|
||||
import regex
|
||||
|
||||
from calibre import force_unicode
|
||||
from calibre.ebooks import parse_css_length
|
||||
from calibre.ebooks.oeb.normalize_css import normalizers, safe_parser
|
||||
|
||||
REGEX_FLAGS = regex.VERSION1 | regex.UNICODE | regex.IGNORECASE
|
||||
|
||||
def compile_pat(pat):
|
||||
import regex
|
||||
REGEX_FLAGS = regex.VERSION1 | regex.UNICODE | regex.IGNORECASE
|
||||
return regex.compile(pat, flags=REGEX_FLAGS)
|
||||
|
||||
def all_properties(decl):
|
||||
@ -327,6 +327,7 @@ def export_rules(serialized_rules):
|
||||
return '\n'.join(lines).encode('utf-8')
|
||||
|
||||
def import_rules(raw_data):
|
||||
import regex
|
||||
pat = regex.compile('\s*(\S+)\s*:\s*(.+)', flags=regex.VERSION1)
|
||||
current_rule = {}
|
||||
|
||||
|
@ -4,13 +4,11 @@
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import,
|
||||
print_function)
|
||||
import regex
|
||||
from collections import deque
|
||||
|
||||
REGEX_FLAGS = regex.VERSION1 | regex.WORD | regex.FULLCASE | regex.IGNORECASE | regex.UNICODE
|
||||
|
||||
|
||||
def compile_pat(pat):
|
||||
import regex
|
||||
REGEX_FLAGS = regex.VERSION1 | regex.WORD | regex.FULLCASE | regex.IGNORECASE | regex.UNICODE
|
||||
return regex.compile(pat, flags=REGEX_FLAGS)
|
||||
|
||||
def matcher(rule):
|
||||
@ -57,7 +55,7 @@ def apply_rules(tag, rules):
|
||||
break
|
||||
if ac == 'replace':
|
||||
if 'matches' in rule['match_type']:
|
||||
tag = regex.sub(rule['query'], rule['replace'], tag, flags=REGEX_FLAGS)
|
||||
tag = compile_pat(rule['query']).sub(rule['replace'], tag)
|
||||
else:
|
||||
tag = rule['replace']
|
||||
if ',' in tag:
|
||||
|
Loading…
x
Reference in New Issue
Block a user