makeBar()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 18
rs 9.5
1
#    Copyright 2017 Starbot Discord Project
2
# 
3
#    Licensed under the Apache License, Version 2.0 (the "License");
4
#    you may not use this file except in compliance with the License.
5
#    You may obtain a copy of the License at
6
# 
7
#        http://www.apache.org/licenses/LICENSE-2.0
8
# 
9
#    Unless required by applicable law or agreed to in writing, software
10
#    distributed under the License is distributed on an "AS IS" BASIS,
11
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
#    See the License for the specific language governing permissions and
13
#    limitations under the License.
14
15
def makeBar(progress):
16
    # Get the progress in half for a shorter progress bar
17
    shortProgress = progress/2
18
    # Convert progress to a string while we are at it
19
    progressString = str(progress)
20
21
    # Get the amount of "done" progress, or the % of 100%
22
    doneProgress = int(shortProgress)
23
    # Get the reverse of above, for the % of 100% not done
24
    undoneProgress = 50-int(shortProgress)
25
26
    # We fill the percentage done with # characters
27
    doneString = '#'*doneProgress
28
    # The rest with whitespaces
29
    undoneString = ' '*undoneProgress
30
31
    # Build our progress bar and return it
32
    return '[{}{}] {}%'.format(doneString, undoneString, progressString.rjust(5))