Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/klfd4/devilry-django
Browse files Browse the repository at this point in the history
  • Loading branch information
rebekkjm committed Jul 25, 2011
2 parents f42f89d + 368d4a5 commit a4cd074
Showing 1 changed file with 59 additions and 38 deletions.
97 changes: 59 additions & 38 deletions devilryclient/plugins/updatemeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,49 +47,70 @@ def run(self):
6: self.delivery_meta
}

# sort the keys by increasing depth
for key in sorted(self.metadata.keys(), key=lambda path: len(path.split(sep))):
if key == '.meta':
continue
print key
#methods[self.depth(key)](key)
methods[self.depth(key)](key)

def subject_meta(self, path):
# not much to do, really
pass

# alias to something shorter
meta = self.metadata[path]['.meta']
try:
meta['num_subjects'] += 1
except KeyError:
meta['num_subjects'] = 0
meta['num_deliveries'] = 0
meta['num_late_deliveries'] = 0
meta['num_periods'] = 0
meta['num_corrected'] = 0
meta['num_groups'] = 0
meta['num_assignments'] = 0

def period_meta(self, path):
print "sdf", path
periods = self.metadata[path]
periods['.meta']['num_assignmentgroups'] = 0 # for this subject
for period in periods.keys():
if period[0] != '.':
path_dict['period'] = period
self.assignment_meta(path_dict)

def assignment_meta(self, path_dict):
subject = path_dict['subject']
period = path_dict['period']
assignments = self.metadata[subject][period]
assignments['.meta']['num_assignmentgroups'] = 0 #for period
for assignment in assignments.keys():
if assignment[0] != '.':
path_dict['assignment'] = assignment
self.group_meta(path_dict)

def group_meta(self, path_dict):
subject = path_dict['subject']
period = path_dict['period']
assignment = path_dict['assignment']
groups = self.metadata[subject][period][assignment]
groups['.meta']['num_assignmentgroups'] = 0 #for assignment
for group in groups.keys():
if group[0] != '.':
path_dict['group'] = group
self.metadata['.meta']['num_assignmentgroups'] += 1
self.metadata[subject]['.meta']['num_assignmentgroups'] += 1
self.metadata[subject][period]['.meta']['num_assignmentgroups'] += 1
self.metadata[subject][period][assignment]['.meta']['num_assignmentgroups'] += 1
self.deadline_meta(path_dict)
# alias to something shorter
meta = self.metadata[path]['.meta']
meta['num_groups'] = 0
meta['num_deliveries'] = 0
meta['num_late_deliveries'] = 0
meta['num_assignments'] = 0

def assignment_meta(self, path):
meta = self.metadata[path]['.meta']
meta['num_groups'] = 0
meta['num_deliveries'] = 0
meta['num_late_deliveries'] = 0

# update upwards
while dirname(path) != '':
path = dirname(path)
self.metadata[path]['.meta']['num_assignments'] += 1

def group_meta(self, path):
# alias to something shorter
meta = self.metadata[path]['.meta']
meta['num_deliveries'] = 0
meta['num_late_deliveries'] = 0

# update upwards
while dirname(path) != '':
path = dirname(path)
self.metadata[path]['.meta']['num_groups'] += 1

# subject = path_dict['subject']
# period = path_dict['period']
# assignment = path_dict['assignment']
# groups = self.metadata[subject][period][assignment]
# groups['.meta']['num_assignmentgroups'] = 0 #for assignment
# for group in groups.keys():
# if group[0] != '.':
# path_dict['group'] = group
# self.metadata['.meta']['num_assignmentgroups'] += 1
# self.metadata[subject]['.meta']['num_assignmentgroups'] += 1
# self.metadata[subject][period]['.meta']['num_assignmentgroups'] += 1
# self.metadata[subject][period][assignment]['.meta']['num_assignmentgroups'] += 1
# self.deadline_meta(path_dict)

def deadline_meta(self, path):
self.metadata[path]['deadline'] = deadline_unformat(basename(path)[2:])
Expand All @@ -105,11 +126,11 @@ def delivery_meta(self, path):
# if delivery[0] != '.':
# path_dict['delivery'] = delivery
# self.file_meta(path_dict)
print path
# alias to something short
meta = self.metadata[path]['.meta']
meta['done'] = "TODO: noooo, we shouldnt overwrite this variable if it existed before sync"
meta['is_late'] = is_late(self.metadata[dirname(path)]['deadline'])
# meta['deliver_time'] =
#is_late(self.metadata[dirname(path)]['deadline'])

def file_meta(self, path_dict):
subject = path_dict['subject']
Expand Down

0 comments on commit a4cd074

Please sign in to comment.