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

Commit

Permalink
--groupxml functionality moved to --patternsxml as it is actually the…
Browse files Browse the repository at this point in the history
… right thing.

Signed-off-by: Marko Saukko <marko.saukko@jollamobile.com>
  • Loading branch information
Marko Saukko committed Nov 28, 2012
1 parent d0142b1 commit 22d9590
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 23 deletions.
9 changes: 3 additions & 6 deletions TODO
@@ -1,7 +1,4 @@
== Fix --patternxml with multiple patterns in single file ==

Decide what to do when there are multiple patterns in single .yaml file and
when user is creating patternxml instead of groupxml. Currently output of
test5 with --patternxml is broken see tests/data/patterns/test5.yaml as it
looses the second pattern.
== Add support for groupxml ==
Currently groupxml isn't working and it is relaced with error message
as the old version did actually patterns.xml and not group.xml

34 changes: 21 additions & 13 deletions repomd-pattern-builder.py
Expand Up @@ -112,25 +112,25 @@ def create_patterns(patterns_dir, version, release, outputdir, newobsapi):
if not f.endswith('.yaml'):
continue

output_file = "%s/%s.xml" % (outputdir,os.path.basename(f).split('.')[0])

print "Working on %s" % (output_file)

stream = file("%s/%s" %(patterns_dir,f), 'r')
xmlroot = etree.Element("temporary_root", nsmap=NSMAP)

process_yaml(stream, version, release, xmlroot, NSMAP, newobsapi)

pattern = xmlroot.find("pattern")

if pattern is None:
continue
for pattern in xmlroot.findall("pattern"):

name = pattern.find("name")
if name == None:
print "Pattern didn't have name skipping."
continue
output_file = "%s/%s.xml" % (outputdir,name.text.lower())
print "Working on %s" % (output_file)

etree.ElementTree(pattern).write(output_file, pretty_print=True)
etree.ElementTree(pattern).write(output_file, pretty_print=True)

def merge_patterns(patterns_dir, version, release, outputdir, newobsapi):
xmlroot = etree.Element("patterns")
output_file = "%s/group.xml" % (outputdir)
output_file = "%s/patterns.xml" % (outputdir)
dirlist = os.listdir(patterns_dir)
dirlist.sort()

Expand All @@ -152,9 +152,12 @@ def merge_patterns(patterns_dir, version, release, outputdir, newobsapi):
parser.add_option("", "--patternxml", action="store_true", dest="patternxml",
default=False,
help="Create separated pattern XML file for each pattern.")
parser.add_option("", "--patternsxml", action="store_true", dest="patternsxml",
default=False,
help="Create merged patterns.xml from all the available patterns.")
parser.add_option("", "--groupxml", action="store_true", dest="groupxml",
default=False,
help="Create merged group.xml from all the available patterns.")
help="Create group.xml.")
parser.add_option("-p", "--patterndir", type="string", dest="patterndir",
default=None,
help="Directory where the pattern .yaml files are located.")
Expand All @@ -169,7 +172,11 @@ def merge_patterns(patterns_dir, version, release, outputdir, newobsapi):

(options, args) = parser.parse_args()

if (not options.groupxml and not options.patternxml):
if (options.groupxml):
print "ERROR: Groupxml isn't supported atm."
exit(1)

if (not options.patternsxml and not options.patternxml):
# Default to patternxml.
options.patternxml = True

Expand All @@ -183,5 +190,6 @@ def merge_patterns(patterns_dir, version, release, outputdir, newobsapi):
if options.patternxml:
create_patterns(options.patterndir, options.version, options.release, options.outputdir, options.newobsapi)

if options.groupxml:
if options.patternsxml:
merge_patterns(options.patterndir, options.version, options.release, options.outputdir, options.newobsapi)

7 changes: 7 additions & 0 deletions tests/data/output-patternxml-valid/test5.1.xml
@@ -0,0 +1,7 @@
<pattern xmlns:rpm="http://linux.duke.edu/metadata/rpm" xmlns="http://novell.com/package/metadata/suse/pattern">
<name>test5.1</name>
<summary>Test5.1</summary>
<description>Test decription</description>
<uservisible/>
<category lang="en">Base Group</category>
</pattern>
8 changes: 4 additions & 4 deletions tests/tests.xml
Expand Up @@ -6,10 +6,10 @@
<case name="pattern-test1">
<description>Test default pattern features</description>
<step>rm -rf /tmp/patternxml-test/ /tmp/groupxml-test/</step>
<step>/usr/bin/repomd-pattern-builder.py --output /tmp/patternxml-test/ -p /opt/tests/repomd-pattern-builder/data/patterns/</step>
<step>diff -ruN /tmp/patternxml-test/ /opt/tests/repomd-pattern-builder/data/output-valid/</step>
<step>/usr/bin/repomd-pattern-builder.py --groupxml --output /tmp/groupxml-test/ -p /opt/tests/repomd-pattern-builder/data/patterns/</step>
<step>diff -ruN /tmp/groupxml-test/ /opt/tests/repomd-pattern-builder/data/output-groupxml-valid/</step>
<step>/usr/bin/repomd-pattern-builder.py --patternxml --output /tmp/patternxml-test/ -p /opt/tests/repomd-pattern-builder/data/patterns/</step>
<step>diff -ruN /tmp/patternxml-test/ /opt/tests/repomd-pattern-builder/data/output-patternxml-valid/</step>
<step>/usr/bin/repomd-pattern-builder.py --patternsxml --output /tmp/groupxml-test/ -p /opt/tests/repomd-pattern-builder/data/patterns/</step>
<step>diff -ruN /tmp/groupxml-test/ /opt/tests/repomd-pattern-builder/data/output-patternsxml-valid/</step>
</case>
</set>
</suite>
Expand Down

0 comments on commit 22d9590

Please sign in to comment.