def version_process(versions, filter_prefix):
 output = []
 for version in versions:
  prefix = ''
  if filter_prefix:
   if (version[0:len(filter_prefix)] != filter_prefix):
    continue
   check_version = version[len(filter_prefix):]
   prefix = filter_prefix
  else:
   check_version = re.sub('^v', '', version)
   if (check_version != version):
    prefix = 'v'
  if (not SemVer.valid(check_version)):
   continue
  output.append({'version': check_version, 'prefix': prefix})
 return output

def version_process ( versions , filter_prefix ) : output = [ ] for version in versions : prefix = '' if filter_prefix : if ( version [ 0 : len ( filter_prefix ) ] != filter_prefix ) : continue check_version = version [ len ( filter_prefix ) : ] prefix = filter_prefix else : check_version = re . sub ( '^v' , '' , version ) if ( check_version != version ) : prefix = 'v' if ( not SemVer . valid ( check_version ) ) : continue output . append ( { 'version' : check_version , 'prefix' : prefix } ) return output
filter a list of versions to ones that are valid semvers .