1import secret
2from random import choices
3from inspect import getsource
4
5fn = 'FN0MI0600204'
6type_error_message = "Опаааааа, тука има нещо нередно."
7
8def raises_error(instance, func):
9 try:
10 func(instance)
11 except TypeError as type_error:
12 return True if str(type_error) == type_error_message else False
13 except BaseException as base_exception:
14 rep = repr(base_exception)
15 return True if type(rep) == str else False
16 except:
17 return False
18 return False
19
20def is_squarer(instance, func):
21 try:
22 nums = [x for x in range(1, 11)]
23 return [x ** 2 if x % 2 == 0 else 0 for x in nums] == [func(instance, x) for x in nums]
24 except:
25 return False
26
27def is_concat(instance, func):
28 try:
29 str_len = 5
30 left_str = ''.join(choices(fn, k=str_len))
31 right_str = ''.join(choices(fn, k=str_len))
32 left_first = left_str + right_str
33 right_first = right_str + left_str
34
35 func_res = func(instance, left=left_str, right=right_str)
36 func_res_reversed = func(instance, left=right_str, right=left_str)
37 return left_first == func_res and func_res_reversed == right_first
38 except:
39 return False
40
41def is_static(func):
42 try:
43 code = getsource(func)
44 return 'self' not in code and 'cls' not in code
45 except:
46 return False
47
48def is_special(caller, attr_name):
49 attr = getattr(caller, attr_name)
50 return (raises_error(caller, attr) or is_squarer(caller, attr) or is_concat(caller, attr) or is_static(attr))
51
52def methodify():
53 def methodify_util(mod, attr, func_names):
54 current = getattr(mod, attr)
55 attrs = [item for item in dir(current) if item.startswith('__') is False]
56 for item in attrs:
57 if 'clue' in item.lower():
58 methodify_util(current, item, func_names)
59
60 current_attr = getattr(current, item)
61 if len(current_attr.__name__) == 1 and is_special(current, item):
62 func_names.append(current_attr.__name__)
63
64 func_names = []
65 attrs = [attr for attr in dir(secret) if attr.startswith('__') is False]
66 for attr in attrs:
67 if 'clue' in attr.lower():
68 methodify_util(secret, attr, func_names)
69
70 faculty_num = []
71 for letter in fn:
72 for func in func_names:
73 if letter == func:
74 faculty_num.append(func)
75 func_names.remove(func)
76
77 return tuple(faculty_num)
E
======================================================================
ERROR: test_metodify (test.TestMethodify)
Test metodify function.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 12, in test_metodify
self.assertIn(methodify(), _RESULTS.keys())
File "/tmp/solution.py", line 68, in methodify
methodify_util(secret, attr, func_names)
File "/tmp/solution.py", line 58, in methodify_util
methodify_util(current, item, func_names)
File "/tmp/solution.py", line 61, in methodify_util
if len(current_attr.__name__) == 1 and is_special(current, item):
AttributeError: 'tuple' object has no attribute '__name__'
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
f | 1 | import secret | f | 1 | import secret |
2 | from random import choices | 2 | from random import choices | ||
3 | from inspect import getsource | 3 | from inspect import getsource | ||
4 | 4 | ||||
5 | fn = 'FN0MI0600204' | 5 | fn = 'FN0MI0600204' | ||
6 | type_error_message = "Опаааааа, тука има нещо нередно." | 6 | type_error_message = "Опаааааа, тука има нещо нередно." | ||
7 | 7 | ||||
8 | def raises_error(instance, func): | 8 | def raises_error(instance, func): | ||
9 | try: | 9 | try: | ||
10 | func(instance) | 10 | func(instance) | ||
11 | except TypeError as type_error: | 11 | except TypeError as type_error: | ||
12 | return True if str(type_error) == type_error_message else False | 12 | return True if str(type_error) == type_error_message else False | ||
13 | except BaseException as base_exception: | 13 | except BaseException as base_exception: | ||
14 | rep = repr(base_exception) | 14 | rep = repr(base_exception) | ||
15 | return True if type(rep) == str else False | 15 | return True if type(rep) == str else False | ||
16 | except: | 16 | except: | ||
17 | return False | 17 | return False | ||
18 | return False | 18 | return False | ||
19 | 19 | ||||
20 | def is_squarer(instance, func): | 20 | def is_squarer(instance, func): | ||
21 | try: | 21 | try: | ||
22 | nums = [x for x in range(1, 11)] | 22 | nums = [x for x in range(1, 11)] | ||
23 | return [x ** 2 if x % 2 == 0 else 0 for x in nums] == [func(instance, x) for x in nums] | 23 | return [x ** 2 if x % 2 == 0 else 0 for x in nums] == [func(instance, x) for x in nums] | ||
t | 24 | except Exception as err: | t | 24 | except: |
25 | return False | 25 | return False | ||
26 | 26 | ||||
27 | def is_concat(instance, func): | 27 | def is_concat(instance, func): | ||
28 | try: | 28 | try: | ||
29 | str_len = 5 | 29 | str_len = 5 | ||
30 | left_str = ''.join(choices(fn, k=str_len)) | 30 | left_str = ''.join(choices(fn, k=str_len)) | ||
31 | right_str = ''.join(choices(fn, k=str_len)) | 31 | right_str = ''.join(choices(fn, k=str_len)) | ||
32 | left_first = left_str + right_str | 32 | left_first = left_str + right_str | ||
33 | right_first = right_str + left_str | 33 | right_first = right_str + left_str | ||
34 | 34 | ||||
35 | func_res = func(instance, left=left_str, right=right_str) | 35 | func_res = func(instance, left=left_str, right=right_str) | ||
36 | func_res_reversed = func(instance, left=right_str, right=left_str) | 36 | func_res_reversed = func(instance, left=right_str, right=left_str) | ||
37 | return left_first == func_res and func_res_reversed == right_first | 37 | return left_first == func_res and func_res_reversed == right_first | ||
38 | except: | 38 | except: | ||
39 | return False | 39 | return False | ||
40 | 40 | ||||
41 | def is_static(func): | 41 | def is_static(func): | ||
42 | try: | 42 | try: | ||
43 | code = getsource(func) | 43 | code = getsource(func) | ||
44 | return 'self' not in code and 'cls' not in code | 44 | return 'self' not in code and 'cls' not in code | ||
45 | except: | 45 | except: | ||
46 | return False | 46 | return False | ||
47 | 47 | ||||
48 | def is_special(caller, attr_name): | 48 | def is_special(caller, attr_name): | ||
49 | attr = getattr(caller, attr_name) | 49 | attr = getattr(caller, attr_name) | ||
50 | return (raises_error(caller, attr) or is_squarer(caller, attr) or is_concat(caller, attr) or is_static(attr)) | 50 | return (raises_error(caller, attr) or is_squarer(caller, attr) or is_concat(caller, attr) or is_static(attr)) | ||
51 | 51 | ||||
52 | def methodify(): | 52 | def methodify(): | ||
53 | def methodify_util(mod, attr, func_names): | 53 | def methodify_util(mod, attr, func_names): | ||
54 | current = getattr(mod, attr) | 54 | current = getattr(mod, attr) | ||
55 | attrs = [item for item in dir(current) if item.startswith('__') is False] | 55 | attrs = [item for item in dir(current) if item.startswith('__') is False] | ||
56 | for item in attrs: | 56 | for item in attrs: | ||
57 | if 'clue' in item.lower(): | 57 | if 'clue' in item.lower(): | ||
58 | methodify_util(current, item, func_names) | 58 | methodify_util(current, item, func_names) | ||
59 | 59 | ||||
60 | current_attr = getattr(current, item) | 60 | current_attr = getattr(current, item) | ||
61 | if len(current_attr.__name__) == 1 and is_special(current, item): | 61 | if len(current_attr.__name__) == 1 and is_special(current, item): | ||
62 | func_names.append(current_attr.__name__) | 62 | func_names.append(current_attr.__name__) | ||
63 | 63 | ||||
64 | func_names = [] | 64 | func_names = [] | ||
65 | attrs = [attr for attr in dir(secret) if attr.startswith('__') is False] | 65 | attrs = [attr for attr in dir(secret) if attr.startswith('__') is False] | ||
66 | for attr in attrs: | 66 | for attr in attrs: | ||
67 | if 'clue' in attr.lower(): | 67 | if 'clue' in attr.lower(): | ||
68 | methodify_util(secret, attr, func_names) | 68 | methodify_util(secret, attr, func_names) | ||
69 | 69 | ||||
70 | faculty_num = [] | 70 | faculty_num = [] | ||
71 | for letter in fn: | 71 | for letter in fn: | ||
72 | for func in func_names: | 72 | for func in func_names: | ||
73 | if letter == func: | 73 | if letter == func: | ||
74 | faculty_num.append(func) | 74 | faculty_num.append(func) | ||
75 | func_names.remove(func) | 75 | func_names.remove(func) | ||
76 | 76 | ||||
77 | return tuple(faculty_num) | 77 | return tuple(faculty_num) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | import secret | f | 1 | import secret |
2 | from random import choices | 2 | from random import choices | ||
3 | from inspect import getsource | 3 | from inspect import getsource | ||
4 | 4 | ||||
5 | fn = 'FN0MI0600204' | 5 | fn = 'FN0MI0600204' | ||
6 | type_error_message = "Опаааааа, тука има нещо нередно." | 6 | type_error_message = "Опаааааа, тука има нещо нередно." | ||
7 | 7 | ||||
8 | def raises_error(instance, func): | 8 | def raises_error(instance, func): | ||
9 | try: | 9 | try: | ||
10 | func(instance) | 10 | func(instance) | ||
11 | except TypeError as type_error: | 11 | except TypeError as type_error: | ||
12 | return True if str(type_error) == type_error_message else False | 12 | return True if str(type_error) == type_error_message else False | ||
13 | except BaseException as base_exception: | 13 | except BaseException as base_exception: | ||
14 | rep = repr(base_exception) | 14 | rep = repr(base_exception) | ||
15 | return True if type(rep) == str else False | 15 | return True if type(rep) == str else False | ||
16 | except: | 16 | except: | ||
17 | return False | 17 | return False | ||
18 | return False | 18 | return False | ||
19 | 19 | ||||
20 | def is_squarer(instance, func): | 20 | def is_squarer(instance, func): | ||
21 | try: | 21 | try: | ||
22 | nums = [x for x in range(1, 11)] | 22 | nums = [x for x in range(1, 11)] | ||
23 | return [x ** 2 if x % 2 == 0 else 0 for x in nums] == [func(instance, x) for x in nums] | 23 | return [x ** 2 if x % 2 == 0 else 0 for x in nums] == [func(instance, x) for x in nums] | ||
24 | except Exception as err: | 24 | except Exception as err: | ||
t | 25 | print(err) | t | 25 | return False |
26 | 26 | ||||
27 | def is_concat(instance, func): | 27 | def is_concat(instance, func): | ||
28 | try: | 28 | try: | ||
29 | str_len = 5 | 29 | str_len = 5 | ||
30 | left_str = ''.join(choices(fn, k=str_len)) | 30 | left_str = ''.join(choices(fn, k=str_len)) | ||
31 | right_str = ''.join(choices(fn, k=str_len)) | 31 | right_str = ''.join(choices(fn, k=str_len)) | ||
32 | left_first = left_str + right_str | 32 | left_first = left_str + right_str | ||
33 | right_first = right_str + left_str | 33 | right_first = right_str + left_str | ||
34 | 34 | ||||
35 | func_res = func(instance, left=left_str, right=right_str) | 35 | func_res = func(instance, left=left_str, right=right_str) | ||
36 | func_res_reversed = func(instance, left=right_str, right=left_str) | 36 | func_res_reversed = func(instance, left=right_str, right=left_str) | ||
37 | return left_first == func_res and func_res_reversed == right_first | 37 | return left_first == func_res and func_res_reversed == right_first | ||
38 | except: | 38 | except: | ||
39 | return False | 39 | return False | ||
40 | 40 | ||||
41 | def is_static(func): | 41 | def is_static(func): | ||
42 | try: | 42 | try: | ||
43 | code = getsource(func) | 43 | code = getsource(func) | ||
44 | return 'self' not in code and 'cls' not in code | 44 | return 'self' not in code and 'cls' not in code | ||
45 | except: | 45 | except: | ||
46 | return False | 46 | return False | ||
47 | 47 | ||||
48 | def is_special(caller, attr_name): | 48 | def is_special(caller, attr_name): | ||
49 | attr = getattr(caller, attr_name) | 49 | attr = getattr(caller, attr_name) | ||
50 | return (raises_error(caller, attr) or is_squarer(caller, attr) or is_concat(caller, attr) or is_static(attr)) | 50 | return (raises_error(caller, attr) or is_squarer(caller, attr) or is_concat(caller, attr) or is_static(attr)) | ||
51 | 51 | ||||
52 | def methodify(): | 52 | def methodify(): | ||
53 | def methodify_util(mod, attr, func_names): | 53 | def methodify_util(mod, attr, func_names): | ||
54 | current = getattr(mod, attr) | 54 | current = getattr(mod, attr) | ||
55 | attrs = [item for item in dir(current) if item.startswith('__') is False] | 55 | attrs = [item for item in dir(current) if item.startswith('__') is False] | ||
56 | for item in attrs: | 56 | for item in attrs: | ||
57 | if 'clue' in item.lower(): | 57 | if 'clue' in item.lower(): | ||
58 | methodify_util(current, item, func_names) | 58 | methodify_util(current, item, func_names) | ||
59 | 59 | ||||
60 | current_attr = getattr(current, item) | 60 | current_attr = getattr(current, item) | ||
61 | if len(current_attr.__name__) == 1 and is_special(current, item): | 61 | if len(current_attr.__name__) == 1 and is_special(current, item): | ||
62 | func_names.append(current_attr.__name__) | 62 | func_names.append(current_attr.__name__) | ||
63 | 63 | ||||
64 | func_names = [] | 64 | func_names = [] | ||
65 | attrs = [attr for attr in dir(secret) if attr.startswith('__') is False] | 65 | attrs = [attr for attr in dir(secret) if attr.startswith('__') is False] | ||
66 | for attr in attrs: | 66 | for attr in attrs: | ||
67 | if 'clue' in attr.lower(): | 67 | if 'clue' in attr.lower(): | ||
68 | methodify_util(secret, attr, func_names) | 68 | methodify_util(secret, attr, func_names) | ||
69 | 69 | ||||
70 | faculty_num = [] | 70 | faculty_num = [] | ||
71 | for letter in fn: | 71 | for letter in fn: | ||
72 | for func in func_names: | 72 | for func in func_names: | ||
73 | if letter == func: | 73 | if letter == func: | ||
74 | faculty_num.append(func) | 74 | faculty_num.append(func) | ||
75 | func_names.remove(func) | 75 | func_names.remove(func) | ||
76 | 76 | ||||
77 | return tuple(faculty_num) | 77 | return tuple(faculty_num) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | import secret | f | 1 | import secret |
2 | from random import choices | 2 | from random import choices | ||
3 | from inspect import getsource | 3 | from inspect import getsource | ||
4 | 4 | ||||
5 | fn = 'FN0MI0600204' | 5 | fn = 'FN0MI0600204' | ||
6 | type_error_message = "Опаааааа, тука има нещо нередно." | 6 | type_error_message = "Опаааааа, тука има нещо нередно." | ||
7 | 7 | ||||
8 | def raises_error(instance, func): | 8 | def raises_error(instance, func): | ||
9 | try: | 9 | try: | ||
10 | func(instance) | 10 | func(instance) | ||
11 | except TypeError as type_error: | 11 | except TypeError as type_error: | ||
12 | return True if str(type_error) == type_error_message else False | 12 | return True if str(type_error) == type_error_message else False | ||
13 | except BaseException as base_exception: | 13 | except BaseException as base_exception: | ||
14 | rep = repr(base_exception) | 14 | rep = repr(base_exception) | ||
15 | return True if type(rep) == str else False | 15 | return True if type(rep) == str else False | ||
16 | except: | 16 | except: | ||
17 | return False | 17 | return False | ||
18 | return False | 18 | return False | ||
19 | 19 | ||||
20 | def is_squarer(instance, func): | 20 | def is_squarer(instance, func): | ||
21 | try: | 21 | try: | ||
22 | nums = [x for x in range(1, 11)] | 22 | nums = [x for x in range(1, 11)] | ||
23 | return [x ** 2 if x % 2 == 0 else 0 for x in nums] == [func(instance, x) for x in nums] | 23 | return [x ** 2 if x % 2 == 0 else 0 for x in nums] == [func(instance, x) for x in nums] | ||
24 | except Exception as err: | 24 | except Exception as err: | ||
25 | print(err) | 25 | print(err) | ||
26 | 26 | ||||
27 | def is_concat(instance, func): | 27 | def is_concat(instance, func): | ||
28 | try: | 28 | try: | ||
29 | str_len = 5 | 29 | str_len = 5 | ||
30 | left_str = ''.join(choices(fn, k=str_len)) | 30 | left_str = ''.join(choices(fn, k=str_len)) | ||
31 | right_str = ''.join(choices(fn, k=str_len)) | 31 | right_str = ''.join(choices(fn, k=str_len)) | ||
32 | left_first = left_str + right_str | 32 | left_first = left_str + right_str | ||
33 | right_first = right_str + left_str | 33 | right_first = right_str + left_str | ||
34 | 34 | ||||
35 | func_res = func(instance, left=left_str, right=right_str) | 35 | func_res = func(instance, left=left_str, right=right_str) | ||
36 | func_res_reversed = func(instance, left=right_str, right=left_str) | 36 | func_res_reversed = func(instance, left=right_str, right=left_str) | ||
37 | return left_first == func_res and func_res_reversed == right_first | 37 | return left_first == func_res and func_res_reversed == right_first | ||
38 | except: | 38 | except: | ||
39 | return False | 39 | return False | ||
40 | 40 | ||||
41 | def is_static(func): | 41 | def is_static(func): | ||
42 | try: | 42 | try: | ||
43 | code = getsource(func) | 43 | code = getsource(func) | ||
44 | return 'self' not in code and 'cls' not in code | 44 | return 'self' not in code and 'cls' not in code | ||
45 | except: | 45 | except: | ||
46 | return False | 46 | return False | ||
47 | 47 | ||||
48 | def is_special(caller, attr_name): | 48 | def is_special(caller, attr_name): | ||
49 | attr = getattr(caller, attr_name) | 49 | attr = getattr(caller, attr_name) | ||
50 | return (raises_error(caller, attr) or is_squarer(caller, attr) or is_concat(caller, attr) or is_static(attr)) | 50 | return (raises_error(caller, attr) or is_squarer(caller, attr) or is_concat(caller, attr) or is_static(attr)) | ||
51 | 51 | ||||
n | 52 | def metodify(): | n | 52 | def methodify(): |
53 | def metodify_util(mod, attr, func_names): | 53 | def methodify_util(mod, attr, func_names): | ||
54 | current = getattr(mod, attr) | 54 | current = getattr(mod, attr) | ||
55 | attrs = [item for item in dir(current) if item.startswith('__') is False] | 55 | attrs = [item for item in dir(current) if item.startswith('__') is False] | ||
56 | for item in attrs: | 56 | for item in attrs: | ||
57 | if 'clue' in item.lower(): | 57 | if 'clue' in item.lower(): | ||
n | 58 | metodify_util(current, item, func_names) | n | 58 | methodify_util(current, item, func_names) |
59 | 59 | ||||
60 | current_attr = getattr(current, item) | 60 | current_attr = getattr(current, item) | ||
61 | if len(current_attr.__name__) == 1 and is_special(current, item): | 61 | if len(current_attr.__name__) == 1 and is_special(current, item): | ||
62 | func_names.append(current_attr.__name__) | 62 | func_names.append(current_attr.__name__) | ||
63 | 63 | ||||
64 | func_names = [] | 64 | func_names = [] | ||
65 | attrs = [attr for attr in dir(secret) if attr.startswith('__') is False] | 65 | attrs = [attr for attr in dir(secret) if attr.startswith('__') is False] | ||
66 | for attr in attrs: | 66 | for attr in attrs: | ||
67 | if 'clue' in attr.lower(): | 67 | if 'clue' in attr.lower(): | ||
t | 68 | metodify_util(secret, attr, func_names) | t | 68 | methodify_util(secret, attr, func_names) |
69 | 69 | ||||
70 | faculty_num = [] | 70 | faculty_num = [] | ||
71 | for letter in fn: | 71 | for letter in fn: | ||
72 | for func in func_names: | 72 | for func in func_names: | ||
73 | if letter == func: | 73 | if letter == func: | ||
74 | faculty_num.append(func) | 74 | faculty_num.append(func) | ||
75 | func_names.remove(func) | 75 | func_names.remove(func) | ||
76 | 76 | ||||
77 | return tuple(faculty_num) | 77 | return tuple(faculty_num) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | import secret | f | 1 | import secret |
2 | from random import choices | 2 | from random import choices | ||
3 | from inspect import getsource | 3 | from inspect import getsource | ||
4 | 4 | ||||
5 | fn = 'FN0MI0600204' | 5 | fn = 'FN0MI0600204' | ||
6 | type_error_message = "Опаааааа, тука има нещо нередно." | 6 | type_error_message = "Опаааааа, тука има нещо нередно." | ||
7 | 7 | ||||
8 | def raises_error(instance, func): | 8 | def raises_error(instance, func): | ||
9 | try: | 9 | try: | ||
10 | func(instance) | 10 | func(instance) | ||
11 | except TypeError as type_error: | 11 | except TypeError as type_error: | ||
12 | return True if str(type_error) == type_error_message else False | 12 | return True if str(type_error) == type_error_message else False | ||
13 | except BaseException as base_exception: | 13 | except BaseException as base_exception: | ||
14 | rep = repr(base_exception) | 14 | rep = repr(base_exception) | ||
15 | return True if type(rep) == str else False | 15 | return True if type(rep) == str else False | ||
16 | except: | 16 | except: | ||
17 | return False | 17 | return False | ||
18 | return False | 18 | return False | ||
19 | 19 | ||||
20 | def is_squarer(instance, func): | 20 | def is_squarer(instance, func): | ||
21 | try: | 21 | try: | ||
22 | nums = [x for x in range(1, 11)] | 22 | nums = [x for x in range(1, 11)] | ||
23 | return [x ** 2 if x % 2 == 0 else 0 for x in nums] == [func(instance, x) for x in nums] | 23 | return [x ** 2 if x % 2 == 0 else 0 for x in nums] == [func(instance, x) for x in nums] | ||
24 | except Exception as err: | 24 | except Exception as err: | ||
25 | print(err) | 25 | print(err) | ||
26 | 26 | ||||
27 | def is_concat(instance, func): | 27 | def is_concat(instance, func): | ||
28 | try: | 28 | try: | ||
29 | str_len = 5 | 29 | str_len = 5 | ||
30 | left_str = ''.join(choices(fn, k=str_len)) | 30 | left_str = ''.join(choices(fn, k=str_len)) | ||
31 | right_str = ''.join(choices(fn, k=str_len)) | 31 | right_str = ''.join(choices(fn, k=str_len)) | ||
32 | left_first = left_str + right_str | 32 | left_first = left_str + right_str | ||
33 | right_first = right_str + left_str | 33 | right_first = right_str + left_str | ||
34 | 34 | ||||
35 | func_res = func(instance, left=left_str, right=right_str) | 35 | func_res = func(instance, left=left_str, right=right_str) | ||
36 | func_res_reversed = func(instance, left=right_str, right=left_str) | 36 | func_res_reversed = func(instance, left=right_str, right=left_str) | ||
37 | return left_first == func_res and func_res_reversed == right_first | 37 | return left_first == func_res and func_res_reversed == right_first | ||
38 | except: | 38 | except: | ||
39 | return False | 39 | return False | ||
40 | 40 | ||||
41 | def is_static(func): | 41 | def is_static(func): | ||
42 | try: | 42 | try: | ||
43 | code = getsource(func) | 43 | code = getsource(func) | ||
44 | return 'self' not in code and 'cls' not in code | 44 | return 'self' not in code and 'cls' not in code | ||
45 | except: | 45 | except: | ||
46 | return False | 46 | return False | ||
47 | 47 | ||||
48 | def is_special(caller, attr_name): | 48 | def is_special(caller, attr_name): | ||
49 | attr = getattr(caller, attr_name) | 49 | attr = getattr(caller, attr_name) | ||
50 | return (raises_error(caller, attr) or is_squarer(caller, attr) or is_concat(caller, attr) or is_static(attr)) | 50 | return (raises_error(caller, attr) or is_squarer(caller, attr) or is_concat(caller, attr) or is_static(attr)) | ||
51 | 51 | ||||
52 | def metodify(): | 52 | def metodify(): | ||
53 | def metodify_util(mod, attr, func_names): | 53 | def metodify_util(mod, attr, func_names): | ||
54 | current = getattr(mod, attr) | 54 | current = getattr(mod, attr) | ||
55 | attrs = [item for item in dir(current) if item.startswith('__') is False] | 55 | attrs = [item for item in dir(current) if item.startswith('__') is False] | ||
56 | for item in attrs: | 56 | for item in attrs: | ||
57 | if 'clue' in item.lower(): | 57 | if 'clue' in item.lower(): | ||
58 | metodify_util(current, item, func_names) | 58 | metodify_util(current, item, func_names) | ||
59 | 59 | ||||
60 | current_attr = getattr(current, item) | 60 | current_attr = getattr(current, item) | ||
61 | if len(current_attr.__name__) == 1 and is_special(current, item): | 61 | if len(current_attr.__name__) == 1 and is_special(current, item): | ||
62 | func_names.append(current_attr.__name__) | 62 | func_names.append(current_attr.__name__) | ||
63 | 63 | ||||
64 | func_names = [] | 64 | func_names = [] | ||
65 | attrs = [attr for attr in dir(secret) if attr.startswith('__') is False] | 65 | attrs = [attr for attr in dir(secret) if attr.startswith('__') is False] | ||
66 | for attr in attrs: | 66 | for attr in attrs: | ||
67 | if 'clue' in attr.lower(): | 67 | if 'clue' in attr.lower(): | ||
68 | metodify_util(secret, attr, func_names) | 68 | metodify_util(secret, attr, func_names) | ||
69 | 69 | ||||
70 | faculty_num = [] | 70 | faculty_num = [] | ||
71 | for letter in fn: | 71 | for letter in fn: | ||
72 | for func in func_names: | 72 | for func in func_names: | ||
73 | if letter == func: | 73 | if letter == func: | ||
74 | faculty_num.append(func) | 74 | faculty_num.append(func) | ||
75 | func_names.remove(func) | 75 | func_names.remove(func) | ||
76 | 76 | ||||
77 | return tuple(faculty_num) | 77 | return tuple(faculty_num) | ||
t | 78 | t | |||
79 | print(metodify()) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|