home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_1143 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  1.1 KB  |  28 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL 3'
  5. __copyright__ = '2009, John Schember <john@nachtimwald.com>'
  6. __docformat__ = 'restructuredtext en'
  7. import os
  8.  
  9. class TxtNewlines(object):
  10.     NEWLINE_TYPES = {
  11.         'system': os.linesep,
  12.         'unix': '\n',
  13.         'old_mac': '\r',
  14.         'windows': '\r\n' }
  15.     
  16.     def __init__(self, newline_type):
  17.         self.newline = self.NEWLINE_TYPES.get(newline_type.lower(), os.linesep)
  18.  
  19.  
  20.  
  21. def specified_newlines(newline, text):
  22.     text = text.replace('\r\n', '\n')
  23.     text = text.replace('\r', '\n')
  24.     if newline == '\n':
  25.         return text
  26.     return text.replace('\n', newline)
  27.  
  28.