From ea232cd3c7b8af29de3fa2619a20e7a24886cdcb Mon Sep 17 00:00:00 2001 From: Adarsh Sanjeev Date: Mon, 4 Jan 2016 22:50:59 +0500 Subject: Changed as per review --- src/engine/SCons/Defaults.py | 16 ++++++++++++---- test/Chmod.py | 32 ++++++++++++++++---------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index 0fbd097..6344975 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -188,10 +188,14 @@ permission_dic = { } def chmod_func(dest, mode): + import SCons.Util + from string import digits SCons.Node.FS.invalidate_node_memos(dest) if not SCons.Util.is_List(dest): dest = [dest] - if str(mode).isdigit(): + if SCons.Util.is_String(mode) and not 0 in [i in digits for i in mode]: + mode = int(mode, 8) + if not SCons.Util.is_String(mode): for element in dest: os.chmod(str(element), mode) else: @@ -205,8 +209,11 @@ def chmod_func(dest, mode): operator = "-" else: raise SyntaxError("Could not find +, - or =") - user = operation.split(operator)[0].strip().replace("a", "ugo") - permission = operation.split(operator)[1].strip() + operation_list = operation.split(operator) + if len(operation_list) is not 2: + raise SyntaxError("More than one operator found") + user = operation_list[0].strip().replace("a", "ugo") + permission = operation_list[1].strip() new_perm = 0 for u in user: for p in permission: @@ -224,7 +231,8 @@ def chmod_func(dest, mode): os.chmod(str(element), curr_perm & ~new_perm) def chmod_strfunc(dest, mode): - if str(mode).isdigit(): + import SCons.Util + if not SCons.Util.is_String(mode): return 'Chmod(%s, 0%o)' % (get_paths_str(dest), mode) else: return 'Chmod(%s, "%s")' % (get_paths_str(dest), str(mode)) diff --git a/test/Chmod.py b/test/Chmod.py index 762d286..c5b2a8d 100644 --- a/test/Chmod.py +++ b/test/Chmod.py @@ -64,11 +64,11 @@ env.Command('f7.out', 'f7.in', [Cat, env = Environment(FILE = 'f9') env.Command('f8.out', 'f8.in', [Chmod(['$FILE', File('f10')], 0666), Cat]) Execute(Chmod(['d11', Dir('d12')], 0777)) -Execute(Chmod('f13', "go=rw")) -Execute(Chmod('f14', "u-r")) -Execute(Chmod('f15', "a+x")) -Execute(Chmod('d16', "uo=x")) -Execute(Chmod(['d17', 'd18'], "o-wx")) +Execute(Chmod('f13', "a=r")) +Execute(Chmod('f14', "ogu+w")) +Execute(Chmod('f15', "ug=rw, go+ rw")) +Execute(Chmod('d16', "0777")) +Execute(Chmod(['d17', 'd18'], "ogu = rwx")) """) test.write('f1', "f1\n") @@ -124,11 +124,11 @@ Chmod("f1-File", 0666) Chmod("d2", 0777) Chmod("d2-Dir", 0777) Chmod(["d11", "d12"], 0777) -Chmod("f13", "go=rw") -Chmod("f14", "u-r") -Chmod("f15", "a+x") -Chmod("d16", "uo=x") -Chmod(["d17", "d18"], "o-wx") +Chmod("f13", "a=r") +Chmod("f14", "ogu+w") +Chmod("f15", "ug=rw, go+ rw") +Chmod("d16", "0777") +Chmod(["d17", "d18"], "ogu = rwx") """, build_str = """\ cat(["bar.out"], ["bar.in"]) @@ -220,17 +220,17 @@ test.fail_test(s != 0777) s = stat.S_IMODE(os.stat(test.workpath('d12'))[stat.ST_MODE]) test.fail_test(s != 0777) s = stat.S_IMODE(os.stat(test.workpath('f13'))[stat.ST_MODE]) -test.fail_test(s != 0066) +test.fail_test(s != 0444) s = stat.S_IMODE(os.stat(test.workpath('f14'))[stat.ST_MODE]) -test.fail_test(s != 0044) +test.fail_test(s != 0666) s = stat.S_IMODE(os.stat(test.workpath('f15'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0666) s = stat.S_IMODE(os.stat(test.workpath('d16'))[stat.ST_MODE]) -test.fail_test(s != 0101) +test.fail_test(s != 0777) s = stat.S_IMODE(os.stat(test.workpath('d17'))[stat.ST_MODE]) -test.fail_test(s != 0554) +test.fail_test(s != 0777) s = stat.S_IMODE(os.stat(test.workpath('d18'))[stat.ST_MODE]) -test.fail_test(s != 0554) +test.fail_test(s != 0777) test.pass_test() -- cgit v0.12