releasing/makecbr/COutputHandler.pm
author kelvzhu
Fri, 12 Nov 2010 17:02:24 +0800
changeset 681 240a07ea3a13
parent 602 3145852acc89
permissions -rw-r--r--
change featuredatabase.xml back
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# COutputHandler
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
package COutputHandler;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use XML::Simple;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use File::Basename;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use File::Spec;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use constant CBROUTPUTFILE => File::Spec->catdir(File::Basename::dirname("$INC{'COutputHandler.pm'}"), 'CBROutputFile.xml');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
sub new {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
    my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
    my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
    bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
    $self->ParseOutputFile();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
    return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
sub CheckOutput {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
    my $line = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
    chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
    my $amendedLine = $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
    $amendedLine =~ s/^-?\s?(error|warning|remark|fatal error):?\s+//i;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
    foreach my $type ('Error', 'Remark', 'Warning') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
        foreach my $toMatch (@{$self->{file}->{$type}}) {           
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
            if ($amendedLine =~ /^$toMatch$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
                return uc($type) . ": $amendedLine\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
            }           
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
    # did not match, return original line
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
    return "$line\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
sub ParseOutputFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
    $self->{file} = XMLin(CBROUTPUTFILE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
    # Compile the regular expressions
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
    foreach my $type ('Error', 'Remark', 'Warning') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
       @{$self->{file}->{$type}} = map { qr/$_/i } @{$self->{file}->{$type}}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
=pod
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
COutputHandler.pm
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
A module that checks output from the CBR Tools and promotes requested errors, warnings and remarks to scanlog compatible versions.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
 use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
 use COutputHandler;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
 # Instantiate implementation of COutputHandler
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
 my $outputHandler = COutputHandler->new();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
 # Pass the string through CheckOutput before printing it to the log
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
 $aLine = $outputHandler->CheckOutput($aLine);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
 print $aLine;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
=head2 Object Management
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
=head3 new
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
To be called without any arguments.  Will parse the XML file containing error, warning and remark messages.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
=head2 Data Management
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
=head3 CheckOuput
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
To be passed a string.  The string is checked to see if it needs to be made scanlog compatible, and if so it is modified and returned.  If not then the original string is returned.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
=head3 ParseOutputFile
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
Parses the XML file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
Copyright (c) 2007 Symbian Software Ltd. All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
=cut