INNER CODE UNIT · Python

get_version

wwood/singlem · admin/build_docs.py:17

def get_version(relpath):
    """Read version info from a file without importing it"""
    for line in io.open(join(dirname(__file__), '..', relpath), encoding="cp437"):
        if "__version__" in line:
            if '"' in line:
                return line.split('"')[1]
            elif "'" in line:
                return line.split("'")[1]


if __name__ == '__main__':
    parent_parser = argparse.ArgumentParser(add_help=False)
    parent_parser.add_argument('--quiet', help='only output errors', action="store_true")
    # version
    parent_parser.add_argument('--version', help='not with v e.g. 0.19.0', required=True)

    args = parent_parser.parse_args()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…