]> mj.ucw.cz Git - pciids.git/blob - scripts/export.pl
Prefix is only with toplevel device classes
[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, description 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         print "$tabs$prefix$id  $name\n";
25         if( defined( $description ) && ( $description ne '' ) ) {
26                 chomp $description;
27                 $description =~ s/\n/\n$tabs#/g;
28                 print "$tabs#$description\n";
29         }
30 }
31
32 $db->commit();