summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2013-10-04 00:13:28 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2013-10-04 00:13:28 -0400
commit31681a96f0021f8161c7b30c84a3d1864246b168 (patch)
treef27fb5c47ec9508444d0d78db3366d5a415c394b
parent365cb466634f2ce63028c26ffd95468f7cf712a4 (diff)
downloadlnmod-31681a96f0021f8161c7b30c84a3d1864246b168.tar.gz
BUGFIX: Unindented file walking for loop
-rwxr-xr-xlnmod.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/lnmod.py b/lnmod.py
index a36593c..b58a0af 100755
--- a/lnmod.py
+++ b/lnmod.py
@@ -45,7 +45,7 @@ def generate_link_map(path):
link_paths = []
links = []
- for root, dirnames, filenames in path:
+ for root, dirnames, filenames in os.walk(os.path.abspath(path), followlinks=False):
# For each directory
for dirname in dirnames:
dir_path = os.path.join(root, dirname)
@@ -54,15 +54,15 @@ def generate_link_map(path):
link_paths.append(readlinkabs(dir_path))
#For each file
- for filename in filenames:
- file_path = os.path.join(root, filename)
- if readlinkabs(file_path):
- # The way os.walk nests filenames; ignore replicated entities
- if file_path in original_paths or file_path in link_paths:
- continue
- #Store symbolic link paths
- original_paths.append(file_path)
- link_paths.append(readlinkabs(file_path))
+ for filename in filenames:
+ file_path = os.path.join(dir_path, filename)
+ if readlinkabs(file_path):
+ # The way os.walk nests filenames; ignore replicated entities
+ if file_path in original_paths or file_path in link_paths:
+ continue
+ #Store symbolic link paths
+ original_paths.append(file_path)
+ link_paths.append(readlinkabs(file_path))
#Generate a list of Links
for original_path, link_path in zip(original_paths, link_paths):
links.append(Link(original_path, link_path))
@@ -133,7 +133,7 @@ if __name__ == "__main__":
print("Search and replace patterns cannot be the same.")
exit(1)
- lmap = generate_link_map(os.walk(os.path.abspath(args.path), followlinks=False))
+ lmap = generate_link_map(args.path)
if not lmap:
print("No symbolic links detected under {0}".format(args.path))
exit(0)