[docs]@typecheckeddefinformation(names:Union[List[str],str]=RegisteredSymbols)->str:""" Returns JSON formatted string containing information about the objects in names Parameters ---------- names : Union[List[str], str] names is either the name of an object or list of names of objects to retrieve info if names is ak.AllSymbols, retrieves info for all symbols in the symbol table if names is ak.RegisteredSymbols, retrieves info for all symbols in the registry Returns ------ str JSON formatted string containing a list of information for each object in names Raises ------ RuntimeError Raised if a server-side error is thrown in the process of retrieving information about the objects in names """ifisinstance(names,str):ifnamesin[AllSymbols,RegisteredSymbols]:returncast(str,generic_msg(cmd="info",args={"names":names}))else:names=[names]# allows user to call ak.information(pda.name)returncast(str,generic_msg(cmd="info",args={"names":json.dumps(names)}))
[docs]deflist_registry(detailed:bool=False):""" Return a list containing the names of all registered objects Parameters ---------- detailed: bool Default = False Return details of registry objects. Currently includes object type for any objects Returns ------- dict Dict containing keys "Components" and "Objects". Raises ------ RuntimeError Raised if there's a server-side error thrown """data=json.loads(cast(str,generic_msg(cmd="list_registry")))objs=json.loads(data["Objects"])ifdata["Objects"]!=""else[]obj_types=json.loads(data["Object_Types"])ifdata["Object_Types"]!=""else[]return{"Objects":list(zip(objs,obj_types))ifdetailedelseobjs,"Components":json.loads(data["Components"]),}
[docs]deflist_symbol_table()->List[str]:""" Return a list containing the names of all objects in the symbol table Parameters ---------- None Returns ------- list List of all object names in the symbol table Raises ------ RuntimeError Raised if there's a server-side error thrown """return[i.nameforiin_parse_json(AllSymbols)]
def_parse_json(names:Union[List[str],str])->List[InfoEntry]:""" Internal method that converts the JSON output of information into a List of InfoEntry objects Parameters ---------- names : Union[List[str], str] Names to pass to information Returns ------- List[InfoEntry] List of InfoEntry python objects for each name in names Raises ------ RuntimeError Raised if a server-side error is thrown """returnjson.loads(information(names),object_hook=lambdad:InfoEntry(**d))
[docs]defpretty_print_information(names:Union[List[str],str]=RegisteredSymbols)->None:""" Prints verbose information for each object in names in a human readable format Parameters ---------- names : Union[List[str], str] names is either the name of an object or list of names of objects to retrieve info if names is ak.AllSymbols, retrieves info for all symbols in the symbol table if names is ak.RegisteredSymbols, retrieves info for all symbols in the registry Returns ------ None Raises ------ RuntimeError Raised if a server-side error is thrown in the process of retrieving information about the objects in names """foriin_parse_json(names):print(i)