Open nathan-at-least opened 10 years ago
Adding underspecified
tag: this sounds like multiple features/tickets:
sender
, repository
, and organization
in common code for all Github events.str.format
. This is already done, see #16.str.format
templates. This is partially done?In any event, some of those features will be obviated, or their implementations drastically altered by #21 which is ahead in the roadmap (0.2.2
versus undecided
).
Github event processing can be simplified and made more consistent to improve maintainability.
What to Change
First, every event has three common sections according to the docs for payloads:
sender
,repository
, andorganization
, so these details could be formatted generally for all messages.Next, it may be possible to replace specific event handling functions with standard
string.format
templates, with two caveates: incorporating multiple items from JSON arrays and special field formatting, such as for URL-encoding^
characters (see #11).The Current Design
Currently there is a FunctionTable mapping github event names to arbitrary functions which return formatted messages. Every such function uses python
%
-interpolation and explicitly selects pieces of the JSON message (using_AttrLookupWrapper
). Since thestring.format
expansions already support attribute lookup, we can replace these functions with simple string templates.Features Which
string.format
Lackslen(einfo.commits)
(see github.py line 112) or truncating long strings as in line 138.