myl-discovery 0.2.0__tar.gz → 0.3.0__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-discovery
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: email autodiscovery
5
5
  Author-email: Philipp Schmitt <philipp@schmitt.co>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: myl-discovery
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: email autodiscovery
5
5
  Author-email: Philipp Schmitt <philipp@schmitt.co>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -8,6 +8,10 @@ pyproject.toml
8
8
  myl_discovery.egg-info/PKG-INFO
9
9
  myl_discovery.egg-info/SOURCES.txt
10
10
  myl_discovery.egg-info/dependency_links.txt
11
+ myl_discovery.egg-info/entry_points.txt
11
12
  myl_discovery.egg-info/requires.txt
12
13
  myl_discovery.egg-info/top_level.txt
13
- myldiscovery/__init__.py
14
+ myldiscovery/__init__.py
15
+ myldiscovery/__main__.py
16
+ myldiscovery/discovery.py
17
+ myldiscovery/main.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ myl-discovery = myldiscovery:main
@@ -1,3 +1,4 @@
1
1
  dnspython
2
2
  requests
3
+ rich
3
4
  xmltodict
@@ -0,0 +1,4 @@
1
+ from .discovery import autodiscover
2
+ from .main import main
3
+
4
+ __all__ = ["main", "autodiscover"]
@@ -0,0 +1,4 @@
1
+ from . import main
2
+
3
+ if __name__ == '__main__':
4
+ main()
@@ -73,7 +73,7 @@ def autodiscover(email_addr, srv_only=False):
73
73
  # 465 -> starttls
74
74
  # 587 -> no
75
75
  "starttls": False,
76
- }
76
+ },
77
77
  }
78
78
 
79
79
  res = requests.get(autoconfig)
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ import argparse
5
+ import logging
6
+
7
+ from rich import print_json
8
+ from rich.console import Console
9
+ from rich.logging import RichHandler
10
+ from rich.table import Table
11
+
12
+ from myldiscovery import autodiscover
13
+
14
+ LOGGER = logging.getLogger(__name__)
15
+
16
+
17
+ def parse_args():
18
+ parser = argparse.ArgumentParser()
19
+ parser.add_argument("-j", "--json", action="store_true", default=False)
20
+ parser.add_argument("-d", "--debug", action="store_true", default=False)
21
+ parser.add_argument("EMAIL")
22
+ return parser.parse_args()
23
+
24
+
25
+ def main():
26
+ console = Console()
27
+ args = parse_args()
28
+
29
+ logging.basicConfig(
30
+ handlers=[RichHandler(console=console, show_time=False)],
31
+ level=logging.DEBUG if args.debug else logging.INFO,
32
+ )
33
+ LOGGER.debug(args)
34
+
35
+ try:
36
+ res = autodiscover(args.EMAIL)
37
+ if args.json:
38
+ print_json(data=res)
39
+ else:
40
+ table = Table(
41
+ expand=True,
42
+ show_header=True,
43
+ header_style="bold",
44
+ show_lines=False,
45
+ box=None,
46
+ )
47
+ table.add_column("Service", style="red")
48
+ table.add_column("Host", style="blue")
49
+ table.add_column("Port", style="green")
50
+ table.add_column("TLS", style="yellow")
51
+ for svc in ["imap", "smtp"]:
52
+ table.add_row(
53
+ svc,
54
+ res[svc]["server"],
55
+ str(res[svc]["port"]),
56
+ "starttls" if res[svc]["starttls"] else "tls",
57
+ )
58
+ console.print(table)
59
+ except Exception:
60
+ console.print_exception(show_locals=True)
61
+
62
+
63
+ if __name__ == "__main__":
64
+ main()
@@ -18,9 +18,13 @@ classifiers = [
18
18
  dependencies = [
19
19
  "dnspython",
20
20
  "requests",
21
+ "rich",
21
22
  "xmltodict"
22
23
  ]
23
- version = "0.2.0"
24
+ version = "0.3.0"
25
+
26
+ [project.scripts]
27
+ myl-discovery = "myldiscovery:main"
24
28
 
25
29
  [tool.black]
26
30
  line-length = 79
File without changes
File without changes
File without changes
File without changes