Changes in tests/pybin/tools.py [f866d15:09bbe78]
- File:
-
- 1 edited
-
tests/pybin/tools.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tests/pybin/tools.py
rf866d15 r09bbe78 88 88 raise 89 89 90 def is_empty(fname):91 if not os.path.isfile(fname):92 return True93 94 if os.stat(fname).st_size == 0:95 return True96 97 return False98 99 90 def is_ascii(fname): 100 91 if settings.dry_run: 101 92 print("is_ascii: %s" % fname) 102 return (True, "")93 return True 103 94 104 95 if not os.path.isfile(fname): 105 return (False, "No file")106 107 code, out = sh("file ",fname, output_file=subprocess.PIPE)96 return False 97 98 code, out = sh("file %s" % fname, output_file=subprocess.PIPE) 108 99 if code != 0: 109 return (False, "'file EXPECT' failed with code {}".format(code))100 return False 110 101 111 102 match = re.search(".*: (.*)", out) 112 103 113 104 if not match: 114 return (False, "Unreadable file type: '{}'".format(out)) 115 116 if "ASCII text" in match.group(1): 117 return (True, "") 118 119 return (False, "File type should be 'ASCII text', was '{}'".format(match.group(1))) 105 return False 106 107 return match.group(1).startswith("ASCII text") 120 108 121 109 def is_exe(fname):
Note:
See TracChangeset
for help on using the changeset viewer.