Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions bin/find-non-ascii
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ def ignore_file(filename, globs):
if not globs:
return False

for glob in globs:
if fnmatch.fnmatch(filename, glob):
return False

return True
return not any(fnmatch.fnmatch(filename, glob) for glob in globs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ignore_file refactored with the following changes:

  • Use any() instead of for loop (use-any)



def find_files(args):
Expand Down
4 changes: 2 additions & 2 deletions bin/svn-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def main():
if filename not in svnignore_data:
continue
svnignore_data.remove(filename)
elif filename in svnignore_data:
continue
else:
if filename in svnignore_data:
continue
Comment on lines +73 to -75
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

svnignore_data.append(filename)

# Optionally sort.
Expand Down
10 changes: 2 additions & 8 deletions bin/unicode2ascii
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,14 @@ def main():
args.files.append("-")

for arg in args.files:
if arg == "-":
text = sys.stdin.read()
else:
text = open(arg, "rb").read()
text = sys.stdin.read() if arg == "-" else open(arg, "rb").read()
utext = text.decode("utf8")
utext = unicodedata.normalize("NFKD", utext)
utext = utext.translate(XTABLE)
try:
utext.encode("ascii", "strict")
except UnicodeEncodeError as err:
if arg == "-":
errfile = ""
else:
errfile = "In '%s', " % arg
errfile = "" if arg == "-" else "In '%s', " % arg
Comment on lines -69 to +76
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

sys.stderr.write(
"ERROR: %s%s\n" % (errfile, str(err))
)
Expand Down
23 changes: 11 additions & 12 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ def clean_link(args, linkname, backup=True):
os.unlink(link_pathname)

elif os.path.exists(link_pathname):
if os.path.isdir(link_pathname):
if not os.listdir(link_pathname):
print("Removing empty directory '{0}'.".format(link_pathname))
if not args.dryrun:
os.rmdir(link_pathname)
return
if os.path.isdir(link_pathname) and not os.listdir(link_pathname):
print("Removing empty directory '{0}'.".format(link_pathname))
if not args.dryrun:
os.rmdir(link_pathname)
return
Comment on lines -139 to +143
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function clean_link refactored with the following changes:


# The destination exists as a file or dir. Back it up.
if backup:
Expand Down Expand Up @@ -552,13 +551,13 @@ def xfwm4_remove_key_binding(args, binding):
binding
]
output = force_run_command(cmdargs)
if output.find("does not exist on channel") != -1:
if args.verbose:
print("Key binding '{0}' already removed.".format(binding))
else:
if output.find("does not exist on channel") == -1:
print("Removing key binding '{0}'.".format(binding))
run_command(args, cmdargs + ["--reset"])

elif args.verbose:
print("Key binding '{0}' already removed.".format(binding))
Comment on lines -555 to +559
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function xfwm4_remove_key_binding refactored with the following changes:



def xfwm4_add_key_binding(args, binding, command):
"""Add a xfwm4 key binding."""
Expand Down Expand Up @@ -850,10 +849,10 @@ def main():
args.is_cygwin = sys.platform == "cygwin"
args.is_windows = sys.platform.startswith("win")
args.is_xwindows = (
exe_in_path("xterm") and
not (args.is_cygwin or args.is_windows)
exe_in_path("xterm") and not args.is_cygwin and not args.is_windows
)

Comment on lines -853 to 854
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)


# Ensure that directories exist.
mkdir(args, True, args.cache_dir, 0o700)
mkdir(args, True, explicit_cache_dir, 0o700)
Expand Down
3 changes: 1 addition & 2 deletions pythonstartup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def _history_pathname():
Default is ~/.python_history, but we are trying to cleanup the
user's home directory.
"""
pathname = os.path.join(xdg_cache_home, "python", "history")
return pathname
return os.path.join(xdg_cache_home, "python", "history")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _history_pathname refactored with the following changes:



def _save_history():
Expand Down