codeplain 0.2.3__py3-none-any.whl → 0.2.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codeplain
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Transform plain language specifications into working code
5
5
  License-File: LICENSE
6
6
  Classifier: Environment :: Console
@@ -1,25 +1,25 @@
1
- codeplain_REST_api.py,sha256=qfzUw9v0-NKII4ibw3vqSBrCeU2WP4RcrrEti43F3zs,18400
1
+ codeplain_REST_api.py,sha256=NJVOwlsnDFhEySeEds4q2GUKdexTfYGp7FIW0yJqL-A,18026
2
2
  concept_utils.py,sha256=vwSY4-FmxyqaDBxhntYzqG8t9pXvAWwiULP0DYQI32o,7905
3
3
  diff_utils.py,sha256=AjiQlqo5pRos_8hVXZo5yBurl5BzSrTMGrQv4dCtRCg,1198
4
4
  event_bus.py,sha256=sduIR3bgIbxAbLhwKd8Gx9YN9gzaeqy9-mNupS04aKw,1759
5
5
  file_utils.py,sha256=4BIxzsteZQOaK-efkvQcoaIfYydsQNFR6elpsxJgXLQ,11591
6
- git_utils.py,sha256=gTRps6RIzJJkyy9amaDxP38FPoxYulZViBWr9V0IPQg,12414
6
+ git_utils.py,sha256=7JFHQRzxsO7GoVzP1BO7px2cgrlqyFequbOozHDV8ig,12353
7
7
  hash_key.py,sha256=lMKgKpOhPeC4UpFf9e7eCNK20FEaDsXTCJ8j3eCWidE,837
8
8
  memory_management.py,sha256=ABrM6PhOsalP_PBq2hCazQvQX9C5rpPHhgT35l68RM4,4357
9
9
  module_renderer.py,sha256=LLjLb34phSJlF2YblwGDy5HKWVdi9mo57rr7s-Hj3RA,6261
10
- plain2code.py,sha256=cIxPkxfxZkPlen5RG5H_rvo22sSGYQ9PnqSlw3ECVkY,9841
10
+ plain2code.py,sha256=vErZtqioqiIN3U3I9U2jUeL7ti_Z38RPcGT0Wuz0xeE,9632
11
11
  plain2code_arguments.py,sha256=PdQjd3orklrtlEyz7-Qdz_m2SvjZtZp6dmbkqXgglSU,11826
12
12
  plain2code_console.py,sha256=-QorOFimS1AWYK7dmFqI3uhjc51cPtEWsaK4DhFibIw,4139
13
13
  plain2code_events.py,sha256=5fPhpRzgJ02xWh0MXqrMv9A4curr2UOE68Y1uKlAcqQ,1347
14
- plain2code_exceptions.py,sha256=Y_2Jmv9rLE5xMqlzp_mDcAIIYsIfS0yR1U3scXUzUng,760
14
+ plain2code_exceptions.py,sha256=eFvJvFeClFR1MY68zHwPKbNy89ya4iaYSaFRE2GWkTE,929
15
15
  plain2code_logger.py,sha256=xSDGN8QAWpA4J6YKyj-kfNWSO-jBl0sfUCFRs7Tflf0,4067
16
16
  plain2code_nodes.py,sha256=Om624mfb5MB1Z09c0Zqtb9G1gGkUY9x-v2hzAf3A2gw,3818
17
17
  plain2code_read_config.py,sha256=QnpbW_Bi9LzDIOubM5x7fVXH1HgiFL3-5Oa_O1EUoE4,2449
18
18
  plain2code_state.py,sha256=InLXdytMXnm9YC4o8MSTbtB1TmqYYUs6rASGBlyA_YY,1274
19
19
  plain2code_utils.py,sha256=3xPXWci5yVdpdK_WrNcbinSV94XSeMQDW5UzDuBMaUM,1767
20
- plain_file.py,sha256=OXbWvErVTVhaeRFUu9f0bzi16P01DShW_jLhNI-tmeA,28931
21
- plain_modules.py,sha256=iDqqamtix5KahMC_v-vfQ7yndugmqtBW1z6XxTB4x6w,4876
22
- plain_spec.py,sha256=zC-VOb_UJOs8OxtEiwQJuonw7Lkmbi7YHyFvvCvUZNo,13529
20
+ plain_file.py,sha256=lF0ZwK_Hycc4rdaHPxJSfe7mfkRYo5QgMngv50AsF74,28430
21
+ plain_modules.py,sha256=6gteJeiK-WvUZDrIt_kJK0MFiptq63rEVpYvV5yYFXc,4881
22
+ plain_spec.py,sha256=jU4dMVoWumkTK-IBdgXsH4-EnAdyRWxR9dI-lHreEyM,13535
23
23
  spinner.py,sha256=Ro6Gd9Przf-whuHqPRY6HwI0T57yJjyNPbhDbigZKZE,2471
24
24
  system_config.py,sha256=mgHLn-CRHLO9Y9vKyI_eFBreY_YhFad-ctZgBYp-rIg,1777
25
25
  config/__init__.py,sha256=beYSsJWmBNHDP5rYmVDouqgEeP3t1lkkepbXJ-oq0F8,37
@@ -63,10 +63,10 @@ tests/__init__.py,sha256=Wk73Io62J15BtlLVIzxmASDWaaJkQLevS4BLK5LDAQg,16
63
63
  tests/conftest.py,sha256=QZcp08htUlJGgmHDlRWFgsWXZ8o8IBWTD5QqJaUMlU8,790
64
64
  tests/test_git_utils.py,sha256=Knc4R2ZkHYVj9iPFKhb0_ewaad_mxPrakOn6gpziHMc,13138
65
65
  tests/test_imports.py,sha256=cdw7u93xNFD064sjwwEWy4oLHhJNlt1-DRDYhHjymFw,2078
66
- tests/test_plainfile.py,sha256=N3f59hpxOO5zULdBtmXZM6KO2PKADoOL5d3WxNTUYXg,11106
66
+ tests/test_plainfile.py,sha256=gUw58XP3PUCDrZxXkrIUNPszlnqY4yW2io3xg6F3ySQ,11086
67
67
  tests/test_plainfileparser.py,sha256=9B9r2jEeUKDMhqb4TJEPK7aatYl1op1z92GDAD4fJ20,18685
68
68
  tests/test_plainspec.py,sha256=ouS899oejStu8u1D3399y5NAxcKlNbLcinNoxZUp59M,2437
69
- tests/test_requires.py,sha256=u8wY-UI7Ryat84htaI0yFXpl-PjX7G90EnMKM35S6No,1182
69
+ tests/test_requires.py,sha256=BwlZeLXIs4m-FGnjLjO4vHkxfEX_QgjYoomb3oIu7Vs,1236
70
70
  tui/__init__.py,sha256=_fy7FowY0RkWdn4kC7XV2jgvQPCj-2gE8fNUb-Mny0A,60
71
71
  tui/components.py,sha256=l7f-jLk0sj9WM8z2IpaHksmSyytXe_bl2GBdHASoIg4,13901
72
72
  tui/models.py,sha256=KMjlWubmPD41GA-BjgiqkaV9v7tLJ0fuWKBDPmZj4JA,1493
@@ -74,8 +74,8 @@ tui/plain2code_tui.py,sha256=7agVU0NnaCuF1LuOSEmjx-XfEOQ6HHr1HlWe_b1Tses,11695
74
74
  tui/state_handlers.py,sha256=HbjgaV-9xGhp3E-3X114zOqPkeNcCjT-R1PbVRxVdso,12674
75
75
  tui/styles.css,sha256=Umm2TLePmywizZGV4Nd8UezZRiK5pFyibYRbpRvGqbs,3056
76
76
  tui/widget_helpers.py,sha256=VJorEM2PjRBzN-jIDmKJPolFgo2d8-2NmTumgC5xeNo,5229
77
- codeplain-0.2.3.dist-info/METADATA,sha256=8GLBTQ7B-NEivsGSRPlOqsTvnFnvkAsF6qyjAAQ0yRc,4278
78
- codeplain-0.2.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
79
- codeplain-0.2.3.dist-info/entry_points.txt,sha256=oDZkBqu9WhtZApb_K6ia8-fn9aojwmAsgnKELceX5T4,46
80
- codeplain-0.2.3.dist-info/licenses/LICENSE,sha256=wsFi5dpbJurnRNfBj8q2RCcF3ryrmdRIfxc3lPcmc4c,1069
81
- codeplain-0.2.3.dist-info/RECORD,,
77
+ codeplain-0.2.4.dist-info/METADATA,sha256=HTXpXKt_9V_qDoBoOuuGi-bDsWQ-nGQeItUOOWCaSxQ,4278
78
+ codeplain-0.2.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
79
+ codeplain-0.2.4.dist-info/entry_points.txt,sha256=oDZkBqu9WhtZApb_K6ia8-fn9aojwmAsgnKELceX5T4,46
80
+ codeplain-0.2.4.dist-info/licenses/LICENSE,sha256=wsFi5dpbJurnRNfBj8q2RCcF3ryrmdRIfxc3lPcmc4c,1069
81
+ codeplain-0.2.4.dist-info/RECORD,,
codeplain_REST_api.py CHANGED
@@ -65,12 +65,6 @@ class CodeplainAPI:
65
65
  if response_json["error_code"] == "PlainSyntaxError":
66
66
  raise plain2code_exceptions.PlainSyntaxError(response_json["message"])
67
67
 
68
- if response_json["error_code"] == "OnlyRelativeLinksAllowed":
69
- raise plain2code_exceptions.OnlyRelativeLinksAllowed(response_json["message"])
70
-
71
- if response_json["error_code"] == "LinkMustHaveTextSpecified":
72
- raise plain2code_exceptions.LinkMustHaveTextSpecified(response_json["message"])
73
-
74
68
  if response_json["error_code"] == "NoRenderFound":
75
69
  raise plain2code_exceptions.NoRenderFound(response_json["message"])
76
70
 
git_utils.py CHANGED
@@ -4,6 +4,7 @@ from typing import Optional, Union
4
4
  from git import Repo
5
5
 
6
6
  import file_utils
7
+ from plain2code_exceptions import InvalidGitRepositoryError
7
8
 
8
9
  FUNCTIONAL_REQUIREMENT_IMPLEMENTED_COMMIT_MESSAGE = (
9
10
  "[Codeplain] Implemented code and unit tests for functional requirement {}"
@@ -25,12 +26,6 @@ MODULE_NAME_MESSAGE = "Module name: {}"
25
26
  RENDER_ID_MESSAGE = "Render ID: {}"
26
27
 
27
28
 
28
- class InvalidGitRepositoryError(Exception):
29
- """Raised when the git repository is in an invalid state."""
30
-
31
- pass
32
-
33
-
34
29
  def _get_full_commit_message(message, module_name, frid, render_id) -> str:
35
30
  full_message = message
36
31
 
plain2code.py CHANGED
@@ -17,7 +17,7 @@ from event_bus import EventBus
17
17
  from module_renderer import ModuleRenderer
18
18
  from plain2code_arguments import parse_arguments
19
19
  from plain2code_console import console
20
- from plain2code_exceptions import MissingAPIKey, PlainSyntaxError
20
+ from plain2code_exceptions import InvalidFridArgument, MissingAPIKey, PlainSyntaxError
21
21
  from plain2code_logger import (
22
22
  CrashLogHandler,
23
23
  IndentedFormatter,
@@ -46,10 +46,6 @@ UNRECOVERABLE_ERROR_EXIT_CODES = [69]
46
46
  TIMEOUT_ERROR_EXIT_CODE = 124
47
47
 
48
48
 
49
- class InvalidFridArgument(Exception):
50
- pass
51
-
52
-
53
49
  def get_render_range(render_range, plain_source):
54
50
  render_range = render_range.split(",")
55
51
  range_end = render_range[1] if len(render_range) == 2 else render_range[0]
@@ -227,23 +223,20 @@ def main():
227
223
 
228
224
  render(args, run_state, codeplain_api, event_bus)
229
225
  except InvalidFridArgument as e:
230
- console.error(f"Error rendering plain code: {str(e)}.\n")
226
+ console.error(f"Invalid FRID argument: {str(e)}.\n")
231
227
  # No need to print render ID since this error is going to be thrown at the very start so user will be able to
232
228
  # see the render ID that's printed at the very start of the rendering process.
233
229
  dump_crash_logs(args)
234
230
  except FileNotFoundError as e:
235
- console.error(f"Error rendering plain code: {str(e)}\n")
231
+ console.error(f"File not found: {str(e)}\n")
236
232
  console.debug(f"Render ID: {run_state.render_id}")
237
233
  dump_crash_logs(args)
238
- except plain_file.InvalidPlainFileExtension as e:
239
- console.error(f"Error rendering plain code: {str(e)}\n")
240
- dump_crash_logs(args)
241
234
  except TemplateNotFoundError as e:
242
- console.error(f"Error: Template not found: {str(e)}\n")
235
+ console.error(f"Template not found: {str(e)}\n")
243
236
  console.error(system_config.get_error_message("template_not_found"))
244
237
  dump_crash_logs(args)
245
238
  except PlainSyntaxError as e:
246
- console.error(f"Error rendering plain code: {str(e)}\n")
239
+ console.error(f"Plain syntax error: {str(e)}\n")
247
240
  dump_crash_logs(args)
248
241
  except KeyboardInterrupt:
249
242
  console.error("Keyboard interrupt")
plain2code_exceptions.py CHANGED
@@ -25,25 +25,35 @@ class PlainSyntaxError(Exception):
25
25
  pass
26
26
 
27
27
 
28
- class OnlyRelativeLinksAllowed(Exception):
28
+ class NoRenderFound(Exception):
29
29
  pass
30
30
 
31
31
 
32
- class LinkMustHaveTextSpecified(Exception):
32
+ class MultipleRendersFound(Exception):
33
33
  pass
34
34
 
35
35
 
36
- class NoRenderFound(Exception):
36
+ class UnexpectedState(Exception):
37
37
  pass
38
38
 
39
39
 
40
- class MultipleRendersFound(Exception):
40
+ class MissingAPIKey(Exception):
41
41
  pass
42
42
 
43
43
 
44
- class UnexpectedState(Exception):
44
+ class InvalidFridArgument(Exception):
45
45
  pass
46
46
 
47
47
 
48
- class MissingAPIKey(Exception):
48
+ class InvalidGitRepositoryError(Exception):
49
+ """Raised when the git repository is in an invalid state."""
50
+
51
+ pass
52
+
53
+
54
+ class InvalidLiquidVariableName(Exception):
55
+ pass
56
+
57
+
58
+ class ModuleDoesNotExistError(Exception):
49
59
  pass
plain_file.py CHANGED
@@ -44,22 +44,6 @@ class PlainFileParseResult:
44
44
  required_concepts: list[str]
45
45
 
46
46
 
47
- class OnlyRelativeLinksAllowed(Exception):
48
- pass
49
-
50
-
51
- class LinkMustHaveTextSpecified(Exception):
52
- pass
53
-
54
-
55
- class InvalidPlainFileExtension(Exception):
56
- pass
57
-
58
-
59
- class PlainModuleNotFound(Exception):
60
- pass
61
-
62
-
63
47
  class PlainRenderer(MarkdownRenderer):
64
48
  def render_link(self, token: Link) -> Iterable[Fragment]:
65
49
  yield from self.embed_span(
@@ -95,12 +79,12 @@ def check_section_for_linked_resources(section):
95
79
  for link in traverse(section, klass=Link):
96
80
  parsed_url = urlparse(link.node.target)
97
81
  if parsed_url.scheme != "" or os.path.isabs(link.node.target):
98
- raise OnlyRelativeLinksAllowed(
82
+ raise PlainSyntaxError(
99
83
  f"Only relative links are allowed (text: {link.node.children[0].content}, target: {link.node.target})."
100
84
  )
101
85
 
102
86
  if len(link.node.children) != 1:
103
- raise LinkMustHaveTextSpecified(f"Link must have text specified (link: {link.node.target}).")
87
+ raise PlainSyntaxError(f"Link must have text specified (link: {link.node.target}).")
104
88
 
105
89
  linked_resources.append({"text": link.node.children[0].content, "target": link.node.target})
106
90
 
@@ -529,7 +513,7 @@ def parse_plain_source( # noqa: C901
529
513
  def read_module_plain_source(module_name: str, template_dirs: list[str]) -> str:
530
514
  plain_source_text = file_utils.open_from(template_dirs, module_name + PLAIN_SOURCE_FILE_EXTENSION)
531
515
  if plain_source_text is None:
532
- raise PlainModuleNotFound(f"Module does not exist ({module_name}).")
516
+ raise PlainSyntaxError(f"Module does not exist ({module_name}).")
533
517
  return plain_source_text
534
518
 
535
519
 
@@ -566,12 +550,9 @@ def process_required_modules(
566
550
  if len(all_required_modules) > 0 and module_name == all_required_modules[-1]:
567
551
  continue
568
552
 
569
- try:
570
- plain_file_parse_result = parse_plain_file(
571
- module_name, code_variables, template_dirs, imported_modules=[], modules_trace=[]
572
- )
573
- except PlainModuleNotFound:
574
- raise PlainSyntaxError(f"Required module not found ({module_name}).")
553
+ plain_file_parse_result = parse_plain_file(
554
+ module_name, code_variables, template_dirs, imported_modules=[], modules_trace=[]
555
+ )
575
556
 
576
557
  if len(plain_file_parse_result.required_modules) == 0:
577
558
  if len(all_required_modules) > 0:
@@ -644,7 +625,7 @@ def plain_file_parser( # noqa: C901
644
625
  # and we need to pass them to the marshalled_plain_source_tree after it's rendered
645
626
  plain_source_file_path = Path(plain_source_file_name)
646
627
  if plain_source_file_path.suffix != PLAIN_SOURCE_FILE_EXTENSION:
647
- raise InvalidPlainFileExtension(
628
+ raise PlainSyntaxError(
648
629
  f"Invalid plain file extension: {plain_source_file_path.suffix}. Expected: {PLAIN_SOURCE_FILE_EXTENSION}."
649
630
  )
650
631
 
@@ -652,16 +633,13 @@ def plain_file_parser( # noqa: C901
652
633
 
653
634
  code_variables = {}
654
635
 
655
- try:
656
- plain_file_parse_result = parse_plain_file(
657
- module_name,
658
- code_variables,
659
- template_dirs,
660
- imported_modules=[],
661
- modules_trace=[],
662
- )
663
- except PlainModuleNotFound as e:
664
- raise PlainSyntaxError(e.message)
636
+ plain_file_parse_result = parse_plain_file(
637
+ module_name,
638
+ code_variables,
639
+ template_dirs,
640
+ imported_modules=[],
641
+ modules_trace=[],
642
+ )
665
643
 
666
644
  if len(plain_file_parse_result.required_concepts) > 0:
667
645
  missing_required_concepts_msg = "Missing required concepts: "
plain_modules.py CHANGED
@@ -7,6 +7,7 @@ from git.exc import NoSuchPathError
7
7
 
8
8
  import git_utils
9
9
  import plain_spec
10
+ from plain2code_exceptions import ModuleDoesNotExistError
10
11
  from render_machine.implementation_code_helpers import ImplementationCodeHelpers
11
12
 
12
13
  CODEPLAIN_MEMORY_SUBFOLDER = ".memory"
@@ -16,10 +17,6 @@ MODULE_FUNCTIONALITIES = "functionalities"
16
17
  REQUIRED_MODULES_FUNCTIONALITIES = "required_modules_functionalities"
17
18
 
18
19
 
19
- class ModuleDoesNotExistError(Exception):
20
- pass
21
-
22
-
23
20
  class PlainModule:
24
21
  def __init__(self, name: str, build_folder: str):
25
22
  self.name = name
plain_spec.py CHANGED
@@ -5,6 +5,8 @@ from typing import Optional
5
5
 
6
6
  from liquid2.filter import with_context
7
7
 
8
+ from plain2code_exceptions import InvalidLiquidVariableName
9
+
8
10
  DEFINITIONS = "definitions"
9
11
  NON_FUNCTIONAL_REQUIREMENTS = "technical specs"
10
12
  TEST_REQUIREMENTS = "test specs"
@@ -23,10 +25,6 @@ ALLOWED_SPECIFICATION_HEADINGS = [
23
25
  ALLOWED_IMPORT_SPECIFICATION_HEADINGS = [DEFINITIONS, NON_FUNCTIONAL_REQUIREMENTS, TEST_REQUIREMENTS]
24
26
 
25
27
 
26
- class InvalidLiquidVariableName(Exception):
27
- pass
28
-
29
-
30
28
  def collect_specification_linked_resources(specification, specification_heading, linked_resources_list):
31
29
  linked_resources = []
32
30
  if "linked_resources" in specification:
tests/test_plainfile.py CHANGED
@@ -267,5 +267,5 @@ def test_psart_with_duplicate_acceptance_test_heading():
267
267
 
268
268
 
269
269
  def test_invalid_plain_file_extension():
270
- with pytest.raises(plain_file.InvalidPlainFileExtension):
270
+ with pytest.raises(PlainSyntaxError):
271
271
  plain_file.plain_file_parser("test.txt", [])
tests/test_requires.py CHANGED
@@ -1,10 +1,11 @@
1
1
  import pytest
2
2
 
3
3
  import plain_file
4
+ from plain2code_exceptions import PlainSyntaxError
4
5
 
5
6
 
6
7
  def test_non_existent_require(get_test_data_path):
7
- with pytest.raises(Exception, match="Required module not found"):
8
+ with pytest.raises(PlainSyntaxError, match="Module does not exist"):
8
9
  plain_file.plain_file_parser("non_existent_require.plain", [get_test_data_path("data/requires")])
9
10
 
10
11