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,109 @@
1
+ def difference(set1, set2):
2
+ """
3
+ Returns the elements of set1 that are not in set2.
4
+
5
+ Args:
6
+ set1 (set or iterable): The first set or iterable.
7
+ set2 (set or iterable): The second set or iterable.
8
+
9
+ Returns:
10
+ set: The set of elements from set1 that are not in set2.
11
+
12
+ Examples:
13
+ >>> set1 = {1, 2, 3}
14
+ >>> set2 = {2, 3, 4}
15
+ >>> difference(set1, set2)
16
+ {1}
17
+
18
+ """
19
+ if not isinstance(set1, set):
20
+ set1 = set(set1)
21
+ return set1.difference(set2)
22
+
23
+ def differences(set1, set2):
24
+ """
25
+ Returns the elements of set1 and set2 that are not present in the other set.
26
+
27
+ Args:
28
+ set1 (set or iterable): The first set or iterable.
29
+ set2 (set or iterable): The second set or iterable.
30
+
31
+ Returns:
32
+ set: The set of elements from set1 and set2 that are not present in the other set.
33
+
34
+ Examples:
35
+ >>> set1 = {1, 2, 3}
36
+ >>> set2 = {2, 3, 4}
37
+ >>> differences(set1, set2)
38
+ {1, 4}
39
+
40
+ """
41
+ dif1 = difference(set1, set2)
42
+ dif2 = difference(set2, set1)
43
+ return dif1.union(dif2)
44
+
45
+ def intersection(set1, set2):
46
+ """
47
+ Returns the intersection of set1 and set2.
48
+
49
+ Args:
50
+ set1 (set or iterable): The first set or iterable.
51
+ set2 (set or iterable): The second set or iterable.
52
+
53
+ Returns:
54
+ set: The set of elements that are common to both set1 and set2.
55
+
56
+ Examples:
57
+ >>> set1 = {1, 2, 3}
58
+ >>> set2 = {2, 3, 4}
59
+ >>> intersection(set1, set2)
60
+ {2, 3}
61
+
62
+ """
63
+ if not isinstance(set1, set):
64
+ set1 = set(set1)
65
+ return set1.intersection(set2)
66
+
67
+ def union_no_dupes(*sets):
68
+ """
69
+ Returns the union of multiple sets, removing duplicate elements.
70
+
71
+ Args:
72
+ *sets (sets or iterables): Multiple sets or iterables.
73
+
74
+ Returns:
75
+ set: The union of all sets, excluding duplicate elements.
76
+
77
+ Examples:
78
+ >>> set1 = {1, 2, 3}
79
+ >>> set2 = {2, 3, 4}
80
+ >>> set3 = {3, 4, 5}
81
+ >>> union_no_dupes(set1, set2, set3)
82
+ {1, 2, 3, 4, 5}
83
+
84
+ """
85
+ output_set = set(sets[0])
86
+ for st in sets[1:]:
87
+ output_set = output_set.union(st)
88
+ return output_set
89
+
90
+ def common(*sts):
91
+ first = set(sts[0])
92
+ common_elements = first.intersection(*sts[1:])
93
+ return common_elements
94
+
95
+ if __name__ == '__main__':
96
+ set1 = {1, 2, 3}
97
+ set2 = {2, 3, 4}
98
+
99
+ print(intersection(set1, set2)) # Output: {2, 3}
100
+ print(union_no_dupes(set1, set2)) # Output: {1, 2, 3, 4}
101
+ print(differences(set1, set2)) # Output: {1, 4}
102
+ print(difference(set1, set2))
103
+
104
+ set3 = {1,2}
105
+ print('common', common(set1, set2, set3))
106
+
107
+
108
+
109
+
File without changes
@@ -0,0 +1,134 @@
1
+ # this class should contain all the global settings
2
+ import os
3
+ # import matplotlib
4
+
5
+ # default_UI = 'pyqt6' # 'non existing'
6
+ default_UI = 'pyqt6' #'pyqt6' #'pyqt6'#'pyside6' #'pyside2' #'pyqt5' # 'non existing'
7
+ # force = False
8
+
9
+ def default_qtpy_UI():
10
+ """
11
+ Returns the default QtPy UI.
12
+
13
+ Returns:
14
+ str: The default QtPy UI.
15
+
16
+ Examples:
17
+ >>> default_qtpy_UI()
18
+ 'pyqt6'
19
+
20
+ """
21
+ global default_UI
22
+ if default_UI not in list_UIs():
23
+ default_UI = list_UIs()[0]
24
+ return default_UI
25
+
26
+ def list_UIs():
27
+ """
28
+ Returns a list of available UI options for QtPy.
29
+
30
+ Returns:
31
+ list: The list of available UI options.
32
+
33
+ Examples:
34
+ >>> list_UIs()
35
+ ['pyqt5', 'pyside2', 'pyqt6', 'pyside6']
36
+
37
+ """
38
+ from qtpy import API_NAMES
39
+ return list(API_NAMES.keys())
40
+
41
+ def set_UI(ignore_if_already_set=True, UI=default_UI):
42
+ """
43
+ Sets the QtPy UI environment variable.
44
+
45
+ Args:
46
+ ignore_if_already_set (bool, optional): Flag to ignore if the UI is already set. Defaults to True.
47
+ UI (str, optional): The UI to set. Defaults to default_UI.
48
+
49
+ Examples:
50
+ >>> set_UI()
51
+ >>> print(os.environ['QT_API'])
52
+ pyqt5
53
+
54
+ """
55
+ if ignore_if_already_set and 'QT_API' in os.environ:
56
+ return
57
+
58
+ if UI is None:
59
+ UI = default_qtpy_UI()
60
+ os.environ['QT_API'] = UI
61
+
62
+ # Set the Matplotlib backend based on the selected QtPy UI
63
+ # if UI == 'pyqt5':
64
+ # matplotlib.use('QtAgg')
65
+ # elif UI == 'pyside2':
66
+ # matplotlib.use('QtAgg')
67
+ # elif UI == 'pyqt6':
68
+ # matplotlib.use('QtAgg')
69
+ # elif UI == 'pyside6':
70
+ # matplotlib.use('QtAgg')
71
+ # else:
72
+ # raise ValueError(f"Unsupported UI: {UI}")
73
+
74
+ def print_default_qtpy_UI_really_in_use():
75
+ """
76
+ Prints the default QtPy UI and the version in use.
77
+
78
+ Examples:
79
+ >>> print_default_qtpy_UI_really_in_use()
80
+ pyqt5 v5.14.0
81
+
82
+ """
83
+ try:
84
+ UI_defined = None
85
+ from qtpy.QtCore import PYQT_VERSION_STR
86
+ try:
87
+ UI_defined = os.environ['QT_API']
88
+ except:
89
+ pass
90
+ print(UI_defined + ' v' + PYQT_VERSION_STR)
91
+ except:
92
+ pass
93
+
94
+ def force_qtpy_to_use_user_specified(bool=True):
95
+ """
96
+ Forces QtPy to use the user-specified UI.
97
+
98
+ Args:
99
+ bool (bool, optional): Flag to enable or disable forcing QtPy to use the user-specified UI. Defaults to True.
100
+
101
+ """
102
+ if bool:
103
+ os.environ['FORCE_QT_API'] = '1'
104
+ else:
105
+ try:
106
+ del os.environ['FORCE_QT_API']
107
+ except:
108
+ pass
109
+
110
+
111
+ if __name__ == '__main__':
112
+ # import os
113
+ # os.environ['QT_API']='tata'
114
+ # print(os.environ['QT_API'])
115
+
116
+ # os.environ['QT_API']='pyqt5'
117
+
118
+ # default_UI='test'
119
+ # # print(default_qtpy_UI())
120
+ # set_UI()
121
+ # print(os.environ['QT_API'])
122
+ # set_UI()
123
+ # print(os.environ['QT_API'])
124
+ # print(list_UIs())
125
+ #
126
+ # print_default_qtpy_UI_really_in_use()
127
+
128
+ # os.environ['QT_API'] = 'pyqt5'
129
+ set_UI()
130
+ print_default_qtpy_UI_really_in_use()
131
+ import matplotlib.pyplot as plt
132
+
133
+ plt.plot([1, 2, 3])
134
+ plt.show()
File without changes
@@ -0,0 +1,225 @@
1
+ """
2
+ A collection of methods to manipulate strings
3
+
4
+ """
5
+ import textwrap
6
+ import re
7
+ import ast
8
+ import traceback
9
+
10
+
11
+ def find_letter_before_h(target_dims):
12
+ try:
13
+ index = target_dims.index('h')
14
+ if index > 0:
15
+ return target_dims[index - 1]
16
+ else:
17
+ return None
18
+ except ValueError:
19
+ return None
20
+
21
+ def is_string_a_list_string(string):
22
+ if string is None:
23
+ return False
24
+ if string.strip().startswith("['") and string.strip().endswith("']"): # maybe it is dangerous to have the quotes ???
25
+ return True
26
+ return False
27
+
28
+ def reload_string_list(string_list):
29
+ try:
30
+ # Attempt to convert the string to a list using ast.literal_eval
31
+ # This is a safe method as it only converts Python's data types (strings, tuples, lists, dicts, booleans, and numbers)
32
+ imported_list = ast.literal_eval(string_list)
33
+
34
+ # Check if all elements in the list are strings
35
+ # if all(isinstance(item, str) for item in imported_list):
36
+ return imported_list
37
+ # else:
38
+ # raise ValueError("Not all elements in the list are strings")
39
+ except:
40
+ # raise ValueError("Invalid string format. Please provide a string that can be converted to a list of strings.")
41
+ traceback.print_exc()
42
+ return string_list
43
+
44
+ def format_string_with_numbers(*args, auto_add_underscore_to_text_if_missing=True, padding_for_all_numbers=None):
45
+ """
46
+ Formats a list of strings and numbers into a single string, with optional automatic addition of underscores to text
47
+ and padding for all numbers.
48
+
49
+ Args:
50
+ *args: A variable-length list of strings and numbers to format.
51
+ auto_add_underscore_to_text_if_missing (bool): Whether to automatically add an underscore to the end of any
52
+ string arguments that don't already end with one. Defaults to True.
53
+ padding_for_all_numbers (int or float): If provided, all numbers will be formatted with this many digits using
54
+ leading zeros (for integers) or trailing zeros (for floats). If an integer is provided, the padding will be
55
+ applied to all numbers, while if a float is provided, the padding will be determined by the number of digits
56
+ after the decimal point. Defaults to None.
57
+
58
+ Returns:
59
+ str: The formatted string.
60
+
61
+ Examples:
62
+ >>> format_string_with_numbers('toto', 10, 'bob', 12, padding_for_all_numbers=3)
63
+ 'toto_010_bob_012'
64
+ >>> format_string_with_numbers('toto', 0.33255121121, 'bob', 12, padding_for_all_numbers=0.2)
65
+ 'toto_0.33_bob_12.00'
66
+ >>> format_string_with_numbers('toto', 0.33255121121, 'bob', 12, padding_for_all_numbers='{:0>9.2f}')
67
+ 'toto_000000.33_bob_000012.00'
68
+ """
69
+ if args is None:
70
+ return None
71
+
72
+ # Check if no arguments were passed
73
+ if not args:
74
+ return ''
75
+
76
+ # Check if padding for numbers was provided and format it accordingly
77
+ if isinstance(padding_for_all_numbers, (int, float)):
78
+ if isinstance(padding_for_all_numbers, int):
79
+ padding_for_all_numbers = '{:0' + str(padding_for_all_numbers) + 'd}'
80
+ else:
81
+ # Remove leading zeros from decimal numbers
82
+ my_string = str(padding_for_all_numbers)
83
+ if my_string.startswith('0'):
84
+ my_string = my_string[1:]
85
+ padding_for_all_numbers = '{:' + my_string + 'f}'
86
+
87
+ output_string = ''
88
+ for arg in args:
89
+ # If the argument is a string, add an underscore to the end if needed
90
+ if isinstance(arg, str):
91
+ if auto_add_underscore_to_text_if_missing and not arg.endswith('_'):
92
+ arg += '_'
93
+ output_string += arg
94
+ else:
95
+ # If padding is provided, format the number with the specified padding
96
+ if padding_for_all_numbers is not None:
97
+ output_string += padding_for_all_numbers.format(arg)
98
+ else:
99
+ output_string += str(arg)
100
+
101
+ # Add an underscore to the end of the number if needed
102
+ if auto_add_underscore_to_text_if_missing:
103
+ output_string += '_'
104
+
105
+ # Remove the last underscore if it exists
106
+ if auto_add_underscore_to_text_if_missing and output_string.endswith('_'):
107
+ output_string = output_string[:-1]
108
+
109
+ return output_string
110
+
111
+ def write_wrapped_text_to_file(file_path, text, line_width=60):
112
+ """
113
+ Write wrapped text to a file, ensuring lines are no longer than a specified width.
114
+
115
+ Parameters:
116
+ - file_path (str): The path to the file where the wrapped text will be written.
117
+ - text (str): The input text to be wrapped and written to the file.
118
+ - line_width (int, optional): The maximum width for each line. Default is 60.
119
+
120
+ Returns:
121
+ None
122
+ """
123
+ # Wrap the text to a maximum line width of 60 characters
124
+ wrapped_text = textwrap.fill(text, width=line_width)
125
+
126
+ # Write the wrapped text to the file
127
+ with open(file_path, 'w') as file:
128
+ file.write(wrapped_text)
129
+
130
+
131
+ def wrap_text(text, line_width=60):
132
+ """
133
+ Wrap the input text to ensure lines are no longer than a specified width.
134
+
135
+ Parameters:
136
+ - text (str): The input text to be wrapped.
137
+ - line_width (int, optional): The maximum width for each line. Default is 60.
138
+
139
+ Returns:
140
+ str: The wrapped text with lines no longer than the specified width.
141
+
142
+ Example:
143
+ >>> wrapped_text = wrap_text("This is a long line that needs to be wrapped to fit within 60 characters per line.")
144
+ >>> print(wrapped_text)
145
+ This is a long line that needs to be wrapped to fit within
146
+ 60 characters per line.
147
+ """
148
+ wrapped_text = textwrap.fill(text, width=line_width)
149
+ return wrapped_text
150
+
151
+ def capitalize_first_letter(input_string):
152
+ # return input_string.capitalize() # DEV NOTE KEEP this is really bad as it removes inner capitalized --> really useless to me then
153
+ try:
154
+ return input_string[:1].upper() + input_string[1:]
155
+ except:
156
+ pass
157
+ return input_string.capitalize() # if it failed roll back to that
158
+
159
+
160
+ def replace_ignore_case(original_string, old_substring, new_substring):
161
+ pattern = re.compile(re.escape(old_substring), re.IGNORECASE)
162
+ modified_string = pattern.sub(new_substring, original_string)
163
+ return modified_string
164
+
165
+
166
+ # do the text chunk splitting here
167
+ def chunk_text_with_overlap(text, chunk_size_words, overlap_words):
168
+ """
169
+ Split the input text into chunks of specified size with an overlap.
170
+
171
+ Args:
172
+ - text (str): The input text to be split into chunks.
173
+ - chunk_size_words (int): The size of each chunk in terms of words.
174
+ - overlap_words (int): The overlap size between adjacent chunks in terms of words.
175
+
176
+ Returns:
177
+ - list: A list containing the text chunks.
178
+ """
179
+ words = text.split()
180
+ chunks = []
181
+ start = 0
182
+ while start < len(words):
183
+ end = min(start + chunk_size_words, len(words))
184
+ chunk = ' '.join(words[start:end])
185
+ chunks.append(chunk)
186
+ start += chunk_size_words - overlap_words
187
+ return chunks
188
+
189
+ def increment_letter(text, handle_texts_more_than_one_letter=False):
190
+ if len(text) == 0:
191
+ return None
192
+ if not handle_texts_more_than_one_letter and len(text)>1:
193
+ return None
194
+ letter = text[0]
195
+ next_char = chr(ord(letter) + 1)
196
+ return next_char + text[1:]
197
+
198
+
199
+ if __name__ == '__main__':
200
+ import sys
201
+ if True:
202
+ text = 'A'
203
+ text = 'a'
204
+ text = 'µ'
205
+ text = 'zouppa'
206
+ print(increment_letter(text))
207
+ sys.exit(0)
208
+
209
+ test = 'CGTGGTCCAAAGCAACCCCGACTACCTGAACGTGGCCAACTATGCGCCCACTCCTGCTCCTTGGTGGTTCAACTGAACTGTGGACAGCAATTAGCATAAATTAGGTTGTA'
210
+ print(wrap_text(test))
211
+
212
+ print(format_string_with_numbers('toto', 10, 'bob', 12, padding_for_all_numbers=3)) # toto_010_bob_012
213
+ print(format_string_with_numbers('toto', 0.33255121121, 'bob', 12, padding_for_all_numbers=0.2)) # toto_0.33_bob_12.00
214
+ print(format_string_with_numbers('toto', 0.33255121121, 'bob', 12, padding_for_all_numbers='{:0>9.2f}')) # toto_000000.33_bob_000012.00
215
+
216
+ # Example usage:
217
+ input_string = "Hello txt, replace TXT with python."
218
+ old_substring = "txt"
219
+ new_substring = "<i>python</i>"
220
+
221
+ result = replace_ignore_case(input_string, old_substring, new_substring)
222
+ print(result)
223
+ # print(help(tools))
224
+ # print(format_string_with_numbers.__doc__)
225
+ # help(format_string_with_numbers)
File without changes
File without changes