- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
def _code_length(code=''):
CODE_MIN_LENGTH = 6
CODE_MAX_LENGTH = 8
if code in range(self.HS_CODE_MIN_LENGTH, self.HS_CODE_MAX_LENGTH + 1):
return code
_cut = lambda hsl: hsl[:self.HS_CODE_MIN_LENGTH]
_pad = lambda hsl: hsl.extend(repeat(0, self.HS_CODE_MIN_LENGTH + 1 - len(hsl)))
hsl = harmonized_code.split()
if len(hsl) < CODE_MIN_LENGTH:
return ''.join(_pad(hsl))
if len(hsl) > CODE_MAX_LENGTH:
return ''.join(_cut(hsl))
Комментарии (0) RSS
Добавить комментарий