fix something
- use index to accelerate generate - fix auto suffix problem - improve progrssbar
This commit is contained in:
@ -2,7 +2,7 @@ import sqlite3
|
||||
import DecoratorConstValue as dcv
|
||||
import json
|
||||
import CustomConfig
|
||||
import sys
|
||||
import Progressbar
|
||||
|
||||
def run():
|
||||
exportDb = sqlite3.connect(CustomConfig.export_db)
|
||||
@ -22,25 +22,16 @@ def run():
|
||||
# decorate each graph
|
||||
print('Generating graph...')
|
||||
currentGraphBlockCell = {}
|
||||
percentageAll = len(graphList)
|
||||
if percentageAll == 0:
|
||||
percentageAll = 1
|
||||
percentageNow = 0
|
||||
percentageCache = 0
|
||||
#debug
|
||||
# graphList=graphList[int(percentageAll*3/4):]
|
||||
Progressbar.initProgressbar(len(graphList))
|
||||
for i in graphList:
|
||||
sys.stdout.write('\r[{}{}]{}%'.format(int(percentageCache / 5) * '#',(20 - int(percentageCache / 5)) * '=', percentageCache))
|
||||
sys.stdout.flush()
|
||||
|
||||
currentGraphBlockCell.clear()
|
||||
buildBlock(exportDb, decorateDb, i, currentGraphBlockCell)
|
||||
graphPIO = buildCell(exportDb, decorateDb, i, currentGraphBlockCell)
|
||||
buildLink(exportDb, decorateDb, i, currentGraphBlockCell, graphPIO)
|
||||
|
||||
percentageNow += 1
|
||||
percentageCache = int(100 * percentageNow / percentageAll)
|
||||
|
||||
Progressbar.stepProgressbar()
|
||||
Progressbar.finProgressbar()
|
||||
|
||||
# export information
|
||||
print('Generating info...')
|
||||
buildInfo(exportDb, decorateDb)
|
||||
|
29
SuperScriptViewer/Progressbar.py
Normal file
29
SuperScriptViewer/Progressbar.py
Normal file
@ -0,0 +1,29 @@
|
||||
import sys
|
||||
|
||||
value_All = 0
|
||||
value_Now = 0
|
||||
progressbar_span = 2
|
||||
progressbar_count = int(100/progressbar_span)
|
||||
|
||||
def initProgressbar(all):
|
||||
global value_Now, value_All
|
||||
value_All = all
|
||||
value_Now = 0
|
||||
|
||||
sys.stdout.write('[{}] 0%'.format(progressbar_count * '='))
|
||||
sys.stdout.flush()
|
||||
|
||||
def stepProgressbar():
|
||||
global value_Now, value_All
|
||||
value_Now += 1
|
||||
if (value_Now > value_All):
|
||||
value_Now = value_All
|
||||
|
||||
percentage = int(value_Now / value_All * 100)
|
||||
percentage_bar = int(value_Now / value_All * progressbar_count)
|
||||
sys.stdout.write('\r[{}{}] {}%'.format(percentage_bar * '#',(progressbar_count - percentage_bar) * '=', percentage))
|
||||
sys.stdout.flush()
|
||||
|
||||
def finProgressbar():
|
||||
sys.stdout.write('\r[{}] 100%\n'.format(progressbar_count * '#'))
|
||||
sys.stdout.flush()
|
@ -30,6 +30,9 @@
|
||||
<Compile Include="DecoratorCore.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Progressbar.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ServerCore.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
Reference in New Issue
Block a user