myl 0.8.9__tar.gz → 0.8.10__tar.gz
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.
- {myl-0.8.9 → myl-0.8.10}/PKG-INFO +1 -1
- {myl-0.8.9 → myl-0.8.10}/myl.egg-info/PKG-INFO +1 -1
- {myl-0.8.9 → myl-0.8.10}/myl.py +67 -8
- {myl-0.8.9 → myl-0.8.10}/pyproject.toml +1 -1
- {myl-0.8.9 → myl-0.8.10}/.github/dependabot.yml +0 -0
- {myl-0.8.9 → myl-0.8.10}/.github/workflows/lint.yaml +0 -0
- {myl-0.8.9 → myl-0.8.10}/.github/workflows/pypi.yaml +0 -0
- {myl-0.8.9 → myl-0.8.10}/.github/workflows/release.yaml +0 -0
- {myl-0.8.9 → myl-0.8.10}/.gitignore +0 -0
- {myl-0.8.9 → myl-0.8.10}/LICENSE +0 -0
- {myl-0.8.9 → myl-0.8.10}/README.md +0 -0
- {myl-0.8.9 → myl-0.8.10}/myl.egg-info/SOURCES.txt +0 -0
- {myl-0.8.9 → myl-0.8.10}/myl.egg-info/dependency_links.txt +0 -0
- {myl-0.8.9 → myl-0.8.10}/myl.egg-info/entry_points.txt +0 -0
- {myl-0.8.9 → myl-0.8.10}/myl.egg-info/requires.txt +0 -0
- {myl-0.8.9 → myl-0.8.10}/myl.egg-info/top_level.txt +0 -0
- {myl-0.8.9 → myl-0.8.10}/setup.cfg +0 -0
{myl-0.8.9 → myl-0.8.10}/myl.py
RENAMED
@@ -1,11 +1,12 @@
|
|
1
1
|
import argparse
|
2
|
+
import json
|
2
3
|
import logging
|
3
4
|
import ssl
|
4
5
|
import sys
|
5
6
|
|
6
7
|
import imap_tools
|
7
8
|
from myldiscovery import autodiscover
|
8
|
-
from rich import print
|
9
|
+
from rich import print, print_json
|
9
10
|
from rich.console import Console
|
10
11
|
from rich.logging import RichHandler
|
11
12
|
from rich.table import Table
|
@@ -82,6 +83,13 @@ def parse_args():
|
|
82
83
|
)
|
83
84
|
parser.add_argument("-S", "--search", help="Search string", default="ALL")
|
84
85
|
parser.add_argument("-H", "--html", help="Show HTML", action="store_true")
|
86
|
+
parser.add_argument(
|
87
|
+
"-j",
|
88
|
+
"--json",
|
89
|
+
help="JSON output",
|
90
|
+
action="store_true",
|
91
|
+
default=False,
|
92
|
+
)
|
85
93
|
parser.add_argument(
|
86
94
|
"-r",
|
87
95
|
"--raw",
|
@@ -146,6 +154,7 @@ def main():
|
|
146
154
|
)
|
147
155
|
return 2
|
148
156
|
|
157
|
+
json_data = []
|
149
158
|
table = Table(
|
150
159
|
show_header=not args.no_title,
|
151
160
|
header_style="bold",
|
@@ -200,6 +209,31 @@ def main():
|
|
200
209
|
if args.raw:
|
201
210
|
print(msg.obj.as_string())
|
202
211
|
return 0
|
212
|
+
elif args.json:
|
213
|
+
print_json(
|
214
|
+
json.dumps(
|
215
|
+
{
|
216
|
+
"uid": msg.uid,
|
217
|
+
"subject": msg.subject,
|
218
|
+
"from": msg.from_,
|
219
|
+
"to": msg.to,
|
220
|
+
"date": msg.date.strftime(
|
221
|
+
"%Y-%m-%d %H:%M:%S"
|
222
|
+
),
|
223
|
+
"timestamp": str(
|
224
|
+
int(msg.date.timestamp())
|
225
|
+
),
|
226
|
+
"content": {
|
227
|
+
"raw": msg.obj.as_string(),
|
228
|
+
"html": msg.html,
|
229
|
+
"text": msg.text,
|
230
|
+
},
|
231
|
+
"attachments": msg.attachments,
|
232
|
+
}
|
233
|
+
)
|
234
|
+
)
|
235
|
+
return 0
|
236
|
+
|
203
237
|
print(msg.text if not args.html else msg.html)
|
204
238
|
for att in msg.attachments:
|
205
239
|
print(
|
@@ -221,16 +255,41 @@ def main():
|
|
221
255
|
if msg.subject
|
222
256
|
else "<no-subject>"
|
223
257
|
)
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
258
|
+
if args.json:
|
259
|
+
json_data.append(
|
260
|
+
{
|
261
|
+
"uid": msg.uid,
|
262
|
+
"subject": msg.subject,
|
263
|
+
"from": msg.from_,
|
264
|
+
"to": msg.to,
|
265
|
+
"date": msg.date.strftime("%Y-%m-%d %H:%M:%S"),
|
266
|
+
"timestamp": str(int(msg.date.timestamp())),
|
267
|
+
"content": {
|
268
|
+
"raw": msg.obj.as_string(),
|
269
|
+
"html": msg.html,
|
270
|
+
"text": msg.text,
|
271
|
+
},
|
272
|
+
"attachments": msg.attachments,
|
273
|
+
}
|
274
|
+
)
|
275
|
+
else:
|
276
|
+
table.add_row(
|
277
|
+
msg.uid if msg.uid else "???",
|
278
|
+
f"{subj_prefix}{subject}",
|
279
|
+
msg.from_,
|
280
|
+
(
|
281
|
+
msg.date.strftime("%H:%M %d/%m/%Y")
|
282
|
+
if msg.date
|
283
|
+
else "???"
|
284
|
+
),
|
285
|
+
)
|
230
286
|
if len(table.rows) >= args.count:
|
231
287
|
break
|
232
288
|
|
233
|
-
|
289
|
+
if args.json:
|
290
|
+
print_json(json.dumps(json_data))
|
291
|
+
else:
|
292
|
+
console.print(table)
|
234
293
|
return 0
|
235
294
|
except Exception:
|
236
295
|
console.print_exception(show_locals=True)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{myl-0.8.9 → myl-0.8.10}/LICENSE
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|