projects
/
perl-cwmp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r278@brr: dpavlin | 2007-11-26 00:17:17 +0100
[perl-cwmp.git]
/
bin
/
dump2test.pl
diff --git
a/bin/dump2test.pl
b/bin/dump2test.pl
index
40edb4d
..
e1c7498
100755
(executable)
--- a/
bin/dump2test.pl
+++ b/
bin/dump2test.pl
@@
-11,6
+11,7
@@
use Data::Dump qw/dump/;
use File::Slurp;
use blib;
use CWMP::Request;
use File::Slurp;
use blib;
use CWMP::Request;
+use YAML::Syck;
my $path = shift @ARGV || die "usage: $0 dump/client_ip/\n";
my $path = shift @ARGV || die "usage: $0 dump/client_ip/\n";
@@
-37,14
+38,19
@@
warn "## requests = ",dump( $requests );
my $test_path = 't/dump/';
my $test_path = 't/dump/';
+sub xml2state {
+ my $xml = shift;
+ $xml =~ s/^.*?</</s;
+ return CWMP::Request->parse( $xml );
+}
+
if ( my $i = $requests->{Inform} ) {
my $xml = read_file($i);
if ( my $i = $requests->{Inform} ) {
my $xml = read_file($i);
- $xml =~ s/^.*?</</s;
# warn "## xml: $xml\n";
# warn "## xml: $xml\n";
- my $state =
CWMP::Request->pars
e( $xml );
+ my $state =
xml2stat
e( $xml );
# warn "## state = ",dump( $state );
# warn "## state = ",dump( $state );
@@
-67,6
+73,8
@@
foreach my $name ( keys %$requests ) {
my $to = "$test_path/$name";
warn "## $from -> $to\n";
next if -e $to;
my $to = "$test_path/$name";
warn "## $from -> $to\n";
next if -e $to;
- write_file( $to, read_file( $from ) );
+ my $xml = read_file( $from );
+ write_file( $to, $xml );
+ DumpFile( "$to.yml", xml2state( $xml ) );
warn "created $to\n";
}
warn "created $to\n";
}