[Collab-qa-commits] r1220 - in udd: . udd

lucas at alioth.debian.org lucas at alioth.debian.org
Sun Sep 7 18:59:23 UTC 2008


Author: lucas
Date: 2008-09-07 18:59:22 +0000 (Sun, 07 Sep 2008)
New Revision: 1220

Removed:
   udd/schema/
Modified:
   udd/udd.py
   udd/udd/bugs_gatherer.pl
   udd/udd/gatherer.py
   udd/udd/src_and_pkg_gatherer.py
Log:
drop schemas, code for drop/setup/schema

Modified: udd/udd/bugs_gatherer.pl
===================================================================
--- udd/udd/bugs_gatherer.pl	2008-09-07 18:58:26 UTC (rev 1219)
+++ udd/udd/bugs_gatherer.pl	2008-09-07 18:59:22 UTC (rev 1220)
@@ -92,41 +92,6 @@
 	return (grep { ($h{$_}++ == 0) || 0 } @_);
 }
 
-sub setup {
-	my ($config, $source, $dbh) = @_;
-	my $schema = $config->{general}->{'schema-dir'} . '/' . $config->{$source}->{schema};
-	open SQL, "<",  $schema or die $!;
-	my $command = join "", <SQL>;
-	close SQL;
-	$command =~ s/%\(([^)]+)\)s/$config->{$source}->{$1}/g;
-	$dbh->prepare($command)->execute() or die $!;
-}
-
-sub tables {
-	my ($config, $source, $dbh) = @_;
-	my @ret = ();
-	foreach my $prefix ($config->{$source}->{table}, $config->{$source}->{'archived-table'}) {
-		foreach my $postfix (qw{_merged_with _found_in _fixed_in _tags}, '') {
-			push @ret, "$prefix$postfix";
-		}
-	}
-	unshift @ret, $config->{$source}->{'usertags-table'};
-	return @ret;
-}
-
-
-sub drop {
-	my ($config, $source, $dbh) = @_;
-	map {
-		$dbh->prepare("DROP VIEW $_")->execute() or die $!;
-	}
-	qw{bugs_rt_affects_stable bugs_rt_affects_testing_and_unstable bugs_rt_affects_unstable bugs_rt_affects_testing};
-
-	foreach my $table (tables($config, $source, $dbh)) {
-		$dbh->prepare("DROP TABLE $table")->execute() or die $!;
-	}
-}
-
 sub run_usertags {
 	my ($config, $source, $dbh) = @_;
 	my %src_config = %{$config->{$source}};
@@ -344,12 +309,6 @@
 
 	if($command eq 'run') {
 		run($config, $source, $dbh);
-	} elsif ($command eq 'setup') {
-		setup($config, $source, $dbh);
-	} elsif ($command eq 'drop') {
-		drop($config, $source, $dbh);
-	} elsif ($command eq 'tables') {
-		print join "\n", tables($config, $source, $dbh)
 	} else {
 		print STDERR "<command> has to be one of run, drop and setup\n";
 		exit(1)

Modified: udd/udd/gatherer.py
===================================================================
--- udd/udd/gatherer.py	2008-09-07 18:58:26 UTC (rev 1219)
+++ udd/udd/gatherer.py	2008-09-07 18:59:22 UTC (rev 1220)
@@ -2,6 +2,7 @@
 
 import aux
 import sys
+import psycopg2
 
 class gatherer:
   """
@@ -25,37 +26,6 @@
     """Return the cursor for the current connection"""
     return self.connection.cursor()
 
-  def setup(self):
-    if 'schema-dir' in self.config['general']:
-      schema_dir = self.config['general']['schema-dir']
-      if 'schema' in self.my_config:
-	schema = schema_dir + '/' + self.my_config['schema']
-	self.eval_sql_file(schema, self.my_config)
-      else:
-	raise Exception("'schema' not specified for source " + self.source)
-    else:
-      raise Exception("'schema-dir' not specified")
-
-  def drop(self):
-    for table in self.tables():
-      self.cursor().execute("DROP TABLE " + table)
-
-  def tables(self):
-    if 'table' in self.my_config:
-     return [self.my_config['table']]
-
-
-  def eval_sql_file(self, path, d = None):
-    """Load the SQL code from the file specified by <path>. Use pythons string
-    formating for the dictionary <d> if it is not None
-    Warning: No quoting for the elements of d is done"""
-    c = file(path).read()
-    if d is not None:
-      c = c % d
-
-    cur = self.cursor()
-    cur.execute(c)
-
   def assert_my_config(self, *keywords):
     for k in keywords:
       if not k in self.my_config:

Modified: udd/udd/src_and_pkg_gatherer.py
===================================================================
--- udd/udd/src_and_pkg_gatherer.py	2008-09-07 18:58:26 UTC (rev 1219)
+++ udd/udd/src_and_pkg_gatherer.py	2008-09-07 18:59:22 UTC (rev 1220)
@@ -15,14 +15,3 @@
   def run(self):
     self.src.run()
     self.pkg.run()
-
-  def drop(self):
-    self.src.drop()
-    self.pkg.drop()
-
-  def setup(self):
-    self.src.setup()
-    self.pkg.setup()
-
-  def tables(self):
-    return self.src.tables() + self.pkg.tables()

Modified: udd/udd.py
===================================================================
--- udd/udd.py	2008-09-07 18:58:26 UTC (rev 1219)
+++ udd/udd.py	2008-09-07 18:59:22 UTC (rev 1220)
@@ -20,7 +20,7 @@
     sys.exit(1)
 
   command = sys.argv[2]
-  if command not in ('run', 'setup', 'drop', 'tables', 'update', 'schema'):
+  if command not in ('run', 'update'):
     sys.stderr.write("command has to be one of 'run', 'setup', 'drop', 'update', 'schema' and 'tables'\n")
     sys.exit(1)
 




More information about the Collab-qa-commits mailing list