robotcode-plugin 2.1.0__tar.gz → 2.2.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.4
2
2
  Name: robotcode-plugin
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Some classes for RobotCode plugin management
5
5
  Project-URL: Donate, https://opencollective.com/robotcode
6
6
  Project-URL: Documentation, https://github.com/robotcodedev/robotcode#readme
@@ -5,6 +5,7 @@ from contextlib import contextmanager
5
5
  from dataclasses import dataclass
6
6
  from enum import Enum, unique
7
7
  from pathlib import Path
8
+ from types import TracebackType
8
9
  from typing import (
9
10
  IO,
10
11
  Any,
@@ -14,6 +15,7 @@ from typing import (
14
15
  Iterator,
15
16
  Literal,
16
17
  Optional,
18
+ Protocol,
17
19
  Sequence,
18
20
  TypeVar,
19
21
  Union,
@@ -39,6 +41,7 @@ __all__ = [
39
41
 
40
42
  F = TypeVar("F", bound=Callable[..., Any])
41
43
  hookimpl = cast(Callable[[F], F], pluggy.HookimplMarker("robotcode"))
44
+ T = TypeVar("T")
42
45
 
43
46
 
44
47
  class UnknownError(click.ClickException):
@@ -83,6 +86,21 @@ class CommonConfig:
83
86
  log_calls: bool = False
84
87
 
85
88
 
89
+ class ProgressBar(Protocol[T]):
90
+ def __enter__(self) -> "ProgressBar[T]": ...
91
+
92
+ def __exit__(
93
+ self,
94
+ exc_type: type[BaseException] | None,
95
+ exc_value: BaseException | None,
96
+ tb: TracebackType | None,
97
+ ) -> None: ...
98
+
99
+ def __iter__(self) -> Iterator[T]: ...
100
+
101
+ def __next__(self) -> T: ...
102
+
103
+
86
104
  class Application:
87
105
  def __init__(self) -> None:
88
106
  self.config = CommonConfig()
@@ -121,6 +139,28 @@ class Application:
121
139
  fg="bright_black",
122
140
  )
123
141
 
142
+ def progressbar(
143
+ self,
144
+ iterable: Iterable[T],
145
+ length: int | None = None,
146
+ label: str | None = None,
147
+ hidden: bool = False,
148
+ show_eta: bool = True,
149
+ show_percent: bool | None = None,
150
+ show_pos: bool = True,
151
+ ) -> ProgressBar[T]:
152
+ return click.progressbar(
153
+ iterable,
154
+ length=length,
155
+ label=label,
156
+ hidden=not self.config.verbose or hidden,
157
+ show_eta=show_eta,
158
+ show_percent=show_percent,
159
+ show_pos=show_pos,
160
+ file=sys.stderr,
161
+ color=self.colored,
162
+ )
163
+
124
164
  def warning(
125
165
  self,
126
166
  message: Union[str, Callable[[], Any], None],
@@ -0,0 +1 @@
1
+ __version__ = "2.2.0"
@@ -1 +0,0 @@
1
- __version__ = "2.1.0"