py2ls 0.1.4.6__py3-none-any.whl → 0.1.4.7__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.
py2ls/ips.py
CHANGED
@@ -40,6 +40,81 @@ from pprint import pp
|
|
40
40
|
from dateutil import parser
|
41
41
|
from datetime import datetime
|
42
42
|
|
43
|
+
def is_num(s):
|
44
|
+
"""
|
45
|
+
Check if a string can be converted to a number (int or float).
|
46
|
+
Parameters:
|
47
|
+
- s (str): The string to check.
|
48
|
+
Returns:
|
49
|
+
- bool: True if the string can be converted to a number, False otherwise.
|
50
|
+
"""
|
51
|
+
try:
|
52
|
+
float(s) # Try converting the string to a float
|
53
|
+
return True
|
54
|
+
except ValueError:
|
55
|
+
return False
|
56
|
+
def isnum(s):
|
57
|
+
return is_num(s)
|
58
|
+
|
59
|
+
def str2time(time_str, fmt='24'):
|
60
|
+
"""
|
61
|
+
Convert a time string into the specified format.
|
62
|
+
Parameters:
|
63
|
+
- time_str (str): The time string to be converted.
|
64
|
+
- fmt (str): The format to convert the time to. Defaults to '%H:%M:%S'.
|
65
|
+
Returns:
|
66
|
+
%I represents the hour in 12-hour format.
|
67
|
+
%H represents the hour in 24-hour format (00 through 23).
|
68
|
+
%M represents the minute.
|
69
|
+
%S represents the second.
|
70
|
+
%p represents AM or PM.
|
71
|
+
- str: The converted time string.
|
72
|
+
"""
|
73
|
+
def time_len_corr(time_str):
|
74
|
+
time_str_= ssplit(time_str,by=[':'," ","digital_num"]) if ':' in time_str else None
|
75
|
+
time_str_split=[]
|
76
|
+
[time_str_split.append(i) for i in time_str_ if is_num(i)]
|
77
|
+
if time_str_split:
|
78
|
+
if len(time_str_split)==2:
|
79
|
+
H,M=time_str_split
|
80
|
+
time_str_full=H+":"+M+":00"
|
81
|
+
elif len(time_str_split)==3:
|
82
|
+
H,M,S=time_str_split
|
83
|
+
time_str_full=H+":"+M+":"+S
|
84
|
+
|
85
|
+
if 'am' in time_str.lower():
|
86
|
+
time_str_full+=" AM"
|
87
|
+
elif "pm"in time_str.lower():
|
88
|
+
time_str_full +=" PM"
|
89
|
+
return time_str_full
|
90
|
+
if '12' in fmt:
|
91
|
+
fmt = "%I:%M:%S %p"
|
92
|
+
elif '24' in fmt:
|
93
|
+
fmt = "%H:%M:%S"
|
94
|
+
|
95
|
+
try:
|
96
|
+
# Try to parse the time string assuming it could be in 24-hour or 12-hour format
|
97
|
+
time_obj = datetime.strptime(time_str, '%H:%M:%S')
|
98
|
+
except ValueError:
|
99
|
+
try:
|
100
|
+
time_obj = datetime.strptime(time_str, '%I:%M:%S %p')
|
101
|
+
except ValueError as e:
|
102
|
+
raise ValueError(f"Unable to parse time string: {time_str}. Error: {e}")
|
103
|
+
|
104
|
+
# Format the time object to the desired output format
|
105
|
+
formatted_time = time_obj.strftime(fmt)
|
106
|
+
return formatted_time
|
107
|
+
|
108
|
+
# # Example usage:
|
109
|
+
# time_str1 = "14:30:45"
|
110
|
+
# time_str2 = "02:30:45 PM"
|
111
|
+
|
112
|
+
# formatted_time1 = str2time(time_str1, fmt='12') # Convert to 12-hour format
|
113
|
+
# formatted_time2 = str2time(time_str2, fmt='24') # Convert to 24-hour format
|
114
|
+
|
115
|
+
# print(formatted_time1) # Output: 02:30:45 PM
|
116
|
+
# print(formatted_time2) # Output: 14:30:45
|
117
|
+
|
43
118
|
def str2date(date_str, fmt='%Y-%m-%d_%H:%M:%S'):
|
44
119
|
"""
|
45
120
|
Convert a date string into the specified format.
|
@@ -100,12 +100,12 @@ py2ls/brain_atlas.py,sha256=w1o5EelRjq89zuFJUNSz4Da8HnTCwAwDAZ4NU4a-bAY,5486
|
|
100
100
|
py2ls/correlators.py,sha256=RbOaJIPLCHJtUm5SFi_4dCJ7VFUPWR0PErfK3K26ad4,18243
|
101
101
|
py2ls/dbhandler.py,sha256=i9dNrpHyx0oIaFieHI4X4tsrCdN-aFxudPTDOgy9Ppo,3574
|
102
102
|
py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
|
103
|
-
py2ls/ips.py,sha256=
|
103
|
+
py2ls/ips.py,sha256=5Ku9XR6kHqRfnnCmpe_l0cFnygDdtkeWPuxVM_0jMF0,127387
|
104
104
|
py2ls/netfinder.py,sha256=dt6hkYeH-ivCHInoUi92MhJMLlXtjRXT3ewKzOwGtWk,31506
|
105
105
|
py2ls/setuptools-70.1.0-py3-none-any.whl,sha256=2bi3cUVal8ip86s0SOvgspteEF8SKLukECi-EWmFomc,882588
|
106
106
|
py2ls/sleep_events_detectors.py,sha256=36MCuRrpurn0Uvzpo3p3b3_JlVsRNHSWCXbJxCGM3mg,51546
|
107
107
|
py2ls/translator.py,sha256=QfDUO0-pXHGMBFZBefiBHzOrC93-__N5sUQY_VP4wes,29734
|
108
108
|
py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
|
109
|
-
py2ls-0.1.4.
|
110
|
-
py2ls-0.1.4.
|
111
|
-
py2ls-0.1.4.
|
109
|
+
py2ls-0.1.4.7.dist-info/METADATA,sha256=r5YnewxwrCFaolNyPhHPiNv9JC5Psg2XsBZKyiZOsvU,17943
|
110
|
+
py2ls-0.1.4.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
111
|
+
py2ls-0.1.4.7.dist-info/RECORD,,
|
File without changes
|