raw regexp
This commit is contained in:
parent
f8e48f54ca
commit
33a7832d64
1 changed files with 15 additions and 15 deletions
|
|
@ -80,13 +80,13 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
path = source_path + 'UI/svg/'
|
path = source_path + 'UI/svg/'
|
||||||
for filename in [filename for filename in os.listdir(path) if not filename[0] in '._']:
|
for filename in [filename for filename in os.listdir(path) if not filename[0] in '._']:
|
||||||
svg = read_text(path + filename)
|
svg = read_text(path + filename)
|
||||||
svg = re.sub('\n\s*', '', svg)
|
svg = re.sub(r'\n\s*', '', svg)
|
||||||
svg = re.sub('<!--.+?-->', '', svg)
|
svg = re.sub(r'<!--.+?-->', '', svg)
|
||||||
# end fix
|
# end fix
|
||||||
ui_images[filename[:-4]] = svg
|
ui_images[filename[:-4]] = svg
|
||||||
if filename.startswith('symbolLoading'):
|
if filename.startswith('symbolLoading'):
|
||||||
for theme in themes:
|
for theme in themes:
|
||||||
theme_svg = re.sub('#808080', format_hex(theme_data[theme]['symbolDefaultColor']), svg)
|
theme_svg = re.sub(r'#808080', format_hex(theme_data[theme]['symbolDefaultColor']), svg)
|
||||||
write_file('%sUI/themes/%s/svg/%s' % (dev_path, theme, filename), theme_svg)
|
write_file('%sUI/themes/%s/svg/%s' % (dev_path, theme, filename), theme_svg)
|
||||||
write_file('%sUI/themes/%s/svg/%s' % (min_path, theme, filename), theme_svg)
|
write_file('%sUI/themes/%s/svg/%s' % (min_path, theme, filename), theme_svg)
|
||||||
|
|
||||||
|
|
@ -101,10 +101,10 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
and (geo or '/Geo/' not in path):
|
and (geo or '/Geo/' not in path):
|
||||||
# write copies in min path
|
# write copies in min path
|
||||||
source = os.path.join(path, filename)
|
source = os.path.join(path, filename)
|
||||||
is_jquery = re.search('^jquery-[\d\.]+\.js$', filename)
|
is_jquery = re.search(r'^jquery-[\d\.]+\.js$', filename)
|
||||||
is_jquery_min = re.search('^jquery-[\d\.]+\.min\.js$', filename)
|
is_jquery_min = re.search(r'^jquery-[\d\.]+\.min\.js$', filename)
|
||||||
is_jquery_plugin = re.search('^jquery\..*?\.js$', filename)
|
is_jquery_plugin = re.search(r'^jquery\..*?\.js$', filename)
|
||||||
is_jsonc = re.search('\.jsonc$', filename)
|
is_jsonc = re.search(r'\.jsonc$', filename)
|
||||||
if is_jquery or is_jquery_min:
|
if is_jquery or is_jquery_min:
|
||||||
target = os.path.join(path.replace(source_path, min_path), 'jquery.js')
|
target = os.path.join(path.replace(source_path, min_path), 'jquery.js')
|
||||||
else:
|
else:
|
||||||
|
|
@ -113,7 +113,7 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
ui_files['dev'].append(target.replace(min_path, ''))
|
ui_files['dev'].append(target.replace(min_path, ''))
|
||||||
ui_files['min'].append(target.replace(min_path, ''))
|
ui_files['min'].append(target.replace(min_path, ''))
|
||||||
if '/Ox/js/' not in source and '/UI/js/' not in source and not is_jquery:
|
if '/Ox/js/' not in source and '/UI/js/' not in source and not is_jquery:
|
||||||
if re.match('^Ox\..+\.js$', filename) or is_jsonc:
|
if re.match(r'^Ox\..+\.js$', filename) or is_jsonc:
|
||||||
js = read_text(source)
|
js = read_text(source)
|
||||||
print('minifiy and write', filename, target)
|
print('minifiy and write', filename, target)
|
||||||
write_file(target, ox.js.minify(js, '' if is_jsonc else comment))
|
write_file(target, ox.js.minify(js, '' if is_jsonc else comment))
|
||||||
|
|
@ -129,7 +129,7 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
if not is_jquery_min:
|
if not is_jquery_min:
|
||||||
write_link(link_source, link_target)
|
write_link(link_source, link_target)
|
||||||
# locales
|
# locales
|
||||||
match = re.search('/(\w+)/json/locale.(\w+).json', source)
|
match = re.search(r'/(\w+)/json/locale.(\w+).json', source)
|
||||||
if match:
|
if match:
|
||||||
module = match.group(1)
|
module = match.group(1)
|
||||||
locale = match.group(2)
|
locale = match.group(2)
|
||||||
|
|
@ -182,12 +182,12 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
if not js_dir + filename in sum(ox_files, []):
|
if not js_dir + filename in sum(ox_files, []):
|
||||||
ox_files[-1].append(js_dir + filename)
|
ox_files[-1].append(js_dir + filename)
|
||||||
js = re.sub(
|
js = re.sub(
|
||||||
'Ox.LOCALES = \{\}',
|
r'Ox.LOCALES = \{\}',
|
||||||
'Ox.LOCALES = ' + json.dumps(locales, indent=4, sort_keys=True),
|
'Ox.LOCALES = ' + json.dumps(locales, indent=4, sort_keys=True),
|
||||||
js
|
js
|
||||||
)
|
)
|
||||||
js = re.sub(
|
js = re.sub(
|
||||||
"Ox.VERSION = '([\d\.]+)'",
|
r"Ox.VERSION = '([\d\.]+)'",
|
||||||
"Ox.VERSION = '%s'" % version,
|
"Ox.VERSION = '%s'" % version,
|
||||||
js
|
js
|
||||||
)
|
)
|
||||||
|
|
@ -238,7 +238,7 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
data = {
|
data = {
|
||||||
# sum(list, []) is flatten
|
# sum(list, []) is flatten
|
||||||
'documentation': sorted(sum(ox_files, [])) + sorted(list(filter(
|
'documentation': sorted(sum(ox_files, [])) + sorted(list(filter(
|
||||||
lambda x: re.search('\.js$', x),
|
lambda x: re.search(r'\.js$', x),
|
||||||
ui_files['dev']
|
ui_files['dev']
|
||||||
)) + ['%s/%s.js' % (x, x) for x in ['Geo', 'Image', 'Unicode']]),
|
)) + ['%s/%s.js' % (x, x) for x in ['Geo', 'Image', 'Unicode']]),
|
||||||
'examples': sorted(sum(map(
|
'examples': sorted(sum(map(
|
||||||
|
|
@ -250,7 +250,7 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
list(filter(
|
list(filter(
|
||||||
lambda x: not re.search('^[._]', x),
|
lambda x: not re.search(r'^[._]', x),
|
||||||
os.listdir(root_path + 'examples/')
|
os.listdir(root_path + 'examples/')
|
||||||
))
|
))
|
||||||
), [])) if os.path.exists(root_path + 'examples/') else (),
|
), [])) if os.path.exists(root_path + 'examples/') else (),
|
||||||
|
|
@ -264,7 +264,7 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
'title': get_title(root_path + 'readme/' + x)
|
'title': get_title(root_path + 'readme/' + x)
|
||||||
},
|
},
|
||||||
filter(
|
filter(
|
||||||
lambda x: not re.search('^[._]', x) and re.search('\.html$', x),
|
lambda x: not re.search(r'^[._]', x) and re.search(r'\.html$', x),
|
||||||
os.listdir(root_path + 'readme/')
|
os.listdir(root_path + 'readme/')
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
|
|
@ -355,7 +355,7 @@ def parse_css(css, values):
|
||||||
) for vals in value]
|
) for vals in value]
|
||||||
)
|
)
|
||||||
return string
|
return string
|
||||||
return re.sub('\$(\w+)(\[\d+\])?', sub, css)
|
return re.sub(r'\$(\w+)(\[\d+\])?', sub, css)
|
||||||
|
|
||||||
def read_file(file):
|
def read_file(file):
|
||||||
print('reading', file)
|
print('reading', file)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue