summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2017-09-29 17:37:31 (GMT)
committerDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2017-09-29 17:37:31 (GMT)
commitf87e1a13d2155984fc9693d7b12a02421331ec10 (patch)
treeaaf2e20cf01122b10766494a58556ce49e1edfbf
parent7c83421ce723aa211168b6fb46d5f8ec7d187a88 (diff)
suspicious: represent filenames as strings, not bytesHEADmaster
A summary file with base64-encoded filenames is a pain to work with.
-rwxr-xr-xsuspicious24
1 files changed, 11 insertions, 13 deletions
diff --git a/suspicious b/suspicious
index 8140254..3a4d056 100755
--- a/suspicious
+++ b/suspicious
@@ -95,7 +95,7 @@ def sortscore(score, reverse=True):
def printscore(report):
for filename, filescore in report:
- print(fsdecode_display(filename) + ':' + str(filescore))
+ print(filename + ':' + str(filescore))
def scorewords(report):
for file in report.keys():
@@ -142,7 +142,7 @@ def summary(report):
filescore = scorefile(report)
text = ""
for filename, filescore in sortscore(filescore):
- text += fsdecode_display(filename) + '(' + str(filescore) + '):'
+ text += filename + '(' + str(filescore) + '):'
for word, wordfreq in report[filename].items():
if wordfreq > 0:
text += word + '(' + str(wordfreq) + ');'
@@ -316,21 +316,19 @@ if len(args) > 0:
for a in args:
filelist.extend(avfs.find(os.fsencode(a), prunedirs))
-skipfileexts_bytes = [os.fsencode(e) for e in options.skipfileextensions]
-
start = datetime.datetime.now()
-for file in filelist:
- file_displayname = fsdecode_display(file)
- if skipfile(file, skipfileexts_bytes):
+for filename_bytes in filelist:
+ file = fsdecode_display(filename_bytes)
+ if skipfile(file, options.skipfileextensions):
skipped += 1
continue
try:
- filecontents = decode_file(file)
+ filecontents = decode_file(filename_bytes)
except OSError:
- print("failed to open: " + file_displayname)
+ print("failed to open: " + file)
continue
if filecontents is None:
- print("possible binary: " + file_displayname)
+ print("possible binary: " + file)
continue
opened +=1
now = datetime.datetime.now()
@@ -339,8 +337,8 @@ for file in filelist:
est = ((now - start) / (opened + skipped)) * len(filelist)
est_hr, est_rem = divmod(est.total_seconds(), 3600)
est_min, est_sec = divmod(est_rem, 60)
- if len(file_displayname)> 52:
- prog_file = file_displayname.split('/')[0] + "/.../" + file_displayname.split('/')[-1]
+ if len(file)> 52:
+ prog_file = file.split('/')[0] + "/.../" + file.split('/')[-1]
if len(prog_file) > 52:
prog_file = prog_file[0:52]
else:
@@ -351,7 +349,7 @@ for file in filelist:
print(progresstext, end='', file=sys.stderr)
sys.stdout.flush()
datasize += len(filecontents)
- filenamescore = scoretext(wordlist, file_displayname, options.maxwholewordlength)
+ filenamescore = scoretext(wordlist, file, options.maxwholewordlength)
filecontentsscore = scoretext(wordlist, filecontents, options.maxwholewordlength)
report[file] = {}
for k in filecontentsscore.keys():