[Formed-commits] r400 - trunk/formed/formed/plugins/export
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Sep 30 09:44:14 CEST 2010
Author: torsten
Date: 2010-09-30 09:44:13 +0200 (Thu, 30 Sep 2010)
New Revision: 400
Modified:
trunk/formed/formed/plugins/export/rules_sh.py
Log:
* formed/formed/plugins/export/rules_sh.py (ExportRulesAsSH.doExport): Filter out duplicted rules.
Modified: trunk/formed/formed/plugins/export/rules_sh.py
===================================================================
--- trunk/formed/formed/plugins/export/rules_sh.py 2010-09-20 14:51:38 UTC (rev 399)
+++ trunk/formed/formed/plugins/export/rules_sh.py 2010-09-30 07:44:13 UTC (rev 400)
@@ -120,19 +120,21 @@
# 1. Header
out.append('#!/bin/bash')
out.append("""DATABASES=`psql -t -c "SELECT datname FROM pg_database WHERE datname LIKE 'ka_%';" postgres`""")
- out.append('echo "DB,%s"' % ",".join("q%s" % [str(i) for i in range(0,len(rules))]))
+ out.append('echo "DB,%s"' % ",".join(["%s" % str(i) for i in range(0,len(rules))]))
out.append("for DB in ${DATABASES}")
out.append("do")
- # 2. Querys
+ # 2. Querys
+ known_rules = []
command = 'q%s=`psql -t -c "%s" ${DB}`'
for num, rule in enumerate(rules):
+ rule_str = recursive_parse(rule.getExpr().prog, document)
out.append('# Eval %s' % num)
out.append('# %s' % rule.getDescription())
out.append(command %
- (num, 'select count(id) from master_tbl where not (%s)' %
- recursive_parse(rule.getExpr().prog, document)))
+ (num, 'select count(id) from master_tbl where not (%s)' % rule_str))
out.append('\n')
+ known_rules.append(rule_str)
# 3. Footer
out.append('echo "${DB},%s"' % ",".join(["${q%s}" % str(i) for i in range(0,len(rules))]))
out.append("done")
@@ -169,9 +171,14 @@
out = codecs.open(path, "wb", "UTF-8")
all_rules = list(document.findAllByClass(data.RuleLeaf, mode, allModes))
error_rules = []
+ known_rules = []
for idx, rule in enumerate(all_rules):
if rule.getMark().find('error') < 0: continue
+ # filter out already generated rules.
+ rule_str = recursive_parse(rule.getExpr().prog, document)
+ if rule_str in known_rules: continue
error_rules.append(rule)
+ known_rules.append(rule_str)
sql = generate_analyse(error_rules, document)
print >> out, sql
finally:
More information about the Formed-commits
mailing list