PEP8 format build.py
This commit is contained in:
parent
dcbee18584
commit
e6b7e24d76
1 changed files with 26 additions and 25 deletions
|
@ -47,7 +47,7 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
for item in os.listdir(path):
|
for item in os.listdir(path):
|
||||||
full_path = '%s%s' % (path, item)
|
full_path = '%s%s' % (path, item)
|
||||||
if os.path.isdir(full_path):
|
if os.path.isdir(full_path):
|
||||||
if not (geo == False and item == 'Geo'):
|
if not (geo is False and item == 'Geo'):
|
||||||
shutil.rmtree(full_path)
|
shutil.rmtree(full_path)
|
||||||
else:
|
else:
|
||||||
os.remove(full_path)
|
os.remove(full_path)
|
||||||
|
@ -96,11 +96,11 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
ui_files = {'dev': [], 'min': []}
|
ui_files = {'dev': [], 'min': []}
|
||||||
for path, dirnames, filenames in os.walk(source_path):
|
for path, dirnames, filenames in os.walk(source_path):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
if not '_' in path and not filename[0] in '._' \
|
if '_' not in path and filename[0] not in '._' \
|
||||||
and not filename.endswith('~') \
|
and not filename.endswith('~') \
|
||||||
and not filename.endswith('.css') \
|
and not filename.endswith('.css') \
|
||||||
and not '/UI/svg' in path \
|
and '/UI/svg' not in path \
|
||||||
and (geo or not '/Geo/' 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('^jquery-[\d\.]+\.js$', filename)
|
||||||
|
@ -114,7 +114,7 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
if is_jquery_plugin:
|
if is_jquery_plugin:
|
||||||
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 not '/Ox/js/' in source and not '/UI/js/' 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('^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)
|
||||||
|
@ -135,7 +135,7 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
if match:
|
if match:
|
||||||
module = match.group(1)
|
module = match.group(1)
|
||||||
locale = match.group(2)
|
locale = match.group(2)
|
||||||
if not module in locales:
|
if module not in locales:
|
||||||
locales[module] = []
|
locales[module] = []
|
||||||
locales[module].append(locale)
|
locales[module].append(locale)
|
||||||
# remove dangling links from dev tree that might
|
# remove dangling links from dev tree that might
|
||||||
|
@ -148,20 +148,20 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
# Ox.js
|
# Ox.js
|
||||||
filenames = [
|
filenames = [
|
||||||
[
|
[
|
||||||
'Core.js' # has to run first so that Ox is defined
|
'Core.js' # has to run first so that Ox is defined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'Function.js', # getSortValue (Array.js) depends on Ox.cache
|
'Function.js', # getSortValue (Array.js) depends on Ox.cache
|
||||||
'Polyfill.js' # FIXME: not clear if needed here
|
'Polyfill.js' # FIXME: not clear if needed here
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'Array.js', # Ox.slice (Collection.js) depends on Ox.toArray, salt (HTML.js) depends on Ox.range
|
'Array.js', # Ox.slice (Collection.js) depends on Ox.toArray, salt (HTML.js) depends on Ox.range
|
||||||
'String.js', # salt (HTML.js) depends on Ox.char
|
'String.js', # salt (HTML.js) depends on Ox.char
|
||||||
'Type.js' # Ox.typeOf needed in Collection.js FF3.6 for Ox.slice fallback
|
'Type.js' # Ox.typeOf needed in Collection.js FF3.6 for Ox.slice fallback
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'Collection.js', # Ox.PATH (Constants.js) depends on Ox.slice
|
'Collection.js', # Ox.PATH (Constants.js) depends on Ox.slice
|
||||||
'Math.js' # Ox.MAX_LATITUDE (Constants.js) depends on Ox.sinh
|
'Math.js' # Ox.MAX_LATITUDE (Constants.js) depends on Ox.sinh
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
js = ''
|
js = ''
|
||||||
|
@ -172,9 +172,9 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
for filename in group:
|
for filename in group:
|
||||||
ox_files[-1].append(js_dir + filename)
|
ox_files[-1].append(js_dir + filename)
|
||||||
ox_files.append([])
|
ox_files.append([])
|
||||||
filenames = sum(filenames, []) # flatten
|
filenames = sum(filenames, []) # flatten
|
||||||
for filename in sorted(os.listdir(source_path + js_dir)):
|
for filename in sorted(os.listdir(source_path + js_dir)):
|
||||||
if not filename in filenames \
|
if filename not in filenames \
|
||||||
and not filename.startswith('.') \
|
and not filename.startswith('.') \
|
||||||
and not filename.startswith('_') \
|
and not filename.startswith('_') \
|
||||||
and not filename.endswith('~'):
|
and not filename.endswith('~'):
|
||||||
|
@ -210,15 +210,15 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
# Ox.UI.css imports all other css files
|
# Ox.UI.css imports all other css files
|
||||||
# svgs are loaded as URLs or dataURLs
|
# svgs are loaded as URLs or dataURLs
|
||||||
# Ox.UI PNGs are loaded on demand
|
# Ox.UI PNGs are loaded on demand
|
||||||
if path != root and not '_' in path and not filename[0] in '._' \
|
if path != root and '_' not in path and filename[0] not in '._' \
|
||||||
and not filename.endswith('~') \
|
and not filename.endswith('~') \
|
||||||
and not 'jquery' in filename \
|
and 'jquery' not in filename \
|
||||||
and not 'locale' in filename \
|
and 'locale' not in filename \
|
||||||
and not filename.endswith('theme.css') \
|
and not filename.endswith('theme.css') \
|
||||||
and not filename.endswith('.svg') \
|
and not filename.endswith('.svg') \
|
||||||
and not 'UI/png' in path:
|
and 'UI/png' not in path:
|
||||||
ui_files['dev'].append(os.path.join(path.replace(source_path, ''), filename))
|
ui_files['dev'].append(os.path.join(path.replace(source_path, ''), filename))
|
||||||
if not '/js/' in path:
|
if '/js/' not in path:
|
||||||
ui_files['min'].append(os.path.join(path.replace(source_path, ''), filename))
|
ui_files['min'].append(os.path.join(path.replace(source_path, ''), filename))
|
||||||
if filename.endswith('.js'):
|
if filename.endswith('.js'):
|
||||||
js += read_text(os.path.join(path, filename)) + '\n'
|
js += read_text(os.path.join(path, filename)) + '\n'
|
||||||
|
@ -301,10 +301,10 @@ def build_oxjs(downloads=False, geo=False):
|
||||||
real_min_path = root_path + 'min/'
|
real_min_path = root_path + 'min/'
|
||||||
if os.path.exists(real_dev_path):
|
if os.path.exists(real_dev_path):
|
||||||
shutil.rmtree(real_dev_path)
|
shutil.rmtree(real_dev_path)
|
||||||
shutil.move(dev_path,real_dev_path)
|
shutil.move(dev_path, real_dev_path)
|
||||||
if os.path.exists(real_min_path):
|
if os.path.exists(real_min_path):
|
||||||
shutil.rmtree(real_min_path)
|
shutil.rmtree(real_min_path)
|
||||||
shutil.move(min_path,real_min_path)
|
shutil.move(min_path, real_min_path)
|
||||||
|
|
||||||
|
|
||||||
def copy_file(source, target):
|
def copy_file(source, target):
|
||||||
|
@ -344,7 +344,7 @@ def parse_css(css, values):
|
||||||
def sub(match):
|
def sub(match):
|
||||||
key = match.group(1)
|
key = match.group(1)
|
||||||
index = match.group(2)
|
index = match.group(2)
|
||||||
value = values[key] if index == None else values[key][int(index[1:-1])]
|
value = values[key] if index is None else values[key][int(index[1:-1])]
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
string = value
|
string = value
|
||||||
else:
|
else:
|
||||||
|
@ -405,5 +405,6 @@ def write_tarfile(file, path, arcname, filter):
|
||||||
f.close()
|
f.close()
|
||||||
return os.path.getsize(file)
|
return os.path.getsize(file)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
build_oxjs(downloads='-downloads' in sys.argv, geo=not '-nogeo' in sys.argv)
|
build_oxjs(downloads='-downloads' in sys.argv, geo='-nogeo' not in sys.argv)
|
||||||
|
|
Loading…
Reference in a new issue