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