Slight script cleanup; make gensyscalls work from any directory.

Also remove a ton of dead code.

Change-Id: I1315623695a004f643b155f121cbafe24b715b8a
This commit is contained in:
Elliott Hughes
2013-06-17 10:26:10 -07:00
parent 560e9f7e7a
commit 18bc975bfe
3 changed files with 16 additions and 264 deletions

View File

@@ -47,32 +47,6 @@ def find_program_name():
def find_program_dir():
return os.path.dirname(sys.argv[0])
def find_file_from_upwards(from_path,target_file):
"""find a file in the current directory or its parents. if 'from_path' is None,
seach from the current program's directory"""
path = from_path
if path == None:
path = os.path.realpath(sys.argv[0])
path = os.path.dirname(path)
D("this script seems to be located in: %s" % path)
while 1:
D("probing "+path)
if path == "":
file = target_file
else:
file = path + "/" + target_file
if os.path.isfile(file):
D("found %s in %s" % (target_file, path))
return file
if path == "":
return None
path = os.path.dirname(path)
class StringOutput:
def __init__(self):
self.line = ""
@@ -143,35 +117,6 @@ def cleanup_dir(path):
for name in dirs:
os.rmdir(os.path.join(root, name))
def update_file( path, newdata ):
"""update a file on disk, only if its content has changed"""
if os.path.exists( path ):
try:
f = open( path, "r" )
olddata = f.read()
f.close()
except:
D("update_file: cannot read existing file '%s'" % path)
return 0
if oldata == newdata:
D2("update_file: no change to file '%s'" % path )
return 0
update = 1
else:
try:
create_file_path(path)
except:
D("update_file: cannot create path to '%s'" % path)
return 0
f = open( path, "w" )
f.write( newdata )
f.close()
return 1
class BatchFileUpdater:
"""a class used to edit several files at once"""