Changeset 2280
- Timestamp:
- 08/30/19 18:37:00 (5 years ago)
- Location:
- trunk/LATMOS-Accounts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/bin/la-dump
r2278 r2280 76 76 'u|username=s' => \my $username, 77 77 'help' => sub { pod2usage(0) }, 78 'f=s' => \my $filename, 78 79 ) or pod2usage(); 79 80 … … 93 94 foreach (@result) { 94 95 my $o = $labase->get_object($otype, $_) or next; 95 push(@Dump, $o->DataDump({ recur => $recur, SubOtype => \@SubOtype })); 96 push(@Dump, $o->DataDump( 97 { 98 recur => $recur, 99 SubOtype => \@SubOtype, 100 noSchema => 1, 101 } 102 )); 96 103 } 97 104 98 require Data::Dumper; 99 print Data::Dumper::Dumper(\@Dump); 105 @fmt = qw(xml) unless (@fmt); 100 106 101 107 foreach my $Format (@fmt) { … … 105 111 for ($Format) { 106 112 /^xml$/ and do { 107 require XML::Simple; 113 eval { 114 require XML::Simple; 115 }; 116 if ($@) { 117 warn "Cannot output xml: XML::Simple perl module missing"; 118 next; 119 } 108 120 my $xml = XML::Simple->new(); 109 121 $string = $xml->XMLout(\@Dump); 110 122 next; 123 }; 124 /^json$/ and do { 125 eval { 126 require JSON; 127 }; 128 if ($@) { 129 warn "Cannot output xml: XML::Simple perl module missing"; 130 next; 131 } 132 my $json = JSON->new; 133 $json->indent(1); 134 $string = $json->encode(\@Dump); 135 next; 136 }; 137 /^yaml$/ and do { 138 eval { 139 require YAML; 140 }; 141 if ($@) { 142 warn "Cannot output xml: XML::Simple perl module missing"; 143 next; 144 } 145 $string = YAML::Dump(\@Dump); 146 next; 147 }; 148 /^pl$/ and do { 149 require Data::Dumper; 150 $string = Data::Dumper::Dumper(\@Dump); 111 151 } 112 152 } 113 153 114 print $string; 154 if ($filename) { 155 my $realFilename = $filename . '.' . $Format; 156 open(my $handle, '>', $realFilename) or do { 157 warn "Cannot open $realFilename for wrinting"; 158 next; 159 }; 160 print $handle $string; 161 close($handle); 162 } else { 163 print $string; 164 } 115 165 } 116 166 -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm
r2278 r2280 882 882 } 883 883 884 $dump->{roAttrs} = [ sort keys %roAttrs ]; 884 $dump->{roAttrs} = [ sort keys %roAttrs ] 885 unless($config->{noSchema}); 885 886 } 886 887
Note: See TracChangeset
for help on using the changeset viewer.