From cf7ecd5e668093b7ade7f33be318291d815bc86e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 28 Aug 2018 10:27:06 +0530 Subject: [PATCH] Do not import fast_data_types at the top level of utility modules --- kitty/cli.py | 2 +- kitty/constants.py | 2 +- kitty/utils.py | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/kitty/cli.py b/kitty/cli.py index a39121122..0dee0c57e 100644 --- a/kitty/cli.py +++ b/kitty/cli.py @@ -9,7 +9,6 @@ from collections import deque from .conf.utils import resolve_config from .constants import appname, defconf, is_macos, is_wayland, str_version -from .fast_data_types import GLFW_KEY_UNKNOWN, glfw_get_key_name CONFIG_HELP = '''\ Specify a path to the configuration file(s) to use. All configuration files are @@ -641,6 +640,7 @@ def print_shortcut(key_sequence, action): names.append(name) if key: if is_native: + from .fast_data_types import GLFW_KEY_UNKNOWN, glfw_get_key_name names.append(glfw_get_key_name(GLFW_KEY_UNKNOWN, key)) else: names.append(krmap[key]) diff --git a/kitty/constants.py b/kitty/constants.py index 914d02e58..3abeab873 100644 --- a/kitty/constants.py +++ b/kitty/constants.py @@ -7,7 +7,6 @@ import pwd import sys from collections import namedtuple -from .fast_data_types import set_boss as set_c_boss appname = 'kitty' version = (0, 11, 3) @@ -94,6 +93,7 @@ def get_boss(): def set_boss(m): + from .fast_data_types import set_boss as set_c_boss get_boss.boss = m set_c_boss(m) diff --git a/kitty/utils.py b/kitty/utils.py index 3585811b8..e559f586e 100644 --- a/kitty/utils.py +++ b/kitty/utils.py @@ -15,16 +15,13 @@ from time import monotonic from .constants import ( appname, is_macos, is_wayland, supports_primary_selection ) -from .fast_data_types import ( - GLSL_VERSION, close_tty, log_error_string, open_tty, redirect_std_streams, - x11_display -) from .rgb import Color, to_color BASE = os.path.dirname(os.path.abspath(__file__)) def load_shaders(name): + from .fast_data_types import GLSL_VERSION vert = open(os.path.join(BASE, '{}_vertex.glsl'.format(name))).read().replace('GLSL_VERSION', str(GLSL_VERSION), 1) frag = open(os.path.join(BASE, '{}_fragment.glsl'.format(name))).read().replace('GLSL_VERSION', str(GLSL_VERSION), 1) return vert, frag @@ -38,6 +35,7 @@ def safe_print(*a, **k): def log_error(*a, **k): + from .fast_data_types import log_error_string try: msg = k.get('sep', ' ').join(map(str, a)) + k.get('end', '') log_error_string(msg.replace('\0', '')) @@ -180,6 +178,7 @@ def detach(fork=True, setsid=True, redirect=True): if setsid: os.setsid() if redirect: + from .fast_data_types import redirect_std_streams redirect_std_streams(os.devnull) @@ -195,6 +194,7 @@ def init_startup_notification_x11(window_handle, startup_id=None): sid = startup_id or os.environ.pop('DESKTOP_STARTUP_ID', None) # ensure child processes dont get this env var if not sid: return + from .fast_data_types import x11_display display = x11_display() if not display: return @@ -369,10 +369,12 @@ def write_all(fd, data): class TTYIO: def __enter__(self): + from .fast_data_types import open_tty self.tty_fd, self.original_termios = open_tty(True) return self def __exit__(self, *a): + from .fast_data_types import close_tty close_tty(self.tty_fd, self.original_termios) def send(self, data):