string-to-code 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl

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.
@@ -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
 
string_to_code/core.py CHANGED
@@ -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"])):
string_to_code/to_ada.py CHANGED
@@ -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:
string_to_code/to_bash.py CHANGED
@@ -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}"'
string_to_code/to_lisp.py CHANGED
@@ -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 = {
string_to_code/to_nim.py CHANGED
@@ -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"}
string_to_code/to_rust.py CHANGED
@@ -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 = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: string-to-code
3
- Version: 0.2.1
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
@@ -0,0 +1,24 @@
1
+ string_to_code/README.md,sha256=A8BkDQpr-Os630YfGnaU-i_kigyVB8bNLhvLfIyzQR8,1225
2
+ string_to_code/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ string_to_code/c_like_utils.py,sha256=G2HMxU6J9Lczv28yTNJSXLAeTyOHY1RV6gKltvf1h1E,2091
4
+ string_to_code/core.py,sha256=Fi_CPHhqZCTZ2L-LK8sSBbHbLAy7nTDywbzfGoKrUZA,3747
5
+ string_to_code/string_to_code.py,sha256=ldAczke3qmY4UnodSP6oaq-Gu89IOubZAXUDflpo61k,1212
6
+ string_to_code/to_ada.py,sha256=-QUNxghg4KcZzqya0YgBoHJnFA2aYwnjw28Qec-EqJc,2264
7
+ string_to_code/to_algol68.py,sha256=ENxJbUKIL-iOXz3QrhXdGVUhrv5b_Ogjt_1NLrYbZjY,1641
8
+ string_to_code/to_ballerina.py,sha256=IocFGqWvSZ2vwEjp0WmGcbgHZsMtVNEtIsenV-kr2FM,1875
9
+ string_to_code/to_bash.py,sha256=VfvtSmzqacOHVaZf8t8z7l0OKsT6qmEnq7gvgu5LCTY,1633
10
+ string_to_code/to_c.py,sha256=jZWxRPCfOglGDh92CN7ndsBPIkkJ80GQVgYG-_nrzYY,1007
11
+ string_to_code/to_cobol.py,sha256=KlO7t2AuEph0nH76HBZ4rTxR5tQecvWhfqvpM2vOpbE,2129
12
+ string_to_code/to_cpp.py,sha256=mBtaByTuwhaEoSXBNmSOWxZ213ZRfY7Y3-hDUVaMZE0,1025
13
+ string_to_code/to_haskell.py,sha256=8JEo-hbPLalx4WW184FhPPYlF14sOL_KYxHGJ21FMIo,1948
14
+ string_to_code/to_java.py,sha256=4SIj3lojYZYIEiS7DyUm7Dv16XQ8wBcFn6KCO7_W0p0,1864
15
+ string_to_code/to_lisp.py,sha256=66iBMh51eTaWP8NPuaRNC5e8g14CaleRVyHo8GPqqwQ,1604
16
+ string_to_code/to_nim.py,sha256=QolGTXNj764qZOEkYJ0uSBhda1tdQCgnYqgUqyrVTMw,1533
17
+ string_to_code/to_pascal.py,sha256=EQ1wUQ-jz5frIB0_OQ3h2v8BDitzKFhVsey_xlX3XMg,1921
18
+ string_to_code/to_python3.py,sha256=ZLU29deSg-rsfR5HmlB5ZCH2pURGmGFdNDfcIZ_DdNU,1588
19
+ string_to_code/to_rust.py,sha256=xbkKKhvFxbOBtSgh-5_hGJ8zSBDt4vNIqEiJW9JsoXw,1925
20
+ string_to_code/utils.py,sha256=SbS_bXtLJd_ROTnxiW41M3_IuoGBiVqDHsxfvEsPyg8,3381
21
+ string_to_code-0.2.2.dist-info/LICENSE,sha256=LQrcSkcUyN1FtFYDxWK05puxNN9o2q8PV-_2SwFDTWc,1068
22
+ string_to_code-0.2.2.dist-info/METADATA,sha256=jcHFz0HhDQVN62WOiKIHM9jiT8CD96Jgl1I7Uq653Hw,1998
23
+ string_to_code-0.2.2.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
24
+ string_to_code-0.2.2.dist-info/RECORD,,
@@ -1,24 +0,0 @@
1
- string_to_code/README.md,sha256=A8BkDQpr-Os630YfGnaU-i_kigyVB8bNLhvLfIyzQR8,1225
2
- string_to_code/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- string_to_code/c_like_utils.py,sha256=_Vcreew0gtkqA1pWx-KRMWwyF55Y6rsgs1HK41SScsA,2101
4
- string_to_code/core.py,sha256=NS7_Ydp_iz3j4zK-D4oNCmhPpsWxuqjKOOddwKwOGWY,3678
5
- string_to_code/string_to_code.py,sha256=ldAczke3qmY4UnodSP6oaq-Gu89IOubZAXUDflpo61k,1212
6
- string_to_code/to_ada.py,sha256=p9WDJ1qoNRnoQQ7JShBw94OShuMW3wjg_FXzjlK0c0c,2288
7
- string_to_code/to_algol68.py,sha256=7r11G4XDfvfatkdr9t0y6s3riQWDBkCyVE7lIdIaytU,1665
8
- string_to_code/to_ballerina.py,sha256=sm461UiMW6SPXCa9ZXM4VBTPDQmx2yyPcLgbiMC_FpY,1899
9
- string_to_code/to_bash.py,sha256=KOc-gnGEtrrr0OilF_gpVmO_sV23oEfuJ4FobTZlkPg,1657
10
- string_to_code/to_c.py,sha256=jZWxRPCfOglGDh92CN7ndsBPIkkJ80GQVgYG-_nrzYY,1007
11
- string_to_code/to_cobol.py,sha256=QYs_ygBSoGYVUqbLc4tjR2i3LXV98vFjjAGU2mzZnqI,2153
12
- string_to_code/to_cpp.py,sha256=mBtaByTuwhaEoSXBNmSOWxZ213ZRfY7Y3-hDUVaMZE0,1025
13
- string_to_code/to_haskell.py,sha256=gKEMjXmFHYabVWdjpDeAyKu1Zu4We2-FejzJ8-BtCk0,1972
14
- string_to_code/to_java.py,sha256=4SIj3lojYZYIEiS7DyUm7Dv16XQ8wBcFn6KCO7_W0p0,1864
15
- string_to_code/to_lisp.py,sha256=qXNWYn1yERCujAyJcWitngR6CXC5xA8JHxE8mvAIe-s,1628
16
- string_to_code/to_nim.py,sha256=C8BTciGaS957xPKmqluyEOS3xlRDE0nv3HEdzD_Bvko,1557
17
- string_to_code/to_pascal.py,sha256=rY-kwrv9myNXI7sBalRio4S6-UJwZTFRNxEr8atzFak,1945
18
- string_to_code/to_python3.py,sha256=abssxuWp36NORt5zieBymyV1wctL-E27azBr-OFouPo,1612
19
- string_to_code/to_rust.py,sha256=P7FCDQSr3uuz7FP1YTcfK2Vb1-9j0ymcjaDa7ifBFf4,1949
20
- string_to_code/utils.py,sha256=SbS_bXtLJd_ROTnxiW41M3_IuoGBiVqDHsxfvEsPyg8,3381
21
- string_to_code-0.2.1.dist-info/LICENSE,sha256=LQrcSkcUyN1FtFYDxWK05puxNN9o2q8PV-_2SwFDTWc,1068
22
- string_to_code-0.2.1.dist-info/METADATA,sha256=nF1ZRBKN2KrrobwDSbj94s0JWdIG7iVt3WuwUPRNfXk,1998
23
- string_to_code-0.2.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
24
- string_to_code-0.2.1.dist-info/RECORD,,