[copr] master: A more pythonic way of counting loop iterations (d3e944a)

bkabrda at fedoraproject.org bkabrda at fedoraproject.org
Mon Jan 28 09:30:26 UTC 2013


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : master

>---------------------------------------------------------------

commit d3e944a85849ae7f49fb69e6efa17df3345bad56
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date:   Mon Jan 28 09:31:37 2013 +0100

    A more pythonic way of counting loop iterations


>---------------------------------------------------------------

 coprs_frontend/coprs/views/api_ns/api_general.py |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/coprs_frontend/coprs/views/api_ns/api_general.py b/coprs_frontend/coprs/views/api_ns/api_general.py
index a5c94ca..bbb8373 100644
--- a/coprs_frontend/coprs/views/api_ns/api_general.py
+++ b/coprs_frontend/coprs/views/api_ns/api_general.py
@@ -117,8 +117,7 @@ def api_list_copr():
             user_relation = 'owned', username = username)
         repos = query.all()
         output = '{"output": "ok",\n"repos":[\n'
-        cnt = 0
-        for repo in repos:
+        for cnt, repo in enumerate(repos):
             output += '{'\
             '"name" : "%s", '\
             '"repos" : "%s", '\
@@ -126,7 +125,6 @@ def api_list_copr():
             '"instructions": "%s" '\
             '}\n' % (repo.name, repo.repos, repo.description,
                 repo.instructions)
-            cnt = cnt + 1
             if cnt < len(repos):
                 output += ','
         output += "]}\n"



More information about the copr-devel mailing list