commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/reports/src/adapters/filters/Standard/Base...


From: Jason Cater
Subject: gnue/reports/src/adapters/filters/Standard/Base...
Date: Mon, 07 Apr 2003 04:45:51 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    03/04/07 04:45:51

Modified files:
        reports/src/adapters/filters/Standard/Base/psutils: 
                                                            
PrinterDefinition.py 

Log message:
        more work

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/adapters/filters/Standard/Base/psutils/PrinterDefinition.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: 
gnue/reports/src/adapters/filters/Standard/Base/psutils/PrinterDefinition.py
diff -c 
gnue/reports/src/adapters/filters/Standard/Base/psutils/PrinterDefinition.py:1.6
 
gnue/reports/src/adapters/filters/Standard/Base/psutils/PrinterDefinition.py:1.7
*** 
gnue/reports/src/adapters/filters/Standard/Base/psutils/PrinterDefinition.py:1.6
    Mon Apr  7 04:25:04 2003
--- 
gnue/reports/src/adapters/filters/Standard/Base/psutils/PrinterDefinition.py    
    Mon Apr  7 04:45:51 2003
***************
*** 32,47 ****
  from gnue.common.utils.FileUtils import openResource
  
  
  class InvalidPPDFormat(StandardError):
    pass
  
  class PrinterDefinition:
  
    def __init__(self, location):
!     self.applyFile(location)
  
  
!   def applyFile(self, location):
  
      # Get a file handle.
      # location can be either a string, or a buffer
--- 32,51 ----
  from gnue.common.utils.FileUtils import openResource
  
  
+ # Just what its name implies...
  class InvalidPPDFormat(StandardError):
    pass
  
+ #
+ # PrinterDefinition
+ #
  class PrinterDefinition:
  
    def __init__(self, location):
!     self.loadFile(location)
  
  
!   def loadFile(self, location):
  
      # Get a file handle.
      # location can be either a string, or a buffer
***************
*** 119,153 ****
            # Get rid of the closing quote
            data = data.strip()[:-1]
  
!           # If this was a Keyword/Option pair, then the PPD spec
!           # allows for the string to contain hex characters
!           # encoded as <ff> (i.e., inside brackets)
!           if Option and data.find('<') >= 0:
              # expand hex references using the "re" module.
              # (we've precompiled these functions at the end)
              data = _hexre.sub(_hexToBinary, data)
  
-         # Treat as a string
-         datatype = 'S'
  
-       # Empty string is, of course, NoValue
-       elif not len(data):
-         datatype = None
- 
-       # Anything else is a plain string
-       else:
-         # Good ol' string type
-         datatype = 'S'
  
        # Handle any imports
        if keyword == 'Import':
!         self.applyFile(data)
  
  
        line = handle.readline()
  
  
!     # If we opened a file, close it. 
      if close:
        handle.close()
  
--- 123,149 ----
            # Get rid of the closing quote
            data = data.strip()[:-1]
  
!           # If this was not a Keyword/Option pair, then the PPD spec
!           # allows for the string to contain hex characters encoded
!           # as <ff> (i.e., inside brackets.)  Does not apply to
!           # Keyword/Option pairs, as <> can be PS commands
!           if not option and data.find('<') >= 0:
              # expand hex references using the "re" module.
              # (we've precompiled these functions at the end)
              data = _hexre.sub(_hexToBinary, data)
  
  
  
        # Handle any imports
        if keyword == 'Import':
!         self.loadFile(data)
  
  
+       # Next in line, please!
        line = handle.readline()
  
  
!     # If we opened a file, close it.
      if close:
        handle.close()
  
***************
*** 158,165 ****
  def _hexToBinary( match ):
    s = str(match.group())[1:-1]
    rs = ""
!   for i in range(len(s)/2):
!     rs += chr(float('0x' + s[i*2:i*2+2]))
    return rs
  
  # Precompile our regular expression
--- 154,165 ----
  def _hexToBinary( match ):
    s = str(match.group())[1:-1]
    rs = ""
!   try:
!     for i in range(len(s)/2):
!       rs += chr(float('0x' + s[i*2:i*2+2]))
!   except ValueError:
!     raise InvalidPPDFormat, 'Not a hexadecimal value: <%s>' % s
! 
    return rs
  
  # Precompile our regular expression




reply via email to

[Prev in Thread] Current Thread [Next in Thread]