Improving coding style

This commit is contained in:
Denis-Cosmin Nutiu 2017-05-27 21:30:50 +03:00
parent 632397ba7b
commit 7e6ea787bd
5 changed files with 6 additions and 8 deletions

View file

@ -26,7 +26,6 @@ def to_zero_count(page_no):
""" """
Will subtract 1 from the argument it gets, converting it to an int. Will subtract 1 from the argument it gets, converting it to an int.
If the conversion fails or the argument it's negatives it returns zero instead. If the conversion fails or the argument it's negatives it returns zero instead.
>>> to_zero_count(3) >>> to_zero_count(3)
2 2
>>> to_zero_count('a') >>> to_zero_count('a')

View file

@ -24,7 +24,7 @@
<td>{{ item.gpu | truncate(50) }}</td> <td>{{ item.gpu | truncate(50) }}</td>
<td>{{ item.cpu | truncate(50) }}</td> <td>{{ item.cpu | truncate(50) }}</td>
<td>{{ item.score }}</td> <td>{{ item.score }}</td>
<td><a href="{{ url_for('scoreboard.result', id=item.id) }}" target="_blank">See more</a></td> <td><a href="{{ url_for('scoreboard.result', rid=item.id) }}" target="_blank">See more</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View file

@ -83,13 +83,13 @@ def result_post():
@utilities.cache.cached(timeout=60*5) @utilities.cache.cached(timeout=60*5)
@scoreboard.route("/result/<id>", methods=['GET']) @scoreboard.route("/result/<rid>", methods=['GET'])
def result(id): def result(rid):
""" """
Fetches an entry from the database and displays it in a view. Fetches an entry from the database and displays it in a view.
The entry is retrieved from the database and the ID is a primary key for the entry. The entry is retrieved from the database and the ID is a primary key for the entry.
""" """
entry_name = Result.query.filter_by(id=id).first() entry_name = Result.query.filter_by(id=rid).first()
if entry_name: if entry_name:
progress_bar_data = dict() progress_bar_data = dict()
progress_bar_data['value'] = utilities.get_progress_bar_score(entry_name.score) progress_bar_data['value'] = utilities.get_progress_bar_score(entry_name.score)

View file

@ -55,7 +55,6 @@ class UtilitiesTestCase(unittest.TestCase):
self.assertEqual(9, r) self.assertEqual(9, r)
def test_get_environment_variable(self): def test_get_environment_variable(self):
import os
self.assertEqual(ut.get_env_variable("TESTING", "false"), 'false') self.assertEqual(ut.get_env_variable("TESTING", "false"), 'false')
os.environ['TESTING'] = 'True' os.environ['TESTING'] = 'True'
self.assertEqual(ut.get_env_variable("TESTING", "false"), 'True') self.assertEqual(ut.get_env_variable("TESTING", "false"), 'True')