Show
Ignore:
Timestamp:
09/27/08 22:02:37 (16 years ago)
Author:
jerome
Message:

Removed unnecessary spaces at EOL.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/cups.py

    r3411 r3413  
    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/>. 
     
    2525try : 
    2626    from pkipplib import pkipplib 
    27 except ImportError :         
     27except ImportError : 
    2828    raise RuntimeError, "The python-pkipplib module is now mandatory. You can download pkipplib from http://www.pykota.com/" 
    2929 
    30 class JobTicket :     
     30class JobTicket : 
    3131    """A class to hold CUPS print job informations.""" 
    3232    def __init__(self, jobid=None, printername=None, copies=1, filename=None, \ 
     
    5050        if self.JobId is not None : 
    5151            self.retrieveAttributesFromCUPS() 
    52          
    53     def getAttributeTypeAndValue(self, ippanswer, attribute, category="job") :     
     52 
     53    def getAttributeTypeAndValue(self, ippanswer, attribute, category="job") : 
    5454        """Retrieves a particular attribute's type and value from an IPP answer. 
    55          
     55 
    5656           Returns a tuple of the form (type, value). 
    5757        """ 
    5858        try : 
    5959            return getattr(ippanswer, category)[attribute][0] 
    60         except KeyError :     
     60        except KeyError : 
    6161            return (None, None) 
    62              
     62 
    6363    def retrieveAttributesFromCUPS(self) : 
    6464        """Retrieve attribute's values from CUPS.""" 
     
    7777        (dummy, self.TimeAtProcessing) = self.getAttributeTypeAndValue(answer, "time-at-processing") 
    7878        (dummy, self.MimeType) = self.getAttributeTypeAndValue(answer, "document-format") 
    79          
    80         for attrib in ("OriginatingUserName",  
     79 
     80        for attrib in ("OriginatingUserName", 
    8181                       "OriginatingHostName", 
    82                        "Title",  
     82                       "Title", 
    8383                       "BillingCode", 
    8484                       "PrinterName", 
     
    8787                       "UUID", 
    8888                       "MimeType") : 
    89             try :            
    90                 setattr(self, attrib,  
     89            try : 
     90                setattr(self, attrib, 
    9191                              getattr(self, attrib).decode("UTF-8", "replace")) 
    92             except AttributeError :                   
     92            except AttributeError : 
    9393                pass 
    94                  
     94 
    9595        self.OriginalUserName = self.OriginatingUserName[:] 
    96      
    97 if __name__ == "__main__" :     
     96 
     97if __name__ == "__main__" : 
    9898    import sys 
    9999    if len(sys.argv) != 2 : 
    100100        sys.stderr.write("usage : python cups.py jobid\n") 
    101     else :     
     101    else : 
    102102        job = JobTicket(int(sys.argv[1]), "FakePrinter") 
    103         for attribute in ("PrinterName", "Charset", "JobId", "Copies",  
    104                           "FileName", "OriginatingUserName",  
    105                           "Title", "BillingCode", "OriginatingHostName",  
    106                           "TimeAtCreation", "TimeAtProcessing", "UUID",  
     103        for attribute in ("PrinterName", "Charset", "JobId", "Copies", 
     104                          "FileName", "OriginatingUserName", 
     105                          "Title", "BillingCode", "OriginatingHostName", 
     106                          "TimeAtCreation", "TimeAtProcessing", "UUID", 
    107107                          "MimeType") : 
    108108            sys.stdout.write("%s : %s\n" % (attribute, repr(getattr(job, attribute))))