boosted-magics 0.0.1__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.
- boosted_magics-0.0.1/PKG-INFO +94 -0
- boosted_magics-0.0.1/README.md +85 -0
- boosted_magics-0.0.1/boosted_magics.egg-info/PKG-INFO +94 -0
- boosted_magics-0.0.1/boosted_magics.egg-info/SOURCES.txt +7 -0
- boosted_magics-0.0.1/boosted_magics.egg-info/dependency_links.txt +1 -0
- boosted_magics-0.0.1/boosted_magics.egg-info/requires.txt +2 -0
- boosted_magics-0.0.1/boosted_magics.egg-info/top_level.txt +1 -0
- boosted_magics-0.0.1/pyproject.toml +17 -0
- boosted_magics-0.0.1/setup.cfg +4 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: boosted-magics
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Metakernel magics with TAB completion
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: metakernel>=1.0.0
|
|
8
|
+
Requires-Dist: statikomand>=0.1.1
|
|
9
|
+
|
|
10
|
+
# Boosted Magics
|
|
11
|
+
|
|
12
|
+
Python package that extends the magics of metakernel to provide TAB completion (complete_request messages) on arguments of the magic.
|
|
13
|
+
|
|
14
|
+
> Supports :
|
|
15
|
+
>
|
|
16
|
+
> - argument name completion
|
|
17
|
+
> - argument value completion, with custom `completer` function
|
|
18
|
+
> - parsing of magic command line with argparse
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install boosted-magics
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Creating a Boosted Magic
|
|
25
|
+
|
|
26
|
+
Boosted Magic subclasses Metakernel Magic, so the magic declaration is the same. To have argument completion, you have to replace @option decorator of Magic with a @boosted_option, as below :
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from boosted_magics import boosted_option, BoostedMagic
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ExampleMagic(BoostedMagic):
|
|
33
|
+
@boosted_option(
|
|
34
|
+
"--very_long_option",
|
|
35
|
+
"-o",
|
|
36
|
+
default=None,
|
|
37
|
+
help="This is a very long option name",
|
|
38
|
+
)
|
|
39
|
+
@boosted_option(
|
|
40
|
+
"--an_other_option_but_which_is_a_flag",
|
|
41
|
+
default=None,
|
|
42
|
+
action="store_true",
|
|
43
|
+
help="This is an other option",
|
|
44
|
+
)
|
|
45
|
+
@boosted_option(
|
|
46
|
+
"-a",
|
|
47
|
+
"--an_option_with_custom_completion_method",
|
|
48
|
+
help="An option with custom completion method",
|
|
49
|
+
completer=lambda w, r: ["customa1", "customa2"],
|
|
50
|
+
)
|
|
51
|
+
def line_example(
|
|
52
|
+
self,
|
|
53
|
+
very_long_option,
|
|
54
|
+
an_other_option_but_which_is_a_flag,
|
|
55
|
+
an_option_with_custom_completion_method,
|
|
56
|
+
):
|
|
57
|
+
"""
|
|
58
|
+
%example : try the boosted magic completion
|
|
59
|
+
"""
|
|
60
|
+
self.kernel: TestKernel
|
|
61
|
+
self.kernel.Print(
|
|
62
|
+
f"Example magic successfully called, with args :\n• very_long_option : {very_long_option}\n• an_other_option : {an_other_option_but_which_is_a_flag}\n• an_option_with_custom_completion_method : {an_option_with_custom_completion_method}"
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def register_magics(kernel) -> None:
|
|
67
|
+
kernel.register_magics(ExampleMagic)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The boosted_option uses [argparse](https://docs.python.org/3/library/argparse.html) under the hood for parsing (replacing optparse of metakernel), at command execution time. Hence, any parameter that you would give to an [argparse argument](https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument) will work for a boosted_option.
|
|
71
|
+
|
|
72
|
+
> This allows flags (`action='store_true'`), ...
|
|
73
|
+
|
|
74
|
+
For argument completion, boosted_magics uses statikomand, a custom package that mimics argparse mechanism for uncomplete commands. Completion is then proposed only for arguments that are not present on the command line.
|
|
75
|
+
|
|
76
|
+
You can create a custom completer function, that will be called just after you added the argument name (see example above). However, you will have to type at least the first letter of the argument value to get completion proposals.
|
|
77
|
+
|
|
78
|
+
## Troubleshooting
|
|
79
|
+
|
|
80
|
+
TAB completion for magic can be broken (some completion erase all line) with older metakernel versions (before 1.0.4). To fix it, install the 1.0.4 (or above) manually within the project that uses boosted-magics :
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uv add "metakernel @ git+https://github.com/Calysto/metakernel.git@afd3ddd"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
or without `uv`:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git clone https://github.com/Calysto/metakernel
|
|
90
|
+
cd metakernel
|
|
91
|
+
git checkout afd3ddd
|
|
92
|
+
pip install -e .
|
|
93
|
+
cd ..
|
|
94
|
+
```
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Boosted Magics
|
|
2
|
+
|
|
3
|
+
Python package that extends the magics of metakernel to provide TAB completion (complete_request messages) on arguments of the magic.
|
|
4
|
+
|
|
5
|
+
> Supports :
|
|
6
|
+
>
|
|
7
|
+
> - argument name completion
|
|
8
|
+
> - argument value completion, with custom `completer` function
|
|
9
|
+
> - parsing of magic command line with argparse
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install boosted-magics
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Creating a Boosted Magic
|
|
16
|
+
|
|
17
|
+
Boosted Magic subclasses Metakernel Magic, so the magic declaration is the same. To have argument completion, you have to replace @option decorator of Magic with a @boosted_option, as below :
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from boosted_magics import boosted_option, BoostedMagic
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ExampleMagic(BoostedMagic):
|
|
24
|
+
@boosted_option(
|
|
25
|
+
"--very_long_option",
|
|
26
|
+
"-o",
|
|
27
|
+
default=None,
|
|
28
|
+
help="This is a very long option name",
|
|
29
|
+
)
|
|
30
|
+
@boosted_option(
|
|
31
|
+
"--an_other_option_but_which_is_a_flag",
|
|
32
|
+
default=None,
|
|
33
|
+
action="store_true",
|
|
34
|
+
help="This is an other option",
|
|
35
|
+
)
|
|
36
|
+
@boosted_option(
|
|
37
|
+
"-a",
|
|
38
|
+
"--an_option_with_custom_completion_method",
|
|
39
|
+
help="An option with custom completion method",
|
|
40
|
+
completer=lambda w, r: ["customa1", "customa2"],
|
|
41
|
+
)
|
|
42
|
+
def line_example(
|
|
43
|
+
self,
|
|
44
|
+
very_long_option,
|
|
45
|
+
an_other_option_but_which_is_a_flag,
|
|
46
|
+
an_option_with_custom_completion_method,
|
|
47
|
+
):
|
|
48
|
+
"""
|
|
49
|
+
%example : try the boosted magic completion
|
|
50
|
+
"""
|
|
51
|
+
self.kernel: TestKernel
|
|
52
|
+
self.kernel.Print(
|
|
53
|
+
f"Example magic successfully called, with args :\n• very_long_option : {very_long_option}\n• an_other_option : {an_other_option_but_which_is_a_flag}\n• an_option_with_custom_completion_method : {an_option_with_custom_completion_method}"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def register_magics(kernel) -> None:
|
|
58
|
+
kernel.register_magics(ExampleMagic)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The boosted_option uses [argparse](https://docs.python.org/3/library/argparse.html) under the hood for parsing (replacing optparse of metakernel), at command execution time. Hence, any parameter that you would give to an [argparse argument](https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument) will work for a boosted_option.
|
|
62
|
+
|
|
63
|
+
> This allows flags (`action='store_true'`), ...
|
|
64
|
+
|
|
65
|
+
For argument completion, boosted_magics uses statikomand, a custom package that mimics argparse mechanism for uncomplete commands. Completion is then proposed only for arguments that are not present on the command line.
|
|
66
|
+
|
|
67
|
+
You can create a custom completer function, that will be called just after you added the argument name (see example above). However, you will have to type at least the first letter of the argument value to get completion proposals.
|
|
68
|
+
|
|
69
|
+
## Troubleshooting
|
|
70
|
+
|
|
71
|
+
TAB completion for magic can be broken (some completion erase all line) with older metakernel versions (before 1.0.4). To fix it, install the 1.0.4 (or above) manually within the project that uses boosted-magics :
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
uv add "metakernel @ git+https://github.com/Calysto/metakernel.git@afd3ddd"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
or without `uv`:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git clone https://github.com/Calysto/metakernel
|
|
81
|
+
cd metakernel
|
|
82
|
+
git checkout afd3ddd
|
|
83
|
+
pip install -e .
|
|
84
|
+
cd ..
|
|
85
|
+
```
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: boosted-magics
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Metakernel magics with TAB completion
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: metakernel>=1.0.0
|
|
8
|
+
Requires-Dist: statikomand>=0.1.1
|
|
9
|
+
|
|
10
|
+
# Boosted Magics
|
|
11
|
+
|
|
12
|
+
Python package that extends the magics of metakernel to provide TAB completion (complete_request messages) on arguments of the magic.
|
|
13
|
+
|
|
14
|
+
> Supports :
|
|
15
|
+
>
|
|
16
|
+
> - argument name completion
|
|
17
|
+
> - argument value completion, with custom `completer` function
|
|
18
|
+
> - parsing of magic command line with argparse
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install boosted-magics
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Creating a Boosted Magic
|
|
25
|
+
|
|
26
|
+
Boosted Magic subclasses Metakernel Magic, so the magic declaration is the same. To have argument completion, you have to replace @option decorator of Magic with a @boosted_option, as below :
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from boosted_magics import boosted_option, BoostedMagic
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ExampleMagic(BoostedMagic):
|
|
33
|
+
@boosted_option(
|
|
34
|
+
"--very_long_option",
|
|
35
|
+
"-o",
|
|
36
|
+
default=None,
|
|
37
|
+
help="This is a very long option name",
|
|
38
|
+
)
|
|
39
|
+
@boosted_option(
|
|
40
|
+
"--an_other_option_but_which_is_a_flag",
|
|
41
|
+
default=None,
|
|
42
|
+
action="store_true",
|
|
43
|
+
help="This is an other option",
|
|
44
|
+
)
|
|
45
|
+
@boosted_option(
|
|
46
|
+
"-a",
|
|
47
|
+
"--an_option_with_custom_completion_method",
|
|
48
|
+
help="An option with custom completion method",
|
|
49
|
+
completer=lambda w, r: ["customa1", "customa2"],
|
|
50
|
+
)
|
|
51
|
+
def line_example(
|
|
52
|
+
self,
|
|
53
|
+
very_long_option,
|
|
54
|
+
an_other_option_but_which_is_a_flag,
|
|
55
|
+
an_option_with_custom_completion_method,
|
|
56
|
+
):
|
|
57
|
+
"""
|
|
58
|
+
%example : try the boosted magic completion
|
|
59
|
+
"""
|
|
60
|
+
self.kernel: TestKernel
|
|
61
|
+
self.kernel.Print(
|
|
62
|
+
f"Example magic successfully called, with args :\n• very_long_option : {very_long_option}\n• an_other_option : {an_other_option_but_which_is_a_flag}\n• an_option_with_custom_completion_method : {an_option_with_custom_completion_method}"
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def register_magics(kernel) -> None:
|
|
67
|
+
kernel.register_magics(ExampleMagic)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The boosted_option uses [argparse](https://docs.python.org/3/library/argparse.html) under the hood for parsing (replacing optparse of metakernel), at command execution time. Hence, any parameter that you would give to an [argparse argument](https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument) will work for a boosted_option.
|
|
71
|
+
|
|
72
|
+
> This allows flags (`action='store_true'`), ...
|
|
73
|
+
|
|
74
|
+
For argument completion, boosted_magics uses statikomand, a custom package that mimics argparse mechanism for uncomplete commands. Completion is then proposed only for arguments that are not present on the command line.
|
|
75
|
+
|
|
76
|
+
You can create a custom completer function, that will be called just after you added the argument name (see example above). However, you will have to type at least the first letter of the argument value to get completion proposals.
|
|
77
|
+
|
|
78
|
+
## Troubleshooting
|
|
79
|
+
|
|
80
|
+
TAB completion for magic can be broken (some completion erase all line) with older metakernel versions (before 1.0.4). To fix it, install the 1.0.4 (or above) manually within the project that uses boosted-magics :
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uv add "metakernel @ git+https://github.com/Calysto/metakernel.git@afd3ddd"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
or without `uv`:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git clone https://github.com/Calysto/metakernel
|
|
90
|
+
cd metakernel
|
|
91
|
+
git checkout afd3ddd
|
|
92
|
+
pip install -e .
|
|
93
|
+
cd ..
|
|
94
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "boosted-magics"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Metakernel magics with TAB completion"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = ["metakernel>=1.0.0", "statikomand>=0.1.1"]
|
|
8
|
+
|
|
9
|
+
[tool.setuptools.packages.find]
|
|
10
|
+
include = ["./boosted_magics"]
|
|
11
|
+
|
|
12
|
+
[dependency-groups]
|
|
13
|
+
dev = ["jupyter-console>=6.6.3"]
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["setuptools>=61.0"]
|
|
17
|
+
build-backend = "setuptools.build_meta"
|