Commits

Nikolaj Sjujskij  committed eb947be

Fix PEP8 issues

  • Participants
  • Parent commits d93c756

Comments (0)

Files changed (3)

 from __future__ import unicode_literals
 
 import psycopg2
-from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT, UNICODE, UNICODEARRAY
+from psycopg2.extensions import (ISOLATION_LEVEL_AUTOCOMMIT, UNICODE,
+                                 UNICODEARRAY)
 
 psycopg2.extensions.register_type(UNICODE)
 psycopg2.extensions.register_type(UNICODEARRAY)
     pass
 
 DEVLIST = DEVS.items()
-DEVLIST.sort(cmp=lambda x,y: cmp(x[1], y[1]))
+DEVLIST.sort(cmp=lambda x, y: cmp(x[1], y[1]))
 
 # query to fetch month data (with DATE_FIELD set)
 QUERY_MONTH = """SELECT ticket.id, ticket.owner, ticket.summary,
                     """.format(DATE_FIELD)
 
 # query to fetch open tickets and first due_date ever assigned to them
-QUERY_OPEN = """SELECT DISTINCT ON (ticket.id) id, owner, summary, reporter, ticket.time,
-                       COALESCE(ticket_change.oldvalue, ticket_custom.value, '')
+QUERY_OPEN = """SELECT DISTINCT ON (ticket.id) id, owner, summary,
+                   reporter, ticket.time,
+                   COALESCE(ticket_change.oldvalue, ticket_custom.value, '')
                                 AS first_due_date
                 FROM ticket
                     LEFT JOIN ticket_custom ON
 from defaults import *
 from utils import dictify, get_tckt_title
 
+
 def other_colour(colour):
     return 'dark' if colour == 'light' else 'light'
 
+
 @app.route("/")
 @app.route('/<int:month>/')
 @app.route('/<int:month>/<int:year>/')
 
     # calculate timestamp boundaries of the month
     clsd_after = calendar.timegm(
-                      (basedate.year, basedate.month, 1) + (0,) * 3) * (10**6)
+                    (basedate.year, basedate.month, 1) + (0,) * 3
+                                ) * (10 ** 6)
     clsd_before = calendar.timegm(
                       (next_year or basedate.year, next_month, 1) + (0,) * 3
-                                 ) * (10**6)
+                                ) * (10 ** 6)
 
     month_data, month_data_raw, opened, closed = ({}, ) * 4
     for trac in TRACS:
             # add ticket to corresponding list of owner's tickets
             owner = tckt['owner']
             # convert timestamp-like ticket.time to `due_date`
-            due_date = datetime.date.fromtimestamp(tckt['closed_at'] // (10**6))
+            due_date = datetime.date.fromtimestamp(tckt['closed_at']
+                                        // (10 ** 6))
             due_date = due_date.strftime(DATEFORMAT)
             user_tckt_list = month_data_raw.get(owner, [])
             user_tckt_list.append({'id': tckt['id'],
                              add_data={'trac': trac['name'],
                                        'base_url': trac['base_url']})
         # for recently closed tickets
-        week_ago = (time.time() - 604800) * (10**6)   # (7 * 24 * 60 * 60) = 604800
+        # (7 * 24 * 60 * 60) = 604800
+        week_ago = (time.time() - 604800) * (10 ** 6)
         cur.execute(QUERY_CLSD_WEEK, (week_ago, ))
         closed = dictify(cur.fetchall(), 'owner',
                              dict2up=closed,
             ##TODO: do it within utils.dictify (pass function in add_data)
             if not ticket['first_due_date']:
                 continue
-            first_due_date = time.strptime(ticket['first_due_date'], DATEFORMAT)
+            first_due_date = time.strptime(ticket['first_due_date'],
+                                           DATEFORMAT)
             first_due_date = datetime.date(first_due_date.tm_year,
                                            first_due_date.tm_mon,
                                            first_due_date.tm_mday)
                }
     return render_template('index.html', **context)
 
+
 @app.route("/toggle-css/")
 def toggle_css():
     ''' Toggles dark stylesheet to light and vice versa '''
 
 if __name__ == "__main__":
     app.run(host=DEBUG_HOST, debug=True)
-
 from datetime import date
 from settings import DEVS
 
+
 def dictify(dicts, key, dict2up={}, add_data={}):
     ''' Rearranges iterable of dictionaries to dictionary of lists
     ({'key': val1, 'otherkey': otherval1, ...},
         result[value].append(d)
     return result
 
+
 def get_tckt_title(tckt_dict):
     ''' Composes title for ticket '''
     created_on = tckt_dict['time']
-    created_on = date.fromtimestamp(created_on // (10**6))
+    created_on = date.fromtimestamp(created_on // (10 ** 6))
     reporter = DEVS.get(tckt_dict['reporter'], tckt_dict['reporter'])
     return '{0} ({1})'.format(reporter, created_on.strftime("%d.%m.%Y"))