| 29 | |
| 30 | |
| 31 | def function_or_method_to_string(func_or_method: Callable) -> str: |
| 32 | is_method = inspect.ismethod(func_or_method) |
| 33 | is_function = inspect.isfunction(func_or_method) |
| 34 | if not is_method and not is_function: |
| 35 | raise ValueError("Input must be a function or method") |
| 36 | module = func_or_method.__module__ |
| 37 | source = inspect.getsource(func_or_method) |
| 38 | line_number = inspect.getsourcelines(func_or_method)[1] |
| 39 | |
| 40 | if is_method: |
| 41 | class_name = func_or_method.__self__.__class__.__name__ |
| 42 | return f"{module}.l_{line_number}.{class_name}\n{source}".strip() |
| 43 | else: |
| 44 | return f"{module}.l_{line_number}\n{source}".strip() |
| 45 | |
| 46 | |
| 47 | def string_to_md5_hash(string: str) -> str: |