def get_android_root(): if"ANDROID_BUILD_TOP"in os.environ: # Verify that the current directory is in the root. # If not, then print an error.
cwd = os.getcwd()
root = os.environ["ANDROID_BUILD_TOP"] if len(cwd) < len(root) ornot root == cwd[:len(root)]:
panic("Not in android tree pointed at by ANDROID_BUILD_TOP (%s)\n" % root) return os.environ["ANDROID_BUILD_TOP"]
panic("Unable to find root of tree, did you forget to lunch a target?\n")
class StringOutput: def __init__(self):
self.line = ""
dirs.reverse() for dir in dirs: #print "dir %s" % dir if os.path.isdir(dir): continue
os.mkdir(dir)
class BatchFileUpdater: """a class used to edit several files at once""" def __init__(self):
self.old_files = set()
self.new_files = set()
self.new_data = {}
def readFile(self,path): #path = os.path.realpath(path) if os.path.exists(path):
self.old_files.add(path)
def readDir(self,path): #path = os.path.realpath(path) for root, dirs, files in os.walk(path): for f in files:
dst = "%s/%s" % (root,f)
self.old_files.add(dst)
def editFile(self,dst,data): """edit a destination file. if the file is not mapped from a source,
it will be added. return0if the file content wasn't changed, 1if it was edited, or2if the file is new""" #dst = os.path.realpath(dst)
result = 1 if os.path.exists(dst):
f = open(dst, "r")
olddata = f.read()
f.close() if olddata == data:
self.old_files.remove(dst) return0 else:
result = 2
self.new_data[dst] = data
self.new_files.add(dst) return result
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.