Skip to content

Commit

Permalink
Replace pkg_resources with importlib.metadata (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart authored Feb 18, 2024
1 parent 60ac235 commit d7d0119
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions plugins/cell/txl_cell/components.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import json
from functools import partial
from importlib.metadata import entry_points

import pkg_resources
from asphalt.core import Component, Context
from pycrdt import Doc, Map, MapEvent, Text
from rich.text import Text as RichText
Expand All @@ -12,7 +12,7 @@
from txl.base import Cell, CellFactory, Contents, Kernel, Widgets
from txl.text_input import TextInput

YDOCS = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="ypywidgets")}
YDOCS = {ep.name: ep.load() for ep in entry_points(group="ypywidgets")}


class Source(TextInput):
Expand Down
4 changes: 2 additions & 2 deletions plugins/console/txl_console/components.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from functools import partial
from importlib.metadata import entry_points
from typing import Any

import pkg_resources
from asphalt.core import Component, Context
from pycrdt import ArrayEvent, Doc
from textual.containers import VerticalScroll
Expand All @@ -11,7 +11,7 @@

from txl.base import CellFactory, Console, Kernels, Kernelspecs, Launcher, MainArea

ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}


class ConsoleMeta(type(Console), type(VerticalScroll)):
Expand Down
4 changes: 2 additions & 2 deletions plugins/local_contents/txl_local_contents/components.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import json
from importlib.metadata import entry_points
from os import scandir
from typing import List, Union

import pkg_resources
from anyio import Path
from asphalt.core import Component, Context
from pycrdt import Doc

from txl.base import Contents

ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}


class LocalContents(Contents):
Expand Down
4 changes: 2 additions & 2 deletions plugins/notebook_editor/txl_notebook_editor/components.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import asyncio
import json
from functools import partial
from importlib.metadata import entry_points
from typing import Any

import anyio
import pkg_resources
from asphalt.core import Component, Context
from httpx import AsyncClient
from textual.containers import VerticalScroll
Expand All @@ -24,7 +24,7 @@
MainArea,
)

ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}


class NotebookEditorMeta(type(Editor), type(VerticalScroll)):
Expand Down
4 changes: 2 additions & 2 deletions plugins/remote_contents/txl_remote_contents/components.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import asyncio
import json
from base64 import b64encode
from importlib.metadata import entry_points
from typing import Any, Dict, List, Optional, Union
from urllib import parse

import httpx
import pkg_resources
from asphalt.core import Component, Context
from httpx_ws import aconnect_ws
from pycrdt import Doc
from pycrdt_websocket import WebsocketProvider

from txl.base import Contents

ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}


class Websocket:
Expand Down
5 changes: 3 additions & 2 deletions plugins/widgets/txl_widgets/components.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pkg_resources
from importlib.metadata import entry_points

from asphalt.core import Component, Context
from pycrdt import TransactionEvent
from ypywidgets.utils import (
Expand All @@ -15,7 +16,7 @@
class _Widgets:
def __init__(self):
self.ydocs = {
ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="ypywidgets")
ep.name: ep.load() for ep in entry_points(group="ypywidgets")
}
self.widgets = {}

Expand Down
5 changes: 3 additions & 2 deletions txl/txl/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import pkg_resources
from importlib.metadata import entry_points

from asphalt.core import CLIApplicationComponent, Context
from asphalt.core.cli import run as asphalt_run
from textual.app import App

components = {
ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="txl.components")
ep.name: ep.load() for ep in entry_points(group="txl.components")
}

disabled = []
Expand Down

0 comments on commit d7d0119

Please sign in to comment.