From 41354a1569b42db2f861748924dae09e53e6f33d Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Mon, 6 Jun 2011 16:35:38 -0400 Subject: [PATCH] removed unnecessary get_tail_name() function and replaced with os.path.split()[1] --- gitup.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/gitup.py b/gitup.py index 10cf40d..4820480 100644 --- a/gitup.py +++ b/gitup.py @@ -55,13 +55,6 @@ def directory_is_git_repo(directory_path): return True return False -def get_tail_name(path): - """Return the name of the right-most directory in a path. Uses - os.path.split, but corrects for an error when the path ends with a /.""" - if path.endswith("/"): - return os.path.split(path[:-1])[1] - return os.path.split(path)[1] - def update_repository(repo_path, repo_name): """Update a single git repository by pulling from the remote.""" out(1, "{}{}{}:".format(ansi['bold'], repo_name, ansi['reset'])) @@ -164,7 +157,8 @@ def update_directories(paths): """Update a list of directories supplied by command arguments.""" for path in paths: path = os.path.abspath(path) # convert relative to absolute path - update_directory(path, get_tail_name(path), is_bookmark=False) + path_name = os.path.split(path)[1] # directory name; "x" in /path/to/x/ + update_directory(path, path_name, is_bookmark=False) def update_bookmarks(): """Loop through and update all bookmarks.""" @@ -207,7 +201,8 @@ def add_bookmarks(paths): if config.has_option("bookmarks", path): out(1, "'{}' is already bookmarked.".format(path)) else: - config.set("bookmarks", path, get_tail_name(path)) + path_name = os.path.split(path)[1] + config.set("bookmarks", path, path_name) out(1, "{}{}{}".format(ansi['bold'], path, ansi['reset'])) save_config_file(config)