Last active
March 28, 2016 12:01
-
-
Save reox/3ce17db8db831b933cf8 to your computer and use it in GitHub Desktop.
Get the latest version of folders named like v23.42.1337
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
versions = filter(lambda x: re.match(r"^v[0-9]+\.[0-9]+\.[0-9]+$", x), os.listdir(path)) | |
# The short form for: | |
# Take the version code like 1.2.197 and create a number out of it: 100020197 (every code part has 4 digits) | |
# Then sort it numerically and take the last one, which should be the largest number | |
last_version = sorted(versions, key=lambda x: sum(map(lambda x: 10 ** ((2-x[0]) * 4) * x[1], enumerate(map(int, x[1:].split("."))))))[-1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment