Changeset 494 for pkpgcounter
- Timestamp:
- 11/21/07 21:27:40 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/plain.py
r493 r494 35 35 """Returns True if data is plain text, else False. 36 36 37 It's hard to detect a plain text file, so we just 38 read the first line, and if it doesn't end in CR or LF 39 we consider it's not plain text. 40 41 TODO : use first and last block's content instead of readline(). 37 It's hard to detect a plain text file, so we just try to 38 extract lines from the first block (sufficiently large). 39 If it's impossible to find one we consider it's not plain text. 42 40 """ 43 line = self.infile.readline() 44 self.infile.seek(0) 45 if line.endswith("\n") or line.endswith("\r") : 41 lines = firstblock.split("\r\n") 42 if len(lines) == 1 : 43 lines = lines[0].split("\r") 44 if len(lines) == 1 : 45 lines = lines[0].split("\n") 46 if len(lines) > 1 : 46 47 self.logdebug("DEBUG: Input file seems to be in the plain text format.") 47 48 return True