This should really raise an error if file not found
This commit is contained in:
@@ -18,14 +18,13 @@ import struct
|
|||||||
import StringIO
|
import StringIO
|
||||||
import os
|
import os
|
||||||
import numpy
|
import numpy
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
# decorator to handle filename or object as first parameter
|
# decorator to handle filename or object as first parameter
|
||||||
def _file_loader(func):
|
def _file_loader(func):
|
||||||
|
@wraps(func)
|
||||||
def wrapper(fileobj, *args):
|
def wrapper(fileobj, *args):
|
||||||
if isinstance(fileobj, basestring):
|
if isinstance(fileobj, basestring):
|
||||||
if not os.path.isfile(fileobj):
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Is actually a filename
|
# Is actually a filename
|
||||||
fileobj = open(fileobj, 'rb',4096)
|
fileobj = open(fileobj, 'rb',4096)
|
||||||
return func(fileobj, *args)
|
return func(fileobj, *args)
|
||||||
|
|||||||
Reference in New Issue
Block a user