Skip to content

Commit 69b9be6

Browse files
author
Sourcery AI
committed
'Refactored by Sourcery'
1 parent 77d4652 commit 69b9be6

File tree

5 files changed

+17
-29
lines changed

5 files changed

+17
-29
lines changed

bin/find-non-ascii

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ def ignore_file(filename, globs):
6262
if not globs:
6363
return False
6464

65-
for glob in globs:
66-
if fnmatch.fnmatch(filename, glob):
67-
return False
68-
69-
return True
65+
return not any(fnmatch.fnmatch(filename, glob) for glob in globs)
7066

7167

7268
def find_files(args):

bin/svn-ignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ def main():
7070
if filename not in svnignore_data:
7171
continue
7272
svnignore_data.remove(filename)
73+
elif filename in svnignore_data:
74+
continue
7375
else:
74-
if filename in svnignore_data:
75-
continue
7676
svnignore_data.append(filename)
7777

7878
# Optionally sort.

bin/unicode2ascii

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,14 @@ def main():
6666
args.files.append("-")
6767

6868
for arg in args.files:
69-
if arg == "-":
70-
text = sys.stdin.read()
71-
else:
72-
text = open(arg, "rb").read()
69+
text = sys.stdin.read() if arg == "-" else open(arg, "rb").read()
7370
utext = text.decode("utf8")
7471
utext = unicodedata.normalize("NFKD", utext)
7572
utext = utext.translate(XTABLE)
7673
try:
7774
utext.encode("ascii", "strict")
7875
except UnicodeEncodeError as err:
79-
if arg == "-":
80-
errfile = ""
81-
else:
82-
errfile = "In '%s', " % arg
76+
errfile = "" if arg == "-" else "In '%s', " % arg
8377
sys.stderr.write(
8478
"ERROR: %s%s\n" % (errfile, str(err))
8579
)

install.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,11 @@ def clean_link(args, linkname, backup=True):
136136
os.unlink(link_pathname)
137137

138138
elif os.path.exists(link_pathname):
139-
if os.path.isdir(link_pathname):
140-
if not os.listdir(link_pathname):
141-
print("Removing empty directory '{0}'.".format(link_pathname))
142-
if not args.dryrun:
143-
os.rmdir(link_pathname)
144-
return
139+
if os.path.isdir(link_pathname) and not os.listdir(link_pathname):
140+
print("Removing empty directory '{0}'.".format(link_pathname))
141+
if not args.dryrun:
142+
os.rmdir(link_pathname)
143+
return
145144

146145
# The destination exists as a file or dir. Back it up.
147146
if backup:
@@ -552,13 +551,13 @@ def xfwm4_remove_key_binding(args, binding):
552551
binding
553552
]
554553
output = force_run_command(cmdargs)
555-
if output.find("does not exist on channel") != -1:
556-
if args.verbose:
557-
print("Key binding '{0}' already removed.".format(binding))
558-
else:
554+
if output.find("does not exist on channel") == -1:
559555
print("Removing key binding '{0}'.".format(binding))
560556
run_command(args, cmdargs + ["--reset"])
561557

558+
elif args.verbose:
559+
print("Key binding '{0}' already removed.".format(binding))
560+
562561

563562
def xfwm4_add_key_binding(args, binding, command):
564563
"""Add a xfwm4 key binding."""
@@ -850,10 +849,10 @@ def main():
850849
args.is_cygwin = sys.platform == "cygwin"
851850
args.is_windows = sys.platform.startswith("win")
852851
args.is_xwindows = (
853-
exe_in_path("xterm") and
854-
not (args.is_cygwin or args.is_windows)
852+
exe_in_path("xterm") and not args.is_cygwin and not args.is_windows
855853
)
856854

855+
857856
# Ensure that directories exist.
858857
mkdir(args, True, args.cache_dir, 0o700)
859858
mkdir(args, True, explicit_cache_dir, 0o700)

pythonstartup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def _history_pathname():
3838
Default is ~/.python_history, but we are trying to cleanup the
3939
user's home directory.
4040
"""
41-
pathname = os.path.join(xdg_cache_home, "python", "history")
42-
return pathname
41+
return os.path.join(xdg_cache_home, "python", "history")
4342

4443

4544
def _save_history():

0 commit comments

Comments
 (0)