codext 1.15.1__tar.gz → 1.15.2__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 (129) hide show
  1. {codext-1.15.1 → codext-1.15.2}/.readthedocs.yml +5 -0
  2. {codext-1.15.1 → codext-1.15.2}/PKG-INFO +1 -1
  3. {codext-1.15.1 → codext-1.15.2}/docs/coverage.svg +1 -1
  4. codext-1.15.2/docs/pages/img/logo.png +0 -0
  5. codext-1.15.2/pytest.ini +2 -0
  6. codext-1.15.2/src/codext/VERSION.txt +1 -0
  7. {codext-1.15.1 → codext-1.15.2}/src/codext/__common__.py +23 -23
  8. {codext-1.15.1 → codext-1.15.2}/src/codext.egg-info/PKG-INFO +1 -1
  9. {codext-1.15.1 → codext-1.15.2}/tests/test_base.py +7 -0
  10. {codext-1.15.1 → codext-1.15.2}/tests/test_generated.py +0 -1
  11. codext-1.15.1/docs/pages/img/logo.png +0 -0
  12. codext-1.15.1/pytest.ini +0 -2
  13. codext-1.15.1/src/codext/VERSION.txt +0 -1
  14. {codext-1.15.1 → codext-1.15.2}/.coveragerc +0 -0
  15. {codext-1.15.1 → codext-1.15.2}/.github/workflows/pypi-publish.yml +0 -0
  16. {codext-1.15.1 → codext-1.15.2}/.github/workflows/python-package.yml +0 -0
  17. {codext-1.15.1 → codext-1.15.2}/.gitignore +0 -0
  18. {codext-1.15.1 → codext-1.15.2}/LICENSE +0 -0
  19. {codext-1.15.1 → codext-1.15.2}/README.md +0 -0
  20. {codext-1.15.1 → codext-1.15.2}/docs/mkdocs.yml +0 -0
  21. {codext-1.15.1 → codext-1.15.2}/docs/pages/cli.md +0 -0
  22. {codext-1.15.1 → codext-1.15.2}/docs/pages/css/extra.css +0 -0
  23. {codext-1.15.1 → codext-1.15.2}/docs/pages/demos/using-bases.gif +0 -0
  24. {codext-1.15.1 → codext-1.15.2}/docs/pages/demos/using-codext.gif +0 -0
  25. {codext-1.15.1 → codext-1.15.2}/docs/pages/demos/using-debase.gif +0 -0
  26. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/base.md +0 -0
  27. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/binary.md +0 -0
  28. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/common.md +0 -0
  29. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/compressions.md +0 -0
  30. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/crypto.md +0 -0
  31. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/hashing.md +0 -0
  32. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/languages.md +0 -0
  33. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/others.md +0 -0
  34. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/stegano.md +0 -0
  35. {codext-1.15.1 → codext-1.15.2}/docs/pages/enc/web.md +0 -0
  36. {codext-1.15.1 → codext-1.15.2}/docs/pages/features.md +0 -0
  37. {codext-1.15.1 → codext-1.15.2}/docs/pages/guessing.md +0 -0
  38. {codext-1.15.1 → codext-1.15.2}/docs/pages/howto.md +0 -0
  39. {codext-1.15.1 → codext-1.15.2}/docs/pages/img/banner.png +0 -0
  40. {codext-1.15.1 → codext-1.15.2}/docs/pages/img/icon.png +0 -0
  41. {codext-1.15.1 → codext-1.15.2}/docs/pages/index.md +0 -0
  42. {codext-1.15.1 → codext-1.15.2}/docs/pages/manipulations.md +0 -0
  43. {codext-1.15.1 → codext-1.15.2}/docs/requirements.txt +0 -0
  44. {codext-1.15.1 → codext-1.15.2}/pyproject.toml +0 -0
  45. {codext-1.15.1 → codext-1.15.2}/requirements.txt +0 -0
  46. {codext-1.15.1 → codext-1.15.2}/setup.cfg +0 -0
  47. {codext-1.15.1 → codext-1.15.2}/src/codext/__info__.py +0 -0
  48. {codext-1.15.1 → codext-1.15.2}/src/codext/__init__.py +0 -0
  49. {codext-1.15.1 → codext-1.15.2}/src/codext/base/__init__.py +0 -0
  50. {codext-1.15.1 → codext-1.15.2}/src/codext/base/_base.py +0 -0
  51. {codext-1.15.1 → codext-1.15.2}/src/codext/base/_base2n.py +0 -0
  52. {codext-1.15.1 → codext-1.15.2}/src/codext/base/base100.py +0 -0
  53. {codext-1.15.1 → codext-1.15.2}/src/codext/base/base122.py +0 -0
  54. {codext-1.15.1 → codext-1.15.2}/src/codext/base/base45.py +0 -0
  55. {codext-1.15.1 → codext-1.15.2}/src/codext/base/base85.py +0 -0
  56. {codext-1.15.1 → codext-1.15.2}/src/codext/base/base91.py +0 -0
  57. {codext-1.15.1 → codext-1.15.2}/src/codext/base/baseN.py +0 -0
  58. {codext-1.15.1 → codext-1.15.2}/src/codext/binary/__init__.py +0 -0
  59. {codext-1.15.1 → codext-1.15.2}/src/codext/binary/baudot.py +0 -0
  60. {codext-1.15.1 → codext-1.15.2}/src/codext/binary/bcd.py +0 -0
  61. {codext-1.15.1 → codext-1.15.2}/src/codext/binary/excess3.py +0 -0
  62. {codext-1.15.1 → codext-1.15.2}/src/codext/binary/gray.py +0 -0
  63. {codext-1.15.1 → codext-1.15.2}/src/codext/binary/manchester.py +0 -0
  64. {codext-1.15.1 → codext-1.15.2}/src/codext/binary/rotate.py +0 -0
  65. {codext-1.15.1 → codext-1.15.2}/src/codext/common/__init__.py +0 -0
  66. {codext-1.15.1 → codext-1.15.2}/src/codext/common/a1z26.py +0 -0
  67. {codext-1.15.1 → codext-1.15.2}/src/codext/common/cases.py +0 -0
  68. {codext-1.15.1 → codext-1.15.2}/src/codext/common/dummy.py +0 -0
  69. {codext-1.15.1 → codext-1.15.2}/src/codext/common/octal.py +0 -0
  70. {codext-1.15.1 → codext-1.15.2}/src/codext/common/ordinal.py +0 -0
  71. {codext-1.15.1 → codext-1.15.2}/src/codext/compressions/__init__.py +0 -0
  72. {codext-1.15.1 → codext-1.15.2}/src/codext/compressions/gzipp.py +0 -0
  73. {codext-1.15.1 → codext-1.15.2}/src/codext/compressions/lz77.py +0 -0
  74. {codext-1.15.1 → codext-1.15.2}/src/codext/compressions/lz78.py +0 -0
  75. {codext-1.15.1 → codext-1.15.2}/src/codext/compressions/pkzip.py +0 -0
  76. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/__init__.py +0 -0
  77. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/affine.py +0 -0
  78. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/atbash.py +0 -0
  79. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/bacon.py +0 -0
  80. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/barbie.py +0 -0
  81. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/citrix.py +0 -0
  82. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/railfence.py +0 -0
  83. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/rot.py +0 -0
  84. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/scytale.py +0 -0
  85. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/shift.py +0 -0
  86. {codext-1.15.1 → codext-1.15.2}/src/codext/crypto/xor.py +0 -0
  87. {codext-1.15.1 → codext-1.15.2}/src/codext/hashing/__init__.py +0 -0
  88. {codext-1.15.1 → codext-1.15.2}/src/codext/hashing/blake.py +0 -0
  89. {codext-1.15.1 → codext-1.15.2}/src/codext/hashing/checksums.py +0 -0
  90. {codext-1.15.1 → codext-1.15.2}/src/codext/hashing/crypt.py +0 -0
  91. {codext-1.15.1 → codext-1.15.2}/src/codext/hashing/md.py +0 -0
  92. {codext-1.15.1 → codext-1.15.2}/src/codext/hashing/sha.py +0 -0
  93. {codext-1.15.1 → codext-1.15.2}/src/codext/hashing/shake.py +0 -0
  94. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/__init__.py +0 -0
  95. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/braille.py +0 -0
  96. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/galactic.py +0 -0
  97. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/ipsum.py +0 -0
  98. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/leetspeak.py +0 -0
  99. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/morse.py +0 -0
  100. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/navajo.py +0 -0
  101. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/radio.py +0 -0
  102. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/southpark.py +0 -0
  103. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/tap.py +0 -0
  104. {codext-1.15.1 → codext-1.15.2}/src/codext/languages/tomtom.py +0 -0
  105. {codext-1.15.1 → codext-1.15.2}/src/codext/macros.json +0 -0
  106. {codext-1.15.1 → codext-1.15.2}/src/codext/others/__init__.py +0 -0
  107. {codext-1.15.1 → codext-1.15.2}/src/codext/others/dna.py +0 -0
  108. {codext-1.15.1 → codext-1.15.2}/src/codext/others/kbshift.py +0 -0
  109. {codext-1.15.1 → codext-1.15.2}/src/codext/others/letters.py +0 -0
  110. {codext-1.15.1 → codext-1.15.2}/src/codext/others/markdown.py +0 -0
  111. {codext-1.15.1 → codext-1.15.2}/src/codext/others/uuencode.py +0 -0
  112. {codext-1.15.1 → codext-1.15.2}/src/codext/stegano/__init__.py +0 -0
  113. {codext-1.15.1 → codext-1.15.2}/src/codext/stegano/hexagram.py +0 -0
  114. {codext-1.15.1 → codext-1.15.2}/src/codext/stegano/klopf.py +0 -0
  115. {codext-1.15.1 → codext-1.15.2}/src/codext/stegano/resistor.py +0 -0
  116. {codext-1.15.1 → codext-1.15.2}/src/codext/stegano/rick.py +0 -0
  117. {codext-1.15.1 → codext-1.15.2}/src/codext/stegano/sms.py +0 -0
  118. {codext-1.15.1 → codext-1.15.2}/src/codext/stegano/whitespace.py +0 -0
  119. {codext-1.15.1 → codext-1.15.2}/src/codext/web/__init__.py +0 -0
  120. {codext-1.15.1 → codext-1.15.2}/src/codext/web/html.py +0 -0
  121. {codext-1.15.1 → codext-1.15.2}/src/codext/web/url.py +0 -0
  122. {codext-1.15.1 → codext-1.15.2}/src/codext.egg-info/SOURCES.txt +0 -0
  123. {codext-1.15.1 → codext-1.15.2}/src/codext.egg-info/dependency_links.txt +0 -0
  124. {codext-1.15.1 → codext-1.15.2}/src/codext.egg-info/entry_points.txt +0 -0
  125. {codext-1.15.1 → codext-1.15.2}/src/codext.egg-info/requires.txt +0 -0
  126. {codext-1.15.1 → codext-1.15.2}/src/codext.egg-info/top_level.txt +0 -0
  127. {codext-1.15.1 → codext-1.15.2}/tests/__init__.py +0 -0
  128. {codext-1.15.1 → codext-1.15.2}/tests/test_common.py +0 -0
  129. {codext-1.15.1 → codext-1.15.2}/tests/test_manual.py +0 -0
@@ -1,5 +1,10 @@
1
1
  version: 2
2
2
 
3
+ build:
4
+ os: "ubuntu-22.04"
5
+ tools:
6
+ python: "3.11"
7
+
3
8
  mkdocs:
4
9
  configuration: docs/mkdocs.yml
5
10
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: codext
3
- Version: 1.15.1
3
+ Version: 1.15.2
4
4
  Summary: Native codecs extension
5
5
  Author-email: Alexandre D'Hondt <alexandre.dhondt@gmail.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="114" height="20" role="img" aria-label="coverage: 99.16%"><title>coverage: 99.16%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="114" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="61" height="20" fill="#555"/><rect x="61" width="53" height="20" fill="#4c1"/><rect width="114" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="315" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text><text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text><text aria-hidden="true" x="865" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">99.16%</text><text x="865" y="140" transform="scale(.1)" fill="#fff" textLength="430">99.16%</text></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="114" height="20" role="img" aria-label="coverage: 99.13%"><title>coverage: 99.13%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="114" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="61" height="20" fill="#555"/><rect x="61" width="53" height="20" fill="#4c1"/><rect width="114" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="315" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text><text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text><text aria-hidden="true" x="865" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">99.13%</text><text x="865" y="140" transform="scale(.1)" fill="#fff" textLength="430">99.13%</text></g></svg>
Binary file
@@ -0,0 +1,2 @@
1
+ [pytest]
2
+ python_paths = src
@@ -0,0 +1 @@
1
+ 1.15.2
@@ -104,9 +104,9 @@ class CodecMacro(tuple):
104
104
  try:
105
105
  self.codecs = MACROS[name]
106
106
  except KeyError:
107
- raise LookupError("unknown macro: %s" % name)
107
+ raise LookupError(f"unknown macro: {name}")
108
108
  if not isinstance(self.codecs, (tuple, list)):
109
- raise ValueError("bad macro list: %s" % str(self.codecs))
109
+ raise ValueError(f"bad macro list: {self.codecs}")
110
110
  self.codecs = [lookup(e, False) for e in self.codecs] # lookup(e, False)
111
111
  self.parameters = {'name': name, 'category': "macro"} # ^ means that macros won't be nestable
112
112
  # test examples to check that the chain of encodings works
@@ -158,7 +158,7 @@ class CodecMacro(tuple):
158
158
  return input, l
159
159
 
160
160
  def __repr__(self):
161
- return "<codext.CodecMacro object for encoding %s at %#x>" % (self.name, id(self))
161
+ return f"<codext.CodecMacro object for encoding {self.name} at {id(self):#x}>"
162
162
 
163
163
 
164
164
  # inspired from: https://stackoverflow.com/questions/10875442/possible-to-change-a-functions-repr-in-python
@@ -172,7 +172,7 @@ class Repr(object):
172
172
  return self.__func(*args, **kwargs)
173
173
 
174
174
  def __repr__(self):
175
- return "<search-function %s at 0x%x>" % (self.__name, id(self))
175
+ return f"<search-function {self.__name} at {id(self):#x}>"
176
176
 
177
177
 
178
178
  def __stdin_pipe():
@@ -200,7 +200,7 @@ def _input(infile):
200
200
 
201
201
  def _set_exc(name, etype="ValueError"):
202
202
  if not hasattr(builtins, name):
203
- exec("class %s(%s): __module__ = 'builtins'" % (name, etype))
203
+ exec(f"class {name}({etype}): __module__ = 'builtins'")
204
204
  setattr(builtins, name, locals()[name])
205
205
  _set_exc("InputSizeLimitError")
206
206
  _set_exc("ParameterError")
@@ -237,11 +237,11 @@ def add(ename, encode=None, decode=None, pattern=None, text=True, add_to_codecs=
237
237
  if encode:
238
238
  if not isinstance(encode, FunctionType):
239
239
  raise ValueError("Bad 'encode' function")
240
- _set_exc("%sEncodeError" % exc_name(ename)) # create the custom encode exception as a builtin
240
+ _set_exc(f"{exc_name(ename)}EncodeError") # create the custom encode exception as a builtin
241
241
  if decode:
242
242
  if not isinstance(decode, FunctionType):
243
243
  raise ValueError("Bad 'decode' function")
244
- _set_exc("%sDecodeError" % exc_name(ename)) # create the custom decode exception as a builtin
244
+ _set_exc(f"{exc_name(ename)}DecodeError") # create the custom decode exception as a builtin
245
245
  if not encode and not decode:
246
246
  raise ValueError("At least one en/decoding function must be defined")
247
247
  for exc in kwargs.get('extra_exceptions', []):
@@ -375,7 +375,7 @@ def add_macro(mname, *encodings):
375
375
  raise ValueError("Macro name already exists")
376
376
  try:
377
377
  ci = lookup(mname, False)
378
- raise ValueError("Macro name clashes with codec '%s'" % ci.name)
378
+ raise ValueError(f"Macro name clashes with codec '{ci.name}'")
379
379
  except LookupError:
380
380
  pass
381
381
  try:
@@ -463,7 +463,7 @@ def add_map(ename, encmap, repl_char="?", sep="", ignore_case=None, no_error=Fal
463
463
  isinstance(mapdict, dict) and p in mapdict.keys():
464
464
  smapdict = {k: v for k, v in mapdict[p].items()}
465
465
  else:
466
- raise LookupError("Bad parameter for encoding '{}': '{}'".format(ename, p))
466
+ raise LookupError(f"Bad parameter for encoding '{ename}': '{p}'")
467
467
  # case 3: dictionary of regex-selected encoding mappings
468
468
  elif isinstance(mapdict, dict) and isinstance(list(mapdict.values())[0], dict):
469
469
  tmp = None
@@ -474,7 +474,7 @@ def add_map(ename, encmap, repl_char="?", sep="", ignore_case=None, no_error=Fal
474
474
  tmp = d
475
475
  break
476
476
  if tmp is None:
477
- raise LookupError("Bad parameter for encoding '{}': '{}'".format(ename, p))
477
+ raise LookupError(f"Bad parameter for encoding '{ename}': '{p}'")
478
478
  smapdict = tmp
479
479
  # case 4: encoding characters translation
480
480
  else:
@@ -494,7 +494,7 @@ def add_map(ename, encmap, repl_char="?", sep="", ignore_case=None, no_error=Fal
494
494
  for k, v in smapdict.items():
495
495
  smapdict[k] = [x.translate(t) for x in v] if isinstance(v, list) else v.translate(t)
496
496
  else:
497
- raise LookupError("Bad parameter for encoding '{}': '{}'".format(ename, p))
497
+ raise LookupError(f"Bad parameter for encoding '{ename}': '{p}'")
498
498
  if ignore_case is not None:
499
499
  cases = ["upper", "lower"]
500
500
  case_d = cases[any(c in str(list(smapdict.values())) for c in "abcdefghijklmnopqrstuvwxyz")]
@@ -538,7 +538,7 @@ def add_map(ename, encmap, repl_char="?", sep="", ignore_case=None, no_error=Fal
538
538
  text = ensure_str(text)
539
539
  if not decode:
540
540
  if intype == "bin":
541
- text = "".join("{:0>8}".format(bin(ord(c))[2:]) for c in text)
541
+ text = "".join(f"{bin(ord(c))[2:]:0>8}" for c in text)
542
542
  elif intype == "ord":
543
543
  text = "".join(str(ord(c)).zfill(3) for c in text)
544
544
  r = ""
@@ -720,7 +720,7 @@ def list_encodings(*categories):
720
720
  enc.append(name)
721
721
  for category in categories:
722
722
  if category not in CODECS_CATEGORIES:
723
- raise ValueError("Category '%s' does not exist" % category)
723
+ raise ValueError(f"Category '{category}' does not exist")
724
724
  return sorted(list(set(enc)), key=_human_keys)
725
725
 
726
726
 
@@ -755,7 +755,7 @@ def remove(name):
755
755
  pass
756
756
  for s in ["En", "De"]:
757
757
  try:
758
- delattr(builtins, "%s%scodeError" % (name.capitalize(), s))
758
+ delattr(builtins, f"{name.capitalize()}{s}codeError")
759
759
  except AttributeError:
760
760
  pass
761
761
  codecs.remove = remove
@@ -801,7 +801,7 @@ def b(s):
801
801
  return s
802
802
 
803
803
 
804
- def ensure_str(s, encoding='utf-8', errors='strict'):
804
+ def ensure_str(s, encoding="utf-8", errors='strict'):
805
805
  """ Dummy str conversion function. """
806
806
  if isinstance(s, bytes):
807
807
  try:
@@ -859,7 +859,7 @@ def handle_error(ename, errors, sep="", repl_char="?", repl_minlen=1, decode=Fal
859
859
  :param decode: whether we are encoding or decoding
860
860
  :param item: position item description (for describing the error ; e.g. "group" or "token")
861
861
  """
862
- exc = "%s%scodeError" % (exc_name(ename), ["En", "De"][decode])
862
+ exc = f"{exc_name(ename)}{['En','De'][decode]}codeError"
863
863
 
864
864
  def _handle_error(token, position, output="", eename=None):
865
865
  """ This handles an encoding/decoding error according to the selected handling mode.
@@ -883,7 +883,7 @@ def handle_error(ename, errors, sep="", repl_char="?", repl_minlen=1, decode=Fal
883
883
  elif errors == "ignore":
884
884
  return ""
885
885
  else:
886
- raise ValueError("Unsupported error handling '{}'".format(errors))
886
+ raise ValueError(f"Unsupported error handling '{errors}'")
887
887
  return _handle_error
888
888
 
889
889
 
@@ -950,7 +950,7 @@ def lookup(encoding, macro=True):
950
950
  try:
951
951
  return CodecMacro(encoding)
952
952
  except LookupError:
953
- e = LookupError("unknown encoding: %s" % encoding)
953
+ e = LookupError(f"unknown encoding: {encoding}")
954
954
  e.__cause__ = e # stop exception chaining
955
955
  raise e
956
956
  codecs.lookup = lookup
@@ -1112,7 +1112,7 @@ def __gen_str_from_re(regex, star_plus_max, repeat_max, yield_max, parsed=False)
1112
1112
  __groups[value[0]] = result
1113
1113
  tokens.append(result)
1114
1114
  else:
1115
- raise NotImplementedError("Unhandled code '{}'".format(code))
1115
+ raise NotImplementedError(f"Unhandled code '{code}'")
1116
1116
  if len(tokens) == 0:
1117
1117
  tokens = [""]
1118
1118
  i = 0
@@ -1231,11 +1231,11 @@ def _load_lang_backend(backend=None):
1231
1231
  stopfunc.CLD3_LANGUAGES if _lb == "cld3" else \
1232
1232
  stopfunc.TEXTBLOB_LANGUAGES if _lb == "textblob" else \
1233
1233
  []):
1234
- n = "lang_%s" % lang
1234
+ n = f"lang_{lang}"
1235
1235
  setattr(stopfunc, n, _lang(lang))
1236
1236
  getattr(stopfunc, n).__name__ = getattr(stopfunc, n).__qualname__ = n
1237
1237
  if LANG:
1238
- flng = "lang_%s" % LANG
1238
+ flng = f"lang_{LANG}"
1239
1239
  if getattr(stopfunc, flng, None):
1240
1240
  stopfunc.default = getattr(stopfunc, flng)
1241
1241
  stopfunc._reload_lang = _load_lang_backend
@@ -1263,7 +1263,7 @@ def __guess(prev_input, input, stop_func, depth, max_depth, min_depth, encodings
1263
1263
  if not stop and (show or debug) and found not in result:
1264
1264
  s = repr(input)
1265
1265
  s = s[2:-1] if s.startswith("b'") and s.endswith("'") else s
1266
- s = "[+] %s: %s" % (", ".join(found), s)
1266
+ s = "[+] {', '.join(found)}: {s}"
1267
1267
  print(s if len(s) <= 80 else s[:77] + "...")
1268
1268
  result[found] = input
1269
1269
  if depth >= max_depth or len(result) > 0 and stop:
@@ -1274,7 +1274,7 @@ def __guess(prev_input, input, stop_func, depth, max_depth, min_depth, encodings
1274
1274
  if len(result) > 0 and stop:
1275
1275
  return
1276
1276
  if debug:
1277
- print("[*] Depth %0{}d/%d: %s".format(len(str(max_depth))) % (depth+1, max_depth, encoding))
1277
+ print(f"[*] Depth %0{len(str(max_depth))}d/%d: {encoding}" % (depth+1, max_depth))
1278
1278
  __guess(input, new_input, stop_func, depth+1, max_depth, min_depth, encodings, result, found + (encoding, ),
1279
1279
  stop, show, scoring_heuristic, extended, debug)
1280
1280
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: codext
3
- Version: 1.15.1
3
+ Version: 1.15.2
4
4
  Summary: Native codecs extension
5
5
  Author-email: Alexandre D'Hondt <alexandre.dhondt@gmail.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -3,6 +3,7 @@
3
3
  """Base codecs tests.
4
4
 
5
5
  """
6
+ import base64
6
7
  import sys
7
8
  from unittest import TestCase
8
9
 
@@ -186,6 +187,12 @@ class TestCodecsBase(TestCase):
186
187
  self.assertEqual(codecs.encode(b(STR), enc), b(b64))
187
188
  self.assertEqual(codecs.decode(b64, enc), STR)
188
189
  self.assertEqual(codecs.decode(b(b64), enc), b(STR))
190
+ # source: https://github.com/dhondta/python-codext/issues/8
191
+ enc = "JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7/KQovQ3JlYXRvciAo/v8AdwBrAGgAdABt"
192
+ dec = b"%PDF-1.4\n1 0 obj\n<<\n/Title (\xfe\xff)\n/Creator (\xfe\xff\x00w\x00k\x00h\x00t\x00m"
193
+ self.assertEqual(codecs.decode(b(enc), "base64"), dec)
194
+ self.assertEqual(base64.b64decode(b(enc)), dec)
195
+
189
196
 
190
197
  def test_codec_base91(self):
191
198
  for b91, enc in zip([",X,<:WRT%yxth90oZB", ",N,<:MHJ%onjXzqeP1", "Jx&[jv4S3Wg>,71@Jk", "yJy^\\IDFsdc?Tof:L#"],
@@ -32,7 +32,6 @@ def make_test(**params):
32
32
  f1 = getattr(codecs, ["decode", "encode"][k.startswith("enc")])
33
33
  f2 = getattr(codecs, ["encode", "decode"][k.startswith("enc")])
34
34
  for ename in m.groups():
35
- #FIXME
36
35
  if ename == "*":
37
36
  # ignore mode only
38
37
  continue
Binary file
codext-1.15.1/pytest.ini DELETED
@@ -1,2 +0,0 @@
1
- [pytest]
2
- pythonpath = src
@@ -1 +0,0 @@
1
- 1.15.1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes