Refactoring Code

## [Setup.py](setup.py)

- Use `with` when opening file to ensure closure

## [Util.py](mako/util.py)

- Remove unnecessary else after guard condition
- Replace if statement with if expression
- Remove unnecessary else after guard condition
- Replace unneeded comprehension with generator
- Inline variable that is immediately returned

## [Template.py](mako/template.py)

- Replace if statement with if expression, Simplify if expression by using or
- Replace list(), dict() or set() with comprehension
- Swap if/else branches, Merge else clause's nested if statement into elif

## [Runtime.py](mako/runtime.py)

- Remove unnecessary else after guard condition

## [PyParser.py](mako/pyparser.py)

- Replace yield inside for loop with yield from
- Lift code into else after jump in control flow, Merge else clause's nested if statement into elif
- Replace if statement with if expression

## [Pygen.py](mako/pygen.py)

- Merge nested if conditions
- Simplify conditional into return statement (removes comment)
- Replace if statement with if expression, Simplify boolean if expression

## [Parsetree.py](mako/parsetree.py)

- Replace unneeded comprehension with generator
- Merge else clause's nested if statement into elif
- Replace unneeded comprehension with generator

## [Lookup.py](mako/lookup.py)

- Swap if/else branches, Merge else clause's nested if statement into elif
- Swap if/else branches, Remove unnecessary else after guard condition

## [Lexer.py](mako/lexer.py)

- Replace if statement with if expression
- Merge nested if conditions
- Swap if/else branches, Remove unnecessary else after guard condition, Merge else clause's nested if statement into elif
- Swap if/else branches, Remove unnecessary else after guard condition

## [Exceptions.py](mako/exceptions.py)

- Replace if statement with if expression, Use `with` when opening file to ensure closure

## [Ast.py](mako/ast.py)

- Replace multiple comparisons of same variable with `in` operator

## [Pygmentplugin.py](mako/ext/pygmentplugin.py)

- Replace if statement with if expression

Closes: #335
Pull-request: https://github.com/sqlalchemy/mako/pull/335
Pull-request-sha: c6243b116441f4b14e1cff00f47ed72aee3d3133

Change-Id: I9093e2f5ca4bb59aa12536b1a0bdf2d58514aa40
15 files changed