string-to-code 0.4.1__tar.gz → 0.5.0__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.0}/PKG-INFO +1 -2
  2. {string_to_code-0.4.1 → string_to_code-0.5.0}/pyproject.toml +4 -4
  3. string_to_code-0.5.0/string_to_code/to_kotlin.py +71 -0
  4. {string_to_code-0.4.1 → string_to_code-0.5.0}/LICENSE +0 -0
  5. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/README.md +0 -0
  6. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/__init__.py +0 -0
  7. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/c_like_utils.py +0 -0
  8. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/core.py +0 -0
  9. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/string_to_code.py +0 -0
  10. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_ada.py +0 -0
  11. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_algol68.py +0 -0
  12. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_ballerina.py +0 -0
  13. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_bash.py +0 -0
  14. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_c.py +0 -0
  15. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_cobol.py +0 -0
  16. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_cpp.py +0 -0
  17. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_fortran90.py +0 -0
  18. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_haskell.py +0 -0
  19. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_java.py +0 -0
  20. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_lisp.py +0 -0
  21. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_lua.py +0 -0
  22. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_nim.py +0 -0
  23. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_pascal.py +0 -0
  24. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_python3.py +0 -0
  25. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/to_rust.py +0 -0
  26. {string_to_code-0.4.1 → string_to_code-0.5.0}/string_to_code/utils.py +0 -0
@@ -1,8 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: string-to-code
3
- Version: 0.4.1
3
+ Version: 0.5.0
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
7
6
  Keywords: code-generation
8
7
  Author: piotr.idzik
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "string-to-code"
3
- version = "0.4.1"
3
+ version = "0.5.0"
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"
@@ -20,12 +20,12 @@ pytest = "8.3.4"
20
20
  pytest-mock = "3.14.0"
21
21
  pylint = "3.3.3"
22
22
  flake8 = "7.1.1"
23
- flake8-pytest-style = "2.0.0"
24
- ruff = "0.8.6"
23
+ flake8-pytest-style = "2.1.0"
24
+ ruff = "0.9.2"
25
25
  coverage = "7.6.10"
26
26
  black = "24.10.0"
27
27
  mypy = "1.14.1"
28
- bandit = "1.8.0"
28
+ bandit = "1.8.2"
29
29
  xenon = "0.9.3"
30
30
 
31
31
  [build-system]
@@ -0,0 +1,71 @@
1
+ """
2
+ provides string_to_kotlin utilities
3
+ """
4
+
5
+ from . import core
6
+ from . import utils
7
+
8
+
9
+ _get_function_name = utils.get_function_name_fun("fun")
10
+
11
+
12
+ def _atom_to_code(in_atom: core.Atom) -> str:
13
+ if in_atom.atom_char == "\n":
14
+ return "println()"
15
+ special_chars = {
16
+ '"': '\\"',
17
+ "'": "\\'",
18
+ "\\": "\\\\",
19
+ "\t": "\\t",
20
+ "{": "{",
21
+ "}": "}",
22
+ }
23
+ res_char = special_chars.get(in_atom.atom_char, in_atom.atom_char)
24
+ return f"print('{res_char}')"
25
+
26
+
27
+ _function_call_str = utils.get_function_call_str_fun(_get_function_name, "", "()")
28
+
29
+
30
+ _call_function_or_atom = utils.get_call_function_or_atom(
31
+ _atom_to_code, _function_call_str
32
+ )
33
+
34
+ _EMPTY_BODY = " // No code needed"
35
+
36
+ _body_to_str = utils.get_body_to_str(
37
+ "\n", " ", _call_function_or_atom, "", _EMPTY_BODY
38
+ )
39
+
40
+
41
+ def _merge_to_full_function(in_function_name, in_function_body):
42
+ body_str = "\n" + in_function_body + "\n"
43
+ return f"fun {in_function_name}() {{{body_str}}}\n"
44
+
45
+
46
+ _function_to_code = utils.get_function_to_code(
47
+ _get_function_name, _body_to_str, _merge_to_full_function
48
+ )
49
+
50
+
51
+ def _main_call_to_code(in_initial_call, **kwargs):
52
+ call_in_main = (
53
+ "\n" + _EMPTY_BODY
54
+ if in_initial_call is None
55
+ else "\n " + _call_function_or_atom(in_initial_call, **kwargs)
56
+ )
57
+ return "fun main() {" + call_in_main + "\n}\n"
58
+
59
+
60
+ def _join_to_final(main_call, function_definitions, **_kwargs):
61
+ function_definitions_str = (
62
+ "\n".join(function_definitions) if function_definitions else ""
63
+ )
64
+ if function_definitions_str:
65
+ function_definitions_str = function_definitions_str + "\n"
66
+ return function_definitions_str + main_call
67
+
68
+
69
+ proc_printer_program, proc = utils.get_all_proc_functions(
70
+ _main_call_to_code, _function_to_code, _join_to_final
71
+ )
File without changes