[docs]defget_max_allocation_size(executable:str)->tuple[int,bool]:"""Returns the maximum heap size allowed for the given executable."""ifplatform.architecture(executable)[0]=="64bit":max_heap_allowed=psutil.virtual_memory().totalthinks_is_64_bit=Trueelse:max_heap_allowed=min(4*1024**3,psutil.virtual_memory().total)thinks_is_64_bit=Falsereturnmax_heap_allowed,thinks_is_64_bit
[docs]defget_jar_ram_defaults()->tuple[str,str,int,int]:"""Returns the default ram for the jar"""# We don't know the java executable at this stage - not worth the extra work required heremax_allocation,__=get_max_allocation_size(sys.executable)min_ram,max_ram,min_ram_int,max_ram_int=_calculate_ram(max_allocation)returnmin_ram,max_ram,min_ram_int,max_ram_int
[docs]defget_jar_ram_actual(executable:str)->tuple[str,str,int,int]:"""Returns the actual ram for the jar"""ifnotexecutable:frompylav.constants.configimportJAVA_EXECUTABLEexecutable=JAVA_EXECUTABLEexecutable=get_true_path(executable,sys.executable)max_allocation,__=get_max_allocation_size(executable)min_ram,max_ram,min_ram_int,max_ram_int=_calculate_ram(max_allocation)returnmin_ram,max_ram,min_ram_int,max_ram_int
[docs]defconvert_function(key:str)->str:"""Converts a key to a valid key."""returnkey.replace("_","-")
[docs]defchange_dict_naming_convention(data:JSON_DICT_TYPE)->JSON_DICT_TYPE:"""Changes the naming convention of a dict."""new={}fork,vindata.items():new_v=vifisinstance(v,dict):new_v=change_dict_naming_convention(v)elifisinstance(v,list):new_v=[]forxinv:ifisinstance(x,dict):new_v.append(change_dict_naming_convention(x))else:new_v.append(x)new[convert_function(k)]=new_vreturnnew