Skip to content

Commit 4c1c316

Browse files
committed
Fixed incorrect file permissions
1 parent 2c82e2c commit 4c1c316

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2971
-2967
lines changed

.github/ISSUE_TEMPLATE/add-encoding.yml

100755100644
File mode changed.

.github/copilot-instructions.md

100755100644
File mode changed.

.github/prompts/add_codec.prompt.md

100755100644
File mode changed.

.github/pull_request_template.md

100755100644
File mode changed.

LICENSE

Lines changed: 674 additions & 674 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
[![DOI](https://zenodo.org/badge/236679865.svg)](https://zenodo.org/badge/latestdoi/236679865)
1212
[![License](https://img.shields.io/pypi/l/codext.svg)](https://pypi.python.org/pypi/codext/)
1313

14-
[**CodExt**](https://github.com/dhondta/python-codext) is a (Python2-3 compatible) library that extends the native [`codecs`](https://docs.python.org/3/library/codecs.html) library (namely for adding new custom encodings and character mappings) and provides **120+ new codecs**, hence its name combining *CODecs EXTension*. It also features a **guess mode** for decoding multiple layers of encoding and **CLI tools** for convenience.
14+
[**CodExt**](https://github.com/dhondta/python-codext) is a (Python2-3 compatible) library that extends the native [`codecs`](https://docs.python.org/3/library/codecs) library (namely for adding new custom encodings and character mappings) and provides **120+ new codecs**, hence its name combining *CODecs EXTension*. It also features a **guess mode** for decoding multiple layers of encoding and **CLI tools** for convenience.
1515

1616
```sh
1717
$ pip install codext
1818
```
1919

2020
Want to contribute a new codec ? | Want to contribute a new macro ?
2121
:----------------------------------:|:------------------------------------:
22-
Check the [documentation](https://python-codext.readthedocs.io/en/latest/howto.html) first<br>Then [PR](https://github.com/dhondta/python-codext/pulls) your new codec | [PR](https://github.com/dhondta/python-codext/pulls) your updated version of [`macros.json`](https://github.com/dhondta/python-codext/blob/main/codext/macros.json)
22+
Check the [documentation](https://python-codext.readthedocs.io/en/latest/howto) first<br>Then [PR](https://github.com/dhondta/python-codext/pulls) your new codec | [PR](https://github.com/dhondta/python-codext/pulls) your updated version of [`macros.json`](https://github.com/dhondta/python-codext/blob/main/codext/macros.json)
2323

2424
## :mag: Demonstrations
2525

@@ -210,7 +210,7 @@ o
210210

211211
## :page_with_curl: List of codecs
212212

213-
#### [BaseXX](https://python-codext.readthedocs.io/en/latest/enc/base.html)
213+
#### [BaseXX](https://python-codext.readthedocs.io/en/latest/enc/base)
214214

215215
- [X] `base1`: useless, but for the sake of completeness
216216
- [X] `base2`: simple conversion to binary (with a variant with a reversed alphabet)
@@ -221,7 +221,7 @@ o
221221
- [X] `base11`: conversion to digits with a "*a*"
222222
- [X] `base16`: simple conversion to hexadecimal (with a variant holding an alphabet with digits and letters inverted)
223223
- [X] `base26`: conversion to alphabet letters
224-
- [X] `base32`: classical conversion according to the RFC4648 with all its variants ([zbase32](https://philzimmermann.com/docs/human-oriented-base-32-encoding.txt), extended hexadecimal, [geohash](https://en.wikipedia.org/wiki/Geohash), [Crockford](https://www.crockford.com/base32.html))
224+
- [X] `base32`: classical conversion according to the RFC4648 with all its variants ([zbase32](https://philzimmermann.com/docs/human-oriented-base-32-encoding.txt), extended hexadecimal, [geohash](https://en.wikipedia.org/wiki/Geohash), [Crockford](https://www.crockford.com/base32))
225225
- [X] `base36`: [Base36](https://en.wikipedia.org/wiki/Base36) conversion to letters and digits (with a variant inverting both groups)
226226
- [X] `base45`: [Base45](https://datatracker.ietf.org/doc/html/draft-faltstrom-base45-04.txt) DRAFT algorithm (with a variant inverting letters and digits)
227227
- [X] `base58`: multiple versions of [Base58](https://en.bitcoinwiki.org/wiki/Base58) (bitcoin, flickr, ripple)
@@ -233,11 +233,11 @@ o
233233
- [X] `base91`: [Base91](http://base91.sourceforge.net) custom conversion
234234
- [X] `base100` (or *emoji*): [Base100](https://github.com/AdamNiederer/base100) custom conversion
235235
- [X] `base122`: [Base100](http://blog.kevinalbs.com/base122) custom conversion
236-
- [X] `base-genericN`: see [base encodings](https://python-codext.readthedocs.io/en/latest/enc/base.html) ; supports any possible base
236+
- [X] `base-genericN`: see [base encodings](https://python-codext.readthedocs.io/en/latest/enc/base) ; supports any possible base
237237

238238
This category also contains `ascii85`, `adobe`, `[x]btoa`, `zeromq` with the `base85` codec.
239239

240-
#### [Binary](https://python-codext.readthedocs.io/en/latest/enc/binary.html)
240+
#### [Binary](https://python-codext.readthedocs.io/en/latest/enc/binary)
241241

242242
- [X] `baudot`: supports CCITT-1, CCITT-2, EU/FR, ITA1, ITA2, MTK-2 (Python3 only), UK, ...
243243
- [X] `baudot-spaced`: variant of `baudot` ; groups of 5 bits are whitespace-separated
@@ -251,7 +251,12 @@ This category also contains `ascii85`, `adobe`, `[x]btoa`, `zeromq` with the `ba
251251
- [X] `manchester-inverted`: variant of `manchester` ; XORes each bit of the input with `10`
252252
- [X] `rotateN`: rotates characters by the specified number of bits (*N* belongs to [1, 7] ; Python 3 only)
253253

254-
#### [Common](https://python-codext.readthedocs.io/en/latest/enc/common.html)
254+
#### [Checksums](https://python-codext.readthedocs.io/en/latest/enc/checksums)
255+
256+
- [X] `adler`: Adler32 algorithm (relies on `zlib`)
257+
- [X] `crc`: CRC of lengths 8, 10-17, 21, 24, 30-32, 40, 64, 82 with a variety of polynoms
258+
259+
#### [Common](https://python-codext.readthedocs.io/en/latest/enc/common)
255260

256261
- [X] `a1z26`: keeps words whitespace-separated and uses a custom character separator
257262
- [X] `cases`: set of case-related encodings (including camel-, kebab-, lower-, pascal-, upper-, snake- and swap-case, slugify, capitalize, title)
@@ -261,7 +266,7 @@ This category also contains `ascii85`, `adobe`, `[x]btoa`, `zeromq` with the `ba
261266
- [X] `ordinal`: dummy character ordinals conversion (converts to 3-digits groups)
262267
- [X] `ordinal-spaced`: variant of `ordinal` ; dummy character ordinals conversion, handling whitespace separators
263268

264-
#### [Compression](https://python-codext.readthedocs.io/en/latest/enc/compressions.html)
269+
#### [Compression](https://python-codext.readthedocs.io/en/latest/enc/compressions)
265270

266271
- [X] `gzip`: standard Gzip compression/decompression
267272
- [X] `lz77`: compresses the given data with the algorithm of Lempel and Ziv of 1977
@@ -272,7 +277,7 @@ This category also contains `ascii85`, `adobe`, `[x]btoa`, `zeromq` with the `ba
272277

273278
> :warning: Compression functions are of course definitely **NOT** encoding functions ; they are implemented for leveraging the `.encode(...)` API from `codecs`.
274279
275-
#### [Cryptography](https://python-codext.readthedocs.io/en/latest/enc/crypto.html)
280+
#### [Cryptography](https://python-codext.readthedocs.io/en/latest/enc/crypto)
276281

277282
- [X] `affine`: aka Affine Cipher
278283
- [X] `atbash`: aka Atbash Cipher
@@ -287,18 +292,17 @@ This category also contains `ascii85`, `adobe`, `[x]btoa`, `zeromq` with the `ba
287292

288293
> :warning: Crypto functions are of course definitely **NOT** encoding functions ; they are implemented for leveraging the `.encode(...)` API from `codecs`.
289294
290-
#### [Hashing](https://python-codext.readthedocs.io/en/latest/enc/hashing.html)
295+
#### [Hashing](https://python-codext.readthedocs.io/en/latest/enc/hashing)
291296

292297
- [X] `blake`: includes BLAKE2b and BLAKE2s (Python 3 only ; relies on `hashlib`)
293-
- [X] `checksums`: includes Adler32 and CRC32 (relies on `zlib`)
294298
- [X] `crypt`: Unix's crypt hash for passwords (Python 3 and Unix only ; relies on `crypt`)
295299
- [X] `md`: aka Message Digest ; includes MD4 and MD5 (relies on `hashlib`)
296300
- [X] `sha`: aka Secure Hash Algorithms ; includes SHA1, 224, 256, 384, 512 (Python2/3) but also SHA3-224, -256, -384 and -512 (Python 3 only ; relies on `hashlib`)
297301
- [X] `shake`: aka SHAKE hashing (Python 3 only ; relies on `hashlib`)
298302

299303
> :warning: Hash functions are of course definitely **NOT** encoding functions ; they are implemented for convenience with the `.encode(...)` API from `codecs` and useful for chaning codecs.
300304
301-
#### [Languages](https://python-codext.readthedocs.io/en/latest/enc/languages.html)
305+
#### [Languages](https://python-codext.readthedocs.io/en/latest/enc/languages)
302306

303307
- [X] `braille`: well-known braille language (Python 3 only)
304308
- [X] `ipsum`: aka lorem ipsum
@@ -312,13 +316,13 @@ This category also contains `ascii85`, `adobe`, `[x]btoa`, `zeromq` with the `ba
312316
- [X] `tap`: converts text to tap/knock code, commonly used by prisoners
313317
- [X] `tomtom`: similar to `morse`, using slashes and backslashes
314318

315-
#### [Others](https://python-codext.readthedocs.io/en/latest/enc/others.html)
319+
#### [Others](https://python-codext.readthedocs.io/en/latest/enc/others)
316320

317321
- [X] `dna`: implements the 8 rules of DNA sequences (N belongs to [1,8])
318322
- [X] `letter-indices`: encodes consonants and/or vowels with their corresponding indices
319323
- [X] `markdown`: unidirectional encoding from Markdown to HTML
320324

321-
#### [Steganography](https://python-codext.readthedocs.io/en/latest/enc/stegano.html)
325+
#### [Steganography](https://python-codext.readthedocs.io/en/latest/enc/stegano)
322326

323327
- [X] `hexagram`: uses Base64 and encodes the result to a charset of [I Ching hexagrams](https://en.wikipedia.org/wiki/Hexagram_%28I_Ching%29) (as implemented [here](https://github.com/qntm/hexagram-encode))
324328
- [X] `klopf`: aka Klopf code ; Polybius square with trivial alphabetical distribution
@@ -328,7 +332,7 @@ This category also contains `ascii85`, `adobe`, `[x]btoa`, `zeromq` with the `ba
328332
- [X] `whitespace`: replaces bits with whitespaces and tabs
329333
- [X] `whitespace_after_before`: variant of `whitespace` ; encodes characters as new characters with whitespaces before and after according to an equation described in the codec name (e.g. "`whitespace+2*after-3*before`")
330334

331-
#### [Web](https://python-codext.readthedocs.io/en/latest/enc/web.html)
335+
#### [Web](https://python-codext.readthedocs.io/en/latest/enc/web)
332336

333337
- [X] `html`: implements entities according to [this reference](https://dev.w3.org/html5/html-author/charref)
334338
- [X] `url`: aka URL encoding

docs/pages/enc/others.md

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,79 @@
1-
## Others
2-
3-
All kinds of other codecs are categorized in "*Others*".
4-
5-
-----
6-
7-
### DNA
8-
9-
This implements the 8 methods of ATGC nucleotides following the rule of complementary pairing, according the literature about coding and computing of DNA sequences.
10-
11-
**Codec** | **Conversions** | **Aliases** | **Comment**
12-
:---: | :---: | --- | ---
13-
`dna` (rule 1) | text <-> DNA-1 | `dna1`, `dna-1`, `dna_1` |
14-
`dna` (rule X) | text <-> DNA-X | ... |
15-
`dna` (rule 8) | text <-> DNA-8 | `dna8`, `dna-8`, `dna_8` |
16-
17-
```python
18-
>>> for i in range(8):
19-
print(codext.encode("this is a test", "dna-%d" % (i + 1)))
20-
GTGAGCCAGCCGGTATACAAGCCGGTATACAAGCAGACAAGTGAGCGGGTATGTGA
21-
CTCACGGACGGCCTATAGAACGGCCTATAGAACGACAGAACTCACGCCCTATCTCA
22-
ACAGATTGATTAACGCGTGGATTAACGCGTGGATGAGTGGACAGATAAACGCACAG
23-
AGACATTCATTAAGCGCTCCATTAAGCGCTCCATCACTCCAGACATAAAGCGAGAC
24-
TCTGTAAGTAATTCGCGAGGTAATTCGCGAGGTAGTGAGGTCTGTATTTCGCTCTG
25-
TGTCTAACTAATTGCGCACCTAATTGCGCACCTACTCACCTGTCTATTTGCGTGTC
26-
GAGTGCCTGCCGGATATCTTGCCGGATATCTTGCTGTCTTGAGTGCGGGATAGAGT
27-
CACTCGGTCGGCCATATGTTCGGCCATATGTTCGTCTGTTCACTCGCCCATACACT
28-
>>> codext.decode("GTGAGCCAGCCGGTATACAAGCCGGTATACAAGCAGACAAGTGAGCGGGTATGTGA", "dna-1")
29-
'this is a test'
30-
```
31-
32-
-----
33-
34-
### Letter indices
35-
36-
This encodes consonants and/or vowels with their respective indices. This codec is case insensitive, strips white spaces and only applies to letters.
37-
38-
**Codec** | **Conversions** | **Aliases** | **Comment**
39-
:---: | :---: | --- | ---
40-
`consonant-indices` | text <-> text with consonant indices | `consonants_indices`, `consonants_index` | while decoding, searches from the longest match, possibly not producing the original input
41-
`vowel-indices` | text <-> text with vowel indices | `vowels_indices`, `vowels_index` |
42-
`consonant-vowel-indices` | text <-> text with consonant and vowel indices | `consonants-vowels_index` | prefixes consonants with `C` and vowels with `V`
43-
44-
```python
45-
>>> codext.encode("This is a test", "consonant-index")
46-
'166I15I15A16E1516'
47-
>>> codext.decode("166I15I15A16E1516", "consonant-index")
48-
'THISISATEST'
49-
```
50-
51-
```python
52-
>>> codext.encode("This is a test", "vowel-index")
53-
'TH3S3S1T2ST'
54-
>>> codext.decode("TH3S3S1T2ST", "vowel-index")
55-
'THISISATEST'
56-
```
57-
58-
```python
59-
>>> codext.encode("This is a test", "consonant-vowel-index")
60-
'C16C6V3C15V3C15V1C16V2C15C16'
61-
>>> codext.decode("C16C6V3C15V3C15V1C16V2C15C16", "consonant-vowel-index")
62-
'THISISATEST'
63-
```
64-
65-
-----
66-
67-
### Markdown
68-
69-
This is only for "encoding" (converting) Markdown to HTML.
70-
71-
**Codec** | **Conversions** | **Aliases** | **Comment**
72-
:---: | :---: | --- | ---
73-
`markdown` | Markdown --> HTML | `markdown`, `Markdown`, `md` | unidirectional !
74-
75-
```python
76-
>>> codext.encode("# Test\nparagraph", "markdown")
77-
'<h1>Test</h1>\n\n<p>paragraph</p>\n'
78-
```
79-
1+
## Others
2+
3+
All kinds of other codecs are categorized in "*Others*".
4+
5+
-----
6+
7+
### DNA
8+
9+
This implements the 8 methods of ATGC nucleotides following the rule of complementary pairing, according the literature about coding and computing of DNA sequences.
10+
11+
**Codec** | **Conversions** | **Aliases** | **Comment**
12+
:---: | :---: | --- | ---
13+
`dna` (rule 1) | text <-> DNA-1 | `dna1`, `dna-1`, `dna_1` |
14+
`dna` (rule X) | text <-> DNA-X | ... |
15+
`dna` (rule 8) | text <-> DNA-8 | `dna8`, `dna-8`, `dna_8` |
16+
17+
```python
18+
>>> for i in range(8):
19+
print(codext.encode("this is a test", "dna-%d" % (i + 1)))
20+
GTGAGCCAGCCGGTATACAAGCCGGTATACAAGCAGACAAGTGAGCGGGTATGTGA
21+
CTCACGGACGGCCTATAGAACGGCCTATAGAACGACAGAACTCACGCCCTATCTCA
22+
ACAGATTGATTAACGCGTGGATTAACGCGTGGATGAGTGGACAGATAAACGCACAG
23+
AGACATTCATTAAGCGCTCCATTAAGCGCTCCATCACTCCAGACATAAAGCGAGAC
24+
TCTGTAAGTAATTCGCGAGGTAATTCGCGAGGTAGTGAGGTCTGTATTTCGCTCTG
25+
TGTCTAACTAATTGCGCACCTAATTGCGCACCTACTCACCTGTCTATTTGCGTGTC
26+
GAGTGCCTGCCGGATATCTTGCCGGATATCTTGCTGTCTTGAGTGCGGGATAGAGT
27+
CACTCGGTCGGCCATATGTTCGGCCATATGTTCGTCTGTTCACTCGCCCATACACT
28+
>>> codext.decode("GTGAGCCAGCCGGTATACAAGCCGGTATACAAGCAGACAAGTGAGCGGGTATGTGA", "dna-1")
29+
'this is a test'
30+
```
31+
32+
-----
33+
34+
### Letter indices
35+
36+
This encodes consonants and/or vowels with their respective indices. This codec is case insensitive, strips white spaces and only applies to letters.
37+
38+
**Codec** | **Conversions** | **Aliases** | **Comment**
39+
:---: | :---: | --- | ---
40+
`consonant-indices` | text <-> text with consonant indices | `consonants_indices`, `consonants_index` | while decoding, searches from the longest match, possibly not producing the original input
41+
`vowel-indices` | text <-> text with vowel indices | `vowels_indices`, `vowels_index` |
42+
`consonant-vowel-indices` | text <-> text with consonant and vowel indices | `consonants-vowels_index` | prefixes consonants with `C` and vowels with `V`
43+
44+
```python
45+
>>> codext.encode("This is a test", "consonant-index")
46+
'166I15I15A16E1516'
47+
>>> codext.decode("166I15I15A16E1516", "consonant-index")
48+
'THISISATEST'
49+
```
50+
51+
```python
52+
>>> codext.encode("This is a test", "vowel-index")
53+
'TH3S3S1T2ST'
54+
>>> codext.decode("TH3S3S1T2ST", "vowel-index")
55+
'THISISATEST'
56+
```
57+
58+
```python
59+
>>> codext.encode("This is a test", "consonant-vowel-index")
60+
'C16C6V3C15V3C15V1C16V2C15C16'
61+
>>> codext.decode("C16C6V3C15V3C15V1C16V2C15C16", "consonant-vowel-index")
62+
'THISISATEST'
63+
```
64+
65+
-----
66+
67+
### Markdown
68+
69+
This is only for "encoding" (converting) Markdown to HTML.
70+
71+
**Codec** | **Conversions** | **Aliases** | **Comment**
72+
:---: | :---: | --- | ---
73+
`markdown` | Markdown --> HTML | `markdown`, `Markdown`, `md` | unidirectional !
74+
75+
```python
76+
>>> codext.encode("# Test\nparagraph", "markdown")
77+
'<h1>Test</h1>\n\n<p>paragraph</p>\n'
78+
```
79+

src/codext/__info__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# -*- coding: UTF-8 -*-
2-
"""Codext package information.
3-
4-
"""
5-
import os
6-
from datetime import datetime
7-
8-
__author__ = "Alexandre D'Hondt"
9-
__copyright__ = "© 2019-{} A. D'Hondt".format(datetime.now().year)
10-
__email__ = "alexandre.dhondt@gmail.com"
11-
__license__ = "GPLv3 (https://www.gnu.org/licenses/gpl-3.0.fr.html)"
12-
__source__ = "https://github.com/dhondta/python-codext"
13-
14-
with open(os.path.join(os.path.dirname(__file__), "VERSION.txt")) as f:
15-
__version__ = f.read().strip()
16-
1+
# -*- coding: UTF-8 -*-
2+
"""Codext package information.
3+
4+
"""
5+
import os
6+
from datetime import datetime
7+
8+
__author__ = "Alexandre D'Hondt"
9+
__copyright__ = "© 2019-{} A. D'Hondt".format(datetime.now().year)
10+
__email__ = "alexandre.dhondt@gmail.com"
11+
__license__ = "GPLv3 (https://www.gnu.org/licenses/gpl-3.0.fr.html)"
12+
__source__ = "https://github.com/dhondta/python-codext"
13+
14+
with open(os.path.join(os.path.dirname(__file__), "VERSION.txt")) as f:
15+
__version__ = f.read().strip()
16+

0 commit comments

Comments
 (0)