Cleanup python generation

- Remove some trailing whitespace
- Slightly sort imports
- Replace is_oneway() calls with a bool