[kde-services-devel] r508 - trunk/commitfilter/rules
josef at new.kstuff.org
josef at new.kstuff.org
Sun Apr 19 14:43:54 CEST 2009
Author: josef
Date: 2009-04-19 14:43:54 +0200 (Sun, 19 Apr 2009)
New Revision: 508
Added:
trunk/commitfilter/rules/simple.xml
Modified:
trunk/commitfilter/rules/cia2eximfilter
Log:
- fixed CIA rule generation
Modified: trunk/commitfilter/rules/cia2eximfilter
===================================================================
--- trunk/commitfilter/rules/cia2eximfilter 2009-04-18 16:53:07 UTC (rev 507)
+++ trunk/commitfilter/rules/cia2eximfilter 2009-04-19 12:43:54 UTC (rev 508)
@@ -10,6 +10,8 @@
str = convert_or([doc.root])
when "and":
str = convert_and([doc.root])
+ when "not":
+ str = convert_not([doc.root])
else
str = convert_match([doc.root])
end
@@ -17,46 +19,57 @@
end
def convert_or(items)
- if not items then return [] end
- exitems = []
+ if items.length == 0 then return [] end
+ exitems_or = []
items.each do |item|
+ exitems = []
exitems += convert_or(item/"/or")
exitems += convert_and(item/"/and")
exitems += convert_not(item/"/not")
exitems += convert_match(item/"/match")
- end
- exitems_or = ""
- exitems.each do |exitem|
- if exitems_or != ""
- exitems_or += " or "
+
+ exitem_or = ""
+ exitems.each do |exitem|
+ if exitem_or != ""
+ exitem_or += " or "
+ end
+ exitem_or += "#{exitem}"
end
- exitems_or += "#{exitem}"
+ if exitems.length > 1
+ exitem_or = "(" + exitem_or + ")"
+ end
+ exitems_or << exitem_or
end
- return [exitems_or]
+ return exitems_or
end
def convert_and(items)
- if not items then return [] end
- exitems = []
+ if items.length == 0 then return [] end
+ exitems_and = []
items.each do |item|
- ##puts "**" + item
+ exitems = []
exitems += convert_or(item/"/or")
exitems += convert_and(item/"/and")
exitems += convert_not(item/"/not")
exitems += convert_match(item/"/match")
- end
- exitems_and = ""
- exitems.each do |exitem|
- if exitems_and != ""
- exitems_and += " and "
+
+ exitem_and = ""
+ exitems.each do |exitem|
+ if exitem_and != ""
+ exitem_and += " and "
+ end
+ exitem_and += "#{exitem}"
end
- exitems_and += "#{exitem}"
+ if exitems.length > 1
+ exitem_and = "(" + exitem_and + ")"
+ end
+ exitems_and << exitem_and
end
- return [exitems_and]
+ return exitems_and
end
def convert_not(items)
- if not items then return [] end
+ if items.length == 0 then return [] end
exitems = []
items.each do |item|
exitems += convert_or(item/"/or")
@@ -64,15 +77,11 @@
exitems += convert_not(item/"/not")
exitems += convert_match(item/"/match")
end
- exitems_not = "not("
+ exitems_not = []
exitems.each do |exitem|
- if exitems_not != "not("
- exitems_not += " and "
- end
- exitems_not += "#{exitem}"
+ exitems_not << "not#{exitem}"
end
- exitems_not += ")"
- return [exitems_not]
+ return exitems_not
end
def convert_match(items)
@@ -80,7 +89,6 @@
items.each do |item|
path = item.attributes["path"]
match = (item/"text()").to_s.strip
- #puts "PATH", path, match.strip
case path
when "author":
exitems << "(author = '#{match}')"
@@ -97,7 +105,12 @@
end
end
-doc = open("example.xml") do |f|
+rulefile = ARGV[0]
+if not rulefile
+ rulefile = "example.xml"
+end
+
+doc = open(rulefile) do |f|
doc = Hpricot.XML(f)
c2e = CIA2Exim.new
Added: trunk/commitfilter/rules/simple.xml
===================================================================
--- trunk/commitfilter/rules/simple.xml (rev 0)
+++ trunk/commitfilter/rules/simple.xml 2009-04-19 12:43:54 UTC (rev 508)
@@ -0,0 +1,9 @@
+<or>
+
+ <and>
+ <match path="author"> micah </match>
+ <not><match path="project"> kde </match></not>
+ <match path="url"> foo </match>
+ </and>
+
+</or>
More information about the kde-services-devel
mailing list