Created
September 8, 2015 00:49
-
-
Save robbintt/60d6f72ffe80c753b571 to your computer and use it in GitHub Desktop.
.pyc vs .py checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Check .pyc files against .py files in a directory and all its descendants to see if any pyc files do not have their accompanying py files. | |
To get input for this, run the command: | |
find . -regex .*pyc? > checker.txt | |
Check if the line ends in pyc. | |
If it does, check if there is a line that is the same without the c. | |
If not, print the pyc line. | |
""" | |
# open the checker.txt file | |
filename = "checker.txt" | |
with open(filename) as f: | |
record = f.readlines() | |
# this is a test | |
# simple failing sample data | |
#record = ["this is a failed test.pyc"] | |
# change to list comprehension if preferred | |
clean_record = list() | |
# clean up the whitespace in each line | |
for line in record: | |
clean_record.append(line.strip()) | |
record = clean_record | |
pyc_only_lines = list() | |
for line in record: | |
if line[-3:] == "pyc" and line[:-1] not in record: | |
print "=====" | |
print line | |
pyc_only_lines.append(line) | |
print "= = = = = = " | |
print "Checked {} records.".format(len(record),) | |
print "{} .pyc only records found.".format(len(pyc_only_lines)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment