myl 0.8.10__tar.gz → 0.8.12__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: myl
3
- Version: 0.8.10
3
+ Version: 0.8.12
4
4
  Summary: Dead simple IMAP CLI client
5
5
  Author-email: Philipp Schmitt <philipp@schmitt.co>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -690,6 +690,7 @@ License-File: LICENSE
690
690
  Requires-Dist: imap-tools<2.0.0,>=1.5.0
691
691
  Requires-Dist: myl-discovery>=0.6.0
692
692
  Requires-Dist: rich<14.0.0,>=13.0.0
693
+ Requires-Dist: html2text>=2024.2.26
693
694
 
694
695
  # 📧 myl
695
696
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: myl
3
- Version: 0.8.10
3
+ Version: 0.8.12
4
4
  Summary: Dead simple IMAP CLI client
5
5
  Author-email: Philipp Schmitt <philipp@schmitt.co>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -690,6 +690,7 @@ License-File: LICENSE
690
690
  Requires-Dist: imap-tools<2.0.0,>=1.5.0
691
691
  Requires-Dist: myl-discovery>=0.6.0
692
692
  Requires-Dist: rich<14.0.0,>=13.0.0
693
+ Requires-Dist: html2text>=2024.2.26
693
694
 
694
695
  # 📧 myl
695
696
 
@@ -1,3 +1,4 @@
1
1
  imap-tools<2.0.0,>=1.5.0
2
2
  myl-discovery>=0.6.0
3
3
  rich<14.0.0,>=13.0.0
4
+ html2text>=2024.2.26
@@ -1,4 +1,8 @@
1
+ #!/usr/bin/env python3
2
+ # coding: utf-8
3
+
1
4
  import argparse
5
+ import html2text
2
6
  import json
3
7
  import logging
4
8
  import ssl
@@ -69,8 +73,12 @@ def parse_args():
69
73
  parser.add_argument(
70
74
  "-u", "--username", help="IMAP username", required=True
71
75
  )
72
- parser.add_argument(
73
- "-p", "--password", help="IMAP password", required=True
76
+ password_group = parser.add_mutually_exclusive_group(required=True)
77
+ password_group.add_argument("-p", "--password", help="IMAP password")
78
+ password_group.add_argument(
79
+ "--password-file",
80
+ help="IMAP password (file path)",
81
+ type=argparse.FileType("r"),
74
82
  )
75
83
  parser.add_argument(
76
84
  "-t", "--no-title", help="Do not show title", action="store_true"
@@ -115,6 +123,10 @@ def main():
115
123
  )
116
124
  LOGGER.debug(args)
117
125
 
126
+ imap_password = args.password or (
127
+ args.password_file and args.password_file.read()
128
+ )
129
+
118
130
  if args.google:
119
131
  args.server = GMAIL_IMAP_SERVER
120
132
  args.port = GMAIL_IMAP_PORT
@@ -128,7 +140,7 @@ def main():
128
140
  if args.auto:
129
141
  try:
130
142
  settings = autodiscover(
131
- args.username, password=args.password
143
+ args.username, password=imap_password
132
144
  ).get("imap")
133
145
  except Exception:
134
146
  error_msg("Failed to autodiscover IMAP settings")
@@ -187,7 +199,7 @@ def main():
187
199
 
188
200
  try:
189
201
  with mb(**mb_kwargs).login(
190
- args.username, args.password, args.folder
202
+ args.username, imap_password, args.folder
191
203
  ) as mailbox:
192
204
  if args.MAILID:
193
205
  msg = next(
@@ -234,7 +246,13 @@ def main():
234
246
  )
235
247
  return 0
236
248
 
237
- print(msg.text if not args.html else msg.html)
249
+ output = msg.text
250
+ if args.html:
251
+ if args.raw:
252
+ output = msg.html
253
+ else:
254
+ output = html2text.html2text(msg.html)
255
+ print(output)
238
256
  for att in msg.attachments:
239
257
  print(
240
258
  f"📎 Attachment: {att.filename}", file=sys.stderr
@@ -283,13 +301,15 @@ def main():
283
301
  else "???"
284
302
  ),
285
303
  )
286
- if len(table.rows) >= args.count:
304
+ if table.row_count >= args.count:
287
305
  break
288
306
 
289
307
  if args.json:
290
308
  print_json(json.dumps(json_data))
291
309
  else:
292
310
  console.print(table)
311
+ if table.row_count == 0:
312
+ print("[yellow italic]No messages[/yellow italic]", file=sys.stderr)
293
313
  return 0
294
314
  except Exception:
295
315
  console.print_exception(show_locals=True)
@@ -19,8 +19,9 @@ dependencies = [
19
19
  "imap-tools >= 1.5.0, < 2.0.0",
20
20
  "myl-discovery >= 0.6.0",
21
21
  "rich >= 13.0.0, <14.0.0",
22
+ "html2text >= 2024.2.26"
22
23
  ]
23
- version = "0.8.10"
24
+ version = "0.8.12"
24
25
 
25
26
  [project.urls]
26
27
  homepage = "https://github.com/pschmitt/myl"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes