Skip to content

Instantly share code, notes, and snippets.

@tuannvm
Created December 7, 2016 02:17
Show Gist options
  • Save tuannvm/d7837a77cf5e16feeadcad6b7b72beae to your computer and use it in GitHub Desktop.
Save tuannvm/d7837a77cf5e16feeadcad6b7b72beae to your computer and use it in GitHub Desktop.
import os
import re
BASEPATH = 'root/devops/tasks'
courses = []
lastLine = []
folders = os.listdir(BASEPATH)
for folder in folders:
readme = open(BASEPATH + '/' + folder + '/README.txt', 'r')
for line in readme:
if '---' in line:
courses.append(readme.next().strip("\n"))
if '---' in line:
break
for folder in folders:
readme = open(BASEPATH + '/' + folder + '/README.txt', 'r')
for line in readme:
if not line.strip('\n'):
continue
tempLine = line
lastLine.append(tempLine.strip('\n'))
for course in sorted(list(set(courses))):
sumScore = 0
missFolders = []
for i in range(len(courses)):
if courses[i] == course:
score = re.match(r'([0-9]+)\/([0-9]+)', str(lastLine[i]))
if score is not None:
if int(score.group(1)) < int(score.group(2)):
sumScore = sumScore + int(score.group(2)) - int(score.group(1))
else:
sumScore = 0
if sumScore != 0:
missFolders.append(folders[i])
if sumScore != 0:
print "%s (%d)" % (course.strip(),sumScore)
for missFolder in sorted(missFolders):
print "--%s" % missFolder.strip()
print ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment