1from info import POSITION as Х
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
Георги Кунчев
21.11.2024 18:45Заради 100-те решения, които качи, а и заради изключително хитрото ти финално решение, за което не се бях сетил, давам бонус точка.
|
t | 1 | import os | t | 1 | from info import POSITION as Х |
2 | |||||
3 | def get_directory_tree(root_dir): | ||||
4 | tree = [] | ||||
5 | for root, dirs, files in os.walk(root_dir): | ||||
6 | level = root.replace(root_dir, '').count(os.sep) | ||||
7 | indent = ' ' * 4 * level | ||||
8 | tree.append(f"{indent}{os.path.basename(root)}/") | ||||
9 | for file in files: | ||||
10 | tree.append(f"{indent} {file}") | ||||
11 | return '\n'.join(tree) | ||||
12 | |||||
13 | directory_tree = get_directory_tree('.') | ||||
14 | |||||
15 | output = f"Directory tree:\n{directory_tree}" | ||||
16 | |||||
17 | raise Exception(output) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
n | 1 | Х = 4 | n | ||
2 | |||||
3 | |||||
4 | import os | 1 | import os | ||
5 | 2 | ||||
n | 6 | files_in_current_directory = os.listdir('.') | n | 3 | def get_directory_tree(root_dir): |
7 | current_directory_files_str = ', '.join(files_in_current_directory) | 4 | tree = [] | ||
5 | for root, dirs, files in os.walk(root_dir): | ||||
6 | level = root.replace(root_dir, '').count(os.sep) | ||||
7 | indent = ' ' * 4 * level | ||||
8 | tree.append(f"{indent}{os.path.basename(root)}/") | ||||
9 | for file in files: | ||||
10 | tree.append(f"{indent} {file}") | ||||
11 | return '\n'.join(tree) | ||||
8 | 12 | ||||
t | 9 | output = f"Files in current directory: {current_directory_files_str}" | t | 13 | directory_tree = get_directory_tree('.') |
14 | |||||
15 | output = f"Directory tree:\n{directory_tree}" | ||||
10 | 16 | ||||
11 | raise Exception(output) | 17 | raise Exception(output) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
n | n | 1 | Х = 4 | ||
1 | 2 | ||||
2 | 3 | ||||
3 | import os | 4 | import os | ||
n | 4 | def find_info_py(root_dir='.'): | n | ||
5 | res = "" | ||||
6 | for dirpath, _, filenames in os.walk(root_dir): | ||||
7 | res += (f"Checking directory: {dirpath}") | ||||
8 | if 'info.py' in filenames: | ||||
9 | res += (f"Found info.py in: {dirpath}") | ||||
10 | return res += os.path.join(dirpath, 'info.py') | ||||
11 | return None | ||||
12 | 5 | ||||
n | 13 | info_py_path = find_info_py() | n | 6 | files_in_current_directory = os.listdir('.') |
7 | current_directory_files_str = ', '.join(files_in_current_directory) | ||||
14 | 8 | ||||
n | 15 | raise Exception(f"RESULT: ${info_py_path}") | n | 9 | output = f"Files in current directory: {current_directory_files_str}" |
16 | 10 | ||||
t | t | 11 | raise Exception(output) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | f | 1 | ||
2 | 2 | ||||
3 | import os | 3 | import os | ||
4 | def find_info_py(root_dir='.'): | 4 | def find_info_py(root_dir='.'): | ||
5 | res = "" | 5 | res = "" | ||
6 | for dirpath, _, filenames in os.walk(root_dir): | 6 | for dirpath, _, filenames in os.walk(root_dir): | ||
7 | res += (f"Checking directory: {dirpath}") | 7 | res += (f"Checking directory: {dirpath}") | ||
8 | if 'info.py' in filenames: | 8 | if 'info.py' in filenames: | ||
9 | res += (f"Found info.py in: {dirpath}") | 9 | res += (f"Found info.py in: {dirpath}") | ||
10 | return res += os.path.join(dirpath, 'info.py') | 10 | return res += os.path.join(dirpath, 'info.py') | ||
11 | return None | 11 | return None | ||
12 | 12 | ||||
13 | info_py_path = find_info_py() | 13 | info_py_path = find_info_py() | ||
14 | 14 | ||||
n | 15 | raise Exception(res) | n | 15 | raise Exception(f"RESULT: ${info_py_path}") |
16 | 16 | ||||
t | 17 | if info_py_path: | t | ||
18 | raise Exception(f"Found info.py at: {info_py_path}") | ||||
19 | else: | ||||
20 | raise Exception("info.py not found in the current directory or subdirectories.") | ||||
21 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | f | 1 | ||
2 | 2 | ||||
3 | import os | 3 | import os | ||
n | 4 | res = "" | n | ||
5 | def find_info_py(root_dir='.'): | 4 | def find_info_py(root_dir='.'): | ||
n | n | 5 | res = "" | ||
6 | for dirpath, _, filenames in os.walk(root_dir): | 6 | for dirpath, _, filenames in os.walk(root_dir): | ||
n | 7 | res += (f"Checking directory: {dirpath}") # Debug print to see the current directory being checked | n | 7 | res += (f"Checking directory: {dirpath}") |
8 | if 'info.py' in filenames: | 8 | if 'info.py' in filenames: | ||
t | 9 | res += (f"Found info.py in: {dirpath}") # Debug print to show where it's found | t | 9 | res += (f"Found info.py in: {dirpath}") |
10 | return os.path.join(dirpath, 'info.py') | 10 | return res += os.path.join(dirpath, 'info.py') | ||
11 | return None | 11 | return None | ||
12 | 12 | ||||
13 | info_py_path = find_info_py() | 13 | info_py_path = find_info_py() | ||
14 | 14 | ||||
15 | raise Exception(res) | 15 | raise Exception(res) | ||
16 | 16 | ||||
17 | if info_py_path: | 17 | if info_py_path: | ||
18 | raise Exception(f"Found info.py at: {info_py_path}") | 18 | raise Exception(f"Found info.py at: {info_py_path}") | ||
19 | else: | 19 | else: | ||
20 | raise Exception("info.py not found in the current directory or subdirectories.") | 20 | raise Exception("info.py not found in the current directory or subdirectories.") | ||
21 | 21 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
t | 1 | import os | t | ||
2 | |||||
3 | def find_info_py(root_dir='.'): | ||||
4 | for dirpath, _, filenames in os.walk(root_dir): | ||||
5 | if 'info.py' in filenames: | ||||
6 | return os.path.join(dirpath, 'info.py') | ||||
7 | return None | ||||
8 | |||||
9 | info_py_path = find_info_py() | ||||
10 | |||||
11 | if info_py_path: | ||||
12 | raise Exception(f"Found info.py at: {info_py_path}") | ||||
13 | else: | ||||
14 | raise Exception("info.py not found in the current directory or subdirectories.") | ||||
15 | 1 | ||||
16 | 2 | ||||
17 | import os | 3 | import os | ||
18 | res = "" | 4 | res = "" | ||
19 | def find_info_py(root_dir='.'): | 5 | def find_info_py(root_dir='.'): | ||
20 | for dirpath, _, filenames in os.walk(root_dir): | 6 | for dirpath, _, filenames in os.walk(root_dir): | ||
21 | res += (f"Checking directory: {dirpath}") # Debug print to see the current directory being checked | 7 | res += (f"Checking directory: {dirpath}") # Debug print to see the current directory being checked | ||
22 | if 'info.py' in filenames: | 8 | if 'info.py' in filenames: | ||
23 | res += (f"Found info.py in: {dirpath}") # Debug print to show where it's found | 9 | res += (f"Found info.py in: {dirpath}") # Debug print to show where it's found | ||
24 | return os.path.join(dirpath, 'info.py') | 10 | return os.path.join(dirpath, 'info.py') | ||
25 | return None | 11 | return None | ||
26 | 12 | ||||
27 | info_py_path = find_info_py() | 13 | info_py_path = find_info_py() | ||
28 | 14 | ||||
29 | raise Exception(res) | 15 | raise Exception(res) | ||
30 | 16 | ||||
31 | if info_py_path: | 17 | if info_py_path: | ||
32 | raise Exception(f"Found info.py at: {info_py_path}") | 18 | raise Exception(f"Found info.py at: {info_py_path}") | ||
33 | else: | 19 | else: | ||
34 | raise Exception("info.py not found in the current directory or subdirectories.") | 20 | raise Exception("info.py not found in the current directory or subdirectories.") | ||
35 | 21 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | import os | f | 1 | import os |
2 | 2 | ||||
3 | def find_info_py(root_dir='.'): | 3 | def find_info_py(root_dir='.'): | ||
4 | for dirpath, _, filenames in os.walk(root_dir): | 4 | for dirpath, _, filenames in os.walk(root_dir): | ||
5 | if 'info.py' in filenames: | 5 | if 'info.py' in filenames: | ||
6 | return os.path.join(dirpath, 'info.py') | 6 | return os.path.join(dirpath, 'info.py') | ||
7 | return None | 7 | return None | ||
8 | 8 | ||||
9 | info_py_path = find_info_py() | 9 | info_py_path = find_info_py() | ||
10 | 10 | ||||
11 | if info_py_path: | 11 | if info_py_path: | ||
12 | raise Exception(f"Found info.py at: {info_py_path}") | 12 | raise Exception(f"Found info.py at: {info_py_path}") | ||
13 | else: | 13 | else: | ||
14 | raise Exception("info.py not found in the current directory or subdirectories.") | 14 | raise Exception("info.py not found in the current directory or subdirectories.") | ||
15 | 15 | ||||
t | t | 16 | |||
17 | import os | ||||
18 | res = "" | ||||
19 | def find_info_py(root_dir='.'): | ||||
20 | for dirpath, _, filenames in os.walk(root_dir): | ||||
21 | res += (f"Checking directory: {dirpath}") # Debug print to see the current directory being checked | ||||
22 | if 'info.py' in filenames: | ||||
23 | res += (f"Found info.py in: {dirpath}") # Debug print to show where it's found | ||||
24 | return os.path.join(dirpath, 'info.py') | ||||
25 | return None | ||||
26 | |||||
27 | info_py_path = find_info_py() | ||||
28 | |||||
29 | raise Exception(res) | ||||
30 | |||||
31 | if info_py_path: | ||||
32 | raise Exception(f"Found info.py at: {info_py_path}") | ||||
33 | else: | ||||
34 | raise Exception("info.py not found in the current directory or subdirectories.") | ||||
35 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
n | 1 | Х = 4 | n | ||
2 | |||||
3 | |||||
4 | import os | 1 | import os | ||
5 | 2 | ||||
n | 6 | files_in_current_directory = os.listdir('./tmp') | n | 3 | def find_info_py(root_dir='.'): |
7 | current_directory_files_str = ', '.join(files_in_current_directory) | 4 | for dirpath, _, filenames in os.walk(root_dir): | ||
5 | if 'info.py' in filenames: | ||||
6 | return os.path.join(dirpath, 'info.py') | ||||
7 | return None | ||||
8 | 8 | ||||
n | 9 | output = f"Files in current directory: {current_directory_files_str}" | n | 9 | info_py_path = find_info_py() |
10 | 10 | ||||
t | 11 | raise Exception(output) | t | 11 | if info_py_path: |
12 | raise Exception(f"Found info.py at: {info_py_path}") | ||||
13 | else: | ||||
14 | raise Exception("info.py not found in the current directory or subdirectories.") | ||||
15 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
n | 1 | import unittest | n | 1 | Х = 4 |
2 | from info import POSITION | ||||
3 | Х = POSITION | ||||
4 | #import info | ||||
5 | 2 | ||||
n | 6 | # raise Exception(str(info.POSITION)) | n | ||
7 | 3 | ||||
n | 8 | #import os | n | 4 | import os |
9 | 5 | ||||
n | 10 | # files_in_current_directory = os.listdir('./tmp') | n | 6 | files_in_current_directory = os.listdir('./tmp') |
11 | # current_directory_files_str = ', '.join(files_in_current_directory) | 7 | current_directory_files_str = ', '.join(files_in_current_directory) | ||
12 | 8 | ||||
n | 13 | #output = f"Files in current directory: {current_directory_files_str}" | n | 9 | output = f"Files in current directory: {current_directory_files_str}" |
14 | 10 | ||||
t | 15 | # raise Exception(output) | t | 11 | raise Exception(output) |
16 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
t | 1 | Х = 42 | t | 1 | import unittest |
2 | from info import POSITION | ||||
3 | Х = POSITION | ||||
2 | #import info | 4 | #import info | ||
3 | 5 | ||||
4 | # raise Exception(str(info.POSITION)) | 6 | # raise Exception(str(info.POSITION)) | ||
5 | 7 | ||||
6 | #import os | 8 | #import os | ||
7 | 9 | ||||
8 | # files_in_current_directory = os.listdir('./tmp') | 10 | # files_in_current_directory = os.listdir('./tmp') | ||
9 | # current_directory_files_str = ', '.join(files_in_current_directory) | 11 | # current_directory_files_str = ', '.join(files_in_current_directory) | ||
10 | 12 | ||||
11 | #output = f"Files in current directory: {current_directory_files_str}" | 13 | #output = f"Files in current directory: {current_directory_files_str}" | ||
12 | 14 | ||||
13 | # raise Exception(output) | 15 | # raise Exception(output) | ||
14 | 16 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
t | 1 | X = 42 | t | 1 | Х = 42 |
2 | #import info | 2 | #import info | ||
3 | 3 | ||||
4 | # raise Exception(str(info.POSITION)) | 4 | # raise Exception(str(info.POSITION)) | ||
5 | 5 | ||||
6 | #import os | 6 | #import os | ||
7 | 7 | ||||
8 | # files_in_current_directory = os.listdir('./tmp') | 8 | # files_in_current_directory = os.listdir('./tmp') | ||
9 | # current_directory_files_str = ', '.join(files_in_current_directory) | 9 | # current_directory_files_str = ', '.join(files_in_current_directory) | ||
10 | 10 | ||||
11 | #output = f"Files in current directory: {current_directory_files_str}" | 11 | #output = f"Files in current directory: {current_directory_files_str}" | ||
12 | 12 | ||||
13 | # raise Exception(output) | 13 | # raise Exception(output) | ||
14 | 14 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | X = 42 | f | 1 | X = 42 |
n | 2 | import info | n | 2 | #import info |
3 | 3 | ||||
n | 4 | raise Exception(str(info.POSITION)) | n | 4 | # raise Exception(str(info.POSITION)) |
5 | 5 | ||||
n | 6 | import os | n | 6 | #import os |
7 | 7 | ||||
n | 8 | files_in_current_directory = os.listdir('./tmp') | n | 8 | # files_in_current_directory = os.listdir('./tmp') |
9 | current_directory_files_str = ', '.join(files_in_current_directory) | 9 | # current_directory_files_str = ', '.join(files_in_current_directory) | ||
10 | 10 | ||||
n | 11 | output = f"Files in current directory: {current_directory_files_str}" | n | 11 | #output = f"Files in current directory: {current_directory_files_str}" |
12 | 12 | ||||
t | 13 | raise Exception(output) | t | 13 | # raise Exception(output) |
14 | 14 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | X = 42 | f | 1 | X = 42 |
n | 2 | import test | n | 2 | import info |
3 | 3 | ||||
t | 4 | raise Exception(str(test.POSITION)) | t | 4 | raise Exception(str(info.POSITION)) |
5 | 5 | ||||
6 | import os | 6 | import os | ||
7 | 7 | ||||
8 | files_in_current_directory = os.listdir('./tmp') | 8 | files_in_current_directory = os.listdir('./tmp') | ||
9 | current_directory_files_str = ', '.join(files_in_current_directory) | 9 | current_directory_files_str = ', '.join(files_in_current_directory) | ||
10 | 10 | ||||
11 | output = f"Files in current directory: {current_directory_files_str}" | 11 | output = f"Files in current directory: {current_directory_files_str}" | ||
12 | 12 | ||||
13 | raise Exception(output) | 13 | raise Exception(output) | ||
14 | 14 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | X = 42 | f | 1 | X = 42 |
2 | import test | 2 | import test | ||
3 | 3 | ||||
t | 4 | raise Exception(str(test)) | t | 4 | raise Exception(str(test.POSITION)) |
5 | 5 | ||||
6 | import os | 6 | import os | ||
7 | 7 | ||||
8 | files_in_current_directory = os.listdir('./tmp') | 8 | files_in_current_directory = os.listdir('./tmp') | ||
9 | current_directory_files_str = ', '.join(files_in_current_directory) | 9 | current_directory_files_str = ', '.join(files_in_current_directory) | ||
10 | 10 | ||||
11 | output = f"Files in current directory: {current_directory_files_str}" | 11 | output = f"Files in current directory: {current_directory_files_str}" | ||
12 | 12 | ||||
13 | raise Exception(output) | 13 | raise Exception(output) | ||
14 | 14 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | X = 42 | f | 1 | X = 42 |
t | 2 | from test import * | t | 2 | import test |
3 | 3 | ||||
4 | raise Exception(str(test)) | 4 | raise Exception(str(test)) | ||
5 | 5 | ||||
6 | import os | 6 | import os | ||
7 | 7 | ||||
8 | files_in_current_directory = os.listdir('./tmp') | 8 | files_in_current_directory = os.listdir('./tmp') | ||
9 | current_directory_files_str = ', '.join(files_in_current_directory) | 9 | current_directory_files_str = ', '.join(files_in_current_directory) | ||
10 | 10 | ||||
11 | output = f"Files in current directory: {current_directory_files_str}" | 11 | output = f"Files in current directory: {current_directory_files_str}" | ||
12 | 12 | ||||
13 | raise Exception(output) | 13 | raise Exception(output) | ||
14 | 14 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | X = 42 | f | 1 | X = 42 |
t | t | 2 | from test import * | ||
3 | |||||
4 | raise Exception(str(test)) | ||||
2 | 5 | ||||
3 | import os | 6 | import os | ||
4 | 7 | ||||
5 | files_in_current_directory = os.listdir('./tmp') | 8 | files_in_current_directory = os.listdir('./tmp') | ||
6 | current_directory_files_str = ', '.join(files_in_current_directory) | 9 | current_directory_files_str = ', '.join(files_in_current_directory) | ||
7 | 10 | ||||
8 | output = f"Files in current directory: {current_directory_files_str}" | 11 | output = f"Files in current directory: {current_directory_files_str}" | ||
9 | 12 | ||||
10 | raise Exception(output) | 13 | raise Exception(output) | ||
11 | 14 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | X = 42 | f | 1 | X = 42 |
2 | 2 | ||||
3 | import os | 3 | import os | ||
4 | 4 | ||||
t | 5 | files_in_current_directory = os.listdir('.') | t | 5 | files_in_current_directory = os.listdir('./tmp') |
6 | current_directory_files_str = ', '.join(files_in_current_directory) | 6 | current_directory_files_str = ', '.join(files_in_current_directory) | ||
7 | 7 | ||||
8 | output = f"Files in current directory: {current_directory_files_str}" | 8 | output = f"Files in current directory: {current_directory_files_str}" | ||
9 | 9 | ||||
10 | raise Exception(output) | 10 | raise Exception(output) | ||
11 | 11 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | X = 42 | f | 1 | X = 42 |
2 | 2 | ||||
3 | import os | 3 | import os | ||
4 | 4 | ||||
5 | files_in_current_directory = os.listdir('.') | 5 | files_in_current_directory = os.listdir('.') | ||
6 | current_directory_files_str = ', '.join(files_in_current_directory) | 6 | current_directory_files_str = ', '.join(files_in_current_directory) | ||
7 | 7 | ||||
8 | output = f"Files in current directory: {current_directory_files_str}" | 8 | output = f"Files in current directory: {current_directory_files_str}" | ||
9 | 9 | ||||
t | 10 | print(output) | t | 10 | raise Exception(output) |
11 | 11 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | X = 42 | f | 1 | X = 42 |
2 | 2 | ||||
3 | import os | 3 | import os | ||
4 | 4 | ||||
5 | files_in_current_directory = os.listdir('.') | 5 | files_in_current_directory = os.listdir('.') | ||
n | 6 | files_in_current_directory_string = ', '.join(files_in_current_directory) | n | 6 | current_directory_files_str = ', '.join(files_in_current_directory) |
7 | 7 | ||||
n | 8 | path = '/your/target/directory' | n | 8 | output = f"Files in current directory: {current_directory_files_str}" |
9 | files_in_directory = os.listdir(path) | ||||
10 | files_in_directory_string = ', '.join(files_in_directory) | ||||
11 | 9 | ||||
n | 12 | result_string = ( | n | 10 | print(output) |
13 | f"Files in current directory: {files_in_current_directory_string}\n" | ||||
14 | f"Files in '{path}': {files_in_directory_string}" | ||||
15 | ) | ||||
16 | 11 | ||||
t | 17 | raise Exeption(result_string) | t |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | X = 42 | f | 1 | X = 42 |
2 | 2 | ||||
t | 3 | raise Exception(__name__) | t | 3 | import os |
4 | |||||
5 | files_in_current_directory = os.listdir('.') | ||||
6 | files_in_current_directory_string = ', '.join(files_in_current_directory) | ||||
7 | |||||
8 | path = '/your/target/directory' | ||||
9 | files_in_directory = os.listdir(path) | ||||
10 | files_in_directory_string = ', '.join(files_in_directory) | ||||
11 | |||||
12 | result_string = ( | ||||
13 | f"Files in current directory: {files_in_current_directory_string}\n" | ||||
14 | f"Files in '{path}': {files_in_directory_string}" | ||||
15 | ) | ||||
16 | |||||
17 | raise Exeption(result_string) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
21.11.2024 18:42