Author: mcbrown
Date: 2007-03-13 12:52:57 +0100 (Tue, 13 Mar 2007)
New Revision: 5326
Log:
Updating ID Mapping tools from main trunk
Modified:
branches/telcos/tools/IDMap.pm
branches/telcos/tools/idmap.pl
Modified: branches/telcos/tools/IDMap.pm
===================================================================
--- branches/telcos/tools/IDMap.pm 2007-03-13 11:15:48 UTC (rev 5325)
+++ branches/telcos/tools/IDMap.pm 2007-03-13 11:52:57 UTC (rev 5326)
Changed blocks: 1, Lines Added: 101, Lines Deleted: 13; 3785 bytes
@@ -46,27 +46,115 @@
open(IDMAP,$file) or croak "Could not load ID map file $file: $!\n";
- while(my $line = <IDMAP>)
+ my @lines = <IDMAP>;
+
+ close(IDMAP);
+
+ if (scalar @lines == 0)
{
- chomp $line;
- my ($id,$type,$parent,$srcfile,$urlbase,$title) = split /:/,$line,6;
+ return;
+ }
- if (exists($self->{$id}))
+ my $version = 0;
+
+ if (defined($lines[0]) &&
+ $lines[0] =~ m/^!!!mapversion:([0-9]+)!!!$/)
+ {
+ $version = $1;
+ shift @lines;
+
+ }
+
+ my ($srcfile,$repository,$docbase,
+ $docversion,$doclang,$urlbase,
+ ) =
+ (undef,undef,undef,
+ undef,undef,undef,
+ );
+
+# if ($version == 0)
+# {
+# carp "Old ID Map version detected\n";
+# }
+
+ if ($version == 1)
+ {
+ if ($lines[0] =~ m/^!!!INFO!!!(.*?)$/)
{
- push @{$self->{$id}->{adds}},$prefix;
+ my ($infoline) = ($1);
+ ($srcfile,$docbase,
+ $docversion,$doclang,$urlbase)
+ = split /:/,$infoline,5;
+ shift @lines;
}
else
{
- $self->{$id} = {id => $id,
- type => $type,
- parent => $parent,
- file => $srcfile,
- prefix => $prefix,
- urlbase => $urlbase,
- title => $title,
- };
+ croak "You have a version $version ID Map but without a valid header; regenerate the ID map for $file and try again!\n";
}
}
+
+ $self->{'__idmap_version__'} = $version;
+
+ foreach my $line (@lines)
+ {
+ chomp $line;
+
+ my ($id,$type,$parent,
+ $title) =
+ (undef,undef,undef,
+ undef);
+
+ if ($version == 0)
+ {
+ ($id,$type,$parent,$srcfile,$urlbase,$title) = split /:/,$line,6;
+
+ if (exists($self->{$id}))
+ {
+ push @{$self->{$id}->{adds}},$prefix;
+ }
+ else
+ {
+ $self->{$id} = {id => $id,
+ type => $type,
+ parent => $parent,
+ file => $srcfile,
+ prefix => $prefix,
+ urlbase => $urlbase,
+ title => $title,
+ idmapversion => $version,
+ };
+ }
+ }
+ elsif ($version == 1)
+ {
+ ($id,$type,$parent,
+ $title) =
+ split /:/,$line,4;
+
+ my $record = {id => $id,
+ type => $type,
+ parent => $parent,
+ file => $srcfile,
+ prefix => $prefix,
+ docbase => $docbase,
+ docversion => $docversion,
+ doclang => $doclang,
+ urlbase => $urlbase,
+ title => $title,
+ idmapversion => $version,
+ };
+
+ if (exists($self->{$id}))
+ {
+ push @{$self->{$id}->{adds}},$prefix;
+ $self->{$id}->{alts}->{$prefix} = $record;
+ }
+ else
+ {
+ $self->{$id} = $record;
+ }
+ }
+ }
}
1;
Modified: branches/telcos/tools/idmap.pl
===================================================================
--- branches/telcos/tools/idmap.pl 2007-03-13 11:15:48 UTC (rev 5325)
+++ branches/telcos/tools/idmap.pl 2007-03-13 11:52:57 UTC (rev 5326)
Changed blocks: 4, Lines Added: 15, Lines Deleted: 3; 1436 bytes
@@ -12,7 +12,7 @@
use File::Path;
use Getopt::Long;
-#my $entities = {};
+my $idmapversion = 1;
my $opt_reconcile = 0;
@@ -53,6 +53,17 @@
my $urlbase = shift;
+my ($docbase,$docversion,$doclang) = ('','','');
+my @elems = split(m{/},$urlbase);
+if (scalar @elems == 3)
+{
+ ($docbase,$docversion,$doclang) = ($elems[0],$elems[1],$elems[2]);
+}
+else
+{
+ ($docbase,$doclang) = ($elems[0],$elems[1]);
+}
+
my $filemap = {};
if ($opt_reconcile)
@@ -105,6 +116,9 @@
open(MAP,">$maptempfile") or die "Couldn't open map destination file ($mapfile): $!";
+ print MAP "!!!mapversion:1!!!\n";
+ printf MAP "!!!INFO!!!%s\n",join(':',$file,$docbase,$docversion,$doclang,$urlbase);
+
foreach my $id (sort { $a cmp $b } keys %{$my_handler->{ids}})
{
if (!defined($id) || $id eq '')
@@ -119,8 +133,6 @@
$id,
$my_handler->{ids}->{$id}->{type} || '',
$my_handler->{ids}->{$id}->{sectionparent} || '',
- $file || '',
- $urlbase || '',
$my_handler->{ids}->{$id}->{title} || $id),
"\n");
}
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r5326 - branches/telcos/tools | mcbrown | 13 Mar |