[Collab-qa-commits] r1122 - in udd: . doc src

neronus-guest at alioth.debian.org neronus-guest at alioth.debian.org
Tue Aug 19 13:55:22 UTC 2008


Author: neronus-guest
Date: 2008-08-19 13:55:21 +0000 (Tue, 19 Aug 2008)
New Revision: 1122

Removed:
   udd/doc/generate_db_schema.pl
Modified:
   udd/TODO
   udd/src/udd.py
Log:
Merged schema output into udd.py


Modified: udd/TODO
===================================================================
--- udd/TODO	2008-08-19 09:43:29 UTC (rev 1121)
+++ udd/TODO	2008-08-19 13:55:21 UTC (rev 1122)
@@ -15,7 +15,6 @@
   - some example queries
 - (prio: medium) primary key for tables which have none yet
 - (prio: high) make udd.py use a default config file, which can be overriden by "-f configfile".
-- (prio: high) merge doc/generate_db_schema.pl into udd-dispatch.py (or udd.py)
 
 packages/sources
 ----------------

Deleted: udd/doc/generate_db_schema.pl
===================================================================
--- udd/doc/generate_db_schema.pl	2008-08-19 09:43:29 UTC (rev 1121)
+++ udd/doc/generate_db_schema.pl	2008-08-19 13:55:21 UTC (rev 1122)
@@ -1,53 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use warnings;
-
-use YAML::Syck;
-
-$YAML::Syck::ImplicitTyping = 1;
-
-sub pyformat {
-	my ($string, %dict) = @_;
-	$string =~ s/%\(([^)]+)\)s/$dict{$1}/g;
-	return $string;
-}
-
-if (@ARGV == 0) {
-	print STDERR "Usage: $0 <config-file> [source 1 [source 2 ...]]\n";
-	exit 1;
-}
-
-my $config = LoadFile($ARGV[0]) or die "Could not load configuration: $!";
-
-my @sources = ();
-if (@ARGV == 1) {
-	@sources = grep { !($_ eq 'general') } keys %{$config};
-} else {
-	@sources = @ARGV[1, $#ARGV];
-}
-
-my $schema_dir = $config->{general}->{'schema-dir'} or die "schema-dir not specified";
-my %schemata = ();
-
-foreach my $source (@sources) {
-	if(not exists $config->{$source}) {
-		print STDERR "No such source: $source\n";
-		exit 1;
-	}
-	my %src_config = %{$config->{$source}};
-	foreach my $schema_tag (qw{schema packages-schema sources-schema}) {
-		if(not exists $src_config{$schema_tag}) {
-			next;
-		}
-		my $schema = "$schema_dir/$src_config{$schema_tag}";
-
-		open SCHEMA, $schema or die "Couldn't read $schema: $!";
-		$schemata{pyformat((join "", <SCHEMA>), %src_config)} = 1;
-		close SCHEMA;
-	}
-}
-
-print join "\n\n", keys %schemata;
-print "\n";
-

Modified: udd/src/udd.py
===================================================================
--- udd/src/udd.py	2008-08-19 09:43:29 UTC (rev 1121)
+++ udd/src/udd.py	2008-08-19 13:55:21 UTC (rev 1122)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# Last-Modified: <Tue Aug 19 09:38:06 2008>
+# Last-Modified: <Tue Aug 19 13:55:40 2008>
 
 """Dispatch udd gatherers
 
@@ -20,8 +20,8 @@
     sys.exit(1)
 
   command = sys.argv[2]
-  if command not in ('run', 'setup', 'drop', 'tables', 'update'):
-    sys.stderr.write("command has to be one of 'run', 'setup', 'drop', 'update' and 'tables'\n")
+  if command not in ('run', 'setup', 'drop', 'tables', 'update', 'schema'):
+    sys.stderr.write("command has to be one of 'run', 'setup', 'drop', 'update', 'schema' and 'tables'\n")
     sys.exit(1)
 
   config = udd.aux.load_config(open(sys.argv[1]).read())
@@ -30,6 +30,7 @@
 
   connection = udd.aux.open_connection(config)
 
+  schemata = {}
   # Process the sources
   for src in sys.argv[3:]:
     src_config = config[src]
@@ -46,6 +47,12 @@
 	    f = open(os.path.join(config['general']['timestamp-folder'], src+".update"), "w")
 	    f.write(asctime())
 	    f.close()
+      elif command == 'schema':
+	for tag in ('schema', 'packages-schema', 'sources-schema'):
+	  if not tag in src_config:
+	    continue
+	  schema = config['general']['schema-dir'] + '/' + src_config[tag]
+	  print (open(schema).read() % src_config)
       else:
 	(src_command,rest) = types[type].split(None, 1)
 	if src_command == "exec":




More information about the Collab-qa-commits mailing list