def to_signum(signum):
 if isinstance(signum, int):
  return signum
 m = re.match('(\\w+)(\\+(\\d+))?', signum)
 if m:
  name = m.group(1).upper()
  if (not name.startswith('SIG')):
   name = ('SIG' + name)
  offset = (int(m.group(3)) if m.group(3) else 0)
  try:
   return (getattr(signal, name) + offset)
  except KeyError:
   pass
 raise ValueError('signal invalid: {}'.format(signum))

def to_signum ( signum ) : if isinstance ( signum , int ) : return signum m = re . match ( '(\\w+)(\\+(\\d+))?' , signum ) if m : name = m . group ( 1 ) . upper ( ) if ( not name . startswith ( 'SIG' ) ) : name = ( 'SIG' + name ) offset = ( int ( m . group ( 3 ) ) if m . group ( 3 ) else 0 ) try : return ( getattr ( signal , name ) + offset ) except KeyError : pass raise ValueError ( 'signal invalid: {}' . format ( signum ) )
resolves the signal number from arbitrary signal representation .