Switch to Python3 importlib
This commit is contained in:
parent
cd2735fa24
commit
c99687cc80
@ -24,7 +24,7 @@ import os
|
|||||||
from decouple import config
|
from decouple import config
|
||||||
import subprocess
|
import subprocess
|
||||||
import click
|
import click
|
||||||
import pkg_resources
|
import importlib
|
||||||
from .util import include_exclude_check
|
from .util import include_exclude_check
|
||||||
|
|
||||||
# TODO: find a place for this
|
# TODO: find a place for this
|
||||||
@ -58,8 +58,10 @@ def command(ctx, include, exclude):
|
|||||||
if not os.path.isdir(dev_root_path):
|
if not os.path.isdir(dev_root_path):
|
||||||
print('Dev root directory doesn\'t exist, creating')
|
print('Dev root directory doesn\'t exist, creating')
|
||||||
|
|
||||||
with pkg_resources.resource_stream(__name__, "data/container-image-list.txt") as container_list_file:
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
containers = container_list_file.read().decode().splitlines()
|
from . import data
|
||||||
|
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
||||||
|
containers = container_list_file.read().splitlines()
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f'Containers: {containers}')
|
print(f'Containers: {containers}')
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
import os
|
import os
|
||||||
from decouple import config
|
from decouple import config
|
||||||
import click
|
import click
|
||||||
import pkg_resources
|
import importlib
|
||||||
from python_on_whales import docker
|
from python_on_whales import docker
|
||||||
from .util import include_exclude_check
|
from .util import include_exclude_check
|
||||||
|
|
||||||
@ -50,8 +50,10 @@ def command(ctx, include, exclude):
|
|||||||
if not os.path.isdir(dev_root_path):
|
if not os.path.isdir(dev_root_path):
|
||||||
print('Dev root directory doesn\'t exist, creating')
|
print('Dev root directory doesn\'t exist, creating')
|
||||||
|
|
||||||
with pkg_resources.resource_stream(__name__, "data/npm-package-list.txt") as package_list_file:
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
packages = package_list_file.read().decode().splitlines()
|
from . import data
|
||||||
|
with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file:
|
||||||
|
packages = package_list_file.read().splitlines()
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f'Packages: {packages}')
|
print(f'Packages: {packages}')
|
||||||
|
0
app/data/__init__.py
Normal file
0
app/data/__init__.py
Normal file
@ -20,7 +20,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from python_on_whales import DockerClient
|
from python_on_whales import DockerClient
|
||||||
import click
|
import click
|
||||||
import pkg_resources
|
import importlib
|
||||||
from .util import include_exclude_check
|
from .util import include_exclude_check
|
||||||
|
|
||||||
|
|
||||||
@ -49,8 +49,10 @@ def command(ctx, include, exclude, cluster, command, services):
|
|||||||
if verbose:
|
if verbose:
|
||||||
print(f"Using cluster name: {cluster}")
|
print(f"Using cluster name: {cluster}")
|
||||||
|
|
||||||
with pkg_resources.resource_stream(__name__, "data/pod-list.txt") as pod_list_file:
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
pods = pod_list_file.read().decode().splitlines()
|
from . import data
|
||||||
|
with importlib.resources.open_text(data, "pod-list.txt") as pod_list_file:
|
||||||
|
pods = pod_list_file.read().splitlines()
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Pods: {pods}")
|
print(f"Pods: {pods}")
|
||||||
|
@ -22,7 +22,7 @@ from decouple import config
|
|||||||
import git
|
import git
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
import click
|
import click
|
||||||
import pkg_resources
|
import importlib
|
||||||
from .util import include_exclude_check
|
from .util import include_exclude_check
|
||||||
|
|
||||||
|
|
||||||
@ -91,8 +91,10 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches_file):
|
|||||||
print('Dev root directory doesn\'t exist, creating')
|
print('Dev root directory doesn\'t exist, creating')
|
||||||
os.makedirs(dev_root_path)
|
os.makedirs(dev_root_path)
|
||||||
|
|
||||||
with pkg_resources.resource_stream(__name__, "data/repository-list.txt") as repository_list_file:
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
all_repos = repository_list_file.read().decode().splitlines()
|
from . import data
|
||||||
|
with importlib.resources.open_text(data, "repository-list.txt") as repository_list_file:
|
||||||
|
all_repos = repository_list_file.read().splitlines()
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print(f"Repos: {all_repos}")
|
print(f"Repos: {all_repos}")
|
||||||
|
Loading…
Reference in New Issue
Block a user