[Collab-qa-commits] r2136 - in udd: sql udd

Andreas Tille tille at alioth.debian.org
Mon Feb 6 21:06:10 UTC 2012


Author: tille
Date: 2012-02-06 21:06:10 +0000 (Mon, 06 Feb 2012)
New Revision: 2136

Modified:
   udd/sql/blends-query-packages.sql
   udd/sql/setup.sql
   udd/sql/upgrade.sql
   udd/udd/aux.py
   udd/udd/ddtp_gatherer.py
Log:
Adapt ddtp gatherer to new way to provide translations


Modified: udd/sql/blends-query-packages.sql
===================================================================
--- udd/sql/blends-query-packages.sql	2012-02-03 08:27:19 UTC (rev 2135)
+++ udd/sql/blends-query-packages.sql	2012-02-06 21:06:10 UTC (rev 2136)
@@ -52,32 +52,32 @@
     FROM (
       SELECT DISTINCT 
              package, distribution, release, component, strip_binary_upload(version) AS version,
-             maintainer, source, section, task, homepage, description, long_description
+             maintainer, source, section, task, homepage, description, long_description, description_md5
         FROM packages
        WHERE package = ANY ($1)
     ) p
     --                                                                                                                                                                   ---+  Ensure we get no old stuff from non-free
     --                                                                                                                                                                      v  packages with different architectures
-    LEFT OUTER JOIN ddtp cs ON cs.language = 'cs' AND cs.package = p.package AND cs.distribution = p.distribution AND cs.release = p.release AND cs.component = p.component AND strip_binary_upload(cs.version) = p.version
-    LEFT OUTER JOIN ddtp da ON da.language = 'da' AND da.package = p.package AND da.distribution = p.distribution AND da.release = p.release AND da.component = p.component AND strip_binary_upload(da.version) = p.version
-    LEFT OUTER JOIN ddtp de ON de.language = 'de' AND de.package = p.package AND de.distribution = p.distribution AND de.release = p.release AND de.component = p.component AND strip_binary_upload(de.version) = p.version
-    LEFT OUTER JOIN ddtp es ON es.language = 'es' AND es.package = p.package AND es.distribution = p.distribution AND es.release = p.release AND es.component = p.component AND strip_binary_upload(es.version) = p.version
-    LEFT OUTER JOIN ddtp fi ON fi.language = 'fi' AND fi.package = p.package AND fi.distribution = p.distribution AND fi.release = p.release AND fi.component = p.component AND strip_binary_upload(fi.version) = p.version
-    LEFT OUTER JOIN ddtp fr ON fr.language = 'fr' AND fr.package = p.package AND fr.distribution = p.distribution AND fr.release = p.release AND fr.component = p.component AND strip_binary_upload(fr.version) = p.version
-    LEFT OUTER JOIN ddtp hu ON hu.language = 'hu' AND hu.package = p.package AND hu.distribution = p.distribution AND hu.release = p.release AND hu.component = p.component AND strip_binary_upload(hu.version) = p.version
-    LEFT OUTER JOIN ddtp it ON it.language = 'it' AND it.package = p.package AND it.distribution = p.distribution AND it.release = p.release AND it.component = p.component AND strip_binary_upload(it.version) = p.version
-    LEFT OUTER JOIN ddtp ja ON ja.language = 'ja' AND ja.package = p.package AND ja.distribution = p.distribution AND ja.release = p.release AND ja.component = p.component AND strip_binary_upload(ja.version) = p.version
-    LEFT OUTER JOIN ddtp ko ON ko.language = 'ko' AND ko.package = p.package AND ko.distribution = p.distribution AND ko.release = p.release AND ko.component = p.component AND strip_binary_upload(ko.version) = p.version
-    LEFT OUTER JOIN ddtp nl ON nl.language = 'nl' AND nl.package = p.package AND nl.distribution = p.distribution AND nl.release = p.release AND nl.component = p.component AND strip_binary_upload(nl.version) = p.version
-    LEFT OUTER JOIN ddtp pl ON pl.language = 'pl' AND pl.package = p.package AND pl.distribution = p.distribution AND pl.release = p.release AND pl.component = p.component AND strip_binary_upload(pl.version) = p.version
-    LEFT OUTER JOIN ddtp pt_BR ON pt_BR.language = 'pt_BR' AND pt_BR.package = p.package AND pt_BR.distribution = p.distribution AND pt_BR.release = p.release AND pt_BR.component = p.component AND strip_binary_upload(pt_BR.version) = p.version
-    LEFT OUTER JOIN ddtp ru ON ru.language = 'ru' AND ru.package = p.package AND ru.distribution = p.distribution AND ru.release = p.release AND ru.component = p.component AND strip_binary_upload(ru.version) = p.version
-    LEFT OUTER JOIN ddtp sk ON sk.language = 'sk' AND sk.package = p.package AND sk.distribution = p.distribution AND sk.release = p.release AND sk.component = p.component AND strip_binary_upload(sk.version) = p.version
-    LEFT OUTER JOIN ddtp sr ON sr.language = 'sr' AND sr.package = p.package AND sr.distribution = p.distribution AND sr.release = p.release AND sr.component = p.component AND strip_binary_upload(sr.version) = p.version
-    LEFT OUTER JOIN ddtp sv ON sv.language = 'sv' AND sv.package = p.package AND sv.distribution = p.distribution AND sv.release = p.release AND sv.component = p.component AND strip_binary_upload(sv.version) = p.version
-    LEFT OUTER JOIN ddtp uk ON uk.language = 'uk' AND uk.package = p.package AND uk.distribution = p.distribution AND uk.release = p.release AND uk.component = p.component AND strip_binary_upload(uk.version) = p.version
-    LEFT OUTER JOIN ddtp zh_CN ON zh_CN.language = 'zh_CN' AND zh_CN.package = p.package AND zh_CN.distribution = p.distribution AND zh_CN.release = p.release AND zh_CN.component = p.component AND strip_binary_upload(zh_CN.version) = p.version
-    LEFT OUTER JOIN ddtp zh_TW ON zh_TW.language = 'zh_TW' AND zh_TW.package = p.package AND zh_TW.distribution = p.distribution AND zh_TW.release = p.release AND zh_TW.component = p.component AND strip_binary_upload(zh_TW.version) = p.version
+    LEFT OUTER JOIN ddtp cs ON cs.language = 'cs' AND cs.package = p.package AND cs.release = p.release  AND cs.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp da ON da.language = 'da' AND da.package = p.package AND da.release = p.release  AND da.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp de ON de.language = 'de' AND de.package = p.package AND de.release = p.release  AND de.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp es ON es.language = 'es' AND es.package = p.package AND es.release = p.release  AND es.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp fi ON fi.language = 'fi' AND fi.package = p.package AND fi.release = p.release  AND fi.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp fr ON fr.language = 'fr' AND fr.package = p.package AND fr.release = p.release  AND fr.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp hu ON hu.language = 'hu' AND hu.package = p.package AND hu.release = p.release  AND hu.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp it ON it.language = 'it' AND it.package = p.package AND it.release = p.release  AND it.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp ja ON ja.language = 'ja' AND ja.package = p.package AND ja.release = p.release  AND ja.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp ko ON ko.language = 'ko' AND ko.package = p.package AND ko.release = p.release  AND ko.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp nl ON nl.language = 'nl' AND nl.package = p.package AND nl.release = p.release  AND nl.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp pl ON pl.language = 'pl' AND pl.package = p.package AND pl.release = p.release  AND pl.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp pt_BR ON pt_BR.language = 'pt_BR' AND pt_BR.package = p.package AND pt_BR.release = p.release AND pt_BR.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp ru ON ru.language = 'ru' AND ru.package = p.package AND ru.release = p.release  AND ru.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp sk ON sk.language = 'sk' AND sk.package = p.package AND sk.release = p.release  AND sk.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp sr ON sr.language = 'sr' AND sr.package = p.package AND sr.release = p.release  AND sr.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp sv ON sv.language = 'sv' AND sv.package = p.package AND sv.release = p.release  AND sv.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp uk ON uk.language = 'uk' AND uk.package = p.package AND uk.release = p.release  AND uk.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp zh_CN ON zh_CN.language = 'zh_CN' AND zh_CN.package = p.package AND zh_CN.release = p.release AND zh_CN.description_md5 = p.description_md5
+    LEFT OUTER JOIN ddtp zh_TW ON zh_TW.language = 'zh_TW' AND zh_TW.package = p.package AND zh_TW.release = p.release AND zh_TW.description_md5 = p.description_md5
     -- extract one single package with highest version and release
     JOIN (
       -- select packages which have versions outside experimental
@@ -200,17 +200,14 @@
 CREATE OR REPLACE FUNCTION ddtp_unique(text, text[]) RETURNS SETOF RECORD AS $$
   SELECT DISTINCT d.package, d.description, d.long_description FROM ddtp d
     JOIN (
-      SELECT dr.package, dr.version, (SELECT release FROM releases WHERE sort = MAX(r.sort)) AS release FROM ddtp dr
-        JOIN (
-          SELECT package, MAX(version) AS version FROM ddtp WHERE language = $1 AND package = ANY ($2) GROUP BY package
-        ) duv ON duv.package = dr.package AND duv.version = dr.version
+      SELECT dr.package, (SELECT release FROM releases WHERE sort = MAX(r.sort)) AS release FROM ddtp dr
         JOIN releases r ON dr.release = r.release
         WHERE language = $1 AND dr.package = ANY ($2)
-        GROUP BY dr.package, dr.version
+        GROUP BY dr.package
     -- sometimes there are different translations of the same package version in different releases
     -- because translators moved on working inbetween releases but we need to select only one of these
     -- (the last one)
-    ) duvr ON duvr.package = d.package AND duvr.version = d.version AND duvr.release = d.release
+    ) duvr ON duvr.package = d.package AND duvr.release = d.release
     WHERE language = $1 AND d.package = ANY ($2)
  $$ LANGUAGE 'SQL';
 

Modified: udd/sql/setup.sql
===================================================================
--- udd/sql/setup.sql	2012-02-03 08:27:19 UTC (rev 2135)
+++ udd/sql/setup.sql	2012-02-06 21:06:10 UTC (rev 2136)
@@ -603,25 +603,12 @@
 
 CREATE TABLE ddtp (
        package      text,
-       distribution text,
        release      text,
-       component    text,   -- == 'main' for the moment
-       version      debversion,   -- different versions for a package might exist because some archs
-                            -- might have problems with newer versions if a new version comes
-                            -- with a new description we might have different translations for
-                            -- a (package, distribution, release, component, language) key so
-                            -- we also need to store the version number of a package translation
-                            -- In case there are different versions with an identical description
-                            -- this field will hold the highest version number according to
-                            -- dpkg --compare-versions
        language     text,
        description  text,
        long_description text,
-       md5sum       text,   -- md5 sum of the original English description as it is used
-                            -- in DDTP.  This is obtained via
-                            --   md5(description || E'\n' || long_description || E'\n')
-                            -- from packages table
-    PRIMARY KEY (package, distribution, release, component, version, language)
+       description_md5  text, -- md5 sum of the original English description
+    PRIMARY KEY (package, release, language, description, description_md5)
 );
 
 GRANT SELECT ON ddtp TO PUBLIC;

Modified: udd/sql/upgrade.sql
===================================================================
--- udd/sql/upgrade.sql	2012-02-03 08:27:19 UTC (rev 2135)
+++ udd/sql/upgrade.sql	2012-02-06 21:06:10 UTC (rev 2136)
@@ -350,3 +350,18 @@
 ALTER TABLE packages add description_md5 text;
 ALTER TABLE ubuntu_packages add description_md5 text;
 ALTER TABLE derivatives_packages add description_md5 text;
+
+-- 2012-02-06
+-- Translation files are now featuring description_md5 fields which enable
+-- more easy determination of package entries
+DROP TABLE ddtp;
+CREATE TABLE ddtp (
+       package      text,
+       release      text,
+       language     text,
+       description  text,
+       long_description text,
+       description_md5  text, -- md5 sum of the original English description
+    PRIMARY KEY (package, release, language, description, description_md5)
+);
+GRANT SELECT ON ddtp TO PUBLIC;

Modified: udd/udd/aux.py
===================================================================
--- udd/udd/aux.py	2012-02-03 08:27:19 UTC (rev 2135)
+++ udd/udd/aux.py	2012-02-06 21:06:10 UTC (rev 2136)
@@ -15,7 +15,7 @@
   "Quote a string for SQL and encode it to UTF-8 if it is a unicode string"
   if isinstance(s, unicode):
     s = s.encode('utf-8')
-  return "'" + s.replace("\\", "\\\\").replace("'", "\\'") + "'"
+  return "'" + s.replace("\\", "\\\\").replace("'", "''") + "'"
 
 def null_or_quote(dict, key):
   "If key is an element of dict, return it quoted. Return NULL otherwise"

Modified: udd/udd/ddtp_gatherer.py
===================================================================
--- udd/udd/ddtp_gatherer.py	2012-02-03 08:27:19 UTC (rev 2135)
+++ udd/udd/ddtp_gatherer.py	2012-02-06 21:06:10 UTC (rev 2136)
@@ -4,11 +4,7 @@
 This script imports translations from the Debian Description
 translation project into the database.  It parses the translation
 files at
-     http://ddtp.debian.net/Translation_udd
-which are enriched by the version numbers of the packages that
-are described which makes it qut simple to assotiate a primary
-key to the translation even if it might be redundant information
-because you have the MD5sum of the descriptions
+    http://ftp.debian.org/debian/dists/${release}/${component}/i18n/
 """
 
 from aux import quote
@@ -23,7 +19,7 @@
 from filecmp import cmp
 import gzip
 import bz2
-from psycopg2 import IntegrityError, InternalError
+from psycopg2 import IntegrityError, InternalError, ProgrammingError
 
 import logging
 import logging.handlers
@@ -41,13 +37,11 @@
 class ddtp():
   def __init__(self, package, release, language):
     self.package          = package
-    self.distribution     = 'debian' # No DDTP translations for debian-backports / debian-volatile
     self.release          = release
-    self.component        = 'main'   # Only main translated for the moment
     self.language         = language
     self.description      = ''
     self.long_description = ''
-    self.md5sum           = ''
+    self.description_md5  = ''
     self.version          = ''
 
   def __str__(self):
@@ -76,52 +70,21 @@
 
     cur = self.cursor()
     query = "PREPARE ddtp_delete (text, text) AS DELETE FROM %s WHERE release = $1 AND language = $2" % my_config['table']
-    # self.log.debug("execute query %s", query)
+    self.log.debug("execute query %s", query)
     cur.execute(query)
     query = """PREPARE ddtp_insert AS INSERT INTO %s
-                   (package, distribution, component, release, language, version, description, long_description, md5sum)
-                    VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)""" % (my_config['table'])
-    # self.log.debug("execute query %s", query)
+                   (package, release, language, description, long_description, description_md5)
+                    VALUES ($1, $2, $3, $4, $5, $6)""" % (my_config['table'])
+    self.log.debug("execute query %s", query)
     cur.execute(query)
 
-    query = """PREPARE ddtp_check_before_insert (text, text, text, text, text, text) AS
+    query = """PREPARE ddtp_check_before_insert (text, text, text, text, text) AS
                   SELECT COUNT(*) FROM %s
-                    WHERE package = $1 AND distribution = $2 AND component = $3 AND
-                          release = $4 AND language = $5 AND version = $6""" % (my_config['table'])
+                    WHERE package = $1 AND release = $2 AND language = $3 AND 
+                          description = $4 AND description_md5 = $5""" % (my_config['table'])
     # self.log.debug("execute query %s", query)
     cur.execute(query)
 
-    query = """PREPARE ddtp_get_duplicate (text, text, text, text, text, text) AS
-                  SELECT description, long_description, md5sum FROM %s
-                    WHERE package = $1 AND distribution = $2 AND component = $3 AND
-                          release = $4 AND language = $5 AND version = $6""" % (my_config['table'])
-    # self.log.debug("execute query %s", query)
-    cur.execute(query)
-
-    # Query for english package description of the i386 architecture because this is the
-    # most popular arch.  In case a package description might differ in very seldom cases
-    # we put the translation of the i386 architecture into UDD
-    query = """PREPARE ddtp_packages_recieve_description_md5 (text, text, text, text, text) AS 
-               SELECT md5(full_description || E'\n' ) AS md5,
-               full_description FROM (
-                 SELECT DISTINCT
-                   description || E'\n' || long_description AS full_description
-                  FROM packages
-                  WHERE package = $1 AND distribution = $2 AND component = $3 AND
-                  release = $4 AND version = $5 AND architecture in ('all', 'i386', 'amd64')
-               ) AS tmp GROUP BY full_description LIMIT 1"""
-    # self.log.debug("execute query %s", query)
-    cur.execute(query)
-
-    # In some cases a just imported translation has to be removed again because
-    # of a further translation which matches MD5 sum of i386 architecture
-    query = """PREPARE ddtp_delete_duplicate(text, text, text, text, text, text) AS 
-               DELETE FROM %s
-                    WHERE package = $1 AND distribution = $2 AND component = $3 AND
-                          release = $4 AND language = $5 AND version = $6""" % (my_config['table'])
-    # self.log.debug("execute query %s", query)
-    cur.execute(query)
-
     pkg = None
 
   def run(self):
@@ -149,19 +112,24 @@
         md5file=dir + 'Translation-' + lang + '.md5'
         try:
           if ( cmp(md5file, md5file + '.prev' ) ):
-            # self.log.debug("%s has not changed.  No update needed.", md5file)
+            self.log.debug("%s has not changed.  No update needed.", md5file)
             continue
           else:
-            # self.log.debug("%s changed.  Go on updating language %s", md5file, lang)
+            self.log.debug("%s changed.  Go on updating language %s (%s)", md5file, lang, rel)
             pass
         except OSError:
-          self.log.info('md5file for %s missing,  Go updating', lang)
+          self.log.info('md5file for language %s in release %s missing -> Go updating', lang, rel)
 
         # Delete only records where we actually have Translation files.  This
         # prevents dump deletion of all data in case of broken downloads
-        query = "EXECUTE ddtp_delete (%s, %s)" % (quote(rel), quote(lang))
-        # self.log.debug("execute query %s", query)
-        cur.execute(query)
+        cur.execute('EXECUTE ddtp_delete (%s, %s)', (rel, lang))
+        self.log.debug('EXECUTE ddtp_delete (%s, %s)', (rel, lang))
+        
+        if debug == 1:
+    	  cur.execute("SELECT COUNT(*) FROM ddtp WHERE release = '%s' AND language = '%s'" % (rel, lang))
+          if cur.rowcount > 0:
+            remaining = cur.fetchone()[0]
+            self.log.debug("Remaining translations for language %s in release %s: %s" %(lang, rel, str(remaining)))
 
         i18n_error_flag=0
         descstring = 'Description-'+lang
@@ -173,85 +141,54 @@
           for stanza in deb822.Sources.iter_paragraphs(g, shared_storage=False):
             if i18n_error_flag == 1:
               continue
-            self.pkg             = ddtp(stanza['package'], rel, lang)
-            self.pkg.md5sum      = stanza['Description-md5']
-            self.pkg.version     = stanza['Version']
+            self.pkg                 = ddtp(stanza['package'], rel, lang)
+            self.pkg.description_md5 = stanza['Description-md5']
             try:
               desc               = stanza[descstring]
             except KeyError, err:
-              self.log.error("file=%s%s, pkg=%s, version=%s (%s)" % (dir, filename, self.pkg.package, self.pkg.version, err))
+              self.log.error("file=%s%s, pkg=%s, description_md5=%s (%s)" % (dir, filename, self.pkg.package, self.pkg.description_md5, err))
               i18n_error_flag=1
               continue
             lines                = desc.splitlines()
             try:
               self.pkg.description = lines[0]
             except IndexError, err:
-              self.log.exception("Did not found first line in description: file=%s%s, pkg=%s, version=%s" % (dir, filename, self.pkg.package, self.pkg.version))
+              self.log.exception("Did not found first line in description: file=%s%s, pkg=%s, description_md5=%s" % (dir, filename, self.pkg.package, self.pkg.description_md5))
               i18n_error_flag=1
               continue
             for line in lines[1:]:
               self.pkg.long_description += line + "\n"
-            query = "EXECUTE ddtp_check_before_insert (%s, %s, %s, %s, %s, %s)" % \
-                    tuple([quote(item) for item in (self.pkg.package, self.pkg.distribution, self.pkg.component, 
-                     self.pkg.release, self.pkg.language, self.pkg.version)])
-            # self.log.debug("execute query %s", query)
-            try:
-              cur.execute(query)
-            except InternalError, err:
-              self.log.exception("Encoding problem reading %s%s", dir, filename)
-              i18n_error_flag=1
-              continue
+
+            query = "EXECUTE ddtp_check_before_insert (%s, %s, %s, %s, %s)" % \
+                        tuple([quote(item) for item in (self.pkg.package, \
+                         self.pkg.release, self.pkg.language, self.pkg.description, \
+                         self.pkg.description_md5)])
+            cur.execute(query)
             if cur.fetchone()[0] > 0:
-              self.log.debug("Just imported key in language %s: (%s)", self.pkg.language,
-                             ", ".join([self.pkg.package, self.pkg.distribution, self.pkg.component, self.pkg.release,
-                                      self.pkg.version, self.pkg.description, self.pkg.md5sum]))
-              query = " EXECUTE ddtp_packages_recieve_description_md5 (%s, %s, %s, %s, %s)" % \
-                    tuple([quote(item) for item in (self.pkg.package, self.pkg.distribution, self.pkg.component, \
-                     self.pkg.release, self.pkg.version)])
-              self.log.debug("execute query %s", query)
-              cur.execute(query)
-              if cur.rowcount <= 0:
-                self.log.warning("Did not find description for most frequent architectures in %s",
-                                 ", ".join([self.pkg.package, self.pkg.distribution, self.pkg.component,
-                                            self.pkg.release, self.pkg.version]))
+              self.log.error("Duplicated key in release %s in language %s for package %s: %s", \
+                              self.pkg.release, self.pkg.language, self.pkg.package, self.pkg.description_md5)
+            else:
+              query = "EXECUTE ddtp_insert (%s, %s, %s, %s, %s, %s)" % \
+                        tuple([quote(item) for item in (self.pkg.package, \
+                         self.pkg.release, self.pkg.language, self.pkg.description, \
+                         self.pkg.long_description, self.pkg.description_md5)])
+              try:
+                self.log.debug("execute query %s", query)
+                cur.execute(query)
+                # self.connection.commit() # commit every single insert as long as translation files are featuring duplicated keys
+              except IntegrityError, err:
+                self.log.exception("Duplicated key in language %s: (%s)", self.pkg.language,
+                                 ", ".join([to_unicode(item) for item in (self.pkg.package, self.pkg.release, self.pkg.description, self.pkg.description_md5)]))
+                self.connection.rollback()
                 continue
-
-              md5sum = cur.fetchone()[0]
-              if  md5sum.startswith(self.pkg.md5sum):
-                self.log.debug("Correct translation is just in the Database.")
+              except ProgrammingError, err:
+                self.log.exception("Problem inserting translation %s: (%s)", self.pkg.language,
+                                 ", ".join([to_unicode(item) for item in (self.pkg.package, self.pkg.release, self.pkg.description, self.pkg.description_md5)]))
+                self.connection.rollback()
                 continue
-
-              query = "EXECUTE ddtp_get_duplicate (%s, %s, %s, %s, %s, %s)" % \
-                    tuple([quote(item) for item in (self.pkg.package, self.pkg.distribution, self.pkg.component, \
-                     self.pkg.release, self.pkg.language, self.pkg.version)])
-              # self.log.debug("execute query %s", query)
-              cur.execute(query)
-              for r in cur.fetchall():
-                if md5sum.startswith(r[2]):
-                  query = "EXECUTE ddtp_delete_duplicate (%s, %s, %s, %s, %s, %s)" % \
-                      tuple([quote(item) for item in (self.pkg.package, self.pkg.distribution, self.pkg.component, \
-                       self.pkg.release, self.pkg.language, self.pkg.version)])
-                  # self.log.debug("execute query %s", query)
-                  cur.execute(query)
-
-            query = "EXECUTE ddtp_insert (%s, %s, %s, %s, %s, %s, %s, %s, %s)" % \
-                        tuple([quote(item) for item in (self.pkg.package, self.pkg.distribution, \
-                         self.pkg.component, self.pkg.release, \
-                         self.pkg.language, self.pkg.version, \
-                         self.pkg.description, \
-                         self.pkg.long_description, \
-                         self.pkg.md5sum)])
-            try:
-              # self.log.debug("execute query %s", query)
-              cur.execute(query)
-            except IntegrityError, err:
-              self.log.exception("Duplicated key in language %s: (%s)", self.pkg.language,
-                                 ", ".join([to_unicode(item) for item in (self.pkg.package, self.pkg.version, self.pkg.description, self.pkg.md5sum)]))
-              self.connection.rollback()
-              continue
         except IOError, err:
           self.log.exception("Error reading %s%s", dir, filename)
-        # commit every successfully language to make sure we get any languages in an willnot be blocked by a single failing import
+        # commit every successfully language to make sure we get any languages in an will not be blocked by a single failing import
         self.connection.commit()
 
     cur.execute("DEALLOCATE ddtp_insert")




More information about the Collab-qa-commits mailing list