Skip to content

Add script for identifying old non-deprecated guides #1394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions ci/old_guides.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from tabulate import tabulate
from operator import itemgetter
import yaml
import regex
import glob

def parse_yaml(filestring):
reg = regex.compile(r'^---(.*?)---',flags=regex.DOTALL)
match = regex.search(reg, filestring)
if not match: return {}
yaml_text = match.group(1)
try:
return yaml.load(yaml_text)
except:
return {}

def make_record(yaml):
if 'title' in yaml:
title = yaml['title']
else:
title = "No title"
record = {
'title': title,
'updated': yaml['modified']
}
return record


def find_old_guides():
old_guides = []
guides_scanned = 0
rootdir = 'docs'
for files in glob.glob('docs/**/*.md',recursive=True):
guides_scanned += 1
filename = files
with open(filename, 'r') as f:
filestring = f.read()
parsed = parse_yaml(filestring)
if 'modified' in parsed and 'deprecated' not in parsed:
record = make_record(parsed)
record['path'] = filename
old_guides.append(record)
print(str(guides_scanned) + " guides scanned.")
old_guides.sort(key=itemgetter('updated'))
oldest_guides = old_guides[0:20]
print(tabulate(oldest_guides))


if __name__ == '__main__':
find_old_guides()