Annotation of loncom/build/lpml_parse.pl, revision 1.2

1.1       harris41    1: #!/usr/bin/perl
1.2     ! albertel    2: 
        !             3: # Scott Harrison
        !             4: # May 2001
        !             5: # 06/19/2001 - Scott Harrison
        !             6: 
1.1       harris41    7: use HTML::TokeParser;
1.2     ! albertel    8: 
        !             9: my $target = shift @ARGV;
        !            10: my $dist = shift @ARGV;
        !            11: 
        !            12: my @parsecontents = <>;
        !            13: my $parsestring = join('',@parsecontents);
        !            14: my $outstring;
        !            15: 
        !            16: $outstring = &xmlparse($parsestring,$target,$dist);
        !            17: print $outstring;
        !            18: 
        !            19: # -------------------------- Parse for an input string and specific target mode
        !            20: sub xmlparse {
        !            21:     my ($parsestring,$target,$dist)=@_;
        !            22:     my $outtext = '';
        !            23:     my $parser = HTML::TokeParser->new($parsestring);
        !            24:     $parser->xml_mode('1');
        !            25:     # strategy: grab first and pass well-parsed information to info-handler subroutines
        !            26:     # There should be errors if bad file format.
        !            27:     # Unlike other XML-handling strategies we use, this script should
        !            28:     # terminate if the XML is bad.
        !            29:     # grab first (and only) lpml section
        !            30:     # grab target(s) root
        !            31:     # grab source root
        !            32:     # grab categories
        !            33:        # foreach category
        !            34:        # attributes: name and type
        !            35:        # grab chown
        !            36:        # grab chmod
        !            37:          # parse user name and group name
        !            38:     # grab rpm (remember to replace \n with real new lines)
        !            39:        # grab rpmSummary
        !            40:        # grab rpmName
        !            41:        # grab rpmVersion
        !            42:        # grab rpmRelease
        !            43:        # grab rpmVendor
        !            44:        # grab rpmBuildRoot
        !            45:        # grab rpmCopyright
        !            46:        # grab rpmGroup
        !            47:        # grab rpmSource
        !            48:        # grab rpmAutoReqProv
        !            49:        # grab rpmdescription
        !            50:        # grab rpmpre
        !            51:     # grab directories
        !            52:        # foreach directory
        !            53:        # grab targetdir(s)
        !            54:        # grab categoryname
        !            55:        # grab (optional) description
        !            56:     # grab files
        !            57:        # foreach file|link|link|fileglob
        !            58:        # grab source
        !            59:        # grab target(s)
        !            60:        # grab categoryname
        !            61:        # grab description
        !            62:        # grab note
        !            63: }
        !            64: 
        !            65: __END__
1.1       harris41   66: 
                     67: while (my $token = $p->get_tag("category")) {
                     68:     my $url = $token->[1]{name} . $token->[1]{type};
                     69:     my $chmodtoken=$p->get_tag("chmod");
                     70:     my $text = $p->get_trimmed_text("/chmod");
                     71:     print "CHMOD: $text\n";
                     72:     my $text = $p->get_trimmed_text("/category");
                     73:     print "$url\t$text\t".join(" ",@{$token->[2]})."\n";
                     74: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>