Show
Ignore:
Timestamp:
10/06/08 00:22:07 (16 years ago)
Author:
jerome
Message:

Removed spaces at EOL.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/pkpgpdls/pjl.py

    r3410 r3436  
    88# the Free Software Foundation, either version 3 of the License, or 
    99# (at your option) any later version. 
    10 #  
     10# 
    1111# This program is distributed in the hope that it will be useful, 
    1212# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414# GNU General Public License for more details. 
    15 #  
     15# 
    1616# You should have received a copy of the GNU General Public License 
    1717# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     
    3535        return self.message 
    3636    __str__ = __repr__ 
    37          
     37 
    3838class PJLParser : 
    3939    """A parser for PJL documents. 
    40      
     40 
    4141       Information extracted for bpl11897.pdf which was 
    4242       downloaded from Hewlett-Packard's website. 
     
    5252        self.parsed = 0 
    5353        self.parse() 
    54          
    55     def __str__(self) :     
     54 
     55    def __str__(self) : 
    5656        """Outputs our variables as a string of text.""" 
    5757        if not self.parsed : 
     
    6262            for (k, v) in self.default_variables.items() : 
    6363                mybuffer.append("  %s : %s" % (k, v)) 
    64         if self.environment_variables :         
     64        if self.environment_variables : 
    6565            mybuffer.append("Environment variables :") 
    6666            for (k, v) in self.environment_variables.items() : 
    6767                mybuffer.append("  %s : %s" % (k, v)) 
    68         return "\n".join(mybuffer)         
    69              
    70     def logdebug(self, message) :     
     68        return "\n".join(mybuffer) 
     69 
     70    def logdebug(self, message) : 
    7171        """Logs a debug message if needed.""" 
    7272        if self.debug : 
    7373            sys.stderr.write("%s\n" % message) 
    74              
    75     def cleanvars(self) :         
     74 
     75    def cleanvars(self) : 
    7676        """Cleans the variables dictionnaries.""" 
    7777        for dicname in ("default", "environment") : 
     
    8080                if len(v) == 1 : 
    8181                    varsdic[k] = v[0] 
    82          
     82 
    8383    def parse(self) : 
    8484        """Parses a JL job.""" 
     
    9595                                  or ((self.jlmarker == "@EJL") and (parts[1].upper() == "JI"))) : 
    9696                        # this is what we are interested in ! 
    97                         try :     
     97                        try : 
    9898                            (varname, value) = "".join(parts[2:]).split("=", 1) # TODO : parse multiple assignments on the same SET/JI statement 
    99                         except :     
     99                        except : 
    100100                            self.logdebug("Invalid JL SET statement [%s]" % repr(statement)) 
    101                         else :     
     101                        else : 
    102102                            # all still looks fine... 
    103103                            if parts[1].upper() == "DEFAULT" : 
    104104                                varsdic = self.default_variables 
    105                             else :     
    106                                 varsdic = self.environment_variables  
     105                            else : 
     106                                varsdic = self.environment_variables 
    107107                            variable = varsdic.setdefault(varname.upper(), []) 
    108108                            variable.append(value) 
     
    121121        self.parsed = 1 
    122122        # self.logdebug("%s\n" % str(self)) 
    123          
     123 
    124124class EJLParser(PJLParser) : 
    125125    """A parser for EJL (Epson Job Language) documents.""" 
    126126    JL = "EJL" 
    127          
    128 def test() :         
     127 
     128def test() : 
    129129    """Test function.""" 
    130130    if (len(sys.argv) < 2) or ((not sys.stdin.isatty()) and ("-" not in sys.argv[1:])) : 
     
    135135            infile = sys.stdin 
    136136            mustclose = 0 
    137         else :     
     137        else : 
    138138            if arg.endswith(".ejl") : 
    139139                klass = EJLParser 
     
    142142        try : 
    143143            parser = klass(infile.read(), debug=1) 
    144         except PJLParserError, msg :     
     144        except PJLParserError, msg : 
    145145            sys.stderr.write("ERROR: %s\n" % msg) 
    146146            sys.stderr.flush() 
    147         if mustclose :     
     147        if mustclose : 
    148148            infile.close() 
    149         print str(parser)             
    150      
    151 if __name__ == "__main__" :     
     149        print str(parser) 
     150 
     151if __name__ == "__main__" : 
    152152    test()