ScriptCollection 3.5.139__py3-none-any.whl → 3.5.142__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.
@@ -33,7 +33,7 @@ from .ProgramRunnerPopen import ProgramRunnerPopen
33
33
  from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
34
34
  from .SCLog import SCLog, LogLevel
35
35
 
36
- version = "3.5.139"
36
+ version = "3.5.142"
37
37
  __version__ = version
38
38
 
39
39
 
@@ -309,7 +309,7 @@ class ScriptCollectionCore:
309
309
 
310
310
  @GeneralUtilities.check_arguments
311
311
  def git_pull_with_retry(self, folder: str, remote: str, localbranchname: str, remotebranchname: str, force: bool = False, amount_of_attempts: int = 5) -> None:
312
- GeneralUtilities.retry_action(lambda: self.git_pull_with_retry(folder, remote, localbranchname, remotebranchname), amount_of_attempts)
312
+ GeneralUtilities.retry_action(lambda: self.git_pull(folder, remote, localbranchname, remotebranchname), amount_of_attempts)
313
313
 
314
314
  @GeneralUtilities.check_arguments
315
315
  def git_pull(self, folder: str, remote: str, localbranchname: str, remotebranchname: str, force: bool = False) -> None:
@@ -2380,10 +2380,18 @@ OCR-content:
2380
2380
  @GeneralUtilities.check_arguments
2381
2381
  def get_ocr_content_of_file(self, file: str, serviceaddress: str, languages: list[str]) -> str: # serviceaddress = None means local executable
2382
2382
  result: str = None
2383
+ extension = Path(file).suffix
2383
2384
  if serviceaddress is None:
2384
- result = "" # TODO call local executable
2385
+ program_result = self.run_program_argsasarray("simpleocr", ["--File", file, "--Languages", "+".join(languages)] + languages)
2386
+ result = program_result[1]
2385
2387
  else:
2386
- result = "" # TODO call remote service
2388
+ languages_for_url = '%2B'.join(languages)
2389
+ package_url: str = f"https://{serviceaddress}/GetOCRContent?languages={languages_for_url}&fileType={extension}"
2390
+ headers = {'Cache-Control': 'no-cache'}
2391
+ r = requests.put(package_url, timeout=5, headers=headers, data=GeneralUtilities.read_binary_from_file(file))
2392
+ if r.status_code != 200:
2393
+ raise ValueError(f"Checking for latest tor package resulted in HTTP-response-code {r.status_code}.")
2394
+ result = GeneralUtilities.bytes_to_string(r.content)
2387
2395
  return result
2388
2396
 
2389
2397
  @GeneralUtilities.check_arguments
@@ -1513,7 +1513,7 @@ class TasksForCommonProjectStructure:
1513
1513
  project_version = self.get_version_of_project(repository_folder)
1514
1514
  codeunit_folder = os.path.join(repository_folder, codeunit_name)
1515
1515
 
1516
- # Check codeunit-conformity
1516
+ # check codeunit-conformity
1517
1517
  # TODO check if foldername=="<codeunitname>[.codeunit.xml]" == <codeunitname> in file
1518
1518
  supported_codeunitspecificationversion = "2.9.4" # should always be the latest version of the ProjectTemplates-repository
1519
1519
  codeunit_file = os.path.join(codeunit_folder, f"{codeunit_name}.codeunit.xml")
@@ -1523,7 +1523,7 @@ class TasksForCommonProjectStructure:
1523
1523
  namespaces = {'cps': 'https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure', 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'}
1524
1524
  root: etree._ElementTree = etree.parse(codeunit_file)
1525
1525
 
1526
- # Check codeunit-spcecification-version
1526
+ # check codeunit-spcecification-version
1527
1527
  try:
1528
1528
  codeunit_file_version = root.xpath('//cps:codeunit/@codeunitspecificationversion', namespaces=namespaces)[0]
1529
1529
  if codeunit_file_version != supported_codeunitspecificationversion:
@@ -1538,27 +1538,27 @@ class TasksForCommonProjectStructure:
1538
1538
  GeneralUtilities.write_message_to_stderr(f'Warning: Codeunitfile "{codeunit_file}" can not be validated due to the following exception:')
1539
1539
  GeneralUtilities.write_exception_to_stderr(exception)
1540
1540
 
1541
- # Check codeunit-name
1541
+ # check codeunit-name
1542
1542
  codeunit_name_in_codeunit_file = root.xpath('//cps:codeunit/cps:name/text()', namespaces=namespaces)[0]
1543
1543
  if codeunit_name != codeunit_name_in_codeunit_file:
1544
1544
  raise ValueError(f"The folder-name ('{codeunit_name}') is not equal to the codeunit-name ('{codeunit_name_in_codeunit_file}').")
1545
1545
 
1546
- # Check owner-name
1546
+ # check owner-name
1547
1547
  codeunit_ownername_in_codeunit_file = self. get_codeunit_owner_name(codeunit_file)
1548
1548
  GeneralUtilities.assert_condition(GeneralUtilities.string_has_content(codeunit_ownername_in_codeunit_file), "No valid name for codeunitowner given.")
1549
1549
 
1550
- # Check owner-emailaddress
1550
+ # check owner-emailaddress
1551
1551
  codeunit_owneremailaddress_in_codeunit_file = self.get_codeunit_owner_emailaddress(codeunit_file)
1552
1552
  GeneralUtilities.assert_condition(GeneralUtilities.string_has_content(codeunit_owneremailaddress_in_codeunit_file), "No valid email-address for codeunitowner given.")
1553
1553
 
1554
- # Check development-state
1554
+ # check development-state
1555
1555
  developmentstate = root.xpath('//cps:properties/@developmentstate', namespaces=namespaces)[0]
1556
1556
  developmentstate_active = "Active development"
1557
1557
  developmentstate_maintenance = "Maintenance-updates only"
1558
1558
  developmentstate_inactive = "Inactive"
1559
1559
  GeneralUtilities.assert_condition(developmentstate in (developmentstate_active, developmentstate_maintenance, developmentstate_inactive), f"Invalid development-state. Must be '{developmentstate_active}' or '{developmentstate_maintenance}' or '{developmentstate_inactive}' but was '{developmentstate}'.")
1560
1560
 
1561
- # Check for mandatory files
1561
+ # check for mandatory files
1562
1562
  files = ["Other/Build/Build.py", "Other/QualityCheck/Linting.py", "Other/Reference/GenerateReference.py"]
1563
1563
  if self.codeunit_has_testable_sourcecode(codeunit_file):
1564
1564
  # TODO check if the testsettings-section appears in the codeunit-file
@@ -1574,7 +1574,7 @@ class TasksForCommonProjectStructure:
1574
1574
  if os.path.isfile(os.path.join(codeunit_folder, "Other", "requirements.txt")):
1575
1575
  self.install_requirementstxt_for_codeunit(codeunit_folder, verbosity)
1576
1576
 
1577
- # Check developer
1577
+ # check developer
1578
1578
  if self.validate_developers_of_repository:
1579
1579
  expected_authors: list[tuple[str, str]] = []
1580
1580
  expected_authors_in_xml = root.xpath('//cps:codeunit/cps:developerteam/cps:developer', namespaces=namespaces)
@@ -1597,19 +1597,30 @@ class TasksForCommonProjectStructure:
1597
1597
 
1598
1598
  # TODO implement cycle-check for dependent codeunits
1599
1599
 
1600
- # Clear previously builded artifacts if desired:
1600
+ # clear previously builded artifacts if desired:
1601
1601
  if clear_artifacts_folder:
1602
1602
  artifacts_folder = os.path.join(codeunit_folder, "Other", "Artifacts")
1603
1603
  GeneralUtilities.ensure_directory_does_not_exist(artifacts_folder)
1604
1604
 
1605
- # Get artifacts from dependent codeunits
1605
+ # get artifacts from dependent codeunits
1606
1606
  # if assume_dependent_codeunits_are_already_built:
1607
1607
  # self.build_dependent_code_units(repository_folder, codeunit_name, verbosity, target_environmenttype, additional_arguments_file, commandline_arguments)
1608
1608
  self.copy_artifacts_from_dependent_code_units(repository_folder, codeunit_name)
1609
1609
 
1610
- # Update codeunit-version
1610
+ # update codeunit-version
1611
1611
  self.update_version_of_codeunit(common_tasks_scripts_file, codeunit_version)
1612
1612
 
1613
+ # set project version
1614
+ package_json_file = os.path.join(repository_folder, "package.json") # TDOO move this to a general project-specific (and codeunit-independent-script)
1615
+ if os.path.isfile(package_json_file):
1616
+ package_json_data: str = None
1617
+ with open(package_json_file, "r", encoding="utf-8") as f1:
1618
+ package_json_data = json.load(f1)
1619
+ package_json_data["version"] = project_version
1620
+ with open(package_json_file, "w", encoding="utf-8") as f2:
1621
+ json.dump(package_json_data, f2, indent=2)
1622
+ GeneralUtilities.write_text_to_file(package_json_file, GeneralUtilities.read_text_from_file(package_json_file).replace("\r", ""))
1623
+
1613
1624
  # set default constants
1614
1625
  self.set_default_constants(os.path.join(codeunit_folder))
1615
1626
 
@@ -2360,6 +2371,7 @@ class TasksForCommonProjectStructure:
2360
2371
  tasks.sort(key=lambda x: x["label"].split("/")[-1], reverse=False) # sort by the label of the task
2361
2372
  for task in tasks:
2362
2373
  if task["type"] == "shell":
2374
+
2363
2375
  description: str = task["label"]
2364
2376
  name: str = GeneralUtilities.to_pascal_case(description)
2365
2377
  command = task["command"]
@@ -2381,11 +2393,18 @@ class TasksForCommonProjectStructure:
2381
2393
  if len(args) > 1:
2382
2394
  command_with_args = f"{command_with_args} {' '.join(args)}"
2383
2395
 
2396
+ if "description" in task:
2397
+ additional_description = task["description"]
2398
+ description = f"{description} ({additional_description})"
2399
+
2384
2400
  if append_cli_args_at_end:
2385
2401
  command_with_args = f"{command_with_args} {{{{.CLI_ARGS}}}}"
2386
- cwd_literal = cwd.replace("\\", "\\\\")
2402
+
2403
+ cwd_literal = cwd.replace("\\", "\\\\").replace('"', '\\"') # escape backslashes and double quotes for YAML
2404
+ description_literal = description.replace("\\", "\\\\").replace('"', '\\"') # escape backslashes and double quotes for YAML
2405
+
2387
2406
  lines.append(f" {name}:")
2388
- lines.append(f' desc: "{description}"')
2407
+ lines.append(f' desc: "{description_literal}"')
2389
2408
  lines.append(' silent: true')
2390
2409
  lines.append(f' dir: "{cwd_literal}"')
2391
2410
  lines.append(" cmds:")
@@ -2397,6 +2416,7 @@ class TasksForCommonProjectStructure:
2397
2416
  for alias in aliases:
2398
2417
  lines.append(f' - {alias}')
2399
2418
  lines.append(GeneralUtilities.empty_string)
2419
+
2400
2420
  GeneralUtilities.write_lines_to_file(task_file, lines)
2401
2421
 
2402
2422
  @GeneralUtilities.check_arguments
@@ -2648,7 +2668,7 @@ class TasksForCommonProjectStructure:
2648
2668
  GeneralUtilities.write_message_to_stdout(message2)
2649
2669
 
2650
2670
  @GeneralUtilities.check_arguments
2651
- def __do_repository_checks(self, repository_folder: str, project_version: str) -> None:
2671
+ def __do_repository_checks(self, repository_folder: str, project_version: str) -> None: # TDOO move this to a general project-specific (and codeunit-independent-script)
2652
2672
  self.__sc.assert_is_git_repository(repository_folder)
2653
2673
  self.__check_if_changelog_exists(repository_folder, project_version)
2654
2674
  self.__check_whether_security_txt_exists(repository_folder)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ScriptCollection
3
- Version: 3.5.139
3
+ Version: 3.5.142
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Home-page: https://github.com/anionDev/ScriptCollection
6
6
  Author: Marius Göcke
@@ -33,11 +33,11 @@ Requires-Dist: ntplib>=0.4.0
33
33
  Requires-Dist: Pillow>=11.2.1
34
34
  Requires-Dist: psutil>=7.0.0
35
35
  Requires-Dist: pycdlib>=1.14.0
36
- Requires-Dist: Pygments>=2.19.1
36
+ Requires-Dist: Pygments>=2.19.2
37
37
  Requires-Dist: pylint>=3.3.7
38
38
  Requires-Dist: pyOpenSSL>=25.1.0
39
- Requires-Dist: PyPDF>=5.6.0
40
- Requires-Dist: pytest>=8.4.0
39
+ Requires-Dist: PyPDF>=5.6.1
40
+ Requires-Dist: pytest>=8.4.1
41
41
  Requires-Dist: PyYAML>=6.0.2
42
42
  Requires-Dist: qrcode>=8.2
43
43
  Requires-Dist: send2trash>=1.8.3
@@ -7,11 +7,11 @@ ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4b
7
7
  ScriptCollection/ProgramRunnerEpew.py,sha256=4pjEd0r9Fcz3TTDv0MdTSd5KkigYXcWUVI1X43regfU,6477
8
8
  ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
9
9
  ScriptCollection/SCLog.py,sha256=Dd2P8vH2PA830wAv6bchlMHHdGE_7At-F4WQY5w4XdA,4016
10
- ScriptCollection/ScriptCollectionCore.py,sha256=rX1wjbWTYkTVGaVzvgDYlCxSVhxfyoIr7Yn4oTJ8qy4,135815
11
- ScriptCollection/TasksForCommonProjectStructure.py,sha256=boOF-cOYdfUPRf5DOgL1yfeO7GYxAn6-W3fdUV84clE,235903
10
+ ScriptCollection/ScriptCollectionCore.py,sha256=RN10QzaK5EYJ7vw2BHlWxc_1GqBM8sPLCdaSMQQiNCA,136482
11
+ ScriptCollection/TasksForCommonProjectStructure.py,sha256=zBrrzssSXrBptgRaj4R_aA5-t_jEncHcjmR2EoYTqzU,237126
12
12
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- scriptcollection-3.5.139.dist-info/METADATA,sha256=9OcBLfJLHZo4Vtr9udrIBQSbqI50JA9oVS0DkjXUCdQ,7694
14
- scriptcollection-3.5.139.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- scriptcollection-3.5.139.dist-info/entry_points.txt,sha256=AvmVO9iyWImExpvzL3YYQ9AOEiUIN9guPRRG_W_VNWY,4116
16
- scriptcollection-3.5.139.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
17
- scriptcollection-3.5.139.dist-info/RECORD,,
13
+ scriptcollection-3.5.142.dist-info/METADATA,sha256=VXRsnflOOEDstkfXPdrZJtVFVRaSA33zxSboT_AiOEE,7694
14
+ scriptcollection-3.5.142.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ scriptcollection-3.5.142.dist-info/entry_points.txt,sha256=AvmVO9iyWImExpvzL3YYQ9AOEiUIN9guPRRG_W_VNWY,4116
16
+ scriptcollection-3.5.142.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
17
+ scriptcollection-3.5.142.dist-info/RECORD,,