Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
I shall do my best! I'm new to this, so please bare with me here.
from itertools import groupby from redminereports import make_redmine getter_issue = lambda i: (i.project.id, i.project.name) columns = ( 'start_date', 'subject', ) project_id = 133 redmine = make_redmine() def render_value(v): try: return v.isoformat() except AttributeError: return v for k, g in groupby(sorted(redmine.issue.filter(project_id = project_id), key = getter_issue), key = getter_issue): for i in g: print('\n'.join( render_value(getattr(i, c, "Column not found: %s" % c)) for c in columns ))
Without AttributeError as a base class getattr() doesn't know to use the default value and you get this:
When ResourceAttrError is an AttributeError, getattr() does it's job: