-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump_db
executable file
·144 lines (99 loc) · 2.53 KB
/
dump_db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/local/bin/perl
use strict;
use warnings;
use Morsulus::Ordinary::Classic;
use Morsulus::Ordinary::Legacy;
use Getopt::Euclid;
use Data::Dumper;
use Try::Tiny;
$Data::Dumper::Pair = ":";
my $ord = Morsulus::Ordinary::Classic->new(dbname => $ARGV{-db});
my $search = {};
if ($ARGV{-regdate})
{
#s/^(.*)$/"$1"/ for (@{$ARGV{-regdate}});
$search->{registration_date} = [ @{$ARGV{-regdate}} ];
}
if ($ARGV{-regonly})
{
$search->{release_date} = '';
}
if ($ARGV{-armonly})
{
$search->{text_blazon_id} = { '!=', undef };
}
if ($ARGV{-anydate})
{
if (keys %$search)
{
die "can't mix -anydate with other args";
}
else
{
$search = [ { registration_date => [ @{$ARGV{-anydate}} ] },
{ release_date => [ @{$ARGV{-anydate}} ] } ];
}
}
if ($ARGV{-regid})
{
$search->{reg_id} = {-in => $ARGV{-regid} }
}
if ($ARGV{-verbose})
{
print STDERR Dumper($search);
}
my $regs = $ord->Registration->search($search);
while (my $reg = $regs->next)
{
#print STDERR
my $item = $ord->get_registration($reg);
next if $ARGV{-nodescs} and $item->descs;
print $ord->get_registration($reg)->canonicalize->to_string, "\n";
}
__END__
=head1 NAME
dump_db - script to dump database files to legacy format
=head1 SYNOPSIS
dump_db -db mydb.db -o oanda.db # dump the whole enchilada
dump_db -db newdb.db -regdate 201301 # extract registrations to STDOUT
For full or partial extracts. Options for partial extracts will grow as
needed. Syntax to be made up on the fly...
=head1 REQUIRED
=over
=item -db <file>
SQLite database file to be created or updated with Ordinary entries.
=for Euclid:
file.type: writable
=back
=head1 OPTIONS
=over
=item -o <file>
Destination for extracted records. Defaults to STDOUT.
=for Euclid:
file.type: writable
file.default: '-'
=item -regdate <regdate>
Extract records with this registration date. Multiple instances
give multiple months. Format is YYYYMM.
=for Euclid:
repeatable
regdate.type: /[0-9]{6}/
=item -anydate <regdate>
Extract records with this registration or release date. Multiple instances
give multiple months. Format is YYYYMM.
=for Euclid:
repeatable
regdate.type: /[0-9]{6}/
=item -regonly
Limit items to those without a release date.
=item -armonly
Limit items to those with armory.
=item -nodescs
Limit items to those without descs.
=item -regid <regid>...
Extract the specific registrations by ID.
=for Euclid:
regid.type: integer
=item -verbose
Emit generous output as you go.
=back