]> mj.ucw.cz Git - pciids.git/blob - scripts/export.pl
Fix export
[pciids.git] / scripts / export.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 BEGIN {
6         unshift @INC, ".";
7 }
8 use PciIds::Db;
9 use PciIds::DBQAny;
10
11 my $db = PciIds::DBQAny::new( connectDb(), {
12         'list' => 'SELECT id, name, note FROM locations WHERE name IS NOT NULL ORDER BY id'
13 } );
14
15 foreach( @{$db->query( 'list', [] )} ) {
16         my( $id, $name, $description ) = @{$_};
17         $_ = $id;
18         my $prefix = ( /^PD\/..$/ ) ? 'C ' : '';
19         s/^P.\///;
20         s/[^\/]//g;
21         s/\//\t/g;
22         my $tabs = $_;
23         $id =~ s/.*\///;
24         $id =~ s/([0-9a-f]{4})([0-9a-f]{4})/$1 $2/;
25         print "$tabs$prefix$id  $name\n";
26         if( defined( $description ) && ( $description ne '' ) ) {
27                 chomp $description;
28                 $description =~ s/\n/\n$tabs#/g;
29                 print "$tabs# $description\n";
30         }
31 }
32
33 $db->commit();