Python-Bytecode-SAX

 view release on metacpan or  search on metacpan

lib/Python/Bytecode/SAX.pm  view on Meta::CPAN

=head1 NAME

Python::Bytecode::SAX - Process Python bytecode, generating SAX events.

=head1 SYNOPSIS

  use Python::Bytecode::SAX;
  use XML::SAX::Writer;
  my $handler = XML::SAX::Writer->new( Output => 'foo.xml' );
  my $parser = Python::Bytecode::SAX->new( Handler => $handler, SAX => 2 );
  $parser->parse_file('foo.pyc');

Or

  use Python::Bytecode::SAX;
  use XML::Handler::YAWriter;
  my $handler = XML::Handler::YAWriter->new(
      AsFile => 'foo.xml',
      Pretty  => {
          CompactAttrIndent  => 1,
          PrettyWhiteIndent  => 1,
          PrettyWhiteNewline => 1,
          CatchEmptyElement  => 1
      }
  );
  my $parser = Python::Bytecode::SAX->new( Handler => $handler, SAX => 1 );
  $parser->parse_file('foo.pyc');

=head1 DESCRIPTION

This module reads and decodes a Python bytecode file, generating SAX1 or SAX2
events (SAX1 is the default) for what it finds.

Until more documentation is written, you can examine the two XML files generated
in the F<t/> directory by C<make test> to get a feel for the overal structure and
the element and attribute names.

=head1 HISTORY

Based on the L<Python::Bytecode> module by Simon Cozens E<lt>simon@cpan.orgE<gt>,
which is based on the F<dis.py> file in the Python Standard Library.

=head1 SEE ALSO

L<Python::Bytecode> by Simon Cozens E<lt>simon@cpan.orgE<gt>.

=head1 AUTHOR

Gregor N. Purdy E<lt>gregor@focusresearch.comE<gt>

=head1 COPYRIGHT

Copyright (C) 2003 Gregor N. Purdy. All rights reserved.

=head1 LICENSE

This program is free software. Its use is subject to the same license as Perl.

=cut

package Python::Bytecode::SAX;
use 5.6.0;

our $VERSION = '0.1';

use strict;
use Data::Dumper;
use Carp;

use overload '""' => sub { my $obj = shift; 
    "<Code object ".$obj->{name}.", file ".$obj->{filename}." line ".$obj->{lineno}." at ".sprintf('0x%x>',0+$obj);
    }, "0+" => sub { $_[0] }, fallback => 1;

my $no_main_yet;


#
# new()
#



( run in 1.643 second using v1.01-cache-2.11-cpan-97f6503c9c8 )