# Path: albow/root.py
# class Cancel(Exception):
#     pass
# 
# Path: mceutils.py
# def showProgress(progressText, progressIterator, cancel=False):
#     """Show the progress for a long-running synchronous operation.
#     progressIterator should be a generator-like object that can return
#     either None, for an indeterminate indicator,
#     A float value between 0.0 and 1.0 for a determinate indicator,
#     A string, to update the progress info label
#     or a tuple of (float value, string) to set the progress and update the label"""
#     class ProgressWidget(Dialog):
#         progressFraction = 0.0
#         firstDraw = False
# 
#         def draw(self, surface):
#             Widget.draw(self, surface)
#             frameStart = datetime.now()
#             frameInterval = timedelta(0, 1, 0) / 2
#             amount = None
# 
#             try:
#                 while datetime.now() < frameStart + frameInterval:
#                     amount = progressIterator.next()
#                     if self.firstDraw is False:
#                         self.firstDraw = True
#                         break
# 
#             except StopIteration:
#                 self.dismiss()
# 
#             infoText = ""
#             if amount is not None:
# 
#                 if isinstance(amount, tuple):
#                     if len(amount) > 2:
#                         infoText = ": " + amount[2]
# 
#                     amount, max = amount[:2]
# 
#                 else:
#                     max = amount
#                 maxwidth = (self.width - self.margin * 2)
#                 if amount is None:
#                     self.progressBar.width = maxwidth
#                     self.progressBar.bg_color = (255, 255, 25, 255)
#                 elif isinstance(amount, basestring):
#                     self.statusText = amount
#                 else:
#                     self.progressAmount = amount
#                     if isinstance(amount, (int, float)):
#                         self.progressFraction = float(amount) / (float(max) or 1)
#                         self.progressBar.width = maxwidth * self.progressFraction
#                         self.statusText = str("{0} / {1}".format(amount, max))
#                     else:
#                         self.statusText = str(amount)
# 
#                 if infoText:
#                     self.statusText += infoText
# 
#         @property
#         def estimateText(self):
#             delta = ((datetime.now() - self.startTime))
#             progressPercent = (int(self.progressFraction * 10000))
#             left = delta * (10000 - progressPercent) / (progressPercent or 1)
#             return "Time left: {0}".format(left)
# 
#         def cancel(self):
#             if cancel:
#                 self.dismiss(False)
# 
#         def idleevent(self, evt):
#             self.invalidate()
# 
#     widget = ProgressWidget()
#     widget.progressText = progressText
#     widget.statusText = ""
#     widget.progressAmount = 0.0
# 
#     progressLabel = ValueDisplay(ref=AttrRef(widget, 'progressText'), width=550)
#     statusLabel = ValueDisplay(ref=AttrRef(widget, 'statusText'), width=550)
#     estimateLabel = ValueDisplay(ref=AttrRef(widget, 'estimateText'), width=550)
# 
#     progressBar = Widget(size=(550, 20), bg_color=(150, 150, 150, 255))
#     widget.progressBar = progressBar
#     col = (progressLabel, statusLabel, estimateLabel, progressBar)
#     if cancel:
#         cancelButton = Button("Cancel", action=widget.cancel, fg_color=(255, 0, 0, 255))
#         col += (Column((cancelButton,), align="r"),)
# 
#     widget.add(Column(col))
#     widget.shrink_wrap()
#     widget.startTime = datetime.now()
#     if widget.present():
#         return widget.progressAmount
#     else:
#         return "Canceled"


import atexit
import os
import shutil
import tempfile
import albow
import numpy
import pymclevel
from pymclevel import BoundingBox
from albow.root import Cancel
from mceutils import showProgress
from pymclevel.mclevelbase import exhaust
        if not chunkCount:
            try:
                chunkCount = len(chunks)
            except TypeError:
                chunkCount = -1

        def _extractUndo():
            yield 0, 0, "Recording undo..."
            for i, (cx, cz) in enumerate(chunks):
                undoLevel.copyChunkFrom(level, cx, cz)
                yield i, chunkCount, "Copying chunk %s..." % ((cx, cz),)
            undoLevel.saveInPlace()

        if chunkCount > 25 or chunkCount < 1:
            if "Canceled" == showProgress("Recording undo...", _extractUndo(), cancel=True):
                if albow.ask("Continue with undo disabled?", ["Continue", "Cancel"]) == "Cancel":
                    raise Cancel
                else:
                    return None
        else:
            exhaust(_extractUndo())

        return undoLevel

    def extractUndoSchematic(self, level, box):
        if box.volume > 131072:
            sch = showProgress("Recording undo...", level.extractZipSchematicIter(box), cancel=True)
        else:
            sch = level.extractZipSchematic(box)
        if sch == "Cancel":

# Path: albow/root.py
# class Cancel(Exception):
#     pass
# 
# Path: mceutils.py
# def showProgress(progressText, progressIterator, cancel=False):
#     """Show the progress for a long-running synchronous operation.
#     progressIterator should be a generator-like object that can return
#     either None, for an indeterminate indicator,
#     A float value between 0.0 and 1.0 for a determinate indicator,
#     A string, to update the progress info label
#     or a tuple of (float value, string) to set the progress and update the label"""
#     class ProgressWidget(Dialog):
#         progressFraction = 0.0
#         firstDraw = False
# 
#         def draw(self, surface):
#             Widget.draw(self, surface)
#             frameStart = datetime.now()
#             frameInterval = timedelta(0, 1, 0) / 2
#             amount = None
# 
#             try:
#                 while datetime.now() < frameStart + frameInterval:
#                     amount = progressIterator.next()
#                     if self.firstDraw is False:
#                         self.firstDraw = True
#                         break
# 
#             except StopIteration:
#                 self.dismiss()
# 
#             infoText = ""
#             if amount is not None:
# 
#                 if isinstance(amount, tuple):
#                     if len(amount) > 2:
#                         infoText = ": " + amount[2]
# 
#                     amount, max = amount[:2]
# 
#                 else:
#                     max = amount
#                 maxwidth = (self.width - self.margin * 2)
#                 if amount is None:
#                     self.progressBar.width = maxwidth
#                     self.progressBar.bg_color = (255, 255, 25, 255)
#                 elif isinstance(amount, basestring):
#                     self.statusText = amount
#                 else:
#                     self.progressAmount = amount
#                     if isinstance(amount, (int, float)):
#                         self.progressFraction = float(amount) / (float(max) or 1)
#                         self.progressBar.width = maxwidth * self.progressFraction
#                         self.statusText = str("{0} / {1}".format(amount, max))
#                     else:
#                         self.statusText = str(amount)
# 
#                 if infoText:
#                     self.statusText += infoText
# 
#         @property
#         def estimateText(self):
#             delta = ((datetime.now() - self.startTime))
#             progressPercent = (int(self.progressFraction * 10000))
#             left = delta * (10000 - progressPercent) / (progressPercent or 1)
#             return "Time left: {0}".format(left)
# 
#         def cancel(self):
#             if cancel:
#                 self.dismiss(False)
# 
#         def idleevent(self, evt):
#             self.invalidate()
# 
#     widget = ProgressWidget()
#     widget.progressText = progressText
#     widget.statusText = ""
#     widget.progressAmount = 0.0
# 
#     progressLabel = ValueDisplay(ref=AttrRef(widget, 'progressText'), width=550)
#     statusLabel = ValueDisplay(ref=AttrRef(widget, 'statusText'), width=550)
#     estimateLabel = ValueDisplay(ref=AttrRef(widget, 'estimateText'), width=550)
# 
#     progressBar = Widget(size=(550, 20), bg_color=(150, 150, 150, 255))
#     widget.progressBar = progressBar
#     col = (progressLabel, statusLabel, estimateLabel, progressBar)
#     if cancel:
#         cancelButton = Button("Cancel", action=widget.cancel, fg_color=(255, 0, 0, 255))
#         col += (Column((cancelButton,), align="r"),)
# 
#     widget.add(Column(col))
#     widget.shrink_wrap()
#     widget.startTime = datetime.now()
#     if widget.present():
#         return widget.progressAmount
#     else:
#         return "Canceled"


# Path: editortools/operation.py
import atexit
import os
import shutil
import tempfile
import albow
import numpy
import pymclevel
from pymclevel import BoundingBox
from albow.root import Cancel
from mceutils import showProgress
from pymclevel.mclevelbase import exhaust

        if not chunkCount:
            try:
                chunkCount = len(chunks)
            except TypeError:
                chunkCount = -1

        def _extractUndo():
            yield 0, 0, "Recording undo..."
            for i, (cx, cz) in enumerate(chunks):
                undoLevel.copyChunkFrom(level, cx, cz)
                yield i, chunkCount, "Copying chunk %s..." % ((cx, cz),)
            undoLevel.saveInPlace()

        if chunkCount > 25 or chunkCount < 1:
            if "Canceled" == showProgress("Recording undo...", _extractUndo(), cancel=True):
                if albow.ask("Continue with undo disabled?", ["Continue", "Cancel"]) == "Cancel":
                    raise Cancel
                else:
                    return None
        else:
            exhaust(_extractUndo())

        return undoLevel

    def extractUndoSchematic(self, level, box):
        if box.volume > 131072:
            sch = showProgress("Recording undo...", level.extractZipSchematicIter(box), cancel=True)
        else:
            sch = level.extractZipSchematic(box)
        if sch == "Cancel":

            raise Cancel