Skip to content

Commit

Permalink
Sync with best practices in distribution files.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Dec 6, 2018
1 parent 66422cd commit 3ee4f19
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
include *.rst
include Dockerfile
include .dockerignore
include *.grib
include *.grib2
include *.rst
include Dockerfile
include LICENSE
include Makefile
include tox.ini
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

PACKAGE := cfgrib
IMAGE := $(PACKAGE)
IMAGE := $(PACKAGE)-image
MODULE := $(PACKAGE)
PYTHONS := python3.7 python3.6 python3.5 pypy3 python2.7 pypy
PYTHON := python
Expand All @@ -13,11 +13,11 @@ export PIP_FIND_LINKS := $(WHEELHOUSE)
export PIP_WHEEL_DIR := $(WHEELHOUSE)
export PIP_INDEX_URL

DOCKERBUILDFLAGS :=
DOCKERBUILDFLAGS := --build-arg PIP_INDEX_URL=$(PIP_INDEX_URL)
DOCKERFLAGS := -e WHEELHOUSE=$(WHEELHOUSE) \
-e PIP_FIND_LINKS=$(PIP_FIND_LINKS) \
-e PIP_WHEEL_DIR=$(PIP_WHEEL_DIR) \
-e PIP_INDEX_URL=$$PIP_INDEX_URL
-e PIP_INDEX_URL=$(PIP_INDEX_URL)
PIP := $(PYTHON) -m pip
MKDIR = mkdir -p

Expand Down
11 changes: 11 additions & 0 deletions cfgrib/eccodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ int codes_write_message(codes_handle* h,const char* file,const char* mode);
*/
codes_handle* codes_grib_handle_new_from_samples (codes_context* c, const char* sample_name);

/**
* Create a handle from a BUFR message contained in a samples directory.
* The message is copied at the creation of the handle
*
* @param c : the context from which the handle will be created (NULL for default context)
* @param sample_name : the name of the sample file (without the .tmpl extension)
* @return the new handle, NULL if the resource is invalid or a problem is encountered
*/
codes_handle* codes_bufr_handle_new_from_samples (codes_context* c, const char* sample_name);


/**
* Clone an existing handle using the context of the original handle,
* The message is copied and reparsed
Expand Down
9 changes: 6 additions & 3 deletions cfgrib/eccodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,12 @@ def codes_get_api_version():

def codes_new_from_samples(samplename, product_kind=CODES_PRODUCT_GRIB):
# type: (bytes, int) -> cffi.FFI.CData
if product_kind != CODES_PRODUCT_GRIB:
raise NotImplementedError("Support implemented only for GRIB.")
handle = lib.codes_grib_handle_new_from_samples(ffi.NULL, samplename)
if product_kind == CODES_PRODUCT_GRIB:
handle = lib.codes_grib_handle_new_from_samples(ffi.NULL, samplename)
elif product_kind == CODES_PRODUCT_BUFR:
handle = lib.codes_bufr_handle_new_from_samples(ffi.NULL, samplename)
else:
raise NotImplementedError("product kind not supported: %r" % product_kind)
if handle == ffi.NULL:
raise ValueError("sample not found: %r" % samplename)
return handle
Expand Down
6 changes: 3 additions & 3 deletions cfgrib/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def from_file(cls, file, offset=None, product_kind=eccodes.CODES_PRODUCT_GRIB, *
# type: (T.IO[bytes], int, int, T.Any) -> Message
if offset is not None:
file.seek(offset)
codes_id = eccodes.codes_handle_new_from_file(file, product_kind=product_kind)
codes_id = eccodes.codes_handle_new_from_file(file, product_kind)
return cls(codes_id=codes_id, **kwargs)

@classmethod
def from_sample_name(cls, sample_name, **kwargs):
codes_id = eccodes.codes_new_from_samples(sample_name.encode('ASCII'))
def from_sample_name(cls, sample_name, product_kind=eccodes.CODES_PRODUCT_GRIB, **kwargs):
codes_id = eccodes.codes_new_from_samples(sample_name.encode('ASCII'), product_kind)
return cls(codes_id=codes_id, **kwargs)

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions ci/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
check-manifest
detox
flake8
ipython
IPython
matplotlib
notebook
pip-tools
# pytest-mypy
pyroma
pytest-mypy
setuptools
tox
tox-pyenv
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ setenv = PYTHONPATH = {toxinidir}
deps = -r{toxinidir}/ci/requirements-tests.txt
commands = pytest -v --flakes --cache-clear --basetemp={envtmpdir} {posargs}

[testenv:docs]
deps = -r{toxinidir}/ci/requirements-docs.txt
commands = sphinx-build -W -b html docs build/sphinx/html

[testenv:qc]
basepython = python3.6
# needed for pytest-cov
usedevelop = true
commands = pytest -v --flakes --pep8 --mccabe --cov=cfgrib --cov=cf2cdm --doctest-glob="*.rst" --cov-report=html --cache-clear --basetemp={envtmpdir} {posargs}

[testenv:docs]
deps = -r{toxinidir}/ci/requirements-docs.txt
commands = sphinx-build -W -b html docs build/sphinx/html

[testenv:deps]
deps =
commands = python setup.py test

0 comments on commit 3ee4f19

Please sign in to comment.