diff --git a/Makefile b/Makefile index 70cc54d..c5b57ba 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ ext: python setup.py build_ext --inplace test: - python -m pytest + python -m pytest tests clean: find pyModeS/decoder -type f -name '*.c' -delete diff --git a/pyModeS/__init__.py b/pyModeS/__init__.py index 4dacfcd..488cb89 100644 --- a/pyModeS/__init__.py +++ b/pyModeS/__init__.py @@ -2,11 +2,11 @@ import os import warnings try: - from .decoder import c_common as common - from .decoder.c_common import * + from . import c_common as common + from .c_common import * except: - from .decoder import common - from .decoder.common import * + from . import common + from .common import * from .decoder import tell from .decoder import adsb @@ -15,6 +15,9 @@ from .decoder import bds from .extra import aero from .extra import tcpclient +from .encoder import encode_adsb + + warnings.simplefilter("once", DeprecationWarning) dirpath = os.path.dirname(os.path.realpath(__file__)) diff --git a/pyModeS/decoder/c_common.pxd b/pyModeS/c_common.pxd similarity index 100% rename from pyModeS/decoder/c_common.pxd rename to pyModeS/c_common.pxd diff --git a/pyModeS/decoder/c_common.pyx b/pyModeS/c_common.pyx similarity index 100% rename from pyModeS/decoder/c_common.pyx rename to pyModeS/c_common.pyx diff --git a/pyModeS/decoder/common.py b/pyModeS/common.py similarity index 98% rename from pyModeS/decoder/common.py rename to pyModeS/common.py index 47ecb94..cb2df95 100644 --- a/pyModeS/decoder/common.py +++ b/pyModeS/common.py @@ -41,10 +41,8 @@ def crc(msg, encode=False): # the CRC generator G = [int("11111111", 2), int("11111010", 2), int("00000100", 2), int("10000000", 2)] - if encode and isinstance(msg, str): + if encode: msg = msg[:-6] + "000000" - elif encode: - msg = msg[:-6] + b"000000" msgbin = hex2bin(msg) msgbin_split = wrap(msgbin, 8) diff --git a/pyModeS/decoder/bds/__init__.py b/pyModeS/decoder/bds/__init__.py index 14b9959..d6e0163 100644 --- a/pyModeS/decoder/bds/__init__.py +++ b/pyModeS/decoder/bds/__init__.py @@ -21,12 +21,7 @@ Common functions for Mode-S decoding import numpy as np from pyModeS.extra import aero - -try: - from pyModeS.decoder import c_common as common -except: - from pyModeS.decoder import common - +from pyModeS import common from pyModeS.decoder.bds import ( bds05, diff --git a/setup.py b/setup.py index 20aba5d..3affbfc 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ from setuptools import setup, find_packages from setuptools.extension import Extension from Cython.Build import cythonize -extensions = [Extension("pyModeS.decoder.c_common", ["pyModeS/decoder/c_common.pyx"])] +extensions = [Extension("pyModeS.c_common", ["pyModeS/c_common.pyx"])] # To use a consistent encoding diff --git a/tests/test_common.py b/tests/test_common.py index 571b0cf..6149ca4 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,4 +1,4 @@ -from pyModeS.decoder import common +from pyModeS import common def test_conversions():