Skip to content

Commit

Permalink
extra lines was commented
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Aug 5, 2023
1 parent 820fe4b commit d6a9cf8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
26 changes: 2 additions & 24 deletions installed/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
import os
import sys
import builtins
import importlib
import inspect
from contextlib import contextmanager
from tempfile import TemporaryDirectory
from threading import RLock
from threading import Lock

import installed
from installed.cli.parsing_comments.get_options_from_comments import get_options_from_comments
from installed.cli.parsing_arguments.get_arguments import get_arguments


def print(text):
with open(os.path.join("tests", "cli", "data", "test.log"), 'a') as file:
file.write(f'({text})')

def start():
arguments = get_arguments()

with installed() as context:
lock = RLock()
lock = Lock()
old_import = builtins.__import__
locations = {}

Expand All @@ -31,7 +26,6 @@ def set_import():
builtins.__import__ = import_wrapper

def get_current_context(where):
print('KEK LOL 1')
if where is None:
return context

Expand All @@ -47,7 +41,6 @@ def get_current_context(where):
return local_context

def import_wrapper(name, *args, **kwargs):
print(f'KEK 1 {name}')
splitted_name = name.split('.')
base_name = splitted_name[0]
base_sequence = '.'.join(splitted_name[:-1])
Expand All @@ -63,39 +56,24 @@ def import_wrapper(name, *args, **kwargs):

current_context = get_current_context(options.pop('where', None))

print('KEK 2')
with lock:
print('KEK 3')
with set_import():
print('KEK 4')
try:
print('KEK 5')
result = __import__(name, *args, **kwargs)
print(f'KEK 6 {name}')
except (ModuleNotFoundError, ImportError) as e:
print(f'KEK 7 {e}')
current_context.install(package_name)
result = current_context.import_here(base_name)
sys.modules[base_name] = result

print('KEK 8')
if 'fromlist' in kwargs and kwargs['fromlist']:
print('KEK 8.1')
if len(splitted_name) > 1:
print('KEK 8.2')
for index, subname in enumerate(splitted_name):
print('KEK 8.3')
if index:
print('KEK 8.4')
try:
print('KEK 8.5')
result = getattr(result, subname)
print('KEK 8.6')
except AttributeError:
print('KEK 8.7')
raise ImportError(f"cannot import name '{last_name}' from '{base_sequence}'")

print('KEK 9')
return result

builtins.__import__ = import_wrapper
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/data/test.log
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(step 0)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_odd')(KEK 8)(KEK 9)(step 1)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_even')(KEK 8)(KEK 9)(step 2)(step 3)(step 4)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(step 0)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_odd')(KEK 8)(KEK 9)(step 1)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_even')(KEK 8)(KEK 9)(step 2)(step 3)(step 4)(KEK 1 _io)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(KEK 1 _io)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(step 0)(KEK 1 is_odd)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_odd')(KEK 8)(KEK 9)(step 1)(KEK 1 is_even)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_even')(KEK 8)(KEK 9)(step 2)(step 3)(step 4)
(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(step 0)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_odd')(KEK 8)(KEK 9)(step 1)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_even')(KEK 8)(KEK 9)(step 2)(step 3)(step 4)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(step 0)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_odd')(KEK 8)(KEK 9)(step 1)(KEK 1)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_even')(KEK 8)(KEK 9)(step 2)(step 3)(step 4)(KEK 1 _io)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(KEK 1 _io)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(step 0)(KEK 1 is_odd)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_odd')(KEK 8)(KEK 9)(step 1)(KEK 1 is_even)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_even')(KEK 8)(KEK 9)(step 2)(step 3)(step 4)(KEK 1 _io)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(KEK 1 _io)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 6 _io)(KEK 8)(KEK 9)(KEK 1 is_odd)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_odd')(KEK 8)(KEK 9)(KEK 1 is_even)(KEK LOL 1)(KEK 2)(KEK 3)(KEK 4)(KEK 5)(KEK 7 No module named 'is_even')(KEK 8)(KEK 9)

0 comments on commit d6a9cf8

Please sign in to comment.