cyberark-tpc-plugin-parser 0.2.0__tar.gz → 0.3.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 (28) hide show
  1. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/PKG-INFO +1 -1
  2. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/cyberark_tpc_plugin_parser.egg-info/PKG-INFO +1 -1
  3. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/pyproject.toml +1 -1
  4. cyberark_tpc_plugin_parser-0.3.0/tests/test_parser.py +54 -0
  5. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/parser.py +11 -35
  6. cyberark_tpc_plugin_parser-0.2.0/tests/test_parser.py +0 -44
  7. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/LICENSE +0 -0
  8. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/README.md +0 -0
  9. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/cyberark_tpc_plugin_parser.egg-info/SOURCES.txt +0 -0
  10. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/cyberark_tpc_plugin_parser.egg-info/dependency_links.txt +0 -0
  11. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/cyberark_tpc_plugin_parser.egg-info/top_level.txt +0 -0
  12. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/setup.cfg +0 -0
  13. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tests/test_lexer.py +0 -0
  14. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/__init__..py +0 -0
  15. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/__init__.py +0 -0
  16. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/lexer.py +0 -0
  17. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/tokens/__init__.py +0 -0
  18. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/tokens/assignment.py +0 -0
  19. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/tokens/comment.py +0 -0
  20. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/tokens/cpm_parameter_validation.py +0 -0
  21. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/tokens/fail_state.py +0 -0
  22. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/tokens/parse_error.py +0 -0
  23. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/tokens/section_header.py +0 -0
  24. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/tokens/transition.py +0 -0
  25. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/utilities/__init__.py +0 -0
  26. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/utilities/regex.py +0 -0
  27. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/utilities/token_name.py +0 -0
  28. {cyberark_tpc_plugin_parser-0.2.0 → cyberark_tpc_plugin_parser-0.3.0}/tpc_plugin_parser/lexer/utilities/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cyberark-tpc-plugin-parser
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A package to help parse CyberArk TPC plugin prompts and process files.
5
5
  Author-email: Peter McDonald <git@petermcdonald.co.uk>
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cyberark-tpc-plugin-parser
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A package to help parse CyberArk TPC plugin prompts and process files.
5
5
  Author-email: Peter McDonald <git@petermcdonald.co.uk>
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cyberark-tpc-plugin-parser"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "A package to help parse CyberArk TPC plugin prompts and process files."
5
5
  keywords = ["cyberark", "parser", "tpc"]
6
6
  authors = [{ name = "Peter McDonald", email = "git@petermcdonald.co.uk"}]
@@ -0,0 +1,54 @@
1
+ """Test the parser."""
2
+
3
+ import pytest
4
+ from tpc_plugin_parser.parser import Parser
5
+
6
+
7
+ class TestParser(object):
8
+ """Test the lexer."""
9
+
10
+ @pytest.mark.parametrize(
11
+ "target_file",
12
+ [
13
+ "tests/data/process.ini",
14
+ ],
15
+ )
16
+ def test_process(self, target_file: str) -> None:
17
+ """
18
+ Test to ensure that process file tokens parses ok.
19
+
20
+ :param target_file: Path to the file.
21
+ """
22
+ with open(target_file, "r") as file_handler:
23
+ file_content = file_handler.read()
24
+
25
+ parser = Parser(file_contents=file_content)
26
+
27
+ assert len(parser.parsed_file) == 6
28
+ assert len(parser.parsed_file["default"]) == 6
29
+ assert len(parser.parsed_file["states"]) == 8
30
+ assert len(parser.parsed_file["transitions"]) == 7
31
+ assert len(parser.parsed_file["CPM Parameters Validation"]) == 5
32
+ assert len(parser.parsed_file["parameters"]) == 5
33
+ assert len(parser.parsed_file["Debug Information"]) == 7
34
+
35
+ @pytest.mark.parametrize(
36
+ "target_file",
37
+ [
38
+ "tests/data/prompts.ini",
39
+ ],
40
+ )
41
+ def test_prompts(self, target_file: str) -> None:
42
+ """
43
+ Test to ensure that prompts file tokens parses ok.
44
+
45
+ :param target_file: Path to the file.
46
+ """
47
+ with open(target_file, "r") as file_handler:
48
+ file_content = file_handler.read()
49
+
50
+ parser = Parser(file_contents=file_content)
51
+
52
+ assert len(parser.parsed_file) == 2
53
+ assert len(parser.parsed_file["default"]) == 6
54
+ assert len(parser.parsed_file["conditions"]) == 8
@@ -1,4 +1,4 @@
1
- """Parser module for reading and processing configuration files."""
1
+ """Parser module for reading and processing TPC files."""
2
2
 
3
3
  from tpc_plugin_parser.lexer.lexer import Lexer
4
4
  from tpc_plugin_parser.lexer.tokens.section_header import SectionHeader
@@ -9,40 +9,25 @@ from tpc_plugin_parser.lexer.utilities.types import ALL_TOKEN_TYPES
9
9
  class Parser(object):
10
10
  """Object to handle parsing ini files."""
11
11
 
12
- __slots__ = (
13
- "_process_file",
14
- "_prompts_file",
15
- )
12
+ __slots__ = ("_file",)
16
13
 
17
- def __init__(self, process_file: str, prompts_file: str) -> None:
14
+ def __init__(self, file_contents: str) -> None:
18
15
  """
19
- Initializes the Parser with the given process and prompts files.
16
+ Initializes the Parser with the given file contents.
20
17
 
21
- :param process_file (str): Content of the process file.
22
- :param prompts_file (str): Content of the prompts file.
18
+ :param file_contents (str): Content of the file to be parsed.
23
19
  """
24
20
 
25
- process_lexer = Lexer(source=process_file)
21
+ process_lexer = Lexer(source=file_contents)
26
22
  self._prepare_process(lexed_process=process_lexer)
27
23
 
28
- prompts_lexer = Lexer(source=prompts_file)
29
- self._prepare_prompts(lexed_prompts=prompts_lexer)
30
-
31
24
  def _prepare_process(self, lexed_process: Lexer) -> None:
32
25
  """
33
26
  Prepare the process file from the lexed result.
34
27
 
35
28
  :param lexed_process: Result of lexing the process file.
36
29
  """
37
- self._process_file = self._process_lex(lexed_file=lexed_process)
38
-
39
- def _prepare_prompts(self, lexed_prompts: Lexer) -> None:
40
- """
41
- Prepare the prompts file from the lexed result.
42
-
43
- :param lexed_prompts: Result of lexing the prompts file.
44
- """
45
- self._prompts_file = self._process_lex(lexed_file=lexed_prompts)
30
+ self._file = self._process_lex(lexed_file=lexed_process)
46
31
 
47
32
  @staticmethod
48
33
  def _process_lex(lexed_file: Lexer):
@@ -71,19 +56,10 @@ class Parser(object):
71
56
  return sorted_lex
72
57
 
73
58
  @property
74
- def process_file(self):
75
- """
76
- Returns the parsed process configuration.
77
-
78
- :return: List of tokens from the process file.
79
- """
80
- return self._process_file
81
-
82
- @property
83
- def prompts_file(self):
59
+ def parsed_file(self):
84
60
  """
85
- Returns the parsed prompts file.
61
+ Returns the parsed file.
86
62
 
87
- :return: List of tokens from the prompts file.
63
+ :return: List of tokens from the file.
88
64
  """
89
- return self._prompts_file
65
+ return self._file
@@ -1,44 +0,0 @@
1
- """Test the parser."""
2
-
3
- import pytest
4
- from tpc_plugin_parser.parser import Parser
5
-
6
-
7
- class TestParser(object):
8
- """Test the lexer."""
9
-
10
- @pytest.mark.parametrize(
11
- "process_file,prompts_file",
12
- [
13
- (
14
- "tests/data/process.ini",
15
- "tests/data/prompts.ini",
16
- ),
17
- ],
18
- )
19
- def test_parser(self, process_file: str, prompts_file: str) -> None:
20
- """
21
- Test to ensure that a token parses ok.
22
-
23
- :param process_file: Path to the process file.
24
- :param prompts_file: Path to the prompts file.
25
- """
26
- with open(process_file, "r") as process_file:
27
- process_content = process_file.read()
28
-
29
- with open(prompts_file, "r") as prompts_file:
30
- prompts_content = prompts_file.read()
31
-
32
- parser = Parser(process_file=process_content, prompts_file=prompts_content)
33
-
34
- assert len(parser.process_file) == 6
35
- assert len(parser.process_file["default"]) == 6
36
- assert len(parser.process_file["states"]) == 8
37
- assert len(parser.process_file["transitions"]) == 7
38
- assert len(parser.process_file["CPM Parameters Validation"]) == 5
39
- assert len(parser.process_file["parameters"]) == 5
40
- assert len(parser.process_file["Debug Information"]) == 7
41
-
42
- assert len(parser.prompts_file) == 2
43
- assert len(parser.prompts_file["default"]) == 6
44
- assert len(parser.prompts_file["conditions"]) == 8