Created
November 13, 2018 13:50
-
-
Save fthiery/29c1a1b52719b94984ec8f302bafd605 to your computer and use it in GitHub Desktop.
Script to filter all lineageos devices by year
This file contains hidden or 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
#!/usr/bin/env python3 | |
# run this a local checkout of https://github.com/LineageOS/lineage_wiki/tree/master/_data/devices | |
import yaml | |
import glob | |
import datetime | |
def get_year(d): | |
if isinstance(d, list): | |
date = next(iter(d[0].values())) | |
return get_year(date) | |
if isinstance(d, datetime.date): | |
return int(d.year) | |
elif isinstance(d, str): | |
return int(d.split('-')[0]) | |
elif isinstance(d, int): | |
return d | |
else: | |
print("Unsupported date format: %s" % d) | |
for path in glob.glob('*.yml'): | |
with open(path, "r") as f: | |
d = yaml.load(f) | |
#print(d['release'], d['codename']) | |
y = get_year(d['release']) | |
if y == 2018: | |
s = "{name} {codename}".format(**d) | |
print(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment