Get the local version of a signature

def get_local_version(sigdir, sig):
    """Get the local version of a signature"""
    version = None
    filename = os.path.join(sigdir, '%s.cvd' % sig)
    if os.path.exists(filename):
        cmd = ['sigtool', '-i', filename]
        sigtool = Popen(cmd, stdout=PIPE, stderr=PIPE)
        while True:
            line = sigtool.stdout.readline()
            if line and line.startswith('Version:'):
                version = line.split()[1]
                break
            if not line:
                break
        sigtool.wait()
    return version