shell: remove module level imports

This commit is contained in:
RhodeCode Admin 2024-04-22 14:54:33 +02:00
parent 70a5f44578
commit 12af6697b8
2 changed files with 14 additions and 3 deletions

View file

@ -54,8 +54,13 @@ class Command(BasePasterCommand):
parser = BasePasterCommand.standard_parser(verbose=True)
summary = "Interactive shell"
def import_all_from_module(self, module_name):
import importlib
module = importlib.import_module(module_name)
globals().update({k: v for k, v in module.__dict__.items() if not k.startswith('_')})
def command(self):
#get SqlAlchemy session
# get SqlAlchemy session
self._init_session()
# imports, used in ipython shell
@ -64,7 +69,7 @@ class Command(BasePasterCommand):
import time
import shutil
import datetime
from rhodecode.model.db import *
self.import_all_from_module('rhodecode.model.db')
try:
from IPython import embed

View file

@ -41,6 +41,12 @@ or reset some user/system settings.
"""
def import_all_from_module(module_name):
import importlib
module = importlib.import_module(module_name)
globals().update({k: v for k, v in module.__dict__.items() if not k.startswith('_')})
def ipython_shell_runner(env, help):
# imports, used in ipython shell
@ -50,7 +56,7 @@ def ipython_shell_runner(env, help):
import shutil
import datetime
from rhodecode.model import user, user_group, repo, repo_group
from rhodecode.model.db import *
import_all_from_module('rhodecode.model.db')
try:
import IPython