diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 018e03c444e1e8869d5828426f56a8b30c3afa7a..fd36b4ff33648a752ceb1078c6e3a563d0ab68d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - test - build + - deploy pages: stage: build @@ -58,17 +59,33 @@ test_python311: .build_python: only: - - master + - tags + except: + - branches stage: build script: - pip install --break-system-packages --upgrade Cython setuptools pip - pip install --break-system-packages -r requirements.txt - python setup.py bdist_wheel - cp dist/*.whl . + after_script: + - pip install twine + - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/* artifacts: paths: - "*.whl" +upload_python311_armv7l: + image: zoo.smok.co/build/build:latest + stage: deploy + dependencies: + - build_python311_armv7l + script: + - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/* + only: + - tags + except: + - branches build_python38: extends: .build_python @@ -92,3 +109,5 @@ build_python311: build_python311_armv7l: extends: .build_python image: zoo.smok.co/build/build:armv7l-python3.11 + after_script: + - echo "Do nothing" diff --git a/README.md b/README.md index c083af24e9e2c2155e268b1c155deeaa7dc374f7..24f381a2429b3c918889fc586f2980538a1a1223 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ MiniJSON ======== - +[](https://git.dms-serwis.com.pl/smokserwis/minijson) +[](https://git.dms-serwis.com.pl/smokserwis/minijson/-/commits/develop) [](https://codeclimate.com/github/smok-serwis/minijson/maintainability) -[](https://codeclimate.com/github/smok-serwis/minijson/test_coverage) [](https://codeclimate.com/github/smok-serwis/minijson) -[](http://minijson.readthedocs.io/en/latest/?badge=latest) [](https://pypi.python.org/pypi/minijson) [](https://badge.fury.io/py/minijson) [](https://pypi.python.org/pypi/minijson) diff --git a/docs/changelog.rst b/docs/changelog.rst index aa8ddeaacca97b8a6396f3ac07c7d339d1b6ff31..e2ce0b56310b3f419ea40dbc7498adcd300c66a8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,7 +4,8 @@ Changelog v3.1.0 ------ -Moved entirely to SMOKs' build architecture. +* Moved entirely to SMOKs' build architecture. +* support for Python 3.7 and 3.6 dropped v3.0.1 ------ diff --git a/docs/conf.py b/docs/conf.py index 7ed3a5eda63d7b030af6c7e8f1bae1e84f45a153..0fc9bfd68e08775caf02ba8d980685cfca05709c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ copyright = '2021 Dronehub Group sp. z o. o.' author = 'Piotr MaĹlanka' # The full version, including alpha/beta/rc tags -release = '2.0' +release = '3.1.0' # -- General configuration --------------------------------------------------- diff --git a/docs/index.rst b/docs/index.rst index d290051784d6261e70a37520afbd14da0f0dce61..90dfc6f69a4d4aec27deb2b377dd73db3109c28b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -28,6 +28,10 @@ is anyway invalid JSON_. .. _JSON: https://www.w3schools.com/js/js_json_objects.asp +.. note:: + + Now I can officially state that minijson is better than same data exported to + JSON and encoded with best gzip. Enjoy! Indices and tables ================== diff --git a/docs/specification.rst b/docs/specification.rst index 63c1a9569c852d9c18995de757b452e1e599ea42..07d2c90dee614df9a1f7919ecdab740413fa7879 100644 --- a/docs/specification.rst +++ b/docs/specification.rst @@ -18,12 +18,14 @@ Type Value consists of: with len of (value & 0x7F) * If value's two highest bits are 0100 or 0101, then four lowest bits encode the number of elements, and the four highest bits encode type of the object: + * 0100 - a list * 0101 - an object whose keys are all strings * 0110 - an object whose keys are not all strings (see value of 19 and 20 to know how it's represented). * Standard representation for a non-key-string object (value 19), string key object (value 11) or list (value 7) follows, sans the element count. + * If value is zero, then next character is the length of the string followed by the string * If value is 1, then next data is signed int * If value is 2, then next data is signed short @@ -64,13 +66,13 @@ Type Value consists of: * If value is 22, then it's True * If value is 23, then it's False * If value is 24, then next what comes is count of bytes, and then bytes follow. This is to be - interpreted as a signed integer + interpreted as a signed integer * If value is 25, then next comes an unsigned char denoting the length of the bytes, and - the remainder is binary data + the remainder is binary data * If value is 26, then next comes an unsigned short denoting the length of the bytes, and - the remainder is binary data + the remainder is binary data * If value is 27, then next comes an unsigned int denoting the length of the bytes, and - the remainder is binary data + the remainder is binary data -Coder **should** encode the value as one having the smallest binary representation, but that is not +Encoder **should** encode the value as one having the smallest binary representation, but that is not required. Decoder **must** parse any arbitrary valid string. diff --git a/docs/usage.rst b/docs/usage.rst index 26d67c97d472c62b4036901dc8d8ab884a5677f9..1e2a84ca3274ecf10ccd1b92b690c7aeab601d23 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -17,12 +17,6 @@ MiniJSON implements the same interface as json or yaml, namely: .. autofunction:: minijson.parse -For serializing objects you got the following: - -.. autofunction:: minijson.dumps_object - -.. autofunction:: minijson.loads_object - And the following exceptions: .. autoclass:: minijson.MiniJSONError diff --git a/minijson.pyx b/minijson.pyx index bc80cdb339f2f309b98c0006add03796dd5b122c..50dfee18fd0b9bc47aafa78ec56de9ee8a61f0a2 100644 --- a/minijson.pyx +++ b/minijson.pyx @@ -9,14 +9,17 @@ class MiniJSONError(ValueError): Note that it inherits from :code:`ValueError`. """ + pass class EncodingError(MiniJSONError): """Error during encoding""" + pass class DecodingError(MiniJSONError): """Error during decoding""" + pass cdef: diff --git a/setup.cfg b/setup.cfg index dd08d965a5e0914920f5bdae2a0c231b17c589fd..1cfea1ac338aa372bb0cd2a2bc6de962c2cf5a3e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,8 +17,6 @@ project_urls = classifier = Development Status :: 5 - Production/Stable Programming Language :: Python - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 diff --git a/tests/test_minijson.py b/tests/test_minijson.py index 526b7e256a188086a9c95047bd28ac3144c57c6a..3e3732c5891674ae26924a227f1d12a5b433b1dc 100644 --- a/tests/test_minijson.py +++ b/tests/test_minijson.py @@ -1,5 +1,7 @@ +import json import typing as tp import unittest +import gzip from minijson import dumps, loads, dumps_object, loads_object, EncodingError, DecodingError, \ switch_default_double, switch_default_float, MiniJSONEncoder @@ -7,6 +9,12 @@ from minijson import dumps, loads, dumps_object, loads_object, EncodingError, De class TestMiniJSON(unittest.TestCase): + def test_gzip_competition(self): + a = {'test': [1, 2, 3], 'bagietka': 'bagietka'} + b = dumps(a) + c = gzip.compress(json.dumps(a).encode(('utf-8'))) + self.assertLess(len(b), len(c)) + def test_encoder_strict_output(self): enc = MiniJSONEncoder(use_strict_order=True) enc.encode({"test": "2", "value": 2})