batoolset 0.1.0__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.
Files changed (162) hide show
  1. batoolset/GUI/__init__.py +0 -0
  2. batoolset/GUI/list_gui.py +513 -0
  3. batoolset/GUI/multi_image_display.py +989 -0
  4. batoolset/GUI/open.py +325 -0
  5. batoolset/GUI/overlay_hints.py +45 -0
  6. batoolset/GUI/paint2.py +1345 -0
  7. batoolset/GUI/scrollablepaint.py +1152 -0
  8. batoolset/IJ_ROIs/__init__.py +0 -0
  9. batoolset/IJ_ROIs/tools.py +40 -0
  10. batoolset/PATH/__init__.py +0 -0
  11. batoolset/PATH/tools.py +79 -0
  12. batoolset/SQLite_tools/__init__.py +0 -0
  13. batoolset/SQLite_tools/tools.py +840 -0
  14. batoolset/__init__.py +0 -0
  15. batoolset/binary/__init__.py +0 -0
  16. batoolset/binary/tools.py +123 -0
  17. batoolset/binarytools/__init__.py +0 -0
  18. batoolset/binarytools/cell_center_detector.py +290 -0
  19. batoolset/clipboard_tools/__init__.py +0 -0
  20. batoolset/clipboard_tools/tools.py +7 -0
  21. batoolset/colors/__init__.py +0 -0
  22. batoolset/colors/colorgen.py +193 -0
  23. batoolset/colors/tools.py +22 -0
  24. batoolset/command_line/__init__.py +0 -0
  25. batoolset/command_line/tools.py +18 -0
  26. batoolset/dialogs/__init__.py +0 -0
  27. batoolset/dialogs/opensave.py +228 -0
  28. batoolset/dicts/__init__.py +0 -0
  29. batoolset/dicts/tools.py +299 -0
  30. batoolset/dims/__init__.py +0 -0
  31. batoolset/dims/tools.py +83 -0
  32. batoolset/draw/__init__.py +0 -0
  33. batoolset/draw/shapes/Position.py +183 -0
  34. batoolset/draw/shapes/__init__.py +0 -0
  35. batoolset/draw/shapes/automated_alignment_drawing_refactored.py +346 -0
  36. batoolset/draw/shapes/circle2d.py +99 -0
  37. batoolset/draw/shapes/compute_optimal_size_all_merged.py +317 -0
  38. batoolset/draw/shapes/ellipse2d.py +336 -0
  39. batoolset/draw/shapes/freehand2d.py +235 -0
  40. batoolset/draw/shapes/group.py +1830 -0
  41. batoolset/draw/shapes/image2d.py +2469 -0
  42. batoolset/draw/shapes/line2d.py +575 -0
  43. batoolset/draw/shapes/point2d.py +257 -0
  44. batoolset/draw/shapes/polygon2d.py +357 -0
  45. batoolset/draw/shapes/polyline2d.py +235 -0
  46. batoolset/draw/shapes/rect2d.py +388 -0
  47. batoolset/draw/shapes/rectangle2d.py +601 -0
  48. batoolset/draw/shapes/scalebar.py +304 -0
  49. batoolset/draw/shapes/serializablefont.py +126 -0
  50. batoolset/draw/shapes/serializableguiparams.py +10 -0
  51. batoolset/draw/shapes/square2d.py +103 -0
  52. batoolset/draw/shapes/textorientation.py +45 -0
  53. batoolset/draw/shapes/tools.py +467 -0
  54. batoolset/draw/shapes/transform2D.py +350 -0
  55. batoolset/draw/shapes/txt2d.py +550 -0
  56. batoolset/draw/widgets/__init__.py +0 -0
  57. batoolset/draw/widgets/col.py +343 -0
  58. batoolset/draw/widgets/image_group.py +248 -0
  59. batoolset/draw/widgets/image_organizer.py +96 -0
  60. batoolset/draw/widgets/paint.py +184 -0
  61. batoolset/draw/widgets/vectorial.py +257 -0
  62. batoolset/figure/__init__.py +0 -0
  63. batoolset/figure/alignment.py +814 -0
  64. batoolset/figure/column.py +1117 -0
  65. batoolset/figure/fig_tools.py +285 -0
  66. batoolset/figure/minimal_debugger_scale_etc.py +139 -0
  67. batoolset/figure/panel.py +697 -0
  68. batoolset/figure/row.py +852 -0
  69. batoolset/figure/user_selection.py +287 -0
  70. batoolset/files/__init__.py +0 -0
  71. batoolset/files/tools.py +1321 -0
  72. batoolset/images/__init__.py +0 -0
  73. batoolset/images/tools.py +81 -0
  74. batoolset/img.py +5216 -0
  75. batoolset/linux/__init__.py +0 -0
  76. batoolset/linux/tools.py +72 -0
  77. batoolset/lists/__init__.py +0 -0
  78. batoolset/lists/tools.py +436 -0
  79. batoolset/luts/__init__.py +0 -0
  80. batoolset/luts/lut_minimal_test.py +1207 -0
  81. batoolset/matplolib/__init__.py +0 -0
  82. batoolset/matplolib/tools.py +44 -0
  83. batoolset/np_tools/__init__.py +0 -0
  84. batoolset/np_tools/tools.py +252 -0
  85. batoolset/np_tools/trash.py +15 -0
  86. batoolset/pandas_tools/__init__.py +0 -0
  87. batoolset/pandas_tools/tools.py +880 -0
  88. batoolset/partials/__init__.py +0 -0
  89. batoolset/partials/tools.py +83 -0
  90. batoolset/plot_tools/__init__.py +0 -0
  91. batoolset/plot_tools/tools.py +70 -0
  92. batoolset/pyqt/__init__.py +0 -0
  93. batoolset/pyqt/tools.py +691 -0
  94. batoolset/re_tools/__init__.py +0 -0
  95. batoolset/re_tools/tools.py +35 -0
  96. batoolset/serialization/__init__.py +0 -0
  97. batoolset/serialization/tools.py +1192 -0
  98. batoolset/sets/__init__.py +0 -0
  99. batoolset/sets/tools.py +109 -0
  100. batoolset/settings/__init__.py +0 -0
  101. batoolset/settings/global_settings.py +134 -0
  102. batoolset/strings/__init__.py +0 -0
  103. batoolset/strings/tools.py +225 -0
  104. batoolset/ta/__init__.py +0 -0
  105. batoolset/ta/database/__init__.py +0 -0
  106. batoolset/ta/database/advanced_sql_plotter.py +1170 -0
  107. batoolset/ta/database/my_qt_table.py +79 -0
  108. batoolset/ta/database/preview_and_edit_sqlite_db.py +405 -0
  109. batoolset/ta/database/sql.py +2141 -0
  110. batoolset/ta/database/sql_column_name_dialog.py +122 -0
  111. batoolset/ta/measurements/TAmeasures.py +2226 -0
  112. batoolset/ta/measurements/__init__.py +0 -0
  113. batoolset/ta/measurements/measurements3D/__init__.py +0 -0
  114. batoolset/ta/measurements/measurements3D/get_point_on_surface_if_centroid_is_bad.py +175 -0
  115. batoolset/ta/measurements/measurements3D/height_map_to_projection.py +82 -0
  116. batoolset/ta/measurements/measurements3D/measures3D.py +208 -0
  117. batoolset/ta/measurements/measurements3D/triangulate.py +331 -0
  118. batoolset/ta/measurements/nematic.py +562 -0
  119. batoolset/ta/measurements/nematic_measurements.py +107 -0
  120. batoolset/ta/segmentation/__init__.py +0 -0
  121. batoolset/ta/segmentation/neo_wshed.py +314 -0
  122. batoolset/ta/selections/__init__.py +0 -0
  123. batoolset/ta/selections/selection.py +329 -0
  124. batoolset/ta/tracking/__init__.py +0 -0
  125. batoolset/ta/tracking/last_tracking_based_on_matching_or_on_translation_from_mermaid_warp.py +653 -0
  126. batoolset/ta/tracking/local_to_track_correspondance.py +138 -0
  127. batoolset/ta/tracking/rapid_detection_of_vertices.py +517 -0
  128. batoolset/ta/tracking/registration.py +108 -0
  129. batoolset/ta/tracking/swap_detector_and_fixer.py +296 -0
  130. batoolset/ta/tracking/track_correction.py +238 -0
  131. batoolset/ta/tracking/tracking_error_detector_and_fixer.py +3099 -0
  132. batoolset/ta/tracking/tracking_yet_another_approach_pyramidal_registration_n_neo_swapping_correction.py +725 -0
  133. batoolset/ta/utils/TA_tools.py +43 -0
  134. batoolset/ta/utils/__init__.py +0 -0
  135. batoolset/ta/utils/rps_tools.py +1783 -0
  136. batoolset/tests/__init__.py +0 -0
  137. batoolset/tests/rps_tools.py +51 -0
  138. batoolset/tests/tools.py +10 -0
  139. batoolset/tools/__init__.py +0 -0
  140. batoolset/tools/early_stopper_class.py +9 -0
  141. batoolset/tools/guided_data_recoverer.py +110 -0
  142. batoolset/tools/logger.py +100 -0
  143. batoolset/tools/mytimer.py +31 -0
  144. batoolset/tools/prompt_color.py +160 -0
  145. batoolset/tools/qthandler.py +118 -0
  146. batoolset/uitools/__init__.py +0 -0
  147. batoolset/uitools/blinker.py +56 -0
  148. batoolset/unsafe/__init__.py +0 -0
  149. batoolset/unsafe/tools.py +115 -0
  150. batoolset/utils/__init__.py +0 -0
  151. batoolset/utils/commontools.py +158 -0
  152. batoolset/utils/loadlist.py +728 -0
  153. batoolset/version.py +10 -0
  154. batoolset/xml/__init__.py +0 -0
  155. batoolset/xml/tools.py +65 -0
  156. batoolset/zip_tools/__init__.py +0 -0
  157. batoolset/zip_tools/tools.py +76 -0
  158. batoolset-0.1.0.dist-info/LICENSE +24 -0
  159. batoolset-0.1.0.dist-info/METADATA +45 -0
  160. batoolset-0.1.0.dist-info/RECORD +162 -0
  161. batoolset-0.1.0.dist-info/WHEEL +5 -0
  162. batoolset-0.1.0.dist-info/top_level.txt +1 -0
File without changes
@@ -0,0 +1,72 @@
1
+ import os
2
+ import subprocess
3
+ import shutil
4
+ import traceback
5
+
6
+ from batoolset.files.tools import smart_name_parser
7
+
8
+
9
+ def create_linux_desktop_shortcut(script_path, shortcut_name, shortcut_description="", icon_path="", store_in_application_folder=True):
10
+ # MEGA TODO --> improve the code --> if the icon already exists in the folder --> change its name or offer overwrite it or offer rename it and apply the change --> appart from that not so bad !!!
11
+
12
+ if not store_in_application_folder:
13
+ try:
14
+ desktop_folder_name = subprocess.check_output(["xdg-user-dir", "DESKTOP"], universal_newlines=True).strip()
15
+ except subprocess.CalledProcessError:
16
+ # Fallback to a default name if the command fails
17
+ desktop_folder_name = "Desktop"
18
+ # Fallback to a default name if the command fails
19
+ desktop_path = os.path.join(os.path.expanduser("~"), desktop_folder_name)
20
+ desktop_file_path = f"{desktop_path}/{shortcut_name}.desktop"
21
+ else:
22
+ desktop_file_path = f"{os.path.join(os.path.expanduser('~'),'.local/share/applications/')}/{shortcut_name}.desktop"
23
+ neo_icon_path=None
24
+
25
+ try:
26
+ if icon_path is not None and icon_path and 'applications' in desktop_file_path:
27
+ neo_icon_path = smart_name_parser(desktop_file_path, 'parent') + '/icons'
28
+ neo_icon_path = os.path.join(neo_icon_path, smart_name_parser(icon_path, 'short'))
29
+ os.makedirs(os.path.dirname(neo_icon_path), exist_ok=True)
30
+ try:
31
+ if icon_path != neo_icon_path: # no need to duplicate the image if already there
32
+ shutil.copy2(icon_path, neo_icon_path)
33
+ except:
34
+ traceback.print_exc()
35
+ except:
36
+ traceback.print_exc()
37
+
38
+ content = f"""[Desktop Entry]
39
+ Version=1.0
40
+ Type=Application
41
+ Terminal=true
42
+ Exec={script_path}
43
+ Name={shortcut_name}
44
+ Comment={shortcut_description}
45
+ Icon={icon_path if neo_icon_path is None else neo_icon_path}
46
+ """
47
+
48
+ with open(desktop_file_path, "w") as desktop_file:
49
+ desktop_file.write(content)
50
+
51
+
52
+
53
+ print(f"Desktop shortcut created at: {desktop_file_path}")
54
+ # move to application folder and run change stuff
55
+
56
+
57
+ if __name__ == '__main__':
58
+
59
+ # TODO ADD 'sudo lshw -C display' --> command to show nvidia
60
+ # sudo ubuntu-drivers install ? https://www.cyberciti.biz/faq/ubuntu-linux-install-nvidia-driver-latest-proprietary-driver/
61
+
62
+ # Example usage:
63
+ script_path = "/home/aigouy/miniconda3/bin/python /home/aigouy/mon_prog/Python/epyseg_pkg/personal/hiC_microC_tmp/EVO_BLASTER_GUI.py"
64
+ shortcut_name = "EVO Blaster"
65
+ shortcut_description = "Runs local blast and identifies the most conserved gene in every species"
66
+ # icon_path = "/home/aigouy/Téléchargements/logo1.png"
67
+ icon_path = "/home/aigouy/.local/share/applications/icons/logo1.png"
68
+
69
+ #/home/aigouy/.local/share/applications/
70
+
71
+
72
+ create_linux_desktop_shortcut(script_path, shortcut_name, shortcut_description, icon_path)
File without changes
@@ -0,0 +1,436 @@
1
+ # contains a set of useful methods for list and list operations
2
+ import itertools
3
+ import itertools
4
+ import sys
5
+ from itertools import combinations
6
+
7
+ def compare_lists_sets(list1, list2):
8
+ return set(list1) == set(list2)
9
+
10
+ def divide_list_into_sublists(lst, num_rows, num_cols):
11
+ # Calculate the total number of elements
12
+ total_elements = num_rows * num_cols
13
+
14
+ # If the list has fewer elements than expected, add None to fill the gaps
15
+ if len(lst) < total_elements:
16
+ lst.extend([None] * (total_elements - len(lst)))
17
+
18
+ # Divide the list into sublists
19
+ sublists = [lst[i:i + num_cols] for i in range(0, total_elements, num_cols)]
20
+
21
+ return sublists
22
+
23
+ def bool_list_to_index_list(bool_list):
24
+ index_list = []
25
+ for i, val in enumerate(bool_list):
26
+ if val:
27
+ index_list.append(i)
28
+ return index_list
29
+
30
+ def is_iterable(obj):
31
+ try:
32
+ iter(obj)
33
+ return True
34
+ except TypeError:
35
+ return False
36
+
37
+ def combine_lists(list1, list2):
38
+ combined_list = [(item1, item2) for item1 in list1 for item2 in list2]
39
+ return combined_list
40
+
41
+ def flatten_iterable(iterable):
42
+ non_iterable_objects = []
43
+
44
+ for obj in iterable:
45
+ # If the object is not iterable, add it to the list of non-iterable objects
46
+ if not is_iterable(obj):
47
+ non_iterable_objects.append(obj)
48
+ # If the object is iterable, recursively call the function on the object
49
+ else:
50
+ non_iterable_objects.extend(flatten_iterable(obj))
51
+
52
+ return non_iterable_objects
53
+
54
+
55
+ def find_first_object_of_type(obj_list, obj_type):
56
+ try:
57
+ # Find the first object of the given type in the list
58
+ obj = next(obj for obj in obj_list if isinstance(obj, obj_type))
59
+ return obj
60
+ except StopIteration:
61
+ # No object of the given type was found in the list
62
+ return None
63
+
64
+
65
+ def find_all_objects_of_type(obj_list, obj_type):
66
+ if not obj_list:
67
+ return None
68
+ # Find all the objects of the given type in the list
69
+ objects = [obj for obj in obj_list if isinstance(obj, obj_type)]
70
+ return objects
71
+
72
+ def find_first_index(element, my_list):
73
+ try:
74
+ # Find the index of the first occurrence of the element in the list
75
+ index = my_list.index(element)
76
+ return index
77
+ except ValueError:
78
+ # The element is not in the list
79
+ return None
80
+
81
+ def get_list_combinatorial(lst, repack_all_to_lists_if_not_lists=True, return_list=True):
82
+ """
83
+ Creates all possible combinations of the elements in a list.
84
+
85
+ Args:
86
+ lst (list): The input list.
87
+ repack_all_to_lists_if_not_lists (bool): If True, converts non-list elements to lists.
88
+ return_list (bool): If True, returns the combinations as a list of lists.
89
+
90
+ Returns:
91
+ list: The list of all possible combinations.
92
+
93
+ Examples:
94
+ >>> lst = ['D', ['1P', 'hinge_undefined'], '1P']
95
+ >>> result = get_list_combinatorial(lst)
96
+ >>> print(result)
97
+ [['D', '1P', '1P'], ['D', 'hinge_undefined', '1P']]
98
+ """
99
+ optimized_list = lst
100
+
101
+ if repack_all_to_lists_if_not_lists:
102
+ optimized_list = [[item] if not isinstance(item, list) else item for item in lst]
103
+
104
+ tmp = list(itertools.product(*optimized_list))
105
+
106
+ if return_list:
107
+ tmp = [list(el) for el in tmp]
108
+
109
+ return tmp
110
+
111
+
112
+ def list_contains_sublist(lst):
113
+ """
114
+ Checks if a list contains any sublists.
115
+
116
+ Args:
117
+ lst (list): The input list.
118
+
119
+ Returns:
120
+ bool: True if the list contains sublists, False otherwise.
121
+
122
+ Examples:
123
+ >>> lst = ['a', 'b', ['c', 'd']]
124
+ >>> result = list_contains_sublist(lst)
125
+ >>> print(result)
126
+ True
127
+ """
128
+ for el in lst:
129
+ if isinstance(el, list):
130
+ return True
131
+
132
+ return False
133
+
134
+ def get_consecutive_file_pairs(file_paths):
135
+ """
136
+ Given a list of file paths, returns a list of tuples,
137
+ where each tuple contains the consecutive pair of file paths.
138
+
139
+ Args:
140
+ file_paths (list): The list of file paths.
141
+
142
+ Returns:
143
+ list: The list of tuples containing consecutive file pairs.
144
+
145
+ Examples:
146
+ >>> file_paths = ['file1.txt', 'file2.txt', 'file3.txt']
147
+ >>> result = get_consecutive_file_pairs(file_paths)
148
+ >>> print(result)
149
+ [('file1.txt', 'file2.txt'), ('file2.txt', 'file3.txt')]
150
+ """
151
+ return [(file_paths[i], file_paths[i+1]) for i in range(len(file_paths)-1)]
152
+
153
+ def flatten_list(input_list):
154
+ """
155
+ Flattens a list containing nested tuples or other elements.
156
+
157
+ Args:
158
+ input_list (list): The input list to be flattened.
159
+
160
+ Returns:
161
+ list: A new list with nested elements flattened.
162
+
163
+ Examples:
164
+ >>> input_list = ['toto', 'tutu', ('bob', 'beb'), 'tata']
165
+ >>> flattened_list = flatten_list(input_list)
166
+ >>> print(flattened_list)
167
+ ['toto', 'tutu', 'bob', 'beb', 'tata']
168
+ """
169
+ # Flatten the list using a list comprehension
170
+ flattened_list = [item for sublist in input_list for item in (sublist if isinstance(sublist, (tuple, list)) else [sublist])]
171
+ return flattened_list
172
+
173
+ def create_all_possible_pairs(single_cutters):
174
+ """
175
+ Create all possible pairs of keys from a dictionary of single-cut restriction enzymes.
176
+
177
+ Args:
178
+ single_cutters (dict): A dictionary where keys represent enzyme names and values
179
+ are associated information for single-cut restriction enzymes.
180
+
181
+ Returns:
182
+ list: A list of tuples containing all unique pairs of enzyme names from the dictionary.
183
+
184
+ Examples:
185
+ >>> single_cutters = {'EcoRI': {'site': 'GAATTC', 'recognition_site': 'G^AATTC', 'cut_site': 1},
186
+ ... 'BamHI': {'site': 'GGATCC', 'recognition_site': 'G^GATCC', 'cut_site': 1}}
187
+ >>> pairs = create_all_possible_pairs(single_cutters)
188
+ >>> print(pairs)
189
+ [('EcoRI', 'BamHI')]
190
+ >>> single_cutters = ['EcoRI','BamHI']
191
+ >>> pairs = create_all_possible_pairs(single_cutters)
192
+ >>> print(pairs)
193
+ [('EcoRI', 'BamHI')]
194
+ """
195
+ if isinstance(single_cutters, dict):
196
+ single_cutters =single_cutters.keys()
197
+ key_pairs = [pair for pair in combinations(single_cutters, 2)]
198
+ return key_pairs
199
+
200
+ def swap_items(lst, index1, index2):
201
+ # Check if the indices are valid
202
+ if index1 < 0 or index1 >= len(lst) or index2 < 0 or index2 >= len(lst):
203
+ print("Invalid indices")
204
+ return
205
+
206
+ print('before swapping', lst)
207
+ # Swap the items
208
+ temp = lst[index1]
209
+ lst[index1] = lst[index2]
210
+ lst[index2] = temp
211
+
212
+ print("Swapped items: ", lst)
213
+
214
+
215
+ # def move_left(lst, indices, distance):
216
+ # # Create a copy of the list
217
+ # lst = lst[:]
218
+ #
219
+ # # Sort the indices in descending order
220
+ # indices = sorted(indices, reverse=True)
221
+ #
222
+ # # Move each element to the left by the given distance
223
+ # for index in indices:
224
+ # element = lst.pop(index)
225
+ # lst.insert(index - distance, element)
226
+ #
227
+ # return lst
228
+
229
+ # def move_left(lst, indices, distance):
230
+ # # Create a copy of the list
231
+ # lst = lst[:]
232
+ #
233
+ # # Sort the indices in descending order
234
+ # indices = sorted(indices, reverse=True)
235
+ #
236
+ # # Move each element to the left by the given distance
237
+ # for index in indices:
238
+ # element = lst.pop(index)
239
+ # lst.insert((index - distance) % len(lst), element)
240
+ #
241
+ # return lst
242
+ # def move_left(lst, indices, distance):
243
+ # """
244
+ # Moves the elements at the specified indices to the left by a given distance in the list.
245
+ # Returns a new list with the elements moved.
246
+ # """
247
+ # new_lst = lst[:] # Make a copy of the original list
248
+ # indices = sorted(indices, reverse=True) # Sort indices in descending order
249
+ #
250
+ # for idx in indices:
251
+ # if idx < distance:
252
+ # continue # Skip if the index is smaller than the distance
253
+ #
254
+ # elem = new_lst.pop(idx) # Remove the element at the index
255
+ # new_lst.insert(idx - distance, elem) # Insert the element at the new position
256
+ #
257
+ # return new_lst
258
+ def move_left(lst, indices, distance=1):
259
+ """
260
+ Moves the elements at the specified indices to the left by a given distance in the list.
261
+ Returns a new list with the elements moved.
262
+ """
263
+ new_lst = lst[:] # Make a copy of the original list
264
+ indices = sorted(indices) # Sort indices in ascending order
265
+
266
+ for idx in indices:
267
+ if idx < distance:
268
+ new_lst.insert(0, new_lst.pop(idx)) # Move element to the front
269
+ else:
270
+ elem = new_lst.pop(idx)
271
+ new_lst.insert(idx - distance, elem)
272
+
273
+ return new_lst
274
+
275
+ def move_right(lst, indices, distance=1):
276
+ """
277
+ Moves the elements at the specified indices to the right by a given distance in the list.
278
+ Returns a new list with the elements moved.
279
+ """
280
+ new_lst = lst[:] # Make a copy of the original list
281
+ indices = sorted(indices, reverse=True) # Sort indices in descending order
282
+
283
+ for idx in indices:
284
+ if idx + distance >= len(new_lst):
285
+ elem = new_lst.pop(idx)
286
+ new_lst.append(elem) # Move element to the end
287
+ else:
288
+ elem = new_lst.pop(idx)
289
+ new_lst.insert(idx + distance, elem)
290
+
291
+ return new_lst
292
+
293
+
294
+ # that is the best I have so far
295
+ # def move_up(items, selected_indices):
296
+ # # Sort selected indices in descending order to prevent interference with previous movements
297
+ # selected_indices.sort(reverse=True)
298
+ # for index in selected_indices:
299
+ # if index > 0:
300
+ # # Swap the item at the current index with the item above it
301
+ # items[index], items[index - 1] = items[index - 1], items[index]
302
+ #
303
+ # def move_down(items, selected_indices):
304
+ # # Sort selected indices in ascending order to prevent interference with previous movements
305
+ # selected_indices.sort()
306
+ # for index in selected_indices:
307
+ # if index < len(items) - 1:
308
+ # # Swap the item at the current index with the item below it
309
+ # items[index], items[index + 1] = items[index + 1], items[index]
310
+
311
+
312
+ # def move_right(lst, indices, distance):
313
+ # """
314
+ # Moves the elements at the specified indices to the right by a given distance in the list.
315
+ # Returns a new list with the elements moved.
316
+ # """
317
+ # new_lst = lst[:] # Make a copy of the original list
318
+ # indices = sorted(indices, reverse=True) # Sort indices in descending order
319
+ #
320
+ # # Keep track of the new index of each element as it is moved
321
+ # new_indices = []
322
+ #
323
+ # for idx in indices:
324
+ # if new_indices:
325
+ # # Adjust the distance for subsequent elements based on the new index of the previous element
326
+ # last_new_idx = new_indices[-1]
327
+ # if last_new_idx + 1 < len(new_lst):
328
+ # distance = min(distance, last_new_idx + 1 - idx)
329
+ # else:
330
+ # distance = 0
331
+ #
332
+ # if idx + distance >= len(new_lst):
333
+ # elem = new_lst.pop(idx)
334
+ # new_lst.append(elem) # Move element to the end
335
+ # new_indices.append(len(new_lst) - 1)
336
+ # else:
337
+ # elem = new_lst.pop(idx)
338
+ # new_lst.insert(idx + distance, elem)
339
+ # new_indices.append(idx + distance)
340
+ #
341
+ # return new_lst
342
+
343
+
344
+
345
+ # def move_left(lst, indices, distance):
346
+ # """
347
+ # Moves the elements at the specified indices to the left by a given distance in the list.
348
+ # Preserves the original order of the elements being moved.
349
+ # Returns a new list with the elements moved.
350
+ # """
351
+ # new_lst = lst[:] # Make a copy of the original list
352
+ # indices = sorted(indices) # Sort indices in ascending order
353
+ #
354
+ # moved_elems = [] # Store the elements being moved
355
+ # for idx in indices:
356
+ # elem = new_lst.pop(idx)
357
+ # if idx < len(lst) - distance:
358
+ # moved_elems.append(elem)
359
+ # else:
360
+ # new_lst.insert(idx - distance, elem)
361
+ #
362
+ # # Insert the moved elements at the beginning of the list
363
+ # new_lst[:0] = moved_elems
364
+ #
365
+ # return new_lst
366
+ # def move_items_by_distance(data, indices, distance, direction="up"):
367
+ # temp_list = [data[i] for i in indices]
368
+ # for i in sorted(indices, reverse=True):
369
+ # del data[i]
370
+ #
371
+ # if direction == "up":
372
+ # target_index = min(indices) - distance
373
+ # else: # direction == "down"
374
+ # target_index = max(indices) + distance + 1
375
+ #
376
+ # # Ensure target_index is within list bounds
377
+ # target_index = max(0, min(target_index, len(data)))
378
+ #
379
+ # data[target_index:target_index] = temp_list
380
+
381
+ if __name__ == '__main__':
382
+
383
+
384
+ if True:
385
+ # Define a list
386
+ lst = [1, 2, 3, 4, 5, 6, 7, 8, 9]
387
+
388
+ # Define the number of rows and columns
389
+ num_rows = 3
390
+ num_cols = 3
391
+
392
+ # Divide the list into sublists
393
+ sublists = divide_list_into_sublists(lst, num_rows, num_cols)
394
+
395
+ # Print the sublists
396
+ for sublist in sublists:
397
+ print(sublist)
398
+
399
+ sys.exit(0)
400
+
401
+ if True:
402
+ # Example usage
403
+ lst = [0, 1, 2, 3, 4, 5, 6, 7]
404
+ indices = [1, 6]
405
+ distance = 5
406
+ print(move_left(lst, indices, distance)) # Output: [1, 0, 2, 3, 4, 6, 5, 7]
407
+
408
+ lst = [0, 1, 2, 3, 4, 5, 6, 7, 8]
409
+ indices = [1, 5, 6]
410
+ distance = 10
411
+
412
+ new_lst = move_right(lst, indices, distance)
413
+ print(new_lst) # Output: [0, 2, 3, 1, 4, 5, 7, 6]
414
+
415
+ # # Example usage:
416
+ # my_list = [0, 1, 2, 3, 4, 5, 6, 7, 8] #['a', 'b', 'c', 'd', 'e', 'f']
417
+ # indices_to_move = [1, 3, 5] # Move 'b', 'd', and 'f'
418
+ #
419
+ # move_items_by_distance(my_list, indices_to_move,1, direction="up")
420
+ # print(my_list) # Output: ['a', 'c', 'e', 'b', 'd', 'f']
421
+
422
+ sys.exit(0)
423
+
424
+ if True:
425
+ import os
426
+
427
+ # list of file paths as strings
428
+ file_paths = ["/path/to/file1.txt", "/path/to/file2.txt", "/path/to/file3.txt"]
429
+
430
+ print(get_consecutive_file_pairs(file_paths))
431
+
432
+ test = ['D', ['1P', 'hinge_undefined'], '1P']
433
+ print(list_contains_sublist(test)) # True
434
+ combi = get_list_combinatorial(test)
435
+ print(combi) # [['D', '1P', '1P'], ['D', 'hinge_undefined', '1P']]
436
+ print(list_contains_sublist(combi[0])) # False
File without changes