Files are processed in sorted order now.
This commit is contained in:
parent
314f6faf8e
commit
864099bc33
48
oobsync.py
48
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."
|
path = os.path.join(projdir, modname + ".vb")
|
||||||
else:
|
f = open(path, "w")
|
||||||
f = open(path, "r+")
|
f.write(modules[modname])
|
||||||
if modules[modname] != f.read():
|
f.close()
|
||||||
f.seek(0)
|
print >> sys.stderr, modname + ".vb added."
|
||||||
f.write(modules[modname])
|
else:
|
||||||
print >> sys.stderr, modname + ".vb updated."
|
path = os.path.join(projdir, curmods[modname])
|
||||||
f.close()
|
f = open(path, "r+")
|
||||||
for modname in [x for x in modules.keys() if not curmods.has_key(x)]:
|
if modules[modname] != f.read():
|
||||||
path = os.path.join(projdir, modname + ".vb")
|
f.seek(0)
|
||||||
f = open(path, "w")
|
f.write(modules[modname])
|
||||||
f.write(modules[modname])
|
print >> sys.stderr, curmods[modname] + " updated."
|
||||||
f.close()
|
f.close()
|
||||||
print >> sys.stderr, modname + ".vb added."
|
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