#NEWLINE# def to_signum( signum ) : #NEWLINE# #INDENT# "Resolves the signal number from arbitrary signal representation.\n\n     Supported formats:\n        10 - plain integers\n        '10' - integers as a strings\n        'KILL' - signal names\n        'SIGKILL' - signal names with SIG prefix\n        'SIGRTMIN+1' - signal names with offsets\n    " #NEWLINE# if isinstance ( signum , int ) : #NEWLINE# #INDENT# return signum #NEWLINE# #UNINDENT# m = re . match ( '(\\w+)(\\+(\\d+))?' , signum ) #NEWLINE# if m : #NEWLINE# #INDENT# name = m . group ( 1 ) . upper ( ) #NEWLINE# if ( not name . startswith ( 'SIG' ) ) : #NEWLINE# #INDENT# name = ( 'SIG' + name ) #NEWLINE# #UNINDENT# offset = ( int ( m . group ( 3 ) ) if m . group ( 3 ) else 0 ) #NEWLINE# try : #NEWLINE# #INDENT# return ( getattr ( signal , name ) + offset ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# raise ValueError ( 'signal invalid: {}' . format ( signum ) )