File: ProgressBar.py

package info (click to toggle)
sumo 0.21.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 40,576 kB
  • ctags: 29,318
  • sloc: cpp: 128,703; xml: 95,049; ansic: 41,637; java: 40,568; python: 25,712; sh: 11,385; makefile: 1,583; perl: 450
file content (41 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# -*- coding: Latin-1 -*-
"""
@file    ProgressBar.py
@author  Sascha Krieg
@author  Daniel Krajzewicz
@author  Michael Behrisch
@date    2008-06-19
@version $Id: ProgressBar.py 15698 2014-02-22 11:08:50Z behrisch $

A simple progress bar for the console

SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
Copyright (C) 2008-2014 DLR (http://www.dlr.de/) and contributors

This file is part of SUMO.
SUMO is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
"""

def startTask(list, fct):    
    """its a simple progress bar for the console. 
    list=list of elements over which would be iterated
    fct= function which is called for every element of the list
    """    
    listLen=len(list)
    lastProz=0    
    for i in range(5,105,5): 
        s="%02d" %i
        print s,    
    print "%"   
     
    for i in range(listLen):
        actProz=(100*i/listLen)                       
        if actProz!=lastProz and actProz%5==0:
            print "**",
            lastProz=actProz
        #call the function
        fct(list[i])