py-multicodec 0.2.1__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. py_multicodec-1.0.0/CONTRIBUTING.rst +223 -0
  2. py_multicodec-1.0.0/HISTORY.rst +39 -0
  3. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/LICENSE +0 -1
  4. py_multicodec-1.0.0/PKG-INFO +129 -0
  5. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/README.rst +32 -8
  6. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/api_reference.rst +7 -1
  7. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/conf.py +65 -66
  8. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/index.rst +8 -7
  9. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/installation.rst +7 -1
  10. py_multicodec-1.0.0/docs/modules.rst +7 -0
  11. py_multicodec-1.0.0/docs/multicodec.rst +61 -0
  12. py_multicodec-1.0.0/multicodec/__init__.py +80 -0
  13. py_multicodec-1.0.0/multicodec/code.py +467 -0
  14. py_multicodec-1.0.0/multicodec/code_table.py +1241 -0
  15. py_multicodec-1.0.0/multicodec/constants.py +1839 -0
  16. py_multicodec-1.0.0/multicodec/exceptions.py +45 -0
  17. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/multicodec/multicodec.py +17 -17
  18. py_multicodec-1.0.0/multicodec/serialization.py +364 -0
  19. py_multicodec-1.0.0/py_multicodec.egg-info/PKG-INFO +129 -0
  20. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/py_multicodec.egg-info/SOURCES.txt +10 -12
  21. py_multicodec-1.0.0/py_multicodec.egg-info/requires.txt +16 -0
  22. py_multicodec-1.0.0/pyproject.toml +171 -0
  23. py_multicodec-1.0.0/setup.cfg +4 -0
  24. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/tests/__init__.py +0 -2
  25. py_multicodec-1.0.0/tests/test_code.py +305 -0
  26. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/tests/test_multicodec.py +14 -17
  27. py_multicodec-1.0.0/tests/test_serialization.py +418 -0
  28. py-multicodec-0.2.1/CONTRIBUTING.rst +0 -114
  29. py-multicodec-0.2.1/HISTORY.rst +0 -13
  30. py-multicodec-0.2.1/PKG-INFO +0 -99
  31. py-multicodec-0.2.1/docs/_build/html/_static/ajax-loader.gif +0 -0
  32. py-multicodec-0.2.1/docs/_build/html/_static/comment-bright.png +0 -0
  33. py-multicodec-0.2.1/docs/_build/html/_static/comment-close.png +0 -0
  34. py-multicodec-0.2.1/docs/_build/html/_static/comment.png +0 -0
  35. py-multicodec-0.2.1/docs/_build/html/_static/down-pressed.png +0 -0
  36. py-multicodec-0.2.1/docs/_build/html/_static/down.png +0 -0
  37. py-multicodec-0.2.1/docs/_build/html/_static/up-pressed.png +0 -0
  38. py-multicodec-0.2.1/docs/_build/html/_static/up.png +0 -0
  39. py-multicodec-0.2.1/docs/readme.rst +0 -1
  40. py-multicodec-0.2.1/multicodec/__init__.py +0 -10
  41. py-multicodec-0.2.1/multicodec/constants.py +0 -448
  42. py-multicodec-0.2.1/py_multicodec.egg-info/PKG-INFO +0 -99
  43. py-multicodec-0.2.1/py_multicodec.egg-info/requires.txt +0 -3
  44. py-multicodec-0.2.1/setup.cfg +0 -41
  45. py-multicodec-0.2.1/setup.py +0 -54
  46. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/AUTHORS.rst +0 -0
  47. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/MANIFEST.in +0 -0
  48. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/Makefile +0 -0
  49. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/_build/html/_static/file.png +0 -0
  50. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/_build/html/_static/minus.png +0 -0
  51. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/_build/html/_static/plus.png +0 -0
  52. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/authors.rst +0 -0
  53. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/contributing.rst +0 -0
  54. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/history.rst +0 -0
  55. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/make.bat +0 -0
  56. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/docs/usage.rst +0 -0
  57. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/py_multicodec.egg-info/dependency_links.txt +0 -0
  58. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/py_multicodec.egg-info/not-zip-safe +0 -0
  59. {py-multicodec-0.2.1 → py_multicodec-1.0.0}/py_multicodec.egg-info/top_level.txt +0 -0
@@ -0,0 +1,223 @@
1
+ .. highlight:: shell
2
+
3
+ ============
4
+ Contributing
5
+ ============
6
+
7
+ Contributions are welcome, and they are greatly appreciated! Every
8
+ little bit helps, and credit will always be given.
9
+
10
+ You can contribute in many ways:
11
+
12
+ Types of Contributions
13
+ ----------------------
14
+
15
+ Report Bugs
16
+ ~~~~~~~~~~~
17
+
18
+ Report bugs at https://github.com/multiformats/py-multicodec/issues.
19
+
20
+ If you are reporting a bug, please include:
21
+
22
+ * Your operating system name and version.
23
+ * Any details about your local setup that might be helpful in troubleshooting.
24
+ * Detailed steps to reproduce the bug.
25
+
26
+ Fix Bugs
27
+ ~~~~~~~~
28
+
29
+ Look through the GitHub issues for bugs. Anything tagged with "bug"
30
+ and "help wanted" is open to whoever wants to implement it.
31
+
32
+ Implement Features
33
+ ~~~~~~~~~~~~~~~~~~
34
+
35
+ Look through the GitHub issues for features. Anything tagged with "enhancement"
36
+ and "help wanted" is open to whoever wants to implement it.
37
+
38
+ Write Documentation
39
+ ~~~~~~~~~~~~~~~~~~~
40
+
41
+ py-multicodec could always use more documentation, whether as part of the
42
+ official py-multicodec docs, in docstrings, or even on the web in blog posts,
43
+ articles, and such.
44
+
45
+ Submit Feedback
46
+ ~~~~~~~~~~~~~~~
47
+
48
+ The best way to send feedback is to file an issue at https://github.com/multiformats/py-multicodec/issues.
49
+
50
+ If you are proposing a feature:
51
+
52
+ * Explain in detail how it would work.
53
+ * Keep the scope as narrow as possible, to make it easier to implement.
54
+ * Remember that this is a volunteer-driven project, and that contributions
55
+ are welcome :)
56
+
57
+ Get Started!
58
+ ------------
59
+
60
+ Ready to contribute? Here's how to set up `multicodec` for local development.
61
+
62
+ 1. Fork the `py-multicodec` repo on GitHub.
63
+ 2. Clone your fork locally::
64
+
65
+ $ git clone git@github.com:your_name_here/py-multicodec.git
66
+
67
+ 3. Install your local copy into a virtualenv. Create and activate a virtual environment::
68
+
69
+ $ python -m venv venv
70
+ $ source venv/bin/activate # On Windows: venv\Scripts\activate
71
+ $ pip install -e ".[dev]"
72
+
73
+ 4. Install pre-commit hooks (optional but recommended)::
74
+
75
+ $ pre-commit install
76
+
77
+ This will set up git hooks to automatically run linting and formatting checks
78
+ before each commit.
79
+
80
+ 5. Create a branch for local development::
81
+
82
+ $ git checkout -b name-of-your-bugfix-or-feature
83
+
84
+ Now you can make your changes locally.
85
+
86
+ 6. When you're done making changes, check that your changes pass linting and the
87
+ tests, including testing other Python versions with tox::
88
+
89
+ $ make lint
90
+ $ make test
91
+ $ tox
92
+
93
+ Or run pre-commit manually on all files::
94
+
95
+ $ pre-commit run --all-files
96
+
97
+ If you installed pre-commit hooks (step 4), they will run automatically on commit.
98
+
99
+ Development Workflow Commands
100
+ -------------------------------
101
+
102
+ The project provides several ``make`` targets to help with development:
103
+
104
+ * ``make fix`` - Automatically fix formatting and linting issues using ruff.
105
+ Use this when you want to auto-fix code style issues.
106
+
107
+ * ``make lint`` - Run all pre-commit hooks on all files to check for code quality
108
+ issues. This includes YAML/TOML validation, trailing whitespace checks, pyupgrade,
109
+ ruff linting and formatting, and mypy type checking.
110
+
111
+ * ``make typecheck`` - Run mypy type checking only. Use this when you want to
112
+ quickly check for type errors without running all other checks.
113
+
114
+ * ``make test`` - Run the test suite with pytest using the default Python version.
115
+ For testing across multiple Python versions, use ``tox`` instead.
116
+
117
+ * ``make pr`` - Run a complete pre-PR check: clean build artifacts, fix formatting,
118
+ run linting, type checking, and tests. This is the recommended command to run
119
+ before submitting a pull request.
120
+
121
+ For a full list of available commands, run ``make help``.
122
+
123
+ 7. Commit your changes and push your branch to GitHub::
124
+
125
+ $ git add .
126
+ $ git commit -m "Your detailed description of your changes."
127
+ $ git push -u origin name-of-your-bugfix-or-feature
128
+
129
+ 8. Submit a pull request through the GitHub website.
130
+
131
+ Pull Request Guidelines
132
+ -----------------------
133
+
134
+ Before you submit a pull request, check that it meets these guidelines:
135
+
136
+ 1. The pull request should include tests.
137
+ 2. If the pull request adds functionality, the docs should be updated. Put
138
+ your new functionality into a function with a docstring, and add the
139
+ feature to the list in README.rst.
140
+ 3. The pull request should work for Python 3.10, 3.11, 3.12, 3.13, and 3.14. Check
141
+ https://github.com/multiformats/py-multicodec/actions
142
+ and make sure that the tests pass for all supported Python versions.
143
+
144
+ Tips
145
+ ----
146
+
147
+ To run a subset of tests::
148
+
149
+ $ pytest tests/test_multicodec.py
150
+
151
+ Releasing
152
+ ---------
153
+
154
+ Releases are typically done from the ``master`` branch, except when releasing a beta (in
155
+ which case the beta is released from ``master``, and the previous stable branch is
156
+ released from said branch).
157
+
158
+ Final test before each release
159
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160
+
161
+ Before releasing a new version, build and test the package that will be released:
162
+
163
+ .. code:: sh
164
+
165
+ git checkout master && git pull
166
+ make package-test
167
+
168
+ This will build the package and install it in a temporary virtual environment. Follow
169
+ the instructions to activate the venv and test whatever you think is important.
170
+
171
+ You can also preview the release notes:
172
+
173
+ .. code:: sh
174
+
175
+ towncrier --draft
176
+
177
+ Build the release notes
178
+ ~~~~~~~~~~~~~~~~~~~~~~~
179
+
180
+ Before bumping the version number, build the release notes. You must include the part of
181
+ the version to bump (see below), which changes how the version number will show in the
182
+ release notes.
183
+
184
+ .. code:: sh
185
+
186
+ make notes bump=$$VERSION_PART_TO_BUMP$$
187
+
188
+ If there are any errors, be sure to re-run make notes until it works.
189
+
190
+ Push the release to github & pypi
191
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
192
+
193
+ After confirming that the release package looks okay, release a new version:
194
+
195
+ .. code:: sh
196
+
197
+ make release bump=$$VERSION_PART_TO_BUMP$$
198
+
199
+ This command will:
200
+
201
+ - Bump the version number as specified wherever it appears in the repo.
202
+ - Create a git commit and tag for the new version.
203
+ - Build the package.
204
+ - Push the commit and tag to github.
205
+ - Push the new package files to pypi.
206
+
207
+ Which version part to bump
208
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
209
+
210
+ ``$$VERSION_PART_TO_BUMP$$`` must be one of: ``major``, ``minor``, ``patch``, ``stage``,
211
+ or ``devnum``.
212
+
213
+ The version format for this repo is ``{major}.{minor}.{patch}`` for stable, and
214
+ ``{major}.{minor}.{patch}-{stage}.{devnum}`` for unstable (``stage`` can be alpha or
215
+ beta).
216
+
217
+ If you are in a beta version, ``make release bump=stage`` will switch to a stable.
218
+
219
+ To issue an unstable version when the current version is stable, specify the new version
220
+ explicitly, like ``make release bump="--new-version 4.0.0-alpha.1"``
221
+
222
+ You can see what the result of bumping any particular version part would be with
223
+ ``bump-my-version show-bump``
@@ -0,0 +1,39 @@
1
+ History
2
+ =======
3
+
4
+ .. towncrier release notes start
5
+
6
+ py-multicodec v1.0.0 (2025-12-18)
7
+ ---------------------------------
8
+
9
+ Improved Documentation
10
+ ~~~~~~~~~~~~~~~~~~~~~~
11
+
12
+ - Fixed Read the Docs build failures by updating deprecated Sphinx settings and adding API documentation generation. (`#29 <https://github.com/multiformats/py-multicodec/issues/29>`__)
13
+
14
+
15
+ Features
16
+ ~~~~~~~~
17
+
18
+ - Added Codec constants, List all codecs function and Reserved range support for Codec management. (`#23 <https://github.com/multiformats/py-multicodec/issues/23>`__)
19
+ - Added serialization with JSON/raw codecs, custom codec interface, encode/decode functions, and a dynamic codec registry. (`#25 <https://github.com/multiformats/py-multicodec/issues/25>`__)
20
+ - Updated codec table from official multicodec repository to include all 603 codecs (up from 460). This adds many previously missing codecs including hash functions (sha2-384, sha2-224, murmur3-x64 variants), encryption algorithms (aes-128/192/256, chacha variants), network protocols (noise, quic-v1, webrtc), and many others. Addresses gap analysis from discussion #1063. (`#31 <https://github.com/multiformats/py-multicodec/issues/31>`__)
21
+
22
+
23
+ Internal Changes - for py-multicodec Contributors
24
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25
+
26
+ - Modernized repository infrastructure to use pyproject.toml, GitHub Actions CI/CD, Python 3.10+ support, ruff for linting/formatting, and pre-commit hooks. (`#21 <https://github.com/multiformats/py-multicodec/issues/21>`__)
27
+ - Dropped ``coverage`` and ``codecov`` references, no longer using it. (`#29 <https://github.com/multiformats/py-multicodec/issues/29>`__)
28
+ - Updated contributing docs and docs config with current release process. (`#35 <https://github.com/multiformats/py-multicodec/issues/35>`__)
29
+
30
+
31
+ 0.1.3 (2018-10-20)
32
+ ------------------
33
+
34
+ * Handle exception when the varint is invalid
35
+
36
+ 0.1.0 (2017-09-03)
37
+ ------------------
38
+
39
+ * First release on PyPI.
@@ -8,4 +8,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
8
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
9
 
10
10
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
-
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-multicodec
3
+ Version: 1.0.0
4
+ Summary: Multicodec implementation in Python
5
+ Author-email: Dhruv Baldawa <dhruv@dhruvb.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/multiformats/py-multicodec
8
+ Project-URL: Download, https://github.com/multiformats/py-multicodec/tarball/1.0.0
9
+ Keywords: multicodec,multiformats,CID,IPFS,IPLD
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Requires-Python: <4.0,>=3.10
21
+ Description-Content-Type: text/x-rst
22
+ License-File: LICENSE
23
+ License-File: AUTHORS.rst
24
+ Requires-Dist: varint<2.0.0,>=1.0.2
25
+ Provides-Extra: dev
26
+ Requires-Dist: Sphinx>=5.0.0; extra == "dev"
27
+ Requires-Dist: build>=0.9.0; extra == "dev"
28
+ Requires-Dist: bump-my-version>=1.2.0; extra == "dev"
29
+ Requires-Dist: mypy; extra == "dev"
30
+ Requires-Dist: pre-commit; extra == "dev"
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: pytest-runner; extra == "dev"
33
+ Requires-Dist: ruff; extra == "dev"
34
+ Requires-Dist: towncrier<25,>=24; extra == "dev"
35
+ Requires-Dist: tox>=4.10.0; extra == "dev"
36
+ Requires-Dist: twine; extra == "dev"
37
+ Requires-Dist: watchdog>=3.0.0; extra == "dev"
38
+ Requires-Dist: wheel>=0.31.0; extra == "dev"
39
+ Dynamic: license-file
40
+
41
+ py-multicodec
42
+ -------------
43
+
44
+ .. image:: https://img.shields.io/pypi/v/py-multicodec.svg
45
+ :target: https://pypi.python.org/pypi/py-multicodec
46
+
47
+ .. image:: https://github.com/multiformats/py-multicodec/actions/workflows/tox.yml/badge.svg?branch=master
48
+ :target: https://github.com/multiformats/py-multicodec/actions/workflows/tox.yml
49
+
50
+ .. image:: https://readthedocs.org/projects/py-multicodec/badge/?version=stable
51
+ :target: https://py-multicodec.readthedocs.io/en/stable/?badge=stable
52
+ :alt: Documentation Status
53
+
54
+
55
+ `Multicodec <https://github.com/multiformats/multicodec>`_ implementation in Python
56
+
57
+ ``multicodec`` *is a self-describing multiformat*, it wraps other formats with a tiny bit of self-description.
58
+
59
+ A multicodec identifier is both a varint and the code identifying the following data, this means that the most
60
+ significant bit of every multicodec code is reserved to signal the continuation.
61
+
62
+ You can check `the table here <https://github.com/multiformats/multicodec/blob/909e183da65818ecd1e672904980e53711da8780/table.csv>`_ for the list of supported codecs by ``py-multicodec``.
63
+
64
+ * Free software: MIT license
65
+ * Documentation: https://py-multicodec.readthedocs.io.
66
+ * Python versions: 3.10, 3.11, 3.12, 3.13, 3.14
67
+
68
+
69
+ Installation
70
+ ============
71
+
72
+ .. code-block:: shell
73
+
74
+ $ pip install py-multicodec
75
+
76
+
77
+ Sample Usage
78
+ ============
79
+
80
+ .. code-block:: python
81
+
82
+ >>> from multicodec import add_prefix, remove_prefix, get_codec
83
+ >>> # adding a prefix to existing data
84
+ >>> add_prefix('sha2-256', b'EiC5TSe5k00')
85
+ b'\x12EiC5TSe5k00'
86
+ >>> # removing prefix from prefixed data
87
+ >>> remove_prefix(b'\x12EiC5TSe5k00')
88
+ EiC5TSe5k00
89
+ >>> # get codec used to prefix the prefixed data
90
+ >>> get_codec(b'\x12EiC5TSe5k00')
91
+ 'sha2-256'
92
+
93
+ Code Management
94
+ ===============
95
+
96
+ In addition to the basic prefix operations, py-multicodec provides type-safe codec
97
+ management functionality:
98
+
99
+ .. code-block:: python
100
+
101
+ >>> from multicodec import Code, known_codes
102
+ >>> from multicodec.code_table import SHA2_256, DAG_CBOR
103
+
104
+ >>> # Use named constants for type-safe codec handling
105
+ >>> code = SHA2_256
106
+ >>> str(code)
107
+ 'sha2-256'
108
+ >>> int(code)
109
+ 18
110
+
111
+ >>> # Create Code from string (name or hex)
112
+ >>> code = Code.from_string("sha2-256")
113
+ >>> code = Code.from_string("0x12") # hex also works
114
+
115
+ >>> # List all known codecs
116
+ >>> all_codes = known_codes()
117
+ >>> len(all_codes)
118
+ 460
119
+
120
+ Updating the lookup table
121
+ ==========================
122
+
123
+ Updating the lookup table is done with a script. The source of truth is the
124
+ `multicodec default table <https://github.com/multiformats/multicodec/blob/master/table.csv>`_.
125
+ Update the table with running:
126
+
127
+ .. code-block:: shell
128
+
129
+ $ curl -X GET https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv | ./tools/update-table.py
@@ -4,11 +4,8 @@ py-multicodec
4
4
  .. image:: https://img.shields.io/pypi/v/py-multicodec.svg
5
5
  :target: https://pypi.python.org/pypi/py-multicodec
6
6
 
7
- .. image:: https://img.shields.io/travis/multiformats/py-multicodec.svg?branch=master
8
- :target: https://travis-ci.org/multiformats/py-multicodec?branch=master
9
-
10
- .. image:: https://codecov.io/gh/multiformats/py-multicodec/branch/master/graph/badge.svg
11
- :target: https://codecov.io/gh/multiformats/py-multicodec
7
+ .. image:: https://github.com/multiformats/py-multicodec/actions/workflows/tox.yml/badge.svg?branch=master
8
+ :target: https://github.com/multiformats/py-multicodec/actions/workflows/tox.yml
12
9
 
13
10
  .. image:: https://readthedocs.org/projects/py-multicodec/badge/?version=stable
14
11
  :target: https://py-multicodec.readthedocs.io/en/stable/?badge=stable
@@ -22,11 +19,11 @@ py-multicodec
22
19
  A multicodec identifier is both a varint and the code identifying the following data, this means that the most
23
20
  significant bit of every multicodec code is reserved to signal the continuation.
24
21
 
25
- You can check `the table here <https://github.com/multiformats/multicodec/blob/7c57cd4477e391d27b8d7cc0995da9e674434ffb/table.csv>`_ for the list of supported codecs by ``py-multicodec``.
22
+ You can check `the table here <https://github.com/multiformats/multicodec/blob/909e183da65818ecd1e672904980e53711da8780/table.csv>`_ for the list of supported codecs by ``py-multicodec``.
26
23
 
27
24
  * Free software: MIT license
28
25
  * Documentation: https://py-multicodec.readthedocs.io.
29
- * Python versions: 3.5, 3.6
26
+ * Python versions: 3.10, 3.11, 3.12, 3.13, 3.14
30
27
 
31
28
 
32
29
  Installation
@@ -44,7 +41,7 @@ Sample Usage
44
41
 
45
42
  >>> from multicodec import add_prefix, remove_prefix, get_codec
46
43
  >>> # adding a prefix to existing data
47
- >>> add_prefix('sha2-256', 'EiC5TSe5k00')
44
+ >>> add_prefix('sha2-256', b'EiC5TSe5k00')
48
45
  b'\x12EiC5TSe5k00'
49
46
  >>> # removing prefix from prefixed data
50
47
  >>> remove_prefix(b'\x12EiC5TSe5k00')
@@ -53,6 +50,33 @@ Sample Usage
53
50
  >>> get_codec(b'\x12EiC5TSe5k00')
54
51
  'sha2-256'
55
52
 
53
+ Code Management
54
+ ===============
55
+
56
+ In addition to the basic prefix operations, py-multicodec provides type-safe codec
57
+ management functionality:
58
+
59
+ .. code-block:: python
60
+
61
+ >>> from multicodec import Code, known_codes
62
+ >>> from multicodec.code_table import SHA2_256, DAG_CBOR
63
+
64
+ >>> # Use named constants for type-safe codec handling
65
+ >>> code = SHA2_256
66
+ >>> str(code)
67
+ 'sha2-256'
68
+ >>> int(code)
69
+ 18
70
+
71
+ >>> # Create Code from string (name or hex)
72
+ >>> code = Code.from_string("sha2-256")
73
+ >>> code = Code.from_string("0x12") # hex also works
74
+
75
+ >>> # List all known codecs
76
+ >>> all_codes = known_codes()
77
+ >>> len(all_codes)
78
+ 460
79
+
56
80
  Updating the lookup table
57
81
  ==========================
58
82
 
@@ -1,16 +1,22 @@
1
1
  API Reference
2
- =============
2
+ -------------
3
3
 
4
4
  .. py:currentmodule:: multicodec
5
5
 
6
6
  .. autofunction:: add_prefix
7
+ :no-index:
7
8
 
8
9
  .. autofunction:: remove_prefix
10
+ :no-index:
9
11
 
10
12
  .. autofunction:: get_codec
13
+ :no-index:
11
14
 
12
15
  .. autofunction:: get_prefix
16
+ :no-index:
13
17
 
14
18
  .. autofunction:: is_codec
19
+ :no-index:
15
20
 
16
21
  .. autofunction:: extract_prefix
22
+ :no-index: