def version_dict(version):
 match = version_re.match((version or ''))
 letters = 'alpha pre'.split()
 numbers = 'major minor1 minor2 minor3 alpha_ver pre_ver'.split()
 if match:
  d = match.groupdict()
  for letter in letters:
   d[letter] = (d[letter] if d[letter] else None)
  for num in numbers:
   if (d[num] == '*'):
    d[num] = 99
   else:
    d[num] = (int(d[num]) if d[num] else None)
 else:
  d = dict(((k, None) for k in numbers))
  d.update(((k, None) for k in letters))
 return d

def version_dict ( version ) : match = version_re . match ( ( version or '' ) ) letters = 'alpha pre' . split ( ) numbers = 'major minor1 minor2 minor3 alpha_ver pre_ver' . split ( ) if match : d = match . groupdict ( ) for letter in letters : d [ letter ] = ( d [ letter ] if d [ letter ] else None ) for num in numbers : if ( d [ num ] == '*' ) : d [ num ] = 99 else : d [ num ] = ( int ( d [ num ] ) if d [ num ] else None ) else : d = dict ( ( ( k , None ) for k in numbers ) ) d . update ( ( ( k , None ) for k in letters ) ) return d
turn a version string into a dict with major/minor/ .