<s> from distutils . version import StrictVersion <EOL> import re <EOL> import string <EOL> __author__ = '<STR_LIT>' <EOL> class DevedVersion ( StrictVersion ) : <EOL> """<STR_LIT>""" <EOL> _strict_re_str = StrictVersion . version_re . pattern [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> _deved_re_str = r'<STR_LIT>' . format ( strict_re = _strict_re_str ) <EOL> _deved_re = re . compile ( _deved_re_str , re . VERBOSE ) <EOL> def __init__ ( self , vstring = None ) : <EOL> match = self . _deved_re . match ( vstring ) <EOL> if not match : <EOL> raise ValueError ( "<STR_LIT>" % vstring ) <EOL> else : <EOL> dev_num_index = len ( match . groups ( ) ) <EOL> if match . group ( dev_num_index ) : <EOL> self . dev = string . atoi ( match . group ( dev_num_index ) ) <EOL> else : <EOL> self . dev = <NUM_LIT:0> <EOL> vstring = match . group ( <NUM_LIT:1> ) <EOL> self . version = None <EOL> StrictVersion . __init__ ( self , vstring ) <EOL> def _increase_version ( self , count = <NUM_LIT:1> , index = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> old_version = self . version <EOL> old_comp = old_version [ index ] <EOL> new_comp = old_comp + count <EOL> new_version = [ ] <EOL> for i , _ in enumerate ( old_version ) : <EOL> if i == index : <EOL> new_version . append ( new_comp ) <EOL> elif i > index : <EOL> new_version . append ( <NUM_LIT:0> ) <EOL> else : <EOL> new_version . append ( old_version [ i ] ) <EOL> self . dev = <NUM_LIT:0> <EOL> self . version = tuple ( new_version ) <EOL> def increase_major ( self , count = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . _increase_version ( count , <NUM_LIT:0> ) <EOL> def increase_minor ( self , count = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . _increase_version ( count , <NUM_LIT:1> ) <EOL> def increase_patch ( self , count = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . _increase_version ( count , <NUM_LIT:2> ) <EOL> def increase_dev ( self , level = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . dev += level <EOL> def __str__ ( self ) : <EOL> prefix = StrictVersion . __str__ ( self ) <EOL> suffix = '<STR_LIT>' . format ( ver = self . dev ) if self . dev > <NUM_LIT:0> else '<STR_LIT>' <EOL> return '<STR_LIT>' . format ( prefix = prefix , suffix = suffix ) </s>
