python-utility-scripts 1.0.20__tar.gz → 1.0.22__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 (18) hide show
  1. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/PKG-INFO +3 -2
  2. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/jira_utils/README.md +3 -1
  3. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/jira_utils/jira_information.py +35 -12
  4. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/pyproject.toml +11 -5
  5. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/.gitignore +0 -0
  6. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/LICENSE +0 -0
  7. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/README.md +0 -0
  8. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/__init__.py +0 -0
  9. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/jira_utils/__init__.py +0 -0
  10. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/polarion/README.md +0 -0
  11. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/polarion/__init__.py +0 -0
  12. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/polarion/polarion_set_automated.py +0 -0
  13. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/polarion/polarion_utils.py +0 -0
  14. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/polarion/polarion_verify_tc_requirements.py +0 -0
  15. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/unused_code/README.md +0 -0
  16. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/unused_code/__init__.py +0 -0
  17. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/unused_code/unused_code.py +0 -0
  18. {python_utility_scripts-1.0.20 → python_utility_scripts-1.0.22}/apps/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-utility-scripts
3
- Version: 1.0.20
3
+ Version: 1.0.22
4
4
  Summary: Python utility scripts
5
5
  Project-URL: Homepage, https://github.com/RedHatQE/python-utility-scripts
6
6
  Project-URL: Repository, https://github.com/RedHatQE/python-utility-scripts
@@ -10,8 +10,9 @@ License-Expression: Apache-2.0
10
10
  License-File: LICENSE
11
11
  Classifier: Operating System :: OS Independent
12
12
  Classifier: Programming Language :: Python :: 3
13
- Requires-Python: ~=3.9
13
+ Requires-Python: >=3.9
14
14
  Requires-Dist: ast-comments>=1.2.2
15
+ Requires-Dist: click>=8.1.7
15
16
  Requires-Dist: jira<4,>=3.6.0
16
17
  Requires-Dist: pyhelper-utils<2,>=1.0.1
17
18
  Requires-Dist: pylero<0.2,>=0.1.0
@@ -15,7 +15,8 @@ pyutils-jira --help
15
15
  ```
16
16
 
17
17
  ## Config file
18
- A config file with the jira connection parameters like url, token, resolved_statuses, skip_project_ids, target_versions should be passed to command line option `--cfg-file`
18
+ A config file with the jira connection parameters like url, token, resolved_statuses, skip_project_ids,
19
+ target_versions should be passed to command line option `--cfg-file`
19
20
 
20
21
  ### Example:
21
22
 
@@ -33,6 +34,7 @@ pyutils-jira:
33
34
  target_versions:
34
35
  - 1.0.0
35
36
  - 2.0.1
37
+ - 3.0.z
36
38
  issue_pattern: "([A-Z]+-[0-9]+)"
37
39
  version_string_not_targeted_jiras: "vfuture"
38
40
  ```
@@ -18,7 +18,11 @@ from apps.utils import ListParamType, all_python_files, get_util_config
18
18
  LOGGER = get_logger(name=__name__)
19
19
 
20
20
 
21
- @retry(retry=retry_if_exception_type(JIRAError), stop=stop_after_attempt(3), wait=wait_fixed(2))
21
+ @retry(
22
+ retry=retry_if_exception_type(JIRAError),
23
+ stop=stop_after_attempt(3),
24
+ wait=wait_fixed(2),
25
+ )
22
26
  @lru_cache
23
27
  def get_issue(
24
28
  jira: JIRA,
@@ -97,6 +101,8 @@ def get_jira_information(
97
101
  file_name: str,
98
102
  ) -> tuple[str, str]:
99
103
  jira_error_string = ""
104
+ re_compile = r"(?<![\d.])\d+\.\d+(?:\.(?:\d+|z))?\b"
105
+
100
106
  try:
101
107
  # check resolved status:
102
108
  jira_issue_metadata = get_issue(jira=jira_object, jira_id=jira_id).fields
@@ -105,17 +111,20 @@ def get_jira_information(
105
111
  if current_jira_status in resolved_status:
106
112
  jira_error_string += f"{jira_id} current status: {current_jira_status} is resolved."
107
113
 
108
- # validate correct target version if provided:
114
+ # validate a correct target version if provided:
109
115
  if jira_target_versions:
110
116
  if skip_project_ids and jira_id.startswith(tuple(skip_project_ids)):
111
117
  return file_name, jira_error_string
112
118
 
113
- fix_version = (
114
- re.search(r"([\d.]+)", jira_issue_metadata.fixVersions[0].name)
115
- if (jira_issue_metadata.fixVersions)
116
- else None
117
- )
118
- current_target_version = fix_version.group(1) if fix_version else target_version_str
119
+ # If a bug has a fix version, extract it using regex
120
+ if (jira_fix_versions := jira_issue_metadata.fixVersions) and (
121
+ found_version := re.findall(re_compile, jira_fix_versions[0].name)
122
+ ):
123
+ current_target_version = found_version[0]
124
+
125
+ else:
126
+ current_target_version = target_version_str
127
+
119
128
  if not any([current_target_version == version for version in jira_target_versions]):
120
129
  jira_error_string += (
121
130
  f"{jira_id} target version: {current_target_version}, does not match expected "
@@ -174,8 +183,18 @@ def process_jira_command_line_config_file(
174
183
  help="Provide comma separated list of Jira Project keys, against which version check should be skipped.",
175
184
  type=ListParamType(),
176
185
  )
177
- @click.option("--url", help="Provide the Jira server URL", type=click.STRING, default=os.getenv("JIRA_SERVER_URL"))
178
- @click.option("--token", help="Provide the Jira token.", type=click.STRING, default=os.getenv("JIRA_TOKEN"))
186
+ @click.option(
187
+ "--url",
188
+ help="Provide the Jira server URL",
189
+ type=click.STRING,
190
+ default=os.getenv("JIRA_SERVER_URL"),
191
+ )
192
+ @click.option(
193
+ "--token",
194
+ help="Provide the Jira token.",
195
+ type=click.STRING,
196
+ default=os.getenv("JIRA_TOKEN"),
197
+ )
179
198
  @click.option(
180
199
  "--issue-pattern",
181
200
  help="Provide the regex for Jira ids",
@@ -226,11 +245,15 @@ def get_jira_mismatch(
226
245
  target_versions=target_versions,
227
246
  )
228
247
 
229
- jira_obj = JIRA(token_auth=jira_config_dict["token"], options={"server": jira_config_dict["url"]})
248
+ jira_obj = JIRA(
249
+ token_auth=jira_config_dict["token"],
250
+ options={"server": jira_config_dict["url"]},
251
+ )
230
252
  jira_error: dict[str, str] = {}
231
253
 
232
254
  if jira_id_dict := get_jiras_from_python_files(
233
- issue_pattern=jira_config_dict["issue_pattern"], jira_url=jira_config_dict["url"]
255
+ issue_pattern=jira_config_dict["issue_pattern"],
256
+ jira_url=jira_config_dict["url"],
234
257
  ):
235
258
  with concurrent.futures.ThreadPoolExecutor() as executor:
236
259
  for file_name, ids in jira_id_dict.items():
@@ -1,8 +1,8 @@
1
1
  [project]
2
2
  name = "python-utility-scripts"
3
- version = "1.0.20"
3
+ version = "1.0.22"
4
4
  description = "Python utility scripts"
5
- requires-python = "~=3.9"
5
+ requires-python = ">=3.9"
6
6
  readme = "README.md"
7
7
  license = "Apache-2.0"
8
8
  classifiers = [
@@ -17,7 +17,8 @@ dependencies = [
17
17
  "tenacity>=9.0.0,<10",
18
18
  "python-simple-logger>=2.0.0,<3",
19
19
  "pyhelper-utils>=1.0.1,<2",
20
- "ast-comments>=1.2.2"
20
+ "ast-comments>=1.2.2",
21
+ "click (>=8.1.7)"
21
22
  ]
22
23
 
23
24
  [[project.authors]]
@@ -39,7 +40,7 @@ dependencies = [
39
40
  omit = [ "tests/*" ]
40
41
 
41
42
  [tool.coverage.report]
42
- fail_under = 65
43
+ fail_under = 68
43
44
  skip_empty = true
44
45
 
45
46
  [tool.coverage.html]
@@ -78,7 +79,12 @@ output-format = "grouped"
78
79
 
79
80
  [dependency-groups]
80
81
  dev = [ "ipdb>=0.13.13,<0.14", "ipython" ]
81
- test = [ "pytest>=8.0.0,<9", "pytest-cov>=6.0.0,<7" ]
82
+ test = [
83
+ "ipdb>=0.13.13",
84
+ "ipython>=8.18.1",
85
+ "pytest>=8.0.0,<9",
86
+ "pytest-cov>=6.0.0,<7"
87
+ ]
82
88
 
83
89
  [build-system]
84
90
  requires = [ "hatchling" ]