소스 검색

Update Dpkg::Changelog and Dpkg::Index to use Dpkg::Interface::Storable

Raphaël Hertzog 16 년 전
부모
커밋
69e9305c84
2개의 변경된 파일과 8개의 추가작업 그리고 29개의 파일을 삭제
  1. 6 9
      scripts/Dpkg/Changelog.pm
  2. 2 20
      scripts/Dpkg/Index.pm

+ 6 - 9
scripts/Dpkg/Changelog.pm

@@ -44,8 +44,9 @@ use Dpkg::Index;
 use Dpkg::Version;
 use Dpkg::Version;
 use Dpkg::Vendor qw(run_vendor_hook);
 use Dpkg::Vendor qw(run_vendor_hook);
 
 
+use base qw(Dpkg::Interface::Storable);
+
 use overload
 use overload
-    '""'  => sub { return $_[0]->output() },
     '@{}' => sub { return $_[0]->{data} };
     '@{}' => sub { return $_[0]->{data} };
 
 
 =over 4
 =over 4
@@ -74,14 +75,6 @@ Parse $filename as a changelog.
 
 
 =cut
 =cut
 
 
-sub load {
-    my ($self, $file) = @_;
-    open(my $fh, "<", $file) or syserr(_g("cannot read %s"), $file);
-    my $ret = $self->parse($fh, $file);
-    close($fh);
-    return $ret;
-}
-
 =item $c->set_options(%opts)
 =item $c->set_options(%opts)
 
 
 Change the value of some options. "verbose" (defaults to 1) defines
 Change the value of some options. "verbose" (defaults to 1) defines
@@ -432,6 +425,10 @@ sub abort_early {
     return;
     return;
 }
 }
 
 
+=item $c->save($filename)
+
+Save the changelog in the given file.
+
 =item $c->output()
 =item $c->output()
 
 
 =item "$c"
 =item "$c"

+ 2 - 20
scripts/Dpkg/Index.pm

@@ -23,9 +23,10 @@ use Dpkg::ErrorHandling;
 use Dpkg::Control;
 use Dpkg::Control;
 use Dpkg::Compression::FileHandle;
 use Dpkg::Compression::FileHandle;
 
 
+use base qw(Dpkg::Interface::Storable);
+
 use overload
 use overload
     '@{}' => sub { return $_[0]->{'order'} },
     '@{}' => sub { return $_[0]->{'order'} },
-    '""' => sub { return $_[0]->output() },
     fallback => 1;
     fallback => 1;
 
 
 =head1 NAME
 =head1 NAME
@@ -151,16 +152,6 @@ sub add {
 Reads the file and creates all items parsed. Returns the number of items
 Reads the file and creates all items parsed. Returns the number of items
 parsed. Handles compressed files transparently based on their extensions.
 parsed. Handles compressed files transparently based on their extensions.
 
 
-=cut
-
-sub load {
-    my ($self, $file) = @_;
-    my $cf = Dpkg::Compression::FileHandle->new(filename => $file);
-    my $res = $self->parse($cf, $file);
-    close($cf) || syserr(_g("cannot close %s"), $file);
-    return $res;
-}
-
 =item $index->parse($fh, $desc)
 =item $index->parse($fh, $desc)
 
 
 Reads the filehandle and creates all items parsed. Returns the number of
 Reads the filehandle and creates all items parsed. Returns the number of
@@ -185,15 +176,6 @@ sub parse {
 Writes the content of the index in a file. Auto-compresses files
 Writes the content of the index in a file. Auto-compresses files
 based on their extensions.
 based on their extensions.
 
 
-=cut
-
-sub save {
-    my ($self, $file) = @_;
-    my $cf = Dpkg::Compression::FileHandle->new(filename => $file);
-    $self->output($cf);
-    close($cf) || syserr(_g("cannot close %s"), $file);
-}
-
 =item my $item = $index->new_item()
 =item my $item = $index->new_item()
 
 
 Creates a new item. Mainly useful for derived objects that would want
 Creates a new item. Mainly useful for derived objects that would want