string-to-code 0.4.1__tar.gz → 0.5.1__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 (26) hide show
  1. {string_to_code-0.4.1 → string_to_code-0.5.1}/PKG-INFO +6 -5
  2. {string_to_code-0.4.1 → string_to_code-0.5.1}/pyproject.toml +12 -12
  3. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/c_like_utils.py +1 -2
  4. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/core.py +4 -4
  5. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_ada.py +1 -3
  6. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_algol68.py +1 -3
  7. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_ballerina.py +2 -11
  8. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_bash.py +1 -3
  9. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_c.py +1 -3
  10. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_cobol.py +1 -3
  11. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_cpp.py +1 -3
  12. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_fortran90.py +1 -3
  13. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_haskell.py +1 -3
  14. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_java.py +2 -10
  15. string_to_code-0.5.1/string_to_code/to_kotlin.py +69 -0
  16. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_lisp.py +1 -3
  17. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_lua.py +1 -2
  18. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_nim.py +1 -4
  19. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_pascal.py +1 -4
  20. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_python3.py +1 -3
  21. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/to_rust.py +1 -4
  22. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/utils.py +1 -0
  23. {string_to_code-0.4.1 → string_to_code-0.5.1}/LICENSE +0 -0
  24. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/README.md +0 -0
  25. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/__init__.py +0 -0
  26. {string_to_code-0.4.1 → string_to_code-0.5.1}/string_to_code/string_to_code.py +1 -1
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "string-to-code"
3
- version = "0.4.1"
3
+ version = "0.5.1"
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"
@@ -10,22 +10,22 @@ repository = "https://github.com/vil02/string_to_code_proj"
10
10
  keywords = ["code-generation"]
11
11
 
12
12
  [tool.poetry.dependencies]
13
- python = ">=3.10,<4.0.0"
13
+ python = ">=3.11,<4.0.0"
14
14
 
15
15
  [tool.poetry.group.dev]
16
16
  optional = true
17
17
 
18
18
  [tool.poetry.group.dev.dependencies]
19
- pytest = "8.3.4"
20
- pytest-mock = "3.14.0"
21
- pylint = "3.3.3"
22
- flake8 = "7.1.1"
23
- flake8-pytest-style = "2.0.0"
24
- ruff = "0.8.6"
25
- coverage = "7.6.10"
26
- black = "24.10.0"
27
- mypy = "1.14.1"
28
- bandit = "1.8.0"
19
+ pytest = "9.2.0"
20
+ pytest-mock = "3.17.0"
21
+ pylint = "4.1.4"
22
+ flake8 = "7.5.0"
23
+ flake8-pytest-style = "2.2.0"
24
+ ruff = "0.17.6"
25
+ coverage = "7.17.5"
26
+ black = "26.10.1"
27
+ mypy = "2.4.1"
28
+ bandit = "1.9.4"
29
29
  xenon = "0.9.3"
30
30
 
31
31
  [build-system]
@@ -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:
@@ -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)
@@ -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):
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
+ )
@@ -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
 
@@ -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:
@@ -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
 
@@ -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
 
@@ -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
 
File without changes
@@ -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: