From 01efec0040a514ffc005565c505696cd79917ce2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 28 Jan 2023 16:37:24 -0800 Subject: [PATCH] src/sage/misc/replace_dot_all.py: Use endswith() --- src/sage/misc/replace_dot_all.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sage/misc/replace_dot_all.py b/src/sage/misc/replace_dot_all.py index 418591153cb..9a62534c714 100644 --- a/src/sage/misc/replace_dot_all.py +++ b/src/sage/misc/replace_dot_all.py @@ -469,11 +469,12 @@ def print_log_messages(): os.chdir(sage.env.SAGE_SRC + '/sage') # change to sage directory dir = os.getcwd() # Get the current working directory walkdir_replace_dot_all(dir, fileRegex, package_regex, verbose=verbosity) - elif args.location.find('.py') == -1 and args.location.find('.pxi') == -1: + elif not (args.location.endswith('.py') or args.location.endswith('.pxi')): + # Assume directory os.chdir(sage.env.SAGE_SRC + '/sage/' + args.location) # change to directory specified by location argument dir = os.getcwd() # Get the current working directory walkdir_replace_dot_all(dir, fileRegex, package_regex, verbose=verbosity) - elif args.location.find('.py') != -1 or args.location.find('.pxi') != -1: + else: # make replacements in file specified by location argument make_replacements_in_file(sage.env.SAGE_SRC + '/sage/' + args.location, package_regex, verbose=verbosity) # ************************************************************************************************************************************************************************