MCPcopy Create free account
hub / github.com/ElementsProject/lightning / list_all_examples

Function list_all_examples

tests/autogenerate-rpc-examples.py:2060–2079  ·  view source on GitHub ↗

list all methods used in 'update_example' calls to ensure that all methods are covered

()

Source from the content-addressed store, hash-verified

2058 global ALL_RPC_EXAMPLES, REGENERATING_RPCS
2059
2060 def list_all_examples():
2061 """list all methods used in 'update_example' calls to ensure that all methods are covered"""
2062 try:
2063 methods = []
2064 file_path = os.path.abspath(__file__)
2065
2066 # Parse and traverse this file's content to list all methods & file names
2067 with open(file_path, "r") as file:
2068 file_content = file.read()
2069 tree = ast.parse(file_content)
2070 for node in ast.walk(tree):
2071 if isinstance(node, ast.Call) and isinstance(node.func, ast.Name) and node.func.id == 'update_example':
2072 for keyword in node.keywords:
2073 if (keyword.arg == 'method' and isinstance(keyword.value, ast.Constant)):
2074 if keyword.value.value not in methods:
2075 methods.append(keyword.value.value)
2076 return methods
2077 except Exception as e:
2078 logger.error(f'Error in listing all examples: {e}')
2079 raise
2080
2081 def list_missing_examples():
2082 """Checks for missing example & log an error if missing."""

Callers 1

test_generate_examplesFunction · 0.85

Calls 3

parseMethod · 0.80
errorMethod · 0.80
readMethod · 0.45

Tested by 1

test_generate_examplesFunction · 0.68