13 ARTIFACT_HASH_PATTERN=re.compile(
r'(?:^|__)([0-9a-f]{64})$')
22 match=ARTIFACT_HASH_PATTERN.search(artifactId)
35 if artifactHash
and artifactId.endswith(artifactHash):
36 displayName=artifactId[:-len(artifactHash)].rstrip(
'_')
37 return displayName
or artifactHash
48 fileName=re.sub(
r'[^0-9A-Za-z_.-]+',
'_',fileName).strip(
'._')
49 length=255-len(extension)
if extension
else 255
50 if len(fileName)<=length:
51 return fileName+extension
54 return fileName[:length]+extension
55 suffix=
'__'+artifactHash
56 prefixLength=max(0,length-len(suffix))
57 prefix=fileName[:prefixLength].rstrip(
'_')
58 return prefix+suffix+extension
70 fileName=fileName.replace(
' ',
'')
71 fileName=fileName.replace(
'/',
'')
72 fileName=fileName.replace(
'\\',
'')
73 if len(extension) != 0:
74 length=255-len(extension)
75 fileName=fileName.split(
'(')[0] +
'_' + hashlib.md5(fileName.encode()).hexdigest()[:16]
76 fileName=fileName[0:length]
98 for index,value
in enumerate(s):
106 if left==right
and left>0
and right>0:
108 ans+=
''.join(stack[0:pos])
112 elif index==len(s)-1:
124 if left==right
and left>0
and right>0:
150 for i
in range(len(s)):
163 if leftMid!=rightMid:
167 if leftMin
and rightMin
and leftMin==rightMin
and flagMid:
168 ansLst.append(stack[0:i+1])
171 if leftMid
and rightMid:
176 ansLst.append(stack[0:i+1])
198 for index,value
in enumerate(s):
209 count_right_middle+=1
211 elif value==separator
and ((count_left_min>count_right_min)
or (count_left_middle>count_right_middle)):
219 if count_left_min!=count_right_min:
222 if count_left_middle!=count_right_middle:
224 if flagMin
and flagMid:
225 ansLst.append(
''.join(lst))
227 elif index==len(s)-1:
228 ansLst.append(
''.join(lst))
247 p_string=p_string.replace(
' ',
'')
263 count_single_yinhao=0
264 count_double_yinhao=0
266 for index,value
in enumerate(p_string):
268 if (value==
"'" or count_single_yinhao)
and not count_double_yinhao:
270 count_single_yinhao+=1
271 if count_single_yinhao&1:
274 elif (value==
'"' or count_double_yinhao)
and not count_single_yinhao:
276 count_double_yinhao+=1
277 if count_double_yinhao&1:
280 count_single_yinhao=0
281 count_double_yinhao=0
292 count_right_middle+=1
306 if count_left_min!=count_right_min:
309 if count_left_middle!=count_right_middle:
312 if count_left_hua!=count_right_hua:
315 if flagMin
and flagMid
and flagHua:
316 parameters.append(
''.join(stack[0:-1]))
319 elif index==len(p_string)-1:
320 parameters.append(
''.join(stack))
345 if left==right
and left>0
and right>0:
def getFileName(fileName, extension)
Normalize and sanitize file name 规范化并清理文件名
def departAPI2(s, separator='.')
Split API call string based on separator "." 根据"."拆分API调用字符串
def shortenArtifactFileName(fileName, extension)
Shorten artifact file name while preserving full hash 缩短运行产物文件名并保留完整hash.
def removeParameter(s, flag=0)
Remove parameter(s) from API call string 去掉API中的参数部分
def getArtifactHash(artifactId)
Return artifact hash from an artifact id 从运行产物id中提取hash.
def getParameter(p_string, separator=',', space=1)
Split parameter string into list of separated parameters 将参数字符串拆分成单个的参数
def getArtifactDisplayName(artifactId)
Return readable artifact display name 返回可读运行产物展示名
def getLastAPIParameter(apiStr)
Get parameter(s) of the last API from the API call string 获取最后一个API参数
def departAPI(s)
Split API call string based on parameter passing 根据参数传递拆分API调用字符串