Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
OBITools
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
25
Issues
25
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools
Commits
cdffb415
Commit
cdffb415
authored
Apr 22, 2014
by
Frédéric Boyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MOD] Erreur de lecture des fichiers (standard, pas les options)
parent
2f7ac4b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
14 deletions
+27
-14
_options.pyx
src/obitools/options/_options.pyx
+10
-1
__init__.py
src/obitools/utils/__init__.py
+17
-13
No files found.
src/obitools/options/_options.pyx
View file @
cdffb415
...
...
@@ -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
src/obitools/utils/__init__.py
View file @
cdffb415
...
...
@@ -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
)
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
)
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
)
except
Exception
as
e
:
print
'Unexpected error: '
,
e
sys
.
exit
();
else
:
rep
=
file
return
rep
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment