robotcode-plugin 0.99.0__tar.gz → 0.100.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.3
2
2
  Name: robotcode-plugin
3
- Version: 0.99.0
3
+ Version: 0.100.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
@@ -1,5 +1,6 @@
1
1
  import dataclasses
2
2
  import sys
3
+ from contextlib import contextmanager
3
4
  from dataclasses import dataclass
4
5
  from enum import Enum, unique
5
6
  from pathlib import Path
@@ -9,6 +10,8 @@ from typing import (
9
10
  AnyStr,
10
11
  Callable,
11
12
  Iterable,
13
+ Iterator,
14
+ Literal,
12
15
  Optional,
13
16
  Sequence,
14
17
  TypeVar,
@@ -20,16 +23,17 @@ import click
20
23
  import pluggy
21
24
  import tomli_w
22
25
 
26
+ from robotcode.core.utils.contextlib import chdir
23
27
  from robotcode.core.utils.dataclasses import as_dict, as_json
24
28
 
25
29
  __all__ = [
26
- "hookimpl",
27
- "CommonConfig",
28
- "pass_application",
29
30
  "Application",
30
- "UnknownError",
31
- "OutputFormat",
32
31
  "ColoredOutput",
32
+ "CommonConfig",
33
+ "OutputFormat",
34
+ "UnknownError",
35
+ "hookimpl",
36
+ "pass_application",
33
37
  ]
34
38
 
35
39
  F = TypeVar("F", bound=Callable[..., Any])
@@ -292,5 +296,18 @@ class Application:
292
296
  self.verbose(f"Exit with code {code}")
293
297
  sys.exit(code)
294
298
 
299
+ @contextmanager
300
+ def chdir(self, path: Union[str, Path, None]) -> Iterator[Optional[Path]]:
301
+ with chdir(path, self.verbose) as result:
302
+ yield result
303
+
304
+ @contextmanager
305
+ def save_syspath(self) -> Iterator[Literal[None]]:
306
+ self._syspath = sys.path[:]
307
+ try:
308
+ yield None
309
+ finally:
310
+ sys.path = self._syspath
311
+
295
312
 
296
313
  pass_application = click.make_pass_decorator(Application, ensure=True)
@@ -0,0 +1 @@
1
+ __version__ = "0.100.0"
@@ -1 +0,0 @@
1
- __version__ = "0.99.0"