Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
Require xmllint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Saukko committed Dec 12, 2011
1 parent 206a06f commit 68727b5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions repomd-pattern-builder.py
Expand Up @@ -32,6 +32,7 @@
NSMAP_GROUP = {None : pattern_ns, "rpm": rpm_ns, "patterns": pattern_ns}

TMP_FILE = "xmllint_tmp.xml"
XMLLINT = "/usr/bin/xmllint"

def process_yaml(stream, proot, newobsapi):
y = yaml.load(stream)
Expand Down Expand Up @@ -110,8 +111,8 @@ def merge_patterns(patterns_dir,outputdir,newobsapi):
xmlroot.set('count', "%d" %count)
tree = etree.ElementTree(xmlroot)
# Indent the XML with xmllint and output to file.
tree.write("%s" % (TMP_FILE))
os.system("xmllint --format %s --output %s" % (TMP_FILE, output_file))
tree.write("%s" % (TMP_FILE))
os.system("%s --format %s --output %s" % (XMLLINT,TMP_FILE, output_file))

if __name__ == '__main__':
parser = optparse.OptionParser()
Expand Down Expand Up @@ -141,7 +142,11 @@ def merge_patterns(patterns_dir,outputdir,newobsapi):
if (not options.patterndir or not os.path.exists(options.patterndir)):
print "Error: Pattern dir '%s' doesn't exist." % (options.patterndir)
exit(1)


if not os.path.exists(XMLLINT):
print "Error: '%s' is required when executing this script."
exit(1)

if options.outputdir and not os.path.exists(options.outputdir):
os.makedirs(options.outputdir)

Expand Down

0 comments on commit 68727b5

Please sign in to comment.