diff --git a/.gitignore b/.gitignore index c9cc692..496eab0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ /build.sh.lviz *.pyc /build.sh +.coverage +coverage.xml diff --git a/Makefile b/Makefile index 16cc83e..7b40c30 100644 --- a/Makefile +++ b/Makefile @@ -29,14 +29,12 @@ update_version: git add GITHASH.txt && \ git add VERSION.txt && \ git commit -m 'Updated version number' -test: install +test: pip install nose coverage --upgrade - cd efel/tests; nosetests -s -v -x --with-coverage --cover-xml \ - --cover-package efel -test3: install3 + python setup.py nosetests +test3: pip3 install nose coverage --upgrade - cd efel/tests; nosetests-3.4 -s -v -x --with-coverage --cover-xml \ - --cover-package efel + python setup.py nosetests pypi: test pip install twine --upgrade rm -rf dist diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..277c055 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,12 @@ +version: 1.0.{build} +build: + verbosity: minimal +environment: + matrix: + - PYTHON: "C:\\Python27" +build_script: + - "python -m pip install numpy" + - "python setup.py build" +test_script: + - "python -m pip install nose coverage --upgrade" + - "python setup.py nosetests" diff --git a/efel/.gitignore b/efel/.gitignore index 0d20b64..2dbc39f 100644 --- a/efel/.gitignore +++ b/efel/.gitignore @@ -1 +1,2 @@ *.pyc +/cppcore.so diff --git a/efel/io.py b/efel/io.py index b822e95..007dedd 100644 --- a/efel/io.py +++ b/efel/io.py @@ -1,6 +1,12 @@ -"""IO handler for eFEL""" +"""IO handler for eFEL + +This module provides the user-facing Python API of the eFEL. +The convenience functions defined here call the underlying 'cppcore' library +to hide the lower level API from the user. +All functions in this module can be called as efel.functionname, it is +not necessary to include 'api' as in efel.api.functionname. + -""" Copyright (c) 2015, EPFL/Blue Brain Project This file is part of eFEL @@ -19,6 +25,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ + +# pylint: disable=R0912 + import os # Python 2 has urlparse module, Python 3 has urllib.parse @@ -38,20 +47,26 @@ def load_fragment(fragment_url, mime_type=None): Load a fragment (e.g. time series data) from a given URL """ - parsed_url = up.urlparse(fragment_url) + parsed_url = up.urlsplit(fragment_url) scheme = parsed_url.scheme server_loc = parsed_url.netloc - path = parsed_url.path + path = os.path.normpath(parsed_url.path).lstrip('\\') fragment_string = parsed_url.fragment if mime_type is None: mimetypes.init() mime_type, _ = mimetypes.guess_type(path) if mime_type is None: - raise TypeError( - 'load_fragment: impossible to guess MIME type from url, ' - 'please specify the type manually as argument: %s' % path) + _, ext = os.path.splitext(path) + if ext.lower() == '.csv': + mime_type = 'text/csv' + else: + raise TypeError( + 'load_fragment: impossible to guess MIME type from url, ' + 'please specify the type manually as argument: ' + 'path=%s, url=%s' % + (path, fragment_url)) if scheme == 'file': file_handle = open(os.path.join(server_loc, path), 'r') diff --git a/efel/tests/test_basic.py b/efel/tests/test_basic.py index 53faa93..8190942 100644 --- a/efel/tests/test_basic.py +++ b/efel/tests/test_basic.py @@ -32,6 +32,8 @@ """ import os +import urllib +import urlparse import nose.tools as nt @@ -43,14 +45,18 @@ 'testdata') -meanfrequency1_url = 'file://%s' % os.path.join(os.path.abspath(testdata_dir), - 'basic', - 'mean_frequency_1.txt') +meanfrequency1_url = urlparse.urljoin('file:', urllib.pathname2url( + os.path.join( + os.path.abspath(testdata_dir), + 'basic', + 'mean_frequency_1.txt'))) -zeroISIlog1_url = 'file://%s' % os.path.join(os.path.abspath(testdata_dir), - 'basic', - 'zero_ISI_log_slope_skip' - '95824004.abf.csv') +zeroISIlog1_url = urlparse.urljoin('file:', urllib.pathname2url( + os.path.join( + os.path.abspath(testdata_dir), + 'basic', + 'zero_ISI_log_slope_skip' + '95824004.abf.csv'))) def test_import(): diff --git a/setup.cfg b/setup.cfg index 9d2ff1f..8d86c1c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,3 +14,11 @@ parentdir_prefix = # Package support both python 2.6 and 2.7 [bdist_wheel] universal = 1 + +[nosetests] +verbosity=2 +nocapture=1 +detailed-errors=1 +with-coverage=1 +cover-package=efel +cover-xml=1