Skip to content

Instantly share code, notes, and snippets.

@fthiery
Created November 13, 2018 13:50
Show Gist options
  • Save fthiery/29c1a1b52719b94984ec8f302bafd605 to your computer and use it in GitHub Desktop.
Save fthiery/29c1a1b52719b94984ec8f302bafd605 to your computer and use it in GitHub Desktop.
Script to filter all lineageos devices by year
#!/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