mtcli 3.7.0.dev3__py3-none-any.whl → 3.7.0.dev5__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.
@@ -0,0 +1,98 @@
1
+ """
2
+ Sistema de carregamento de plugins do mtcli.
3
+
4
+ Este módulo carrega automaticamente:
5
+
6
+ 1. Plugins internos localizados em `mtcli.plugins`
7
+ 2. Plugins externos registrados via entry points `mtcli.plugins`
8
+
9
+ Plugins devem expor uma função:
10
+
11
+ register(cli)
12
+
13
+ onde `cli` é o grupo principal do Click.
14
+ """
15
+
16
+ import importlib
17
+ import pkgutil
18
+
19
+ import click
20
+
21
+ try:
22
+ from importlib.metadata import entry_points
23
+ except ImportError: # Python < 3.10
24
+ from importlib_metadata import entry_points
25
+
26
+ import mtcli.plugins
27
+
28
+
29
+ def load_internal_plugins(cli: click.Group) -> None:
30
+ """
31
+ Carrega plugins internos do pacote `mtcli.plugins`.
32
+
33
+ Cada módulo encontrado deve expor a função:
34
+
35
+ register(cli)
36
+
37
+ Args:
38
+ cli: grupo principal do Click.
39
+ """
40
+
41
+ for module_info in pkgutil.iter_modules(mtcli.plugins.__path__):
42
+
43
+ module_name = f"mtcli.plugins.{module_info.name}"
44
+
45
+ module = importlib.import_module(module_name)
46
+
47
+ if hasattr(module, "register"):
48
+ module.register(cli)
49
+
50
+
51
+ def load_external_plugins(cli: click.Group) -> None:
52
+ """
53
+ Carrega plugins externos instalados via entry points.
54
+
55
+ Os plugins devem declarar no pyproject.toml:
56
+
57
+ [project.entry-points."mtcli.plugins"]
58
+ nome = "pacote.plugin:register"
59
+
60
+ Args:
61
+ cli: grupo principal do Click.
62
+ """
63
+
64
+ eps = entry_points()
65
+
66
+ plugins = (
67
+ eps.select(group="mtcli.plugins")
68
+ if hasattr(eps, "select")
69
+ else eps.get("mtcli.plugins", [])
70
+ )
71
+
72
+ for ep in plugins:
73
+
74
+ plugin = ep.load()
75
+
76
+ if callable(plugin) and not isinstance(plugin, click.Command):
77
+ plugin(cli)
78
+
79
+ elif isinstance(plugin, click.Command):
80
+ cli.add_command(plugin)
81
+
82
+ else:
83
+ raise TypeError(
84
+ f"Plugin {ep.name} inválido: deve ser um comando Click ou função register."
85
+ )
86
+
87
+
88
+ def load_plugins(cli: click.Group) -> None:
89
+ """
90
+ Carrega todos os plugins (internos e externos).
91
+
92
+ Args:
93
+ cli: grupo principal do Click.
94
+ """
95
+
96
+ load_internal_plugins(cli)
97
+ load_external_plugins(cli)
98
+
mtcli/plugin_loader.py CHANGED
@@ -8,8 +8,8 @@ Este módulo descobre e registra plugins de duas fontes:
8
8
 
9
9
  Plugins podem expor:
10
10
 
11
- função ``register(cli)``
12
- objeto ``click.Command``
11
+ função ``register(cli)``
12
+ objeto ``click.Command``
13
13
 
14
14
  Entry point exemplo:
15
15
 
@@ -78,8 +78,8 @@ def register_plugin(cli: click.Group, plugin, name: str) -> None:
78
78
 
79
79
  O plugin pode ser:
80
80
 
81
- função ``register(cli)``
82
- objeto ``click.Command``
81
+ função ``register(cli)``
82
+ objeto ``click.Command``
83
83
 
84
84
  Parameters
85
85
  ----------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mtcli
3
- Version: 3.7.0.dev3
3
+ Version: 3.7.0.dev5
4
4
  Summary: Aplicativo CLI para exibir gráficos do MetaTrader 5 screen reader friendly
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -28,7 +28,8 @@ mtcli/models/signals_model.py,sha256=XhyCErgyuHF0o85vnjIVJlgsCF7XFsWQltSbLZ3Aals
28
28
  mtcli/models/unconsecutive_bar_model.py,sha256=AiClcoyYnk3K6D1YkC0E2PRUhbGwsjdSnh1vIHZsIe8,2079
29
29
  mtcli/mt5_context.py,sha256=oLevCe4nYeZ6VtGoaO-j7U4xzACE09wGmX38P0oRg5A,2147
30
30
  mtcli/plugin.py,sha256=Wabbr22BVi32D-XNM7XS45bRdgKob7EKO6TuWtq9_ZM,414
31
- mtcli/plugin_loader.py,sha256=tuL2dVYvyJpat5qagG1j3lJhEJRgAhKcn6lspNZr67w,5295
31
+ mtcli/plugin_loader - Copia.py,sha256=8c0PPsKuOfacV2UgZkH6MmaipV7lXH4_GHrhmggP12g,2220
32
+ mtcli/plugin_loader.py,sha256=tjLDxxGEU_29WMWjmRwYKF1kaAvHsqd8NbueVtTnAdU,5283
32
33
  mtcli/plugin_manager.py,sha256=JTK6rmhjLa9MdyUiGgufAAnaaBhUI1Bm4g4t6p18WdU,555
33
34
  mtcli/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
35
  mtcli/plugins/exemplo.py-dist,sha256=q8H_sBpI-IZej9RvkCl2o_br9q2z_WXXn_qA1MRRbBo,538
@@ -65,8 +66,8 @@ mtcli/views/ranges_view.py,sha256=5gA2bAJuco-Xj964nsjs87tZ-079O7xKvaeif1UJ-PQ,12
65
66
  mtcli/views/rates_view.py,sha256=Jkdbg-Q_OVJuID-Q9HFUVICCF1jE82d-qfZWNm1JJ_4,1214
66
67
  mtcli/views/vars_view.py,sha256=Vpcej41qnZSvvSyvXYyW8W7CEFdqTxBd8NczV84XPJY,1635
67
68
  mtcli/views/volumes_view.py,sha256=d_6YxM0vA1revwoPwnwUjV19KcqnddVgdpBHTt5Vqms,1575
68
- mtcli-3.7.0.dev3.dist-info/entry_points.txt,sha256=sFL07BcOh-MKaij-M26bNlRbmlw9Xx0CTYTPtHegfI8,99
69
- mtcli-3.7.0.dev3.dist-info/licenses/LICENSE,sha256=Z-2ANeRgM9IjXnHeg9mA2gillM6eTQj8sIExAGNe2-8,1092
70
- mtcli-3.7.0.dev3.dist-info/METADATA,sha256=GFkl2N34O4Pj9I0P-ikGqTtkuDi48PW8L-K-jYQhG9M,3650
71
- mtcli-3.7.0.dev3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
72
- mtcli-3.7.0.dev3.dist-info/RECORD,,
69
+ mtcli-3.7.0.dev5.dist-info/entry_points.txt,sha256=sFL07BcOh-MKaij-M26bNlRbmlw9Xx0CTYTPtHegfI8,99
70
+ mtcli-3.7.0.dev5.dist-info/licenses/LICENSE,sha256=Z-2ANeRgM9IjXnHeg9mA2gillM6eTQj8sIExAGNe2-8,1092
71
+ mtcli-3.7.0.dev5.dist-info/METADATA,sha256=80GUTSdwxGX2vaql6enilI3MnUh_eJj81KbnpEg9FZQ,3650
72
+ mtcli-3.7.0.dev5.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
73
+ mtcli-3.7.0.dev5.dist-info/RECORD,,