string-to-code 0.4.1__py3-none-any.whl → 0.5.1__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.
@@ -4,8 +4,7 @@ utilities for C-like languages
4
4
 
5
5
  import typing
6
6
 
7
- from . import core
8
- from . import utils
7
+ from . import core, utils
9
8
 
10
9
 
11
10
  def escape_special_char(in_atom: core.Atom) -> str:
string_to_code/core.py CHANGED
@@ -2,9 +2,9 @@
2
2
  core functions of the string_to_code module
3
3
  """
4
4
 
5
- import typing
6
- import random
7
5
  import functools
6
+ import random
7
+ import typing
8
8
 
9
9
  Strings: typing.TypeAlias = list[str]
10
10
 
@@ -83,10 +83,10 @@ def get_function_namer(
83
83
 
84
84
  def _prepare_printer_program(
85
85
  in_str: str,
86
- ) -> typing.Tuple[InitialCall, SimpleFunctions]:
86
+ ) -> tuple[InitialCall, SimpleFunctions]:
87
87
  needed_functions: SimpleFunctions = []
88
88
 
89
- @functools.lru_cache(maxsize=None)
89
+ @functools.cache
90
90
  def _generate_code(in_str: str) -> CalledListEntry:
91
91
  if len(in_str) == 1:
92
92
  return Atom(in_str)
@@ -4,8 +4,8 @@ Provides utilities related to:
4
4
  - calling proc-like functions, where target language is specified programmatically
5
5
  """
6
6
 
7
- import pathlib
8
7
  import importlib
8
+ import pathlib
9
9
 
10
10
 
11
11
  def _remove_prefix(in_str: str, in_prefix: str) -> str:
string_to_code/to_ada.py CHANGED
@@ -2,9 +2,7 @@
2
2
  provides string_to_ada utilities
3
3
  """
4
4
 
5
- from . import utils
6
- from . import core
7
-
5
+ from . import core, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun("Proc_")
10
8
 
@@ -2,9 +2,7 @@
2
2
  provides string_to_algol68 utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
-
5
+ from . import core, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun("p")
10
8
 
@@ -2,10 +2,7 @@
2
2
  provides string_to_ballereina utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
- from . import c_like_utils
8
-
5
+ from . import c_like_utils, core, utils
9
6
 
10
7
  _get_function_name = utils.get_function_name_fun("fun_")
11
8
 
@@ -53,13 +50,7 @@ def _main_call_to_code(in_initial_call, **kwargs):
53
50
  if in_initial_call is not None
54
51
  else ""
55
52
  )
56
- return "".join(
57
- [
58
- "public function main() {\n",
59
- initial_call_str,
60
- "}",
61
- ]
62
- )
53
+ return f"public function main() {{\n{initial_call_str}}}"
63
54
 
64
55
 
65
56
  def _join_to_final(main_call, function_definitions, **_kwargs):
string_to_code/to_bash.py CHANGED
@@ -2,9 +2,7 @@
2
2
  provides string_to_bash utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
-
5
+ from . import core, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun()
10
8
 
string_to_code/to_c.py CHANGED
@@ -2,9 +2,7 @@
2
2
  provides string_to_c utilities
3
3
  """
4
4
 
5
- from . import utils
6
- from . import c_like_utils
7
-
5
+ from . import c_like_utils, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun()
10
8
 
@@ -2,9 +2,7 @@
2
2
  provides string_to_cobol utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
-
5
+ from . import core, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun("P_")
10
8
 
string_to_code/to_cpp.py CHANGED
@@ -2,9 +2,7 @@
2
2
  provides string_to_cpp utilities
3
3
  """
4
4
 
5
- from . import utils
6
- from . import c_like_utils
7
-
5
+ from . import c_like_utils, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun()
10
8
 
@@ -2,9 +2,7 @@
2
2
  provides string_to_fortran90 utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
-
5
+ from . import core, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun("fun_")
10
8
 
@@ -2,9 +2,7 @@
2
2
  provides string_to_haskell utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
-
5
+ from . import core, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun()
10
8
 
string_to_code/to_java.py CHANGED
@@ -2,9 +2,7 @@
2
2
  provides string_to_java utilities
3
3
  """
4
4
 
5
- from . import utils
6
- from . import c_like_utils
7
-
5
+ from . import c_like_utils, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun("fun")
10
8
 
@@ -45,13 +43,7 @@ def _main_call_to_code(in_initial_call, **kwargs):
45
43
  if in_initial_call is not None
46
44
  else " "
47
45
  )
48
- return "".join(
49
- [
50
- " public static void main(String[] args) {\n",
51
- initial_call_str,
52
- "}",
53
- ]
54
- )
46
+ return f" public static void main(String[] args) {{\n{initial_call_str}}}"
55
47
 
56
48
 
57
49
  def _join_to_final(main_call, function_definitions, **kwargs):
@@ -0,0 +1,69 @@
1
+ """
2
+ provides string_to_kotlin utilities
3
+ """
4
+
5
+ from . import core, utils
6
+
7
+ _get_function_name = utils.get_function_name_fun("fun")
8
+
9
+
10
+ def _atom_to_code(in_atom: core.Atom) -> str:
11
+ if in_atom.atom_char == "\n":
12
+ return "println()"
13
+ special_chars = {
14
+ '"': '\\"',
15
+ "'": "\\'",
16
+ "\\": "\\\\",
17
+ "\t": "\\t",
18
+ "{": "{",
19
+ "}": "}",
20
+ }
21
+ res_char = special_chars.get(in_atom.atom_char, in_atom.atom_char)
22
+ return f"print('{res_char}')"
23
+
24
+
25
+ _function_call_str = utils.get_function_call_str_fun(_get_function_name, "", "()")
26
+
27
+
28
+ _call_function_or_atom = utils.get_call_function_or_atom(
29
+ _atom_to_code, _function_call_str
30
+ )
31
+
32
+ _EMPTY_BODY = " // No code needed"
33
+
34
+ _body_to_str = utils.get_body_to_str(
35
+ "\n", " ", _call_function_or_atom, "", _EMPTY_BODY
36
+ )
37
+
38
+
39
+ def _merge_to_full_function(in_function_name, in_function_body):
40
+ body_str = "\n" + in_function_body + "\n"
41
+ return f"fun {in_function_name}() {{{body_str}}}\n"
42
+
43
+
44
+ _function_to_code = utils.get_function_to_code(
45
+ _get_function_name, _body_to_str, _merge_to_full_function
46
+ )
47
+
48
+
49
+ def _main_call_to_code(in_initial_call, **kwargs):
50
+ call_in_main = (
51
+ "\n" + _EMPTY_BODY
52
+ if in_initial_call is None
53
+ else "\n " + _call_function_or_atom(in_initial_call, **kwargs)
54
+ )
55
+ return "fun main() {" + call_in_main + "\n}\n"
56
+
57
+
58
+ def _join_to_final(main_call, function_definitions, **_kwargs):
59
+ function_definitions_str = (
60
+ "\n".join(function_definitions) if function_definitions else ""
61
+ )
62
+ if function_definitions_str:
63
+ function_definitions_str = function_definitions_str + "\n"
64
+ return function_definitions_str + main_call
65
+
66
+
67
+ proc_printer_program, proc = utils.get_all_proc_functions(
68
+ _main_call_to_code, _function_to_code, _join_to_final
69
+ )
string_to_code/to_lisp.py CHANGED
@@ -2,9 +2,7 @@
2
2
  provides string_to_lisp utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
-
5
+ from . import core, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun()
10
8
 
string_to_code/to_lua.py CHANGED
@@ -2,8 +2,7 @@
2
2
  provides string_to_lua utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
5
+ from . import core, utils
7
6
 
8
7
 
9
8
  def _get_table_name(**kwargs) -> str:
string_to_code/to_nim.py CHANGED
@@ -2,10 +2,7 @@
2
2
  provides string_to_nim utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
- from . import c_like_utils
8
-
5
+ from . import c_like_utils, core, utils
9
6
 
10
7
  _get_function_name = utils.get_function_name_fun("fun")
11
8
 
@@ -2,10 +2,7 @@
2
2
  provides string_to_pascal utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
- from . import c_like_utils
8
-
5
+ from . import c_like_utils, core, utils
9
6
 
10
7
  _get_function_name = utils.get_function_name_fun("p_")
11
8
 
@@ -2,9 +2,7 @@
2
2
  provides string_to_python utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
-
5
+ from . import core, utils
8
6
 
9
7
  _get_function_name = utils.get_function_name_fun()
10
8
 
string_to_code/to_rust.py CHANGED
@@ -2,10 +2,7 @@
2
2
  provides string_to_rust utilities
3
3
  """
4
4
 
5
- from . import core
6
- from . import utils
7
- from . import c_like_utils
8
-
5
+ from . import c_like_utils, core, utils
9
6
 
10
7
  _get_function_name = utils.get_function_name_fun()
11
8
 
string_to_code/utils.py CHANGED
@@ -3,6 +3,7 @@ utilities for to_some_language modules
3
3
  """
4
4
 
5
5
  import typing
6
+
6
7
  from . import core
7
8
 
8
9
 
@@ -1,19 +1,20 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: string-to-code
3
- Version: 0.4.1
3
+ Version: 0.5.1
4
4
  Summary: Generates a piece of messy code in a given language displaying a given string
5
- Home-page: https://github.com/vil02/string_to_code_proj
6
5
  License: MIT
6
+ License-File: LICENSE
7
7
  Keywords: code-generation
8
8
  Author: piotr.idzik
9
9
  Author-email: vil02@o2.pl
10
- Requires-Python: >=3.10,<4.0.0
10
+ Requires-Python: >=3.11,<4.0.0
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
17
18
  Project-URL: Repository, https://github.com/vil02/string_to_code_proj
18
19
  Description-Content-Type: text/markdown
19
20
 
@@ -0,0 +1,27 @@
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=gW3f2NyjW-a63SAa497rJzVDTWpvpZ_XGET2IGMrq2g,2365
4
+ string_to_code/core.py,sha256=fiW5MW26DWko2vK7vHyGMXb9B2spk_N2Z1S906o9iBU,4414
5
+ string_to_code/string_to_code.py,sha256=GHutPsTcUWUoi7JYEi0zaRpPSidMbqo-fsksVx9Qdlo,1304
6
+ string_to_code/to_ada.py,sha256=yteFY4-qxwf6mmTB4OXoI-0v1-r0-bdh1yAEdscd8XM,2337
7
+ string_to_code/to_algol68.py,sha256=oU43PqqCZBAI1clH6c125ABzJXmxnW_puDaa0IlSt_M,1735
8
+ string_to_code/to_ballerina.py,sha256=thrh3KIN1O8To2KEGAkAd517qAZl_f2hvxMdwLEMDE8,1776
9
+ string_to_code/to_bash.py,sha256=jYnjCrJ7X1H30VJUMbPm4h8sTpbzYBZrFIJC7LSSOtU,1620
10
+ string_to_code/to_c.py,sha256=eRLQuvShA4m-KeRWtG-LEf_ok8eURAnrJ6nUOIGILJg,994
11
+ string_to_code/to_cobol.py,sha256=JsOq-SwQAhRAWwgaW4gE7kexjTPqbQa9fdXx_PLY8yw,2116
12
+ string_to_code/to_cpp.py,sha256=VHC-FpH0D-3BxhBS1o12iIAP5Gng7ARxo4N6pb3g-Vc,1012
13
+ string_to_code/to_fortran90.py,sha256=Ks3Hj8EqUBfotqnmavX4181BZVPUXCiu6CSzfB2EAvM,1778
14
+ string_to_code/to_haskell.py,sha256=9nMg81KxqYaqSvaF9HKvSnC8KGbgwsoT_as79Iy8DkM,1963
15
+ string_to_code/to_java.py,sha256=2gqIZdrXHWAPc5va7Nr0x29-TV6aCVXHGD29DqXKCco,1778
16
+ string_to_code/to_kotlin.py,sha256=Cd6amuiGszNmUflsFhX7Z3TqEdKnm0ZKGFupPKuZg_U,1808
17
+ string_to_code/to_lisp.py,sha256=fuxV0Do4DquDvIJlJSUGgB7DlB4eICs4kTKPpANPrMk,1591
18
+ string_to_code/to_lua.py,sha256=PlhF6NunxISlOTOmX_somy2vAeLpwSsrI-ui2P6EjoY,2032
19
+ string_to_code/to_nim.py,sha256=im-GkAI9Lm0WOIPjFe1SaItcv9qJpN0oSTLH52bpQ84,1507
20
+ string_to_code/to_pascal.py,sha256=VjVBhlHY79mdHrFDqfYCPhgUwdSvwZ_xP-wAjSJrufc,1909
21
+ string_to_code/to_python3.py,sha256=CRA-dZCplD4sbyvVk9HBDo77WET-GIxah57aQDd4i8c,1575
22
+ string_to_code/to_rust.py,sha256=FGdBOih3cou1uyIlSe7pxH6RKP8XGfdGC7VVZyeMfKM,1899
23
+ string_to_code/utils.py,sha256=P7XhiTXFgzhG2dJPkI3Wj7Y3X4Tdiizgmu_nBN8N6vM,3848
24
+ string_to_code-0.5.1.dist-info/METADATA,sha256=c9D_XpFfmCjPngvye3owZ5-ATEP2WABIT3U0spvOT1k,1975
25
+ string_to_code-0.5.1.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
26
+ string_to_code-0.5.1.dist-info/licenses/LICENSE,sha256=LQrcSkcUyN1FtFYDxWK05puxNN9o2q8PV-_2SwFDTWc,1068
27
+ string_to_code-0.5.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.0.0
2
+ Generator: poetry-core 2.5.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,26 +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=C_mEQbq8fy-pbsPrnLOTGrWFG6UpA8G2yE2LytFTQR0,2378
4
- string_to_code/core.py,sha256=IlDiX7LzDe2Vbq_NvHTBc0M3-Jnu5st6gs3ptlF3pW0,4439
5
- string_to_code/string_to_code.py,sha256=rwgMKr33ljgGXO4TCOFUeX_UuEyWM8wXTKz4RKGx8pE,1304
6
- string_to_code/to_ada.py,sha256=BFyJzve3-jewks73WVuicuMWIbWJ7FbrMBugXZFnji0,2351
7
- string_to_code/to_algol68.py,sha256=IfDTxAW52o3oBHJ25GTaDOLQU_ZQ9NvCd37tsHIGrwg,1749
8
- string_to_code/to_ballerina.py,sha256=Z8F8r9hLZ5mvHzsjT5XDx_2cDlojBzva7UZcrMIQca0,1876
9
- string_to_code/to_bash.py,sha256=FJI2WTYO0gDDFSyRwHwERuLFKqOBX79y4xsXa_K_5D4,1634
10
- string_to_code/to_c.py,sha256=CeCzih5WoNABUg4dgps82wG783H8nW3FHj-69HZ5iOU,1008
11
- string_to_code/to_cobol.py,sha256=eOWf6I5paH4eBpwUxmgrNN9AoBPFr0weYmeJe2CkEzk,2130
12
- string_to_code/to_cpp.py,sha256=PJYScszyoSToyHmVbWvrNFtZsRkDWFaPg49Ug0xlnzk,1026
13
- string_to_code/to_fortran90.py,sha256=wyMxeaW68l9AqMjvkosEpbarUnGWw4aZTX3sOzhWc5E,1792
14
- string_to_code/to_haskell.py,sha256=WvNznkqmYXSsfrl5LkoDedB_uyJIgvqBz_YMM065PD0,1977
15
- string_to_code/to_java.py,sha256=63LPDTrMqnukXMW0XHVX6aXHq-63NckQLiG3YmdaAYg,1865
16
- string_to_code/to_lisp.py,sha256=BKkJorzyAbSmmOUt3otqHAapjOR6GblMM-ymekga1wY,1605
17
- string_to_code/to_lua.py,sha256=DeRnBH3PFmyABqFVqmXNSN4c79awYkZJ9ZTmeabIAKI,2045
18
- string_to_code/to_nim.py,sha256=W74i6MRjQ5eYeatGyMwE-wYNEzN06l5oOXBv3lfbXgM,1534
19
- string_to_code/to_pascal.py,sha256=OE2qefRgYhvx8AOn83m3q2gQh_Haoo3fqo12IfxKT28,1936
20
- string_to_code/to_python3.py,sha256=BJwjyhRB2IBOE3-xwkkMV3vZU-e2xreppYBKQeA1whg,1589
21
- string_to_code/to_rust.py,sha256=hTCjlortLhR7FwsBgbrFRcwXpKWA6ed2UYnz1OK8R7I,1926
22
- string_to_code/utils.py,sha256=0On1KjJ0dMHyS4xp1f8RIJcfcT5-CfocHTx3kDVRi5I,3847
23
- string_to_code-0.4.1.dist-info/LICENSE,sha256=LQrcSkcUyN1FtFYDxWK05puxNN9o2q8PV-_2SwFDTWc,1068
24
- string_to_code-0.4.1.dist-info/METADATA,sha256=iAZ9y5sfe7u-mpuuqby2JlpqidG0o8f9ewS5jRFnmIU,1958
25
- string_to_code-0.4.1.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
26
- string_to_code-0.4.1.dist-info/RECORD,,