Define a function for popping to the top-level dist directory.

This commit is contained in:
Eric S. Raymond 2008-03-31 11:17:00 +00:00
parent b1a9d29509
commit 513921c01c
2 changed files with 15 additions and 12 deletions

View file

@ -8,6 +8,20 @@ import sys, os, re, sre_constants, md5, glob
resource_extensions = ("png", "jpg", "ogg", "wav", "map", "mask")
image_reference = r"[A-Za-z0-9{}.][A-Za-z0-9_/+{}.-]*\.(png|jpg)(?=(~.*)?)"
def pop_to_top(whoami):
"Pop upward to the top-level directory."
upwards = os.getcwd().split(os.sep)
upwards.reverse()
for pathpart in upwards:
if pathpart == "wesnoth":
break
else:
os.chdir("..")
else:
sys.stderr.write(whoami + ": must be run from within a Battle "
"for Wesnoth source tree.\n")
sys.exit(1)
def string_strip(value):
"String-strip the value"
if value.startswith('"'):

View file

@ -96,18 +96,7 @@ if __name__ == "__main__":
else:
dst = arguments.pop()
# First, pop upward to the top-level directory.
upwards = os.getcwd().split(os.sep)
upwards.reverse()
for pathpart in upwards:
if pathpart == "wesnoth":
break
else:
os.chdir("..")
else:
sys.stderr.write("wmlmove: must be run from within a Battle "
"for Wesnoth source tree.\n")
sys.exit(1)
pop_to_top("wmlmove")
if listspaces:
print "\n".join(map(os.path.basename, scopelist()))