ScriptCollection 4.3.23__py3-none-any.whl → 4.3.25__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.
@@ -38,7 +38,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
38
38
  from .ProgramRunnerPopen import ProgramRunnerPopen
39
39
  from .SCLog import SCLog, LogLevel
40
40
 
41
- version = "4.3.23"
41
+ version = "4.3.25"
42
42
  __version__ = version
43
43
 
44
44
  class VSCodeWorkspaceShellTask:
@@ -152,6 +152,41 @@ class VSCodeWorkspaceMongoDBConnection:
152
152
  """
153
153
  return result
154
154
 
155
+ class GitHubIssueSummary:
156
+ number:int = None
157
+ title:str = None
158
+ state:str = None # "open" or "closed"
159
+ tags:list[str] = None # the labels of the issue
160
+
161
+ def __init__(self,number:int,title:str,state:str,tags:list[str]):
162
+ self.number=number
163
+ self.title=title
164
+ self.state=state
165
+ self.tags=tags
166
+
167
+
168
+ class GitHubIssueComment:
169
+ author:str = None #nullable
170
+ body:str = None
171
+ created_at:str = None #nullable
172
+
173
+ def __init__(self,author:str,body:str,created_at:str):
174
+ self.author=author
175
+ self.body=body
176
+ self.created_at=created_at
177
+
178
+
179
+ class GitHubIssue:
180
+ summary:GitHubIssueSummary = None
181
+ description:str = None #nullable (the body of the issue)
182
+ comments:list[GitHubIssueComment] = None
183
+
184
+ def __init__(self,summary:GitHubIssueSummary,description:str,comments:list[GitHubIssueComment]):
185
+ self.summary=summary
186
+ self.description=description
187
+ self.comments=comments
188
+
189
+
155
190
  class ScriptCollectionCore:
156
191
 
157
192
  # The purpose of this property is to use it when testing your code which uses scriptcollection for external program-calls.
@@ -165,6 +200,8 @@ class ScriptCollectionCore:
165
200
  log: SCLog = None
166
201
  # Magic string which can be used inside the arguments of run_command_in_folder. Every occurrence of it will be replaced by the (resolved) actual_folder.
167
202
  run_command_in_folder_actual_folder_placeholder: str = "{actual_folder}"
203
+ # Base-url of the GitHub-REST-API. This is an internal constant on purpose and deliberately not exposed as a parameter of the GitHub-functions.
204
+ __github_api_base_url: str = "https://api.github.com"
168
205
 
169
206
 
170
207
  def __init__(self):
@@ -314,6 +351,73 @@ class ScriptCollectionCore:
314
351
  self.run_program("docker",arg,arguments_for_log=arg_for_log,print_live_output=self.log.loglevel==LogLevel.Debug)
315
352
 
316
353
 
354
+ @GeneralUtilities.check_arguments
355
+ def get_issues_of_github_repository(self, owner: str, repository: str, github_token: str = None) -> list[GitHubIssueSummary]:
356
+ """Retrieves all issues (open and closed) of the given GitHub-repository and returns for each issue its number, title, state and tags.
357
+ Use 'get_github_issue_details' to retrieve the full details (description, comments) of a specific issue.
358
+ 'github_token' is optional but recommended: without it only public repositories are accessible and a low unauthenticated rate-limit applies.
359
+ This function only returns the retrieved data; it does not modify anything."""
360
+ headers = self.__get_github_api_headers(github_token)
361
+ result: list[GitHubIssueSummary] = []
362
+ issues_url = f"{self.__github_api_base_url}/repos/{owner}/{repository}/issues"
363
+ # 'state=all' returns open and closed issues. GitHub returns pull-requests on this endpoint too; they are filtered out below.
364
+ raw_issues = self.__get_all_github_pages(issues_url, {"state": "all", "per_page": "100"}, headers)
365
+ for raw_issue in raw_issues:
366
+ if "pull_request" in raw_issue: # this entry is a pull-request, not an issue
367
+ continue
368
+ tags = [label["name"] for label in raw_issue.get("labels", [])]
369
+ result.append(GitHubIssueSummary(raw_issue["number"], raw_issue["title"], raw_issue["state"], tags))
370
+ return result
371
+
372
+ @GeneralUtilities.check_arguments
373
+ def get_github_issue_details(self, owner: str, repository: str, issue_number: int, github_token: str = None) -> GitHubIssue:
374
+ """Retrieves the full details of a single issue of the given GitHub-repository:
375
+ title, description (body), comments, state ('open' or 'closed') and tags (labels).
376
+ 'github_token' is optional but recommended: without it only public repositories are accessible and a low unauthenticated rate-limit applies.
377
+ This function only returns the retrieved data; it does not modify anything."""
378
+ headers = self.__get_github_api_headers(github_token)
379
+ issue_url = f"{self.__github_api_base_url}/repos/{owner}/{repository}/issues/{issue_number}"
380
+ response = requests.get(issue_url, headers=headers, timeout=30)
381
+ response.raise_for_status() # check if statuscode = 200
382
+ raw_issue = response.json()
383
+ tags = [label["name"] for label in raw_issue.get("labels", [])]
384
+ summary = GitHubIssueSummary(raw_issue["number"], raw_issue["title"], raw_issue["state"], tags)
385
+ comments: list[GitHubIssueComment] = []
386
+ if raw_issue.get("comments", 0) > 0:
387
+ raw_comments = self.__get_all_github_pages(raw_issue["comments_url"], {"per_page": "100"}, headers)
388
+ for raw_comment in raw_comments:
389
+ author = raw_comment["user"]["login"] if raw_comment.get("user") is not None else None
390
+ comments.append(GitHubIssueComment(author, raw_comment.get("body"), raw_comment.get("created_at")))
391
+ return GitHubIssue(summary, raw_issue.get("body"), comments)
392
+
393
+ @GeneralUtilities.check_arguments
394
+ def __get_github_api_headers(self, github_token: str) -> dict:
395
+ headers = {"Accept": "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28"}
396
+ if GeneralUtilities.string_has_content(github_token):
397
+ headers["Authorization"] = f"Bearer {github_token}"
398
+ return headers
399
+
400
+ @GeneralUtilities.check_arguments
401
+ def __get_all_github_pages(self, url: str, query_parameters: dict, headers: dict) -> list:
402
+ """Requests all pages of a paginated GitHub-API-endpoint (following the 'Link'-header) and returns the concatenated result-items."""
403
+ result: list = []
404
+ next_url = url
405
+ next_parameters = query_parameters
406
+ while next_url is not None:
407
+ response = requests.get(next_url, params=next_parameters, headers=headers, timeout=30)
408
+ response.raise_for_status() # check if statuscode = 200
409
+ result.extend(response.json())
410
+ # follow the pagination using the 'Link'-header ( https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api ).
411
+ next_url = None
412
+ next_parameters = None # the 'next'-url from the Link-header already contains all required query-parameters
413
+ link_header = response.headers.get("Link")
414
+ if link_header is not None:
415
+ for link in link_header.split(","):
416
+ parts = link.split(";")
417
+ if len(parts) >= 2 and 'rel="next"' in parts[1]:
418
+ next_url = parts[0].strip().lstrip("<").rstrip(">")
419
+ return result
420
+
317
421
  @GeneralUtilities.check_arguments
318
422
  def python_file_has_errors(self, file: str, working_directory: str, treat_warnings_as_errors: bool = True, display_file: str = None) -> tuple[bool, list[str]]:
319
423
  errors = list()
@@ -2441,7 +2545,7 @@ class ScriptCollectionCore:
2441
2545
  self.git_clone(temp_folder, repository_folder, include_submodules=False)
2442
2546
  # the local clone already checks out the source's current branch on the tagged commit; the explicit checkout only guarantees gitversion sees the correct branch-name (and thus the correct increment-rule)
2443
2547
  self.run_program_argsasarray("git", ["checkout", branch_name], temp_folder, throw_exception_if_exitcode_is_not_zero=True)
2444
- self.run_program("git","-c user.name=\"noname\" -c user.email=\"noname@example.com\" commit -m empty --quiet --allow-empty", temp_folder, no_changes_behavior=1)
2548
+ self.run_program("git","-c user.name=\"noname\" -c user.email=\"noname@example.com\" commit -m empty --quiet --allow-empty", temp_folder)
2445
2549
  result = self.get_version_from_gitversion(temp_folder, "MajorMinorPatch")
2446
2550
  self.__next_gitversion_cache[cache_key] = result
2447
2551
  self.__write_next_version_to_disk_cache(repository_folder, commit_id, branch_name, result)
@@ -107,8 +107,8 @@ class TFCPS_CodeUnit_BuildCodeUnits:
107
107
  self.sc.log.log(GeneralUtilities.get_line())
108
108
 
109
109
  self.search_for_secrets()
110
- self.__search_for_vulnerabilities()
111
110
  self.__normalize_md_and_txt_line_endings()
111
+ self.tfcps_tools_general.generate_svg_files_from_plantuml_files_for_repository(self.repository, self.use_cache())
112
112
 
113
113
  if self.is_pre_merge():
114
114
  self.__translate()
@@ -372,10 +372,6 @@ class TFCPS_CodeUnit_BuildCodeUnits:
372
372
  self.sc.generate_chart_diagram(diagram_definition_file,os.path.basename(diagram_svg_file))
373
373
  self.sc.format_xml_file(diagram_svg_file)
374
374
 
375
- @GeneralUtilities.check_arguments
376
- def __search_for_vulnerabilities(self):
377
- pass#TODO
378
-
379
375
  @GeneralUtilities.check_arguments
380
376
  def search_for_secrets(self) -> None:
381
377
  self.sc.log.log("Search for secrets...")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.3.23
3
+ Version: 4.3.25
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Author-email: Marius Göcke <marius.goecke@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=zVD-gZY85o8wiGFcpYAGNDl-tXaKzipl1Bkhqy2ois4,4681
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=RXsiceQ8W6a8YDk_2BPscVbIAmDIpIxqe9WHBy2r4CM,5233
11
11
  ScriptCollection/SCLog.py,sha256=LdzSJy3NnnwYCCefz2h4tiTy4BjT8lOz3IBG_bMOg9E,4821
12
- ScriptCollection/ScriptCollectionCore.py,sha256=r8OZFw3AFvH2IwIS_OY8bps3AKOyXSNj-7UZFYJMjaY,240339
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=i1D4_NncFUcgbdOkR2B2zs_iPVAhE5MsB-snXmay1HI,246308
13
13
  ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
14
14
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=WO2M28c2tUwsXFNa2L9zqMhdlyObWm3qpPE0LdIs7SE,2315
@@ -35,7 +35,7 @@ ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html,sha256=CX9S1bdOz
35
35
  ScriptCollection/TFCPS/SCTaskRunnerServer.py,sha256=rpuwSsQ6YQfZS2LGnvOH5ql8zs_-cHU4LQttS7XNT60,11272
36
36
  ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=oICRtl85n2puWvchcJIkmLZL1BAylMbzH7ltBGWfqgY,31973
37
37
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=Ll5EOkpVpPiFrM2mLeQXolaF7075IwgtnHXvfdpkH4k,9904
38
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=FAb1AIfsFUg4kIrSleDu1mjbGJTHmqVjTxSQBErtFcI,31104
38
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=uY1A8UeZZFFQ-Fdtf_V1zIWkvXCsePEpMtzZjamLmK4,31077
39
39
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=X2NgZgbOkJsdZ6wMHB_RuS_rQCuz5oQCqzYrxyXBN9Q,6680
40
40
  ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=5vCFfDiU8bvfcnoKNs2ATS8nsl6mYXcIuX7XfYE0tvg,2116
41
41
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=zp7n0Li7GTi4tERDMgDcJ-o3m6131m31zvkat0lALEc,7781
@@ -63,8 +63,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=Bd1gxCk9Fb
63
63
  ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
65
65
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
- scriptcollection-4.3.23.dist-info/METADATA,sha256=mQtFTL13JeD0ATzyX3UvVWJPaBJOK5Z9UU1cNFHMNmM,7816
67
- scriptcollection-4.3.23.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
68
- scriptcollection-4.3.23.dist-info/entry_points.txt,sha256=Iq9YMSTWNCAJpBzM5L9CQx80tL9-XUu6MzDRAdBrIPg,5875
69
- scriptcollection-4.3.23.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
70
- scriptcollection-4.3.23.dist-info/RECORD,,
66
+ scriptcollection-4.3.25.dist-info/METADATA,sha256=lAXTpAwrNwVxrcYWA-9f8lCpUdKoBBUh_V2QTPGHZHY,7816
67
+ scriptcollection-4.3.25.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
68
+ scriptcollection-4.3.25.dist-info/entry_points.txt,sha256=Iq9YMSTWNCAJpBzM5L9CQx80tL9-XUu6MzDRAdBrIPg,5875
69
+ scriptcollection-4.3.25.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
70
+ scriptcollection-4.3.25.dist-info/RECORD,,