add support for defining order via a .order file

This commit is contained in:
Damien Churchill 2010-03-28 03:36:51 +01:00
parent eaa03a6f2c
commit 4d5d31a2b0
3 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1 @@
+ OptionsManager.js

View File

@ -359,6 +359,23 @@ class ScriptResource(resource.Resource, component.Component):
for dirpath, dirnames, filenames in os.walk(filepath, False): for dirpath, dirnames, filenames in os.walk(filepath, False):
files = fnmatch.filter(filenames, "*.js") files = fnmatch.filter(filenames, "*.js")
files.sort() files.sort()
order_file = os.path.join(dirpath, '.order')
if os.path.isfile(order_file):
for line in open(order_file, 'rb'):
line = line.strip()
if not line or line[0] == '#':
continue
try:
pos, filename = line.split()
files.pop(files.index(filename))
if pos == '+':
files.insert(0, filename)
else:
files.append(filename)
except:
pass
dirpath = dirpath[len(filepath)+1:] dirpath = dirpath[len(filepath)+1:]
if dirpath: if dirpath:
scripts.extend(['js/' + path + '/' + dirpath + '/' + f for f in files]) scripts.extend(['js/' + path + '/' + dirpath + '/' + f for f in files])