py2ls 0.1.9.8__py3-none-any.whl → 0.1.10.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.
py2ls/batman.py ADDED
@@ -0,0 +1,183 @@
1
+ import smtplib
2
+ from email.mime.text import MIMEText
3
+ from email.mime.multipart import MIMEMultipart
4
+ from email.mime.base import MIMEBase
5
+ from email import encoders
6
+ import schedule
7
+ import time
8
+ from datetime import datetime
9
+ import os
10
+
11
+
12
+ signature_styles = [
13
+ "", # none
14
+ (
15
+ "------------------------------------------------------------------------------------------------\n"
16
+ "Jianfeng Liu, PhD\n"
17
+ "Institute of Medical Psychology and Behavioural Neurobiology\n"
18
+ "University of Tübingen\n"
19
+ "Otfried-Müller-Str. 25\n"
20
+ "72076 Tübingen\n\n"
21
+ ),
22
+ f"Pappelweg 8\n72076 Tübingen\n\n",
23
+ ]
24
+
25
+
26
+ def email_to(**kwargs):
27
+ """
28
+ usage:
29
+ email_to(who="example@gmail.com",
30
+ subject="test",
31
+ what="this is the body",
32
+ attachments="/Users/test.pdf")
33
+ Send an email with optional attachments.
34
+
35
+ :param who: Recipient email address
36
+ :param subject: Email subject
37
+ :param what: Email what
38
+ :param attachments: List of file paths to attach
39
+ """
40
+ who, what, subject = None, None, None
41
+ attachments = False
42
+ pause_sec = False # default 10 seconds pause
43
+ signature = signature_styles[0]
44
+
45
+ # params config
46
+ for k, v in kwargs.items():
47
+ if any(
48
+ [
49
+ "who" in k.lower(),
50
+ "whe" in k.lower(),
51
+ all(["@" in k.lower(), "." in k.lower()]),
52
+ ]
53
+ ): # 'who' or "where"
54
+ who = v
55
+ if any(["sub" in k.lower(), "hea" in k.lower()]): # 'subject', 'header'
56
+ subject = v
57
+ if any(
58
+ ["wha" in k.lower(), "con" in k.lower(), "bod" in k.lower()]
59
+ ): # 'what','content','body'
60
+ what = v
61
+ if any(["att" in k.lower(), "fil" in k.lower()]): # 'attachments', 'file'
62
+ attachments = v # optional
63
+ if any(
64
+ ["paus" in k.lower(), "tim" in k.lower(), "delay" in k.lower()]
65
+ ): # 'attachments', 'file'
66
+ pause_sec = v # optional
67
+ if any(["sig" in k.lower()]): # 'attachments', 'file'
68
+ signature = v # optional
69
+ if not isinstance(v, str):
70
+ signature = signature_styles[v]
71
+
72
+ # config sender
73
+ email_address = "andyandhope@gmail.com"
74
+ email_password = "myff ltls sfym wehe" # this is fake info
75
+
76
+ # Create email message
77
+ message = MIMEMultipart()
78
+ message["From"] = email_address
79
+ message["To"] = who
80
+ message["Subject"] = subject
81
+
82
+ # add signature
83
+ if signature:
84
+ what += f"\n\n{signature}\n"
85
+
86
+ # the eamil's body
87
+ message.attach(MIMEText(what, "plain"))
88
+
89
+ # attach files
90
+ if attachments:
91
+ if isinstance(attachments, str):
92
+ attachments = [attachments]
93
+ for file in attachments:
94
+ part = MIMEBase("application", "octet-stream")
95
+ try:
96
+ with open(file, "rb") as attachment:
97
+ part.set_payload(attachment.read())
98
+ encoders.encode_base64(part)
99
+
100
+ fname = os.path.basename(file)
101
+ print(fname)
102
+ part.add_header(
103
+ "Content-Disposition", f'attachment; filename= "{fname}"'
104
+ )
105
+ message.attach(part)
106
+ except FileNotFoundError:
107
+ print(f"File not found: {file}")
108
+ except Exception as e:
109
+ print(f"Error attaching file {file}: {e}")
110
+ if pause_sec:
111
+ time.sleep(pause_sec)
112
+ # Send the email
113
+ try:
114
+ with smtplib.SMTP("smtp.gmail.com", 587) as server:
115
+ server.starttls()
116
+ server.login(email_address, email_password)
117
+ server.sendmail(email_address, who, message.as_string())
118
+ print(f"Email successfully sent to {who}")
119
+ except Exception as e:
120
+ print(f"Failed to send email: {e}")
121
+
122
+
123
+ def email_to_every(who, subject, what, when, attachments=None):
124
+ """
125
+ Check the time and send an email when the time matches the when.
126
+
127
+ :param who: Recipient email address
128
+ :param subject: Email subject
129
+ :param what: Email what
130
+ :param when: Time to send the email in HH:MM format
131
+ :param attachments: List of file paths to attach
132
+ """
133
+ current_time = datetime.now().strftime("%H:%M")
134
+ if current_time == when:
135
+ email_to(
136
+ who=who,
137
+ subject=subject,
138
+ what=what,
139
+ attachments=attachments,
140
+ )
141
+
142
+
143
+ # Example usage
144
+ def example_job():
145
+ # Example email details
146
+ reminder_subject = "Reminder: Important Meeting Tomorrow"
147
+ reminder_what = (
148
+ "Don't forget about the meeting tomorrow at 10 AM in the conference room."
149
+ )
150
+ who = "Jianfeng.Liu0413@gmail.com"
151
+ when = "14:30" # Send time in 24-hour format
152
+
153
+ # Optional attachments
154
+ attachments = ["path/to/attachment1.pdf", "path/to/attachment2.jpg"]
155
+
156
+ # Schedule the email
157
+ email_to_every(who, reminder_subject, reminder_what, when, attachments)
158
+
159
+
160
+ if __name__ == "__main__":
161
+ # Schedule the job to run every minute
162
+ schedule.every(1).minutes.do(example_job)
163
+
164
+ while True:
165
+ schedule.run_pending()
166
+ time.sleep(1)
167
+
168
+ # example2:
169
+ email_to(
170
+ who="Jianfeng.Liu@medizin.uni-tuebingen.de",
171
+ subj="test",
172
+ wha="this is the body",
173
+ signat="\n\n Best, Jianfeng\n",
174
+ att="/Users/macjianfeng/Dropbox/Downloads/_*_doc-xlsx/20240822-preprints_full_20190101_20201031-2.xlsx",
175
+ )
176
+ # example3:
177
+ email_to(
178
+ who="Jianfeng.Liu@medizin.uni-tuebingen.de",
179
+ subj="test",
180
+ wha="this is the test",
181
+ signat=2,
182
+ att="/Users/macjianfeng/Dropbox/Downloads/_*_doc-xlsx/20240822-preprints_full_20190101_20201031-2.xlsx",
183
+ )
@@ -0,0 +1,213 @@
1
+ {
2
+ "style": "style6",
3
+ "layer": [
4
+ "b",
5
+ "bx",
6
+ "e",
7
+ "v",
8
+ "s",
9
+ "l"
10
+ ],
11
+ "b": {
12
+ "go": 0,
13
+ "loc": "c",
14
+ "FaceAlpha": 1,
15
+ "EdgeColor": "k",
16
+ "EdgeAlpha": 1,
17
+ "LineStyle": "-",
18
+ "LineWidth": 0.8,
19
+ "x_width": 0.85,
20
+ "ShowBaseLine": "off",
21
+ "hatch": null,
22
+ "FaceColor": [
23
+ "#474747",
24
+ "#FF2C00",
25
+ "#0C5DA5",
26
+ "#845B97",
27
+ "#58BBCC"
28
+ ],
29
+ "x_dist": 0.85
30
+ },
31
+ "e": {
32
+ "go": 0,
33
+ "loc": "l",
34
+ "LineWidth": 1,
35
+ "CapLineWidth": 1,
36
+ "CapSize": 2,
37
+ "Marker": "none",
38
+ "LineStyle": "none",
39
+ "LineColor": "k",
40
+ "LineJoin": "round",
41
+ "MarkerSize": "auto",
42
+ "MarkerEdgeColor": "none",
43
+ "Visible": true,
44
+ "Orientation": "vertical",
45
+ "error": "sem",
46
+ "x_width": 0.16999999999999998,
47
+ "cap_dir": "b",
48
+ "LineAlpha": 0.5,
49
+ "FaceColor": [
50
+ "#474747",
51
+ "#FF2C00",
52
+ "#0C5DA5",
53
+ "#845B97",
54
+ "#58BBCC"
55
+ ],
56
+ "x_dist": 0.16999999999999998
57
+ },
58
+ "s": {
59
+ "go": 0,
60
+ "loc": "r",
61
+ "cmap": null,
62
+ "FaceAlpha": 1,
63
+ "x_width": 0.16999999999999998,
64
+ "Marker": "o",
65
+ "MarkerSize": 15,
66
+ "LineWidth": 0.8,
67
+ "MarkerEdgeColor": "k",
68
+ "FaceColor": [
69
+ "#474747",
70
+ "#FF2C00",
71
+ "#0C5DA5",
72
+ "#845B97",
73
+ "#58BBCC"
74
+ ],
75
+ "x_dist": 0.16999999999999998
76
+ },
77
+ "l": {
78
+ "go": 1,
79
+ "LineStyle": "-",
80
+ "LineColor": "k",
81
+ "LineWidth": 0.5,
82
+ "LineAlpha": 0.5
83
+ },
84
+ "bx": {
85
+ "go": 1,
86
+ "loc": "c",
87
+ "EdgeColor": "k",
88
+ "FaceAlpha": 0.85,
89
+ "EdgeAlpha": 1,
90
+ "LineStyle": "-",
91
+ "x_width": 0.1,
92
+ "ShowBaseLine": "off",
93
+ "Notch": false,
94
+ "Outliers": false,
95
+ "OutlierMarker": "+",
96
+ "OutlierColor": "r",
97
+ "OutlierSize": 6,
98
+ "LineWidth": 0.5,
99
+ "Whisker": 0.5,
100
+ "Orientation": "vertical",
101
+ "BoxLineWidth": 0.5,
102
+ "WhiskerLineStyle": "-",
103
+ "WhiskerLineColor": "k",
104
+ "WhiskerLineWidth": 0.5,
105
+ "Caps": true,
106
+ "CapLineColor": "k",
107
+ "CapLineWidth": 0.5,
108
+ "CapSize": 0,
109
+ "MedianLine": false,
110
+ "MedianLineStyle": "-",
111
+ "MedianStyle": "line",
112
+ "MedianLineColor": "k",
113
+ "MedianLineWidth": 2.0,
114
+ "MedianLineTop": false,
115
+ "MeanLine": true,
116
+ "showmeans": false,
117
+ "MeanLineStyle": "-",
118
+ "MeanLineColor": "w",
119
+ "MeanLineWidth": 2.0,
120
+ "FaceColor": [
121
+ "#474747",
122
+ "#FF2C00",
123
+ "#0C5DA5",
124
+ "#845B97",
125
+ "#58BBCC"
126
+ ],
127
+ "x_dist": 0.2,
128
+ "OutlierFaceColor": "r",
129
+ "OutlierEdgeColor": "r"
130
+ },
131
+ "v": {
132
+ "go": 1,
133
+ "x_width": 0.3,
134
+ "loc": "r",
135
+ "EdgeColor": "none",
136
+ "FaceAlpha": 0.9,
137
+ "BandWidth": "scott",
138
+ "Function": "pdf",
139
+ "Kernel": "gau",
140
+ "NumPoints": 500,
141
+ "BoundaryCorrection": "reflection",
142
+ "x_dist": 0.1,
143
+ "FaceColor": [
144
+ "#474747",
145
+ "#FF2C00",
146
+ "#0C5DA5",
147
+ "#845B97",
148
+ "#58BBCC"
149
+ ]
150
+ },
151
+ "c": [
152
+ "#474747",
153
+ "#FF2C00",
154
+ "#0C5DA5",
155
+ "#845B97",
156
+ "#58BBCC"
157
+ ],
158
+ "loc": {
159
+ "go": 0,
160
+ "xloc": [
161
+ 1,
162
+ 2,
163
+ 3,
164
+ 4,
165
+ 5
166
+ ]
167
+ },
168
+ "r": {
169
+ "go": 0,
170
+ "bw_adjust": 1,
171
+ "clip": false,
172
+ "FaceColor": [
173
+ "#474747",
174
+ "#FF2C00",
175
+ "#0C5DA5",
176
+ "#845B97",
177
+ "#58BBCC",
178
+ "#FF9500",
179
+ "#D57DBE",
180
+ "#474747",
181
+ "#FF2C00",
182
+ "#0C5DA5",
183
+ "#845B97",
184
+ "#58BBCC",
185
+ "#FF9500",
186
+ "#D57DBE",
187
+ "#474747",
188
+ "#FF2C00",
189
+ "#0C5DA5",
190
+ "#845B97",
191
+ "#58BBCC",
192
+ "#FF9500"
193
+ ],
194
+ "FaceAlpha": 1,
195
+ "EdgeLineWidth": 1.5,
196
+ "fill": true,
197
+ "EdgeColor": "none",
198
+ "xLineWidth": 2.0,
199
+ "xLineColor": "none",
200
+ "aspect": 8,
201
+ "subplot_hspace": -0.3,
202
+ "subplot_height": 0.75,
203
+ "subplot_ylabel": "",
204
+ "column4color": null,
205
+ "row_labels": null,
206
+ "row_label_loc_xscale": 0.01,
207
+ "row_label_loc_yscale": 0.05,
208
+ "fontweight": "normal",
209
+ "fontsize": 11.0,
210
+ "color_row_label": "k",
211
+ "ylabel": null
212
+ }
213
+ }
@@ -0,0 +1,213 @@
1
+ {
2
+ "style": "style6",
3
+ "layer": [
4
+ "b",
5
+ "bx",
6
+ "e",
7
+ "v",
8
+ "s",
9
+ "l"
10
+ ],
11
+ "b": {
12
+ "go": 0,
13
+ "loc": "c",
14
+ "FaceAlpha": 1,
15
+ "EdgeColor": "k",
16
+ "EdgeAlpha": 1,
17
+ "LineStyle": "-",
18
+ "LineWidth": 0.8,
19
+ "x_width": 0.85,
20
+ "ShowBaseLine": "off",
21
+ "hatch": null,
22
+ "FaceColor": [
23
+ "#474747",
24
+ "#FF2C00",
25
+ "#0C5DA5",
26
+ "#845B97",
27
+ "#58BBCC"
28
+ ],
29
+ "x_dist": 0.85
30
+ },
31
+ "e": {
32
+ "go": 0,
33
+ "loc": "l",
34
+ "LineWidth": 1,
35
+ "CapLineWidth": 1,
36
+ "CapSize": 2,
37
+ "Marker": "none",
38
+ "LineStyle": "none",
39
+ "LineColor": "k",
40
+ "LineJoin": "round",
41
+ "MarkerSize": "auto",
42
+ "MarkerEdgeColor": "none",
43
+ "Visible": true,
44
+ "Orientation": "vertical",
45
+ "error": "sem",
46
+ "x_width": 0.16999999999999998,
47
+ "cap_dir": "b",
48
+ "LineAlpha": 0.5,
49
+ "FaceColor": [
50
+ "#474747",
51
+ "#FF2C00",
52
+ "#0C5DA5",
53
+ "#845B97",
54
+ "#58BBCC"
55
+ ],
56
+ "x_dist": 0.16999999999999998
57
+ },
58
+ "s": {
59
+ "go": 0,
60
+ "loc": "r",
61
+ "cmap": null,
62
+ "FaceAlpha": 1,
63
+ "x_width": 0.16999999999999998,
64
+ "Marker": "o",
65
+ "MarkerSize": 15,
66
+ "LineWidth": 0.8,
67
+ "MarkerEdgeColor": "k",
68
+ "FaceColor": [
69
+ "#474747",
70
+ "#FF2C00",
71
+ "#0C5DA5",
72
+ "#845B97",
73
+ "#58BBCC"
74
+ ],
75
+ "x_dist": 0.16999999999999998
76
+ },
77
+ "l": {
78
+ "go": 1,
79
+ "LineStyle": "-",
80
+ "LineColor": "k",
81
+ "LineWidth": 0.5,
82
+ "LineAlpha": 0.5
83
+ },
84
+ "bx": {
85
+ "go": 1,
86
+ "loc": "c",
87
+ "EdgeColor": "k",
88
+ "FaceAlpha": 0.85,
89
+ "EdgeAlpha": 1,
90
+ "LineStyle": "-",
91
+ "x_width": 0.1,
92
+ "ShowBaseLine": "off",
93
+ "Notch": false,
94
+ "Outliers": false,
95
+ "OutlierMarker": "+",
96
+ "OutlierColor": "r",
97
+ "OutlierSize": 6,
98
+ "LineWidth": 0.5,
99
+ "Whisker": 0.5,
100
+ "Orientation": "vertical",
101
+ "BoxLineWidth": 0.5,
102
+ "WhiskerLineStyle": "-",
103
+ "WhiskerLineColor": "k",
104
+ "WhiskerLineWidth": 0.5,
105
+ "Caps": true,
106
+ "CapLineColor": "k",
107
+ "CapLineWidth": 0.5,
108
+ "CapSize": 0,
109
+ "MedianLine": true,
110
+ "MedianLineStyle": "-",
111
+ "MedianStyle": "line",
112
+ "MedianLineColor": "k",
113
+ "MedianLineWidth": 2.0,
114
+ "MedianLineTop": false,
115
+ "MeanLine": false,
116
+ "showmeans": false,
117
+ "MeanLineStyle": "-",
118
+ "MeanLineColor": "w",
119
+ "MeanLineWidth": 2.0,
120
+ "FaceColor": [
121
+ "#474747",
122
+ "#FF2C00",
123
+ "#0C5DA5",
124
+ "#845B97",
125
+ "#58BBCC"
126
+ ],
127
+ "x_dist": 0.2,
128
+ "OutlierFaceColor": "r",
129
+ "OutlierEdgeColor": "r"
130
+ },
131
+ "v": {
132
+ "go": 1,
133
+ "x_width": 0.3,
134
+ "loc": "r",
135
+ "EdgeColor": "none",
136
+ "FaceAlpha": 0.9,
137
+ "BandWidth": "scott",
138
+ "Function": "pdf",
139
+ "Kernel": "gau",
140
+ "NumPoints": 500,
141
+ "BoundaryCorrection": "reflection",
142
+ "x_dist": 0.1,
143
+ "FaceColor": [
144
+ "#474747",
145
+ "#FF2C00",
146
+ "#0C5DA5",
147
+ "#845B97",
148
+ "#58BBCC"
149
+ ]
150
+ },
151
+ "c": [
152
+ "#474747",
153
+ "#FF2C00",
154
+ "#0C5DA5",
155
+ "#845B97",
156
+ "#58BBCC"
157
+ ],
158
+ "loc": {
159
+ "go": 0,
160
+ "xloc": [
161
+ 1,
162
+ 2,
163
+ 3,
164
+ 4,
165
+ 5
166
+ ]
167
+ },
168
+ "r": {
169
+ "go": 0,
170
+ "bw_adjust": 1,
171
+ "clip": false,
172
+ "FaceColor": [
173
+ "#474747",
174
+ "#FF2C00",
175
+ "#0C5DA5",
176
+ "#845B97",
177
+ "#58BBCC",
178
+ "#FF9500",
179
+ "#D57DBE",
180
+ "#474747",
181
+ "#FF2C00",
182
+ "#0C5DA5",
183
+ "#845B97",
184
+ "#58BBCC",
185
+ "#FF9500",
186
+ "#D57DBE",
187
+ "#474747",
188
+ "#FF2C00",
189
+ "#0C5DA5",
190
+ "#845B97",
191
+ "#58BBCC",
192
+ "#FF9500"
193
+ ],
194
+ "FaceAlpha": 1,
195
+ "EdgeLineWidth": 1.5,
196
+ "fill": true,
197
+ "EdgeColor": "none",
198
+ "xLineWidth": 2.0,
199
+ "xLineColor": "none",
200
+ "aspect": 8,
201
+ "subplot_hspace": -0.3,
202
+ "subplot_height": 0.75,
203
+ "subplot_ylabel": "",
204
+ "column4color": null,
205
+ "row_labels": null,
206
+ "row_label_loc_xscale": 0.01,
207
+ "row_label_loc_yscale": 0.05,
208
+ "fontweight": "normal",
209
+ "fontsize": 11.0,
210
+ "color_row_label": "k",
211
+ "ylabel": null
212
+ }
213
+ }