extensions: Make extensions conform with PEP8

This commit is contained in:
Thomas Lauf 2017-03-01 20:42:32 +01:00
parent 97ab53afeb
commit 310f48973e
4 changed files with 114 additions and 111 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python
################################################################################
###############################################################################
#
# Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez.
#
@ -23,7 +23,7 @@
#
# http://www.opensource.org/licenses/mit-license.php
#
################################################################################
###############################################################################
import sys
import json

View file

@ -1,38 +1,41 @@
#!/usr/bin/env python
################################################################################
##
## Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http:##www.opensource.org/licenses/mit-license.php
##
################################################################################
###############################################################################
#
# Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# http://www.opensource.org/licenses/mit-license.php
#
###############################################################################
import sys
import json
import datetime
def formatSeconds(seconds):
''' Convert seconds: 3661
def format_seconds(seconds):
"""Convert seconds to a formatted string
Convert seconds: 3661
To formatted: 1:01:01
'''
"""
hours = int(seconds / 3600)
minutes = int(seconds % 3600) / 60
seconds = seconds % 60
@ -111,12 +114,12 @@ if max_width > 0:
# Compose table rows.
grand_total = 0
for tag in sorted(totals):
formatted = formatSeconds(totals[tag].seconds)
formatted = format_seconds(totals[tag].seconds)
grand_total += totals[tag].seconds
print '%-*s %10s' % (max_width, tag, formatted)
if untagged is not None:
formatted = formatSeconds(untagged.seconds)
formatted = format_seconds(untagged.seconds)
grand_total += untagged.seconds
print '%-*s %10s' % (max_width, '', formatted)
@ -126,7 +129,7 @@ if max_width > 0:
else:
print ' ' * max_width, '----------'
print '%-*s %10s' % (max_width, 'Total', formatSeconds(grand_total))
print '%-*s %10s' % (max_width, 'Total', format_seconds(grand_total))
else:
print 'No data in the range %s - %s' % (start, end)