def json_repr(self, db): res = [resources.json_repr(resources.add_defaults(r, db.resources), db) for r in self.resources] outlinks = compute_outlinks(self.tag, db) dependencies = [{'from_tag': dep.tag, 'to_tag': self.tag, 'reason': dep.reason} for dep in self.dependencies] pointers = [p.json_repr(db.nodes) for p in self.pointers] goals = [p.json_repr(db.nodes) for p in self.goals] flags = [db.flags[f] for f in self.flags if f in db.flags] d = {'tag': self.tag, 'title': self.title, 'id': self.id, 'summary': self.summary, 'goals': goals, 'pointers': pointers, 'dependencies': dependencies, 'resources': res, 'questions': self.questions, 'outlinks': outlinks, 'is_shortcut': 0, 'flags': flags, } if self.tag in db.concept_times: d['time'] = max(db.concept_times[self.tag], work_estimates.MIN_TIME) return d
def check(self): all_errors = {} for tag in self.nodes: curr_errors = [] all_errors[tag] = curr_errors # shortcut dependencies should be a strict subset of concept dependencies if tag in self.shortcuts: for sdep in self.shortcuts[tag].dependencies: found = False for ndep in self.nodes[tag].dependencies: if ndep.tag == sdep.tag: found = True if ndep.shortcut and not sdep.shortcut: curr_errors.append( 'Shortcut allowed for dependency %s in full concept, but not in shortcut' % sdep.tag) if not found: curr_errors.append( 'Dependency %s required for shortcut, but not full concept' % sdep.tag) # resources should have the required fields for r in self.nodes[tag].resources: if 'source' in r and r['source'] not in self.resources: curr_errors.append('Resource with unknown source %s' % r['source']) r_with_defaults = resources.add_defaults(r, self.resources) if 'source' in r: name = r['source'] elif 'title' in r: name = '"' + r['title'] + '"' else: name = '???' REQUIRED_FIELDS = ['title', 'resource_type', 'url'] for field in REQUIRED_FIELDS: if field not in r_with_defaults: curr_errors.append('Resource %s missing %s' % (name, field)) return all_errors
def json_repr(self, db): res = [ resources.json_repr(resources.add_defaults(r, db.resources), db) for r in self.resources ] outlinks = compute_outlinks(self.tag, db) dependencies = [{ 'from_tag': dep.tag, 'to_tag': self.tag, 'reason': dep.reason } for dep in self.dependencies] pointers = [p.json_repr(db.nodes) for p in self.pointers] goals = [p.json_repr(db.nodes) for p in self.goals] flags = [db.flags[f] for f in self.flags if f in db.flags] d = { 'tag': self.tag, 'title': self.title, 'id': self.id, 'summary': self.summary, 'goals': goals, 'pointers': pointers, 'dependencies': dependencies, 'resources': res, 'questions': self.questions, 'outlinks': outlinks, 'is_shortcut': 0, 'flags': flags, } if self.tag in db.concept_times: d['time'] = max(db.concept_times[self.tag], work_estimates.MIN_TIME) return d
def check(self): all_errors = {} for tag in self.nodes: curr_errors = [] all_errors[tag] = curr_errors # shortcut dependencies should be a strict subset of concept dependencies if tag in self.shortcuts: for sdep in self.shortcuts[tag].dependencies: found = False for ndep in self.nodes[tag].dependencies: if ndep.tag == sdep.tag: found = True if ndep.shortcut and not sdep.shortcut: curr_errors.append('Shortcut allowed for dependency %s in full concept, but not in shortcut' % sdep.tag) if not found: curr_errors.append('Dependency %s required for shortcut, but not full concept' % sdep.tag) # resources should have the required fields for r in self.nodes[tag].resources: if 'source' in r and r['source'] not in self.resources: curr_errors.append('Resource with unknown source %s' % r['source']) r_with_defaults = resources.add_defaults(r, self.resources) if 'source' in r: name = r['source'] elif 'title' in r: name = '"' + r['title'] + '"' else: name = '???' REQUIRED_FIELDS = ['title', 'resource_type', 'url'] for field in REQUIRED_FIELDS: if field not in r_with_defaults: curr_errors.append('Resource %s missing %s' % (name, field)) return all_errors
def node_resources(node, resource_defaults): return [resources.add_defaults(r, resource_defaults) for r in node.resources]
def node_resources(node, resource_defaults): return [ resources.add_defaults(r, resource_defaults) for r in node.resources ]