ScriptCollection 3.5.44__py3-none-any.whl → 3.5.45__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.
@@ -889,3 +889,19 @@ class GeneralUtilities:
889
889
  if print_result:
890
890
  GeneralUtilities.write_message_to_stdout(f"Result: {result}")
891
891
  return result
892
+
893
+ @staticmethod
894
+ @check_arguments
895
+ def assert_is_git_repository(folder: str) -> str:
896
+ git_file_or_folder = os.path.join(folder, ".git")
897
+ GeneralUtilities.assert_condition(os.path.isdir(git_file_or_folder) or os.path.isfile(git_file_or_folder), f"'{folder}' is not a git-repository.")
898
+
899
+ @staticmethod
900
+ @check_arguments
901
+ def assert_file_exists(file: str) -> str:
902
+ GeneralUtilities.assert_condition(os.path.isfile(file), f"File '{file}' does not exist.")
903
+
904
+ @staticmethod
905
+ @check_arguments
906
+ def assert_folder_exists(folder: str) -> str:
907
+ GeneralUtilities.assert_condition(os.path.isdir(folder), f"Folder '{folder}' does not exist.")
@@ -31,7 +31,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
31
31
  from .ProgramRunnerPopen import ProgramRunnerPopen
32
32
  from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
33
33
 
34
- version = "3.5.44"
34
+ version = "3.5.45"
35
35
  __version__ = version
36
36
 
37
37
 
@@ -1251,18 +1251,18 @@ class ScriptCollectionCore:
1251
1251
  out_line = None
1252
1252
  err_line = None
1253
1253
  try:
1254
- out_line = q_stdout.get_nowait()
1254
+ out_line = q_stdout.get_nowait() # TODO read all avaliable lines
1255
1255
  reading_stdout_last_time_resulted_in_exception = False
1256
1256
  except Empty:
1257
1257
  reading_stdout_last_time_resulted_in_exception = True
1258
1258
 
1259
1259
  try:
1260
- err_line = q_stderr.get_nowait()
1260
+ err_line = q_stderr.get_nowait() # TODO read all avaliable lines
1261
1261
  reading_stderr_last_time_resulted_in_exception = False
1262
1262
  except Empty:
1263
1263
  reading_stderr_last_time_resulted_in_exception = True
1264
1264
 
1265
- time.sleep(0.01)
1265
+ time.sleep(0.01) # this is required to not finish too early
1266
1266
 
1267
1267
  yield (out_line, err_line)
1268
1268
 
@@ -1118,12 +1118,11 @@ class TasksForCommonProjectStructure:
1118
1118
  ca_folder = os.path.join(product_folder, "Other", "Resources", "CA")
1119
1119
  generate_certificate = True
1120
1120
  if os.path.isdir(ca_folder):
1121
- try:
1122
- ca_file = [file for file in GeneralUtilities.get_direct_files_of_folder(ca_folder) if file.endswith(".crt")][-1] # pylint:disable=unused-variable
1123
- certificate_is_valid = True # TODO check if certificate is really valid
1121
+ ca_files = [file for file in GeneralUtilities.get_direct_files_of_folder(ca_folder) if file.endswith(".crt")]
1122
+ if len(ca_files) > 0:
1123
+ ca_file = ca_files[-1] # pylint:disable=unused-variable
1124
+ certificate_is_valid = True # TODO check if certificate is really valid
1124
1125
  generate_certificate = not certificate_is_valid
1125
- except FileNotFoundError:
1126
- pass
1127
1126
  if generate_certificate:
1128
1127
  self.__sc.generate_certificate_authority(ca_folder, ca_name, "DE", "SubjST", "SubjL", "SubjO", "SubjOU")
1129
1128
  # TODO add switch to auto-install the script if desired
@@ -1178,7 +1177,9 @@ class TasksForCommonProjectStructure:
1178
1177
 
1179
1178
  @GeneralUtilities.check_arguments
1180
1179
  def copy_product_resource_to_codeunit_resource_folder(self, codeunit_folder: str, resourcename: str) -> None:
1181
- src_folder = GeneralUtilities.resolve_relative_path(f"../Other/Resources/{resourcename}", codeunit_folder)
1180
+ repository_folder = GeneralUtilities.resolve_relative_path(f"..", codeunit_folder)
1181
+ GeneralUtilities.assert_is_git_repository(repository_folder)
1182
+ src_folder = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resourcename}", repository_folder)
1182
1183
  GeneralUtilities.assert_condition(os.path.isdir(src_folder), f"Required product-resource {resourcename} does not exist. Expected folder: {src_folder}")
1183
1184
  trg_folder = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resourcename}", codeunit_folder)
1184
1185
  GeneralUtilities.ensure_directory_does_not_exist(trg_folder)
@@ -1196,6 +1197,7 @@ class TasksForCommonProjectStructure:
1196
1197
 
1197
1198
  @GeneralUtilities.check_arguments
1198
1199
  def get_codeunits(self, repository_folder: str, ignore_disabled_codeunits: bool = True) -> list[str]:
1200
+ GeneralUtilities.assert_is_git_repository(repository_folder)
1199
1201
  result: list[str] = []
1200
1202
  for direct_subfolder in GeneralUtilities.get_direct_folders_of_folder(repository_folder):
1201
1203
  subfoldername = os.path.basename(direct_subfolder)
@@ -1217,6 +1219,7 @@ class TasksForCommonProjectStructure:
1217
1219
  def merge_to_main_branch(self, repository_folder: str, source_branch: str = "other/next-release", target_branch: str = "main", verbosity: int = 1, additional_arguments_file: str = None, fast_forward_source_branch: bool = False) -> None:
1218
1220
  # This is an automatization for automatic merges. Usual this merge would be done by a pull request in a sourcecode-version-control-platform
1219
1221
  # (like GitHub, GitLab or Azure DevOps)
1222
+ GeneralUtilities.assert_is_git_repository(repository_folder)
1220
1223
  self.assert_no_uncommitted_changes(repository_folder)
1221
1224
 
1222
1225
  src_branch_commit_id = self.__sc.git_get_commit_id(repository_folder, source_branch)
@@ -1243,6 +1246,7 @@ class TasksForCommonProjectStructure:
1243
1246
  self.__sc.git_checkout(build_repository_folder, createRelease_configuration.build_repository_branch)
1244
1247
 
1245
1248
  repository_folder = GeneralUtilities.resolve_relative_path(f"Submodules{os.path.sep}{createRelease_configuration.repository_folder_name}", build_repository_folder)
1249
+ GeneralUtilities.assert_is_git_repository(repository_folder)
1246
1250
  mergeInformation = MergeToStableBranchInformationForProjectInCommonProjectFormat(repository_folder, createRelease_configuration.additional_arguments_file, createRelease_configuration.artifacts_folder)
1247
1251
 
1248
1252
  # TODO check if repository_folder-merge-source-branch and repository_folder-merge-target-branch have different commits
@@ -1634,6 +1638,7 @@ class TasksForCommonProjectStructure:
1634
1638
 
1635
1639
  @GeneralUtilities.check_arguments
1636
1640
  def get_version_of_project(self, repository_folder: str) -> str:
1641
+ GeneralUtilities.assert_is_git_repository(repository_folder)
1637
1642
  return ScriptCollectionCore().get_semver_version_from_gitversion(repository_folder)
1638
1643
 
1639
1644
  @GeneralUtilities.check_arguments
@@ -2367,6 +2372,7 @@ class TasksForCommonProjectStructure:
2367
2372
  def build_codeunits(self, repository_folder: str, verbosity: int = 1, target_environmenttype: str = "QualityCheck", additional_arguments_file: str = None, is_pre_merge: bool = False, export_target_directory: str = None, commandline_arguments: list[str] = [], do_git_clean_when_no_changes: bool = False) -> None:
2368
2373
  self.__check_target_environmenttype(target_environmenttype)
2369
2374
  repository_folder = GeneralUtilities.resolve_relative_path_from_current_working_directory(repository_folder)
2375
+ GeneralUtilities.assert_is_git_repository(repository_folder)
2370
2376
  codeunits = self.get_codeunits(repository_folder, False)
2371
2377
  self.build_specific_codeunits(repository_folder, codeunits, verbosity, target_environmenttype, additional_arguments_file, is_pre_merge, export_target_directory, False, commandline_arguments, do_git_clean_when_no_changes)
2372
2378
 
@@ -2848,9 +2854,12 @@ class TasksForCommonProjectStructure:
2848
2854
  # constants
2849
2855
  folder_of_this_file = os.path.dirname(generic_prepare_new_release_arguments.current_file)
2850
2856
  build_repository_folder = GeneralUtilities.resolve_relative_path("../..", folder_of_this_file)
2857
+ GeneralUtilities.assert_is_git_repository(build_repository_folder)
2851
2858
 
2852
2859
  repository_folder = GeneralUtilities.resolve_relative_path(f"../../Submodules/{generic_prepare_new_release_arguments.product_name}", folder_of_this_file)
2853
- reference_folder = GeneralUtilities.resolve_relative_path(f"../../Submodules/{generic_prepare_new_release_arguments.product_name}Reference", folder_of_this_file)
2860
+ GeneralUtilities.assert_is_git_repository(repository_folder)
2861
+ reference_folder = repository_folder+"Reference"
2862
+ GeneralUtilities.assert_is_git_repository(reference_folder)
2854
2863
  verbosity: int = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(generic_prepare_new_release_arguments.commandline_arguments, 1)
2855
2864
 
2856
2865
  merge_source_branch = "other/next-release" # TODO make this configurable
@@ -2902,6 +2911,7 @@ class TasksForCommonProjectStructure:
2902
2911
  build_repository_folder = GeneralUtilities.resolve_relative_path("../..", folder_of_this_file)
2903
2912
  repository_folder_name = generic_create_release_arguments.product_name
2904
2913
  repository_folder = GeneralUtilities.resolve_relative_path(f"../../Submodules/{generic_create_release_arguments.product_name}", folder_of_this_file)
2914
+ GeneralUtilities.assert_is_git_repository(repository_folder)
2905
2915
 
2906
2916
  merge_source_branch = "main" # TODO make this configurable
2907
2917
  main_branch = "stable" # TODO make this configurable
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ScriptCollection
3
- Version: 3.5.44
3
+ Version: 3.5.45
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
@@ -1,16 +1,16 @@
1
1
  ScriptCollection/Executables.py,sha256=ls3wGZpt48YwwtO0QGWWyIImSE87SyzbL-WxhpwQJug,20837
2
- ScriptCollection/GeneralUtilities.py,sha256=coLosZMy17SzEBwvl7PUooPSFCsW0O3tM6G7iA1YrI0,36870
2
+ ScriptCollection/GeneralUtilities.py,sha256=YLVXHzKfyN3F50SE-xzrz2YHmLtaS70OogWOSjm4mrc,37570
3
3
  ScriptCollection/ProcessesRunner.py,sha256=3mu4ZxzZleQo0Op6o9EYTCFiJfb6kx5ov2YfZfT89mU,1395
4
4
  ScriptCollection/ProgramRunnerBase.py,sha256=7QAjoqOz6XPmJH19F2k-Z1fFQB_uZnPFvn-T54IJcHQ,2324
5
5
  ScriptCollection/ProgramRunnerEpew.py,sha256=C2Rs3YWOWWWJct7XmKphp5CF1tf0j4Fp-ljV2drLTfs,6349
6
6
  ScriptCollection/ProgramRunnerPopen.py,sha256=G3LgQUVCfaq7XjBsGzalElH31Hbr0etttGR2_H87YzA,3512
7
7
  ScriptCollection/RPStream.py,sha256=NRRHL3YSP3D9MuAV2jB_--0KUKCsvJGxeKnxgrRZ9kY,1545
8
- ScriptCollection/ScriptCollectionCore.py,sha256=XzduxCnIixxB2Blc4v7-zNYa9R801lsDmt_-vQNZfLs,103654
9
- ScriptCollection/TasksForCommonProjectStructure.py,sha256=WqkrpofkzX6NXQOu8ewLAxldh3aj0b3nYtUtFRpr_8c,207901
8
+ ScriptCollection/ScriptCollectionCore.py,sha256=5XEZn6gsooKL-d9QlliE7Jp_fjqwNGexTTwmcqNjazU,103764
9
+ ScriptCollection/TasksForCommonProjectStructure.py,sha256=nYGBxOiyIh5Uq-6CbRCb3-eqMIAv7CqZKRKe1uexMcU,208562
10
10
  ScriptCollection/UpdateCertificates.py,sha256=Eynbgu7k9jLxApP2D_8Il77B6BFjJap6K7oTeEAZYbk,7790
11
11
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- ScriptCollection-3.5.44.dist-info/METADATA,sha256=iEXboM0721iM6EEZADkXVy8-uJ-BrqX8Fpwvqw0Y8rI,7665
13
- ScriptCollection-3.5.44.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
- ScriptCollection-3.5.44.dist-info/entry_points.txt,sha256=_O7BmQ81LdDfrj5uOhjshg9Xc-tABHQJIxDOyOGRzzI,2397
15
- ScriptCollection-3.5.44.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
16
- ScriptCollection-3.5.44.dist-info/RECORD,,
12
+ ScriptCollection-3.5.45.dist-info/METADATA,sha256=7WsZEeomKvQmqBYteUe5TpZqd8g7PHj690UaIUMTG1k,7665
13
+ ScriptCollection-3.5.45.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
+ ScriptCollection-3.5.45.dist-info/entry_points.txt,sha256=_O7BmQ81LdDfrj5uOhjshg9Xc-tABHQJIxDOyOGRzzI,2397
15
+ ScriptCollection-3.5.45.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
16
+ ScriptCollection-3.5.45.dist-info/RECORD,,