Skip to content

Commit 6a1fc44

Browse files
Merge pull request #5 from davidbrochart/entrypoints
Improve jupyter_ydoc.ydocs
2 parents 402fabe + 619d7d1 commit 6a1fc44

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,17 @@ print(ydocs)
2121
Which is just a shortcut to:
2222

2323
```py
24-
import sys
25-
import jupyter_ydoc
24+
import pkg_resources
2625

27-
# See compatibility note on `group` keyword in https://docs.python.org/3/library/importlib.metadata.html#entry-points
28-
if sys.version_info < (3, 10):
29-
from importlib_metadata import entry_points
30-
else:
31-
from importlib.metadata import entry_points
32-
33-
ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}
26+
ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
3427
```
3528

3629
Or directly import them:
3730
```py
3831
from jupyter_ydoc import YFile, YNotebook
3932
```
4033

41-
The `jupyter_ydoc` entry point group can be populated with your own document, e.g. by adding the
34+
The `"jupyter_ydoc"` entry point group can be populated with your own documents, e.g. by adding the
4235
following to your package's `setup.cfg`:
4336

4437
```

jupyter_ydoc/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
import sys
1+
import pkg_resources
22

33
from .ydoc import YFile, YNotebook # noqa
44

5-
# See compatibility note on `group` keyword in
6-
# https://docs.python.org/3/library/importlib.metadata.html#entry-points
7-
if sys.version_info < (3, 10):
8-
from importlib_metadata import entry_points
9-
else:
10-
from importlib.metadata import entry_points
11-
12-
ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}
5+
ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
136

147
__version__ = "0.1.1"

0 commit comments

Comments
 (0)