atomicshop 2.16.11__py3-none-any.whl → 2.16.13__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.

Potentially problematic release.


This version of atomicshop might be problematic. Click here for more details.

atomicshop/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '2.16.11'
4
+ __version__ = '2.16.13'
@@ -32,10 +32,10 @@ def __comparison_usage_example(
32
32
  main folder.
33
33
 
34
34
  Usage:
35
- from atomicshop.filesystem import get_file_paths_from_directory, ComparisonOperator
35
+ from atomicshop.filesystem import get_paths_from_directory, ComparisonOperator
36
36
 
37
37
  # Get full paths of all the 'engine_config.ini' files.
38
- engine_config_path_list = get_file_paths_from_directory(
38
+ engine_config_path_list = get_paths_from_directory(
39
39
  directory_fullpath=some_directory_path,
40
40
  file_name_check_tuple=(config_file_name, ComparisonOperator.EQ))
41
41
  """
@@ -0,0 +1,29 @@
1
+ from operator import attrgetter
2
+
3
+
4
+ def sort_by_attributes(
5
+ list_instance: list,
6
+ attribute_list: list,
7
+ reverse: bool = False,
8
+ case_insensitive: bool = False
9
+ ):
10
+ """
11
+ Sort a list of objects by their attributes.
12
+
13
+ :param list_instance: list of objects.
14
+ :param attribute_list: list of attributes (strings). The sorting will be done by the attributes in the list.
15
+ In the appearing order in the list.
16
+ :param reverse: bool, sort in reverse order.
17
+ :param case_insensitive: bool, sorting will be case-insensitive.
18
+ """
19
+
20
+ for attribute in attribute_list:
21
+ if case_insensitive:
22
+ list_instance = sorted(
23
+ list_instance, key=lambda obj: getattr(obj, attribute).lower(), reverse=reverse
24
+ )
25
+ else:
26
+ list_instance = sorted(
27
+ list_instance, key=attrgetter(attribute), reverse=reverse
28
+ )
29
+ return list_instance
@@ -74,20 +74,20 @@ def search_for_hyperlink_in_files(directory_path: str, hyperlink: str, relative_
74
74
  raise NotADirectoryError(f"Directory doesn't exist: {directory_path}")
75
75
 
76
76
  # Get all the docx files in the specified directory.
77
- files = filesystem.get_file_paths_from_directory(
78
- directory_path, file_name_check_pattern="*\.docx",
77
+ files = filesystem.get_paths_from_directory(
78
+ directory_path, get_file=True, file_name_check_pattern="*\.docx",
79
79
  add_relative_directory=True, relative_file_name_as_directory=True)
80
80
 
81
81
  found_in_files: list = list()
82
82
  for file_path in files:
83
- hyperlinks = get_hyperlinks(file_path['file_path'])
83
+ hyperlinks = get_hyperlinks(file_path.path)
84
84
  if hyperlink in hyperlinks:
85
85
  found_in_files.append(file_path)
86
86
 
87
87
  if relative_paths:
88
88
  result_list = list()
89
89
  for found_file in found_in_files:
90
- result_list.append(found_file['relative_dir'])
90
+ result_list.append(found_file.relative_dir)
91
91
  else:
92
92
  result_list = found_in_files
93
93