ctfsolver.find_usage.manager_gathering

Attributes

Classes

ManagerGathering

ManagerFunction provides utility methods for introspecting and managing functions within a class and Python source files.

Module Contents

class ManagerGathering(*args, **kwargs)[source]

Bases: ctfsolver.managers.manager_functions.ManagerFunction, ctfsolver.managers.manager_folder.ManagerFolder

ManagerFunction provides utility methods for introspecting and managing functions within a class and Python source files.

This class includes methods to:
  • List all callable functions defined in the class.

  • Retrieve references to function usages in a given file.

  • Extract function definitions from Python files using the AST module.

get_self_functions()[source]

Lists all callable functions of the class instance, excluding special methods.

get_function_reference(function, file)[source]

Finds and returns all lines in the specified file where the given function name appears.

Parameters:
  • function (str) – The name of the function to search for.

  • file (str) – The path to the file to search in.

Returns:

Lines from the file containing the function name.

Return type:

list[str]

Raises:

ValueError – If the function is not found in the class.

get_functions_from_file(file_path, function_name=None)[source]

Parses the given Python file and returns function definitions using AST.

Parameters:
  • file_path (Path) – Path to the Python file.

  • function_name (str, optional) – Specific function name to search for.

Returns:

List of function definitions, a single function definition, or None.

Return type:

list[ast.FunctionDef] | ast.FunctionDef | None

find_function_from_file(file_path, function_name)[source]

Deprecated. Use get_functions_from_file instead.

gathering_target[source]
manager_error[source]
manager_class[source]
initializing_all_ancestors(*args, **kwargs)[source]
Description:

Initializes all the ancestors of the class

handling_global_config()[source]
get_gathering_target()[source]
get_org_information()[source]
renaming_method()[source]
adding_to_file(filename, method_source)[source]
Parameters:
  • filename (str)

  • method_source (str)

tabbing(text, num=1, function=False, space=True, space_num=4)[source]
Parameters:
gathering_all_solution_files()[source]
check_functions(target_info, solution_info, solution_name)[source]
method_enumeration(target_methods, method_name)[source]

Enumerates methods in target_methods that match method_name with optional numbering (e.g., foo, foo_1, foo_2).

main()[source]
manager[source]