<s> __all__ = ( "<STR_LIT>" ) <EOL> from subprocess import Popen , PIPE <EOL> def call_git_describe ( ) : <EOL> try : <EOL> p = Popen ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> stdout = PIPE , stderr = PIPE ) <EOL> p . stderr . close ( ) <EOL> line = p . stdout . readlines ( ) [ <NUM_LIT:0> ] <EOL> return line . strip ( ) . decode ( '<STR_LIT:utf-8>' ) <EOL> except : <EOL> return None <EOL> def read_release_version ( ) : <EOL> try : <EOL> f = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> try : <EOL> version = f . readlines ( ) [ <NUM_LIT:0> ] <EOL> return version . strip ( ) <EOL> finally : <EOL> f . close ( ) <EOL> except : <EOL> return None <EOL> def write_release_version ( version ) : <EOL> f = open ( "<STR_LIT>" , "<STR_LIT:w>" ) <EOL> f . write ( "<STR_LIT>" % version ) <EOL> f . close ( ) <EOL> def get_git_version ( ) : <EOL> release_version = read_release_version ( ) <EOL> version = call_git_describe ( ) <EOL> if version is None : <EOL> version = release_version <EOL> if version is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if version != release_version : <EOL> write_release_version ( version ) <EOL> return version [ <NUM_LIT:1> : ] <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> print ( get_git_version ( ) ) </s>
