summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Borean <jborean93@gmail.com>2018-01-31 08:58:03 +1000
committerGitHub <noreply@github.com>2018-01-31 08:58:03 +1000
commit62b87bc92512a242b567b6dd7bc2924adccb5d0f (patch)
treea0f5e69ce2d7b7ea7c4a3cbd53ef9795e65d9a6a
parentc24e092865020529cd20da1794205cf34d34a6c6 (diff)
downloadansible-62b87bc92512a242b567b6dd7bc2924adccb5d0f.tar.gz
change .encode to to_bytes (#35522)
ignore backup dir in test integration targets folder
-rwxr-xr-xtest/sanity/code-smell/no-illegal-filenames.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/sanity/code-smell/no-illegal-filenames.py b/test/sanity/code-smell/no-illegal-filenames.py
index 182527d6b1..0e339cdd8b 100755
--- a/test/sanity/code-smell/no-illegal-filenames.py
+++ b/test/sanity/code-smell/no-illegal-filenames.py
@@ -5,8 +5,11 @@
# https://msdn.microsoft.com/en-us/library/aa365247#naming_conventions
import os
+import re
import struct
+from ansible.module_utils.basic import to_bytes
+
ILLEGAL_CHARS = [
b'<',
b'>',
@@ -62,16 +65,23 @@ def check_path(path, dir=False):
if file_name[-1] in ILLEGAL_END_CHARS:
errors.append("Illegal %s name end-char '%s': %s" % (type_name, file_name[-1], path))
- bfile = file_name.encode('utf-8')
+ bfile = to_bytes(file_name, encoding='utf-8')
for char in ILLEGAL_CHARS:
if char in bfile:
- errors.append("Illegal char %s in %s name: %s" % (char, type_name, path.encode('utf-8')))
+ bpath = to_bytes(path, encoding='utf-8')
+ errors.append("Illegal char %s in %s name: %s" % (char, type_name, bpath))
return errors
def main():
errors = []
+ pattern = re.compile("^./test/integration/targets/.*/backup")
+
for root, dirs, files in os.walk('.'):
+ # ignore test/integration/targets/*/backup
+ if pattern.match(root):
+ continue
+
for dir_name in dirs:
errors += check_path(os.path.abspath(os.path.join(root, dir_name)), dir=True)