[MOD] Erreur de lecture des fichiers (standard, pas les options)
This commit is contained in:
@ -92,6 +92,15 @@ def allEntryIterator(files,entryIterator,with_progress=False,histo_step=102):
|
||||
for line in sys.stdin:
|
||||
yield line
|
||||
else:
|
||||
import os, stat
|
||||
|
||||
mode = os.fstat(0).st_mode
|
||||
if stat.S_ISFIFO(mode):
|
||||
pass
|
||||
elif stat.S_ISREG(mode):
|
||||
pass
|
||||
else:
|
||||
print>>sys.stderr, "No Entry to process"
|
||||
sys.exit()
|
||||
for entry in entryIterator(sys.stdin):
|
||||
yield entry
|
||||
|
||||
|
@ -45,19 +45,23 @@ def universalOpen(file,*options):
|
||||
@return: an iterator on text lines.
|
||||
'''
|
||||
if isinstance(file,str):
|
||||
if urllib2.urlparse.urlparse(file)[0]=='':
|
||||
rep = open(file,*options)
|
||||
else:
|
||||
rep = urllib2.urlopen(file,timeout=15)
|
||||
try:
|
||||
if urllib2.urlparse.urlparse(file)[0]=='':
|
||||
rep = open(file,*options)
|
||||
else:
|
||||
rep = urllib2.urlopen(file,timeout=15)
|
||||
|
||||
if file[-3:] == '.gz':
|
||||
rep = GzipFile(fileobj=rep)
|
||||
if file[-4:] == '.zip':
|
||||
zip = ZipFile(file=rep)
|
||||
data = zip.infolist()
|
||||
assert len(data)==1,'Only zipped file containning a single file can be open'
|
||||
name = data[0].filename
|
||||
rep = zip.open(name)
|
||||
if file[-3:] == '.gz':
|
||||
rep = GzipFile(fileobj=rep)
|
||||
if file[-4:] == '.zip':
|
||||
zip = ZipFile(file=rep)
|
||||
data = zip.infolist()
|
||||
assert len(data)==1,'Only zipped file containning a single file can be open'
|
||||
name = data[0].filename
|
||||
rep = zip.open(name)
|
||||
except Exception as e:
|
||||
print 'Unexpected error: ', e
|
||||
sys.exit();
|
||||
else:
|
||||
rep = file
|
||||
return rep
|
||||
|
Reference in New Issue
Block a user