Last active
April 11, 2018 03:10
-
-
Save thurask/dc8a61bc416e44682f01f7a0fdb427db to your computer and use it in GitHub Desktop.
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
import os | |
from defusedxml import ElementTree | |
def has_curef(infile): | |
with open(infile, "r") as afile: | |
data = afile.read() | |
sentinel = True if "CUREF" in data else False | |
return sentinel | |
def searcher(indir): | |
candidates = [x for x in os.listdir(indir) if x.endswith(".xml")] | |
passes = [y for y in candidates if has_curef(y)] | |
return passes | |
def extractor(xmlfile): | |
with open(xmlfile, "r") as afile: | |
data = afile.read() | |
root = ElementTree.fromstring(data) | |
curef = root.find("CUREF") | |
tvver = root.find("VERSION").find("TV") | |
return curef.text, tvver.text | |
def main(): | |
passes = searcher(os.getcwd()) | |
verdict = {} | |
for passfile in passes: | |
curef, tvver = extractor(passfile) | |
verdict[curef] = tvver | |
for prd in sorted(verdict.keys()): | |
print("PRD-{0}: {1}".format(prd, verdict[prd])) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment