-
Notifications
You must be signed in to change notification settings - Fork 315
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
Refactor to use more helpers from details
#773
Comments
In There were even more of these, before I added the Each I refactored This greatly simplified the code for def _tsv(self, start_datetime, event_list):
keys = set(self.details.keys())
keys.update(DETAILS_DEFAULT)
handlers = [handler
for key, handler in HANDLERS.items()
if key in keys]
header_row = chain.from_iterable(handler.fieldnames
for handler in handlers)
print(*header_row, sep='\t')
for event in event_list:
if self.options['ignore_started'] and (event['s'] < self.now):
continue
if self.options['ignore_declined'] and self._DeclinedEvent(event):
continue
row = []
for handler in handlers:
row.extend(handler.get(event))
output = ('\t'.join(row)).replace('\n', r'\n')
print(output)
The code for def AgendaUpdate(self, file=sys.stdin):
reader = DictReader(file, dialect=excel_tab)
if len(self.cals) != 1:
raise GcalcliError('Must specify a single calendar.')
cal = self.cals[0]
for row in reader:
action = row.get('action', ACTION_DEFAULT)
if action not in ACTIONS:
raise GcalcliError('Action "{}" not supported.'.format(action))
getattr(actions, action)(row, cal, self) Each row dispatches to one of the |
My suggestion for priority of refactoring is:
|
As follow-up from #550, the code could use some cleanup to make better use fo common
details
helpers:details.Handler
subclassesDetail.format()
handlers that could be used forgcalcli.gcal.GoogleCalendarInterface._PrintEvent()
.@michaelmhoffman
The text was updated successfully, but these errors were encountered: