Add destructor to Progress class
This commit is contained in:
parent
98e7c9a214
commit
f9437a7ec0
@ -46,8 +46,6 @@ def clone_blocks(cursor, args):
|
||||
"INSERT OR REPLACE INTO blocks (pos, data) VALUES (?, ?)",
|
||||
(newPos, data))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# deleteblocks command
|
||||
#
|
||||
@ -62,8 +60,6 @@ def delete_blocks(cursor, args):
|
||||
progress.print_bar(i, len(list))
|
||||
cursor.execute("DELETE FROM blocks WHERE pos = ?", (pos,))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# fillblocks command
|
||||
#
|
||||
@ -90,8 +86,6 @@ def fill_blocks(cursor, args):
|
||||
data = parsedData.serialize()
|
||||
cursor.execute("UPDATE blocks SET data = ? WHERE pos = ?", (data, pos))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# overlayblocks command
|
||||
#
|
||||
@ -111,8 +105,6 @@ def overlay_blocks(cursor, sCursor, args):
|
||||
"INSERT OR REPLACE INTO blocks (pos, data) VALUES (?, ?)",
|
||||
(pos, data))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# replacenodes command
|
||||
#
|
||||
@ -181,8 +173,6 @@ def replace_nodes(cursor, args):
|
||||
|
||||
cursor.execute("UPDATE blocks SET data = ? WHERE pos = ?", (data, pos))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# setparam2 command
|
||||
#
|
||||
@ -219,8 +209,6 @@ def set_param2(cursor, args):
|
||||
data = parsedData.serialize()
|
||||
cursor.execute("UPDATE blocks SET data = ? WHERE pos = ?", (data, pos))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# deletemeta command
|
||||
#
|
||||
@ -253,8 +241,6 @@ def delete_meta(cursor, args):
|
||||
data = parsedData.serialize()
|
||||
cursor.execute("UPDATE blocks SET data = ? WHERE pos = ?", (data, pos))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# setmetavar command
|
||||
#
|
||||
@ -296,8 +282,6 @@ def set_meta_var(cursor, args):
|
||||
data = parsedData.serialize()
|
||||
cursor.execute("UPDATE blocks SET data = ? WHERE pos = ?", (data, pos))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# replaceininv command
|
||||
#
|
||||
@ -350,8 +334,6 @@ def replace_in_inv(cursor, args):
|
||||
data = parsedData.serialize()
|
||||
cursor.execute("UPDATE blocks SET data = ? WHERE pos = ?", (data, pos))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# deletetimers
|
||||
#
|
||||
@ -385,8 +367,6 @@ def delete_timers(cursor, args):
|
||||
data = parsedData.serialize()
|
||||
cursor.execute("UPDATE blocks SET data = ? WHERE pos = ?", (data, pos))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
||||
#
|
||||
# deleteobjects
|
||||
#
|
||||
@ -430,5 +410,3 @@ def delete_objects(cursor, args):
|
||||
parsedData.serialize_static_objects(objects)
|
||||
data = parsedData.serialize()
|
||||
cursor.execute("UPDATE blocks SET data = ? WHERE pos = ?", (data, pos))
|
||||
|
||||
progress.print_bar(len(list), len(list))
|
||||
|
@ -6,10 +6,17 @@ class Progress:
|
||||
"""Prints a progress bar with time elapsed."""
|
||||
|
||||
def __init__(self):
|
||||
self.last_total = 0
|
||||
self.start_time = time.time()
|
||||
|
||||
|
||||
def __del__(self):
|
||||
self.print_bar(self.last_total, self.last_total)
|
||||
|
||||
|
||||
def print_bar(self, completed, total):
|
||||
self.last_total = total
|
||||
|
||||
if completed % 100 == 0 or completed == total:
|
||||
if total > 0:
|
||||
percent = round(completed / total * 100, 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user