<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> from os . path import dirname , isdir , join <EOL> import re <EOL> from subprocess import CalledProcessError , Popen , PIPE <EOL> try : <EOL> from subprocess import check_output <EOL> except ImportError : <EOL> def check_output ( * popenargs , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in kwargs : <EOL> raise ValueError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> process = Popen ( stdout = PIPE , * popenargs , ** kwargs ) <EOL> output , unused_err = process . communicate ( ) <EOL> retcode = process . poll ( ) <EOL> if retcode : <EOL> cmd = kwargs . get ( "<STR_LIT:args>" ) <EOL> if cmd is None : <EOL> cmd = popenargs [ <NUM_LIT:0> ] <EOL> raise CalledProcessError ( retcode , cmd ) <EOL> return output <EOL> version_re = re . compile ( '<STR_LIT>' , re . M ) <EOL> __all__ = [ '<STR_LIT>' ] <EOL> def get_version ( ) : <EOL> d = dirname ( __file__ ) <EOL> if isdir ( join ( d , '<STR_LIT>' ) ) : <EOL> cmd = '<STR_LIT>' . split ( ) <EOL> try : <EOL> version = check_output ( cmd ) . decode ( ) . strip ( ) <EOL> except CalledProcessError : <EOL> print ( '<STR_LIT>' ) <EOL> exit ( <NUM_LIT:1> ) <EOL> if '<STR_LIT:->' in version : <EOL> version = '<STR_LIT>' . join ( version . split ( '<STR_LIT:->' ) [ : <NUM_LIT:2> ] ) <EOL> else : <EOL> with open ( join ( d , '<STR_LIT>' ) ) as f : <EOL> version = version_re . search ( f . read ( ) ) . group ( <NUM_LIT:1> ) <EOL> return version <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> print ( get_version ( ) ) </s>
