MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / get_random_code

Function get_random_code

apps/base/utils.py:99–113  ·  view source on GitHub ↗
(style: str | None = None)

Source from the content-addressed store, hash-verified

97
98
99async def get_random_code(style: str | None = None) -> str:
100 code_style = style or get_code_generate_type()
101 if code_style == "num":
102 code_style = "number"
103 if code_style == "string":
104 code_style = "secret"
105
106 while True:
107 code = (
108 await get_random_num()
109 if code_style == "number"
110 else await get_random_string()
111 )
112 if not await FileCodes.filter(code=code).exists():
113 return str(code)
114
115
116async def calculate_file_hash(file: UploadFile, chunk_size=1024 * 1024) -> str:

Callers 1

get_expire_infoFunction · 0.85

Calls 5

get_random_numFunction · 0.90
get_random_stringFunction · 0.90
get_code_generate_typeFunction · 0.85
existsMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected