summaryrefslogtreecommitdiffstats
path: root/jenkins_jobs/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'jenkins_jobs/utils.py')
-rw-r--r--jenkins_jobs/utils.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/jenkins_jobs/utils.py b/jenkins_jobs/utils.py
index 4ce8ad2c..5bb7af84 100644
--- a/jenkins_jobs/utils.py
+++ b/jenkins_jobs/utils.py
@@ -22,14 +22,14 @@ import os.path
from six.moves import input
-def wrap_stream(stream, encoding='utf-8'):
+def wrap_stream(stream, encoding="utf-8"):
try:
stream_enc = stream.encoding
except AttributeError:
stream_enc = locale.getpreferredencoding()
- if hasattr(stream, 'buffer'):
+ if hasattr(stream, "buffer"):
stream = stream.buffer
if str(stream_enc).lower() == str(encoding).lower():
@@ -47,21 +47,27 @@ def recurse_path(root, excludes=None):
patterns = [e for e in excludes if os.path.sep not in e]
absolute = [e for e in excludes if os.path.isabs(e)]
- relative = [e for e in excludes if os.path.sep in e and
- not os.path.isabs(e)]
+ relative = [e for e in excludes if os.path.sep in e and not os.path.isabs(e)]
for root, dirs, files in os.walk(basepath, topdown=True):
# sort in-place to ensure dirnames are visited in alphabetical order
# a predictable order makes it easier to use the retain_anchors option
dirs.sort()
dirs[:] = [
- d for d in dirs
+ d
+ for d in dirs
if not any([fnmatch.fnmatch(d, pattern) for pattern in patterns])
- if not any([fnmatch.fnmatch(os.path.abspath(os.path.join(root, d)),
- path)
- for path in absolute])
- if not any([fnmatch.fnmatch(os.path.relpath(os.path.join(root, d)),
- path)
- for path in relative])
+ if not any(
+ [
+ fnmatch.fnmatch(os.path.abspath(os.path.join(root, d)), path)
+ for path in absolute
+ ]
+ )
+ if not any(
+ [
+ fnmatch.fnmatch(os.path.relpath(os.path.join(root, d)), path)
+ for path in relative
+ ]
+ )
]
pathlist.extend([os.path.join(root, path) for path in dirs])
@@ -69,5 +75,5 @@ def recurse_path(root, excludes=None):
def confirm(question):
- answer = input('%s (Y/N): ' % question).upper().strip()
- return answer == 'Y'
+ answer = input("%s (Y/N): " % question).upper().strip()
+ return answer == "Y"