Files are processed in sorted order now.
This commit is contained in:
parent
314f6faf8e
commit
864099bc33
38
oobsync.py
38
oobsync.py
@ -97,23 +97,27 @@ def update_source_dir(projdir, modules):
|
|||||||
path = os.path.join(projdir, entry)
|
path = os.path.join(projdir, entry)
|
||||||
if os.path.isfile(path) and entry.lower().endswith(".vb"):
|
if os.path.isfile(path) and entry.lower().endswith(".vb"):
|
||||||
modname = entry[0:-3]
|
modname = entry[0:-3]
|
||||||
curmods[modname] = True
|
curmods[modname] = entry
|
||||||
if not modules.has_key(modname):
|
for modname in sorted(modules.keys()):
|
||||||
os.remove(path)
|
if not curmods.has_key(modname):
|
||||||
print >> sys.stderr, modname + ".vb removed."
|
|
||||||
else:
|
|
||||||
f = open(path, "r+")
|
|
||||||
if modules[modname] != f.read():
|
|
||||||
f.seek(0)
|
|
||||||
f.write(modules[modname])
|
|
||||||
print >> sys.stderr, modname + ".vb updated."
|
|
||||||
f.close()
|
|
||||||
for modname in [x for x in modules.keys() if not curmods.has_key(x)]:
|
|
||||||
path = os.path.join(projdir, modname + ".vb")
|
path = os.path.join(projdir, modname + ".vb")
|
||||||
f = open(path, "w")
|
f = open(path, "w")
|
||||||
f.write(modules[modname])
|
f.write(modules[modname])
|
||||||
f.close()
|
f.close()
|
||||||
print >> sys.stderr, modname + ".vb added."
|
print >> sys.stderr, modname + ".vb added."
|
||||||
|
else:
|
||||||
|
path = os.path.join(projdir, curmods[modname])
|
||||||
|
f = open(path, "r+")
|
||||||
|
if modules[modname] != f.read():
|
||||||
|
f.seek(0)
|
||||||
|
f.write(modules[modname])
|
||||||
|
print >> sys.stderr, curmods[modname] + " updated."
|
||||||
|
f.close()
|
||||||
|
for modname in sorted(curmods.keys()):
|
||||||
|
if not modules.has_key(modname):
|
||||||
|
path = os.path.join(projdir, curmods[modname])
|
||||||
|
os.remove(path)
|
||||||
|
print >> sys.stderr, curmods[modname] + " removed."
|
||||||
return
|
return
|
||||||
|
|
||||||
def read_basic_modules(libraries, libname):
|
def read_basic_modules(libraries, libname):
|
||||||
@ -132,20 +136,20 @@ def update_basic_modules(libraries, libname, modules):
|
|||||||
libraries.createLibrary(libname)
|
libraries.createLibrary(libname)
|
||||||
print >> sys.stderr, "Library " + libname + " created."
|
print >> sys.stderr, "Library " + libname + " created."
|
||||||
library = libraries.getByName(libname)
|
library = libraries.getByName(libname)
|
||||||
for modname in modules.keys():
|
for modname in sorted(modules.keys()):
|
||||||
library.insertByName(modname, modules[modname])
|
library.insertByName(modname, modules[modname])
|
||||||
print >> sys.stderr, "Module " + modname + " added."
|
print >> sys.stderr, "Module " + modname + " added."
|
||||||
else:
|
else:
|
||||||
library = libraries.getByName(libname)
|
library = libraries.getByName(libname)
|
||||||
origmods = library.getElementNames()
|
curmods = sorted(library.getElementNames())
|
||||||
for modname in modules.keys():
|
for modname in sorted(modules.keys()):
|
||||||
if not library.hasByName(modname):
|
if not modname in curmods:
|
||||||
library.insertByName(modname, modules[modname])
|
library.insertByName(modname, modules[modname])
|
||||||
print >> sys.stderr, "Module " + modname + " added."
|
print >> sys.stderr, "Module " + modname + " added."
|
||||||
elif modules[modname] != library.getByName(modname).encode("utf-8"):
|
elif modules[modname] != library.getByName(modname).encode("utf-8"):
|
||||||
library.replaceByName(modname, modules[modname])
|
library.replaceByName(modname, modules[modname])
|
||||||
print >> sys.stderr, "Module " + modname + " updated."
|
print >> sys.stderr, "Module " + modname + " updated."
|
||||||
for modname in origmods:
|
for modname in curmods:
|
||||||
if not modules.has_key(modname):
|
if not modules.has_key(modname):
|
||||||
library.removeByName(modname)
|
library.removeByName(modname)
|
||||||
print >> sys.stderr, "Module " + modname + " removed."
|
print >> sys.stderr, "Module " + modname + " removed."
|
||||||
|
Loading…
Reference in New Issue
Block a user