string-to-code 0.2.0__tar.gz → 0.2.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 (23) hide show
  1. {string_to_code-0.2.0 → string_to_code-0.2.2}/PKG-INFO +1 -1
  2. {string_to_code-0.2.0 → string_to_code-0.2.2}/pyproject.toml +2 -1
  3. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/c_like_utils.py +2 -3
  4. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/core.py +6 -1
  5. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_ada.py +1 -2
  6. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_algol68.py +1 -2
  7. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_ballerina.py +1 -2
  8. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_bash.py +1 -2
  9. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_cobol.py +1 -2
  10. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_haskell.py +1 -2
  11. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_lisp.py +1 -2
  12. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_nim.py +1 -2
  13. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_pascal.py +1 -2
  14. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_python3.py +1 -2
  15. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_rust.py +1 -2
  16. {string_to_code-0.2.0 → string_to_code-0.2.2}/LICENSE +0 -0
  17. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/README.md +0 -0
  18. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/__init__.py +0 -0
  19. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/string_to_code.py +0 -0
  20. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_c.py +0 -0
  21. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_cpp.py +0 -0
  22. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/to_java.py +0 -0
  23. {string_to_code-0.2.0 → string_to_code-0.2.2}/string_to_code/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: string-to-code
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Generates a piece of messy code in a given language displaying a given string
5
5
  Home-page: https://github.com/vil02/string_to_code_proj
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "string-to-code"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "Generates a piece of messy code in a given language displaying a given string "
5
5
  authors = ["piotr.idzik <vil02@o2.pl>"]
6
6
  readme = "./string_to_code/README.md"
@@ -22,6 +22,7 @@ pylint = ">=2.0"
22
22
  flake8 = ">=5.0"
23
23
  coverage = ">=6.0"
24
24
  black = ">=21.0"
25
+ mypy = ">=1.4"
25
26
 
26
27
  [build-system]
27
28
  requires = ["poetry-core"]
@@ -6,7 +6,7 @@ from . import core
6
6
  from . import utils
7
7
 
8
8
 
9
- def escape_special_char(in_atom):
9
+ def escape_special_char(in_atom: core.Atom) -> str:
10
10
  """
11
11
  if in_char is a special_character function returns its escape sequences
12
12
  otherwise it returns in_char
@@ -24,8 +24,7 @@ def escape_special_char(in_atom):
24
24
  def get_atom_to_code(in_printer_function_name, in_escape_special_char_fun):
25
25
  """returns the atom_to_code type function"""
26
26
 
27
- def _inner(in_atom):
28
- assert isinstance(in_atom, core.Atom)
27
+ def _inner(in_atom: core.Atom) -> str:
29
28
  res_char = in_escape_special_char_fun(in_atom)
30
29
  return f"{in_printer_function_name}('{res_char}');"
31
30
 
@@ -1,11 +1,16 @@
1
1
  """
2
2
  core functions of the string_to_code module
3
3
  """
4
+ import typing
4
5
  import collections
5
6
  import random
6
7
  import functools
7
8
 
8
- Atom = collections.namedtuple("Atom", "atom_char")
9
+
10
+ class Atom(typing.NamedTuple):
11
+ """represents a single character to be printed"""
12
+
13
+ atom_char: str
9
14
 
10
15
 
11
16
  class SimpleFunction(collections.namedtuple("SimpleFunction", ["called_list"])):
@@ -10,12 +10,11 @@ _get_function_name = utils.get_function_name_fun("Proc_")
10
10
  _NULL_CALL = "null;"
11
11
 
12
12
 
13
- def atom_to_code(in_atom):
13
+ def atom_to_code(in_atom: core.Atom) -> str:
14
14
  """
15
15
  returns a string/piece of Ada code resulting in printing the
16
16
  in_atom.atom_char to the standard output
17
17
  """
18
- assert isinstance(in_atom, core.Atom)
19
18
  if in_atom.atom_char == "\n":
20
19
  return "Ada.Text_IO.New_Line;"
21
20
  return f"Ada.Text_IO.Put(Character'Val({ord(in_atom.atom_char)}));"
@@ -8,12 +8,11 @@ from . import utils
8
8
  _get_function_name = utils.get_function_name_fun("p")
9
9
 
10
10
 
11
- def atom_to_code(in_atom):
11
+ def atom_to_code(in_atom: core.Atom) -> str:
12
12
  """
13
13
  returns a string/piece of ALGOL 68 code resulting in printing the
14
14
  in_atom.atom_char to the standard output
15
15
  """
16
- assert isinstance(in_atom, core.Atom)
17
16
  special_char_dict = {"\n": "newline", '"': '""""'}
18
17
  res_char = special_char_dict.get(in_atom.atom_char, f'"{in_atom.atom_char}"')
19
18
  return f"print({res_char});"
@@ -9,12 +9,11 @@ from . import c_like_utils
9
9
  _get_function_name = utils.get_function_name_fun("fun_")
10
10
 
11
11
 
12
- def atom_to_code(in_atom):
12
+ def atom_to_code(in_atom: core.Atom) -> str:
13
13
  """
14
14
  returns a string/piece of ballerina code resulting in printing the
15
15
  in_atom.atom_char to the standard output
16
16
  """
17
- assert isinstance(in_atom, core.Atom)
18
17
  if in_atom.atom_char == "\n":
19
18
  res = "io:println();"
20
19
  else:
@@ -8,12 +8,11 @@ from . import utils
8
8
  _get_function_name = utils.get_function_name_fun()
9
9
 
10
10
 
11
- def atom_to_code(in_atom):
11
+ def atom_to_code(in_atom: core.Atom) -> str:
12
12
  """
13
13
  returns a string/piece of bash code resulting in printing the
14
14
  in_atom.atom_char to the standard output
15
15
  """
16
- assert isinstance(in_atom, core.Atom)
17
16
  special_chars = {
18
17
  r'"': r"\"",
19
18
  "\\": "\\\\",
@@ -8,7 +8,7 @@ from . import utils
8
8
  _get_function_name = utils.get_function_name_fun("P_")
9
9
 
10
10
 
11
- def atom_to_code(in_atom):
11
+ def atom_to_code(in_atom: core.Atom) -> str:
12
12
  """
13
13
  returns a string/piece of cobol code resulting in printing the
14
14
  in_atom.atom_char to the standard output
@@ -23,7 +23,6 @@ def atom_to_code(in_atom):
23
23
  }
24
24
  return special_char_dict.get(in_char, "'" + in_char + "'")
25
25
 
26
- assert isinstance(in_atom, core.Atom)
27
26
  res = f"DISPLAY {proc_char(in_atom.atom_char)} " "WITH NO ADVANCING END-DISPLAY."
28
27
  return res
29
28
 
@@ -8,12 +8,11 @@ from . import utils
8
8
  _get_function_name = utils.get_function_name_fun()
9
9
 
10
10
 
11
- def atom_to_code(in_atom):
11
+ def atom_to_code(in_atom: core.Atom) -> str:
12
12
  """
13
13
  returns a string/piece of bash code resulting in printing the
14
14
  in_atom.atom_char to the standard output
15
15
  """
16
- assert isinstance(in_atom, core.Atom)
17
16
  special_chars = {r'"': r"\"", "\\": "\\\\", "\n": "\\n", "\t": "\\t"}
18
17
  res_char = special_chars.get(in_atom.atom_char, in_atom.atom_char)
19
18
  return f'"{res_char}"'
@@ -8,12 +8,11 @@ from . import utils
8
8
  _get_function_name = utils.get_function_name_fun()
9
9
 
10
10
 
11
- def atom_to_code(in_atom):
11
+ def atom_to_code(in_atom: core.Atom) -> str:
12
12
  """
13
13
  returns a string/piece of lisp code resulting in printing the
14
14
  in_atom.atom_char to the standard output
15
15
  """
16
- assert isinstance(in_atom, core.Atom)
17
16
 
18
17
  def proc_char(in_char):
19
18
  special_char_dict = {
@@ -9,12 +9,11 @@ from . import c_like_utils
9
9
  _get_function_name = utils.get_function_name_fun("fun")
10
10
 
11
11
 
12
- def atom_to_code(in_atom):
12
+ def atom_to_code(in_atom: core.Atom) -> str:
13
13
  """
14
14
  returns a string/piece of nim code resulting in printing the
15
15
  in_atom.atom_char to the standard output
16
16
  """
17
- assert isinstance(in_atom, core.Atom)
18
17
  return f"stdout.write '{c_like_utils.escape_special_char(in_atom)}'"
19
18
 
20
19
 
@@ -9,12 +9,11 @@ from . import c_like_utils
9
9
  _get_function_name = utils.get_function_name_fun("p_")
10
10
 
11
11
 
12
- def atom_to_code(in_atom):
12
+ def atom_to_code(in_atom: core.Atom) -> str:
13
13
  """
14
14
  returns a string/piece of Pascal code resulting in printing the
15
15
  in_atom.atom_char to the standard output
16
16
  """
17
- assert isinstance(in_atom, core.Atom)
18
17
  if in_atom.atom_char == "\n":
19
18
  res = "WriteLn();"
20
19
  else:
@@ -8,12 +8,11 @@ from . import utils
8
8
  _get_function_name = utils.get_function_name_fun()
9
9
 
10
10
 
11
- def atom_to_code(in_atom):
11
+ def atom_to_code(in_atom: core.Atom) -> str:
12
12
  """
13
13
  returns a string/piece of python code resulting in printing the
14
14
  in_atom.atom_char to the standard output
15
15
  """
16
- assert isinstance(in_atom, core.Atom)
17
16
  print_arg = ""
18
17
  if in_atom.atom_char != "\n":
19
18
  special_chars = {r'"': r"\"", r"'": r"\'", "\\": "\\\\", "\t": "\\t"}
@@ -9,12 +9,11 @@ from . import c_like_utils
9
9
  _get_function_name = utils.get_function_name_fun()
10
10
 
11
11
 
12
- def atom_to_code(in_atom):
12
+ def atom_to_code(in_atom: core.Atom) -> str:
13
13
  """
14
14
  returns a string/piece of Rust code resulting in printing the
15
15
  in_atom.atom_char to the standard output
16
16
  """
17
- assert isinstance(in_atom, core.Atom)
18
17
  if in_atom.atom_char == "\n":
19
18
  return "println!();"
20
19
  special_chars = {
File without changes