Changeset 07bfe2d2 for this_version.py


Ignore:
Timestamp:
Mar 23, 2017, 3:44:32 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, sampler
Children:
c6c20be
Parents:
c23d45f
git-author:
Martin Hermant <martin.hermant@gmail.com> (03/16/17 16:35:17)
git-committer:
Paul Brossier <piem@piem.org> (03/23/17 15:44:32)
Message:

fix pep8 errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • this_version.py

    rc23d45f r07bfe2d2  
    44
    55__version_info = {}
     6
    67
    78def get_version_info():
     
    1213    if not __version_info:
    1314        this_file_dir = os.path.dirname(os.path.abspath(__file__))
    14         version_file = os.path.join(this_file_dir,  'VERSION')
     15        version_file = os.path.join(this_file_dir, 'VERSION')
    1516
    1617        if not os.path.isfile(version_file):
    1718            raise SystemError("VERSION file not found.")
    1819
     20        for l in open(version_file).readlines():
    1921
    20         for l in open(version_file).readlines():
    21           #exec (l.strip())
    22           if l.startswith('AUBIO_MAJOR_VERSION'):
    23               __version_info['AUBIO_MAJOR_VERSION'] = int(l.split('=')[1])
    24           if l.startswith('AUBIO_MINOR_VERSION'):
    25               __version_info['AUBIO_MINOR_VERSION'] = int(l.split('=')[1])
    26           if l.startswith('AUBIO_PATCH_VERSION'):
    27               __version_info['AUBIO_PATCH_VERSION'] = int(l.split('=')[1])
    28           if l.startswith('AUBIO_VERSION_STATUS'):
    29               __version_info['AUBIO_VERSION_STATUS'] = l.split('=')[1].strip()[1:-1]
     22            if l.startswith('AUBIO_MAJOR_VERSION'):
     23                __version_info['AUBIO_MAJOR_VERSION'] = int(l.split('=')[1])
     24            if l.startswith('AUBIO_MINOR_VERSION'):
     25                __version_info['AUBIO_MINOR_VERSION'] = int(l.split('=')[1])
     26            if l.startswith('AUBIO_PATCH_VERSION'):
     27                __version_info['AUBIO_PATCH_VERSION'] = int(l.split('=')[1])
     28            if l.startswith('AUBIO_VERSION_STATUS'):
     29                __version_info['AUBIO_VERSION_STATUS'] = \
     30                    l.split('=')[1].strip()[1:-1]
    3031
    31           if l.startswith('LIBAUBIO_LT_CUR'):
    32             __version_info['LIBAUBIO_LT_CUR'] = int(l.split('=')[1])
    33           if l.startswith('LIBAUBIO_LT_REV'):
    34             __version_info['LIBAUBIO_LT_REV'] = int(l.split('=')[1])
    35           if l.startswith('LIBAUBIO_LT_AGE'):
    36             __version_info['LIBAUBIO_LT_AGE'] = int(l.split('=')[1])
     32            if l.startswith('LIBAUBIO_LT_CUR'):
     33                __version_info['LIBAUBIO_LT_CUR'] = int(l.split('=')[1])
     34            if l.startswith('LIBAUBIO_LT_REV'):
     35                __version_info['LIBAUBIO_LT_REV'] = int(l.split('=')[1])
     36            if l.startswith('LIBAUBIO_LT_AGE'):
     37                __version_info['LIBAUBIO_LT_AGE'] = int(l.split('=')[1])
    3738
    38         if len(__version_info) <6:
     39        if len(__version_info) < 6:
    3940            raise SystemError("Failed parsing VERSION file.")
    40 
    4141
    4242        # switch version status with commit sha in alpha releases
    4343        if __version_info['AUBIO_VERSION_STATUS'] and \
    44         '~alpha' in __version_info['AUBIO_VERSION_STATUS'] :
     44                '~alpha' in __version_info['AUBIO_VERSION_STATUS']:
    4545            AUBIO_GIT_SHA = get_git_revision_hash()
    4646            if AUBIO_GIT_SHA:
    47               __version_info['AUBIO_VERSION_STATUS'] = '~git'+AUBIO_GIT_SHA
     47                __version_info['AUBIO_VERSION_STATUS'] = '~git' + AUBIO_GIT_SHA
    4848
    4949    return __version_info
     
    5252def get_aubio_version_tuple():
    5353    d = get_version_info()
    54     return (d['AUBIO_MAJOR_VERSION'],d['AUBIO_MINOR_VERSION'],d['AUBIO_PATCH_VERSION'])
     54    return (d['AUBIO_MAJOR_VERSION'],
     55            d['AUBIO_MINOR_VERSION'],
     56            d['AUBIO_PATCH_VERSION'])
     57
    5558
    5659def get_libaubio_version_tuple():
    5760    d = get_version_info()
    58     return (d['LIBAUBIO_LT_CUR'],d['LIBAUBIO_LT_REV'],d['LIBAUBIO_LT_AGE'])
     61    return (d['LIBAUBIO_LT_CUR'], d['LIBAUBIO_LT_REV'], d['LIBAUBIO_LT_AGE'])
     62
    5963
    6064def get_libaubio_version():
    61     return '%s.%s.%s'%get_libaubio_version_tuple()
     65    return '%s.%s.%s' % get_libaubio_version_tuple()
    6266
    63 def get_aubio_version(add_status = True):
     67
     68def get_aubio_version(add_status=True):
    6469    # return string formatted as MAJ.MIN.PATCH.{~git<sha> , ''}
    6570    vdict = get_version_info()
    66     verstr = '%s.%s.%s'%get_aubio_version_tuple()
     71    verstr = '%s.%s.%s' % get_aubio_version_tuple()
    6772    if add_status and vdict['AUBIO_VERSION_STATUS']:
    68         verstr += "."+vdict['AUBIO_VERSION_STATUS']
     73        verstr += "." + vdict['AUBIO_VERSION_STATUS']
    6974    return verstr
    7075
    71 def get_aubio_pyversion(add_status = True):
     76
     77def get_aubio_pyversion(add_status=True):
    7278    # convert to version for python according to pep 440
    7379    # see https://www.python.org/dev/peps/pep-0440/
    7480    # outputs MAJ.MIN.PATCH+a0{.git<sha> , ''}
    7581    vdict = get_version_info()
    76     verstr = '%s.%s.%s'%get_aubio_version_tuple()
    77     if add_status and vdict['AUBIO_VERSION_STATUS'] :
    78       if '~git' in vdict['AUBIO_VERSION_STATUS']:
    79           verstr += "+a0."+vdict['AUBIO_VERSION_STATUS'][1:]
    80       elif '~alpha':
    81           verstr += "+a0"
    82       else:
    83           raise SystemError("Aubio version statut not supported : %s"%vdict['AUBIO_VERSION_STATUS'])
     82    verstr = '%s.%s.%s' % get_aubio_version_tuple()
     83    if add_status and vdict['AUBIO_VERSION_STATUS']:
     84        if '~git' in vdict['AUBIO_VERSION_STATUS']:
     85            verstr += "+a0." + vdict['AUBIO_VERSION_STATUS'][1:]
     86        elif '~alpha':
     87            verstr += "+a0"
     88        else:
     89            raise SystemError("Aubio version statut not supported : %s" %
     90                              vdict['AUBIO_VERSION_STATUS'])
    8491    return verstr
    8592
    8693
    87 
    88 def get_git_revision_hash( short=True):
     94def get_git_revision_hash(short=True):
    8995
    9096    if not os.path.isdir('.git'):
     
    96102    if not os.path.exists(aubio_dir):
    97103        raise SystemError("git / root folder not found")
    98     gitcmd = ['git','-C',aubio_dir ,'rev-parse']
     104    gitcmd = ['git', '-C', aubio_dir, 'rev-parse']
    99105    if short:
    100106        gitcmd.append('--short')
     
    103109        outCmd = subprocess.check_output(gitcmd).strip().decode('utf8')
    104110    except Exception as e:
    105         print ('git command error :%s'%e)
     111        print('git command error :%s' % e)
    106112        return None
    107113    return outCmd
    108 
    109 
Note: See TracChangeset for help on using the changeset viewer.