# 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
            sch = showProgress("Recording undo...", level.extractZipSchematicIter(box), cancel=True)
        else:
            sch = level.extractZipSchematic(box)
        if sch == "Cancel":
            raise Cancel
        if sch:
            sch.sourcePoint = box.origin

        return sch


    # represents a single undoable operation
    def perform(self, recordUndo=True):
        " Perform the operation. Record undo information if recordUndo"

    def undo(self):
        """ Undo the operation. Ought to leave the Operation in a state where it can be performed again.
            Default implementation copies all chunks in undoLevel back into level. Non-chunk-based operations
            should override this."""

        if self.undoLevel:

            def _undo():
                yield 0, 0, "Undoing..."
                if hasattr(self.level, 'copyChunkFrom'):
                    for i, (cx, cz) in enumerate(self.undoLevel.allChunks):
                        self.level.copyChunkFrom(self.undoLevel, cx, cz)
                        yield i, self.undoLevel.chunkCount, "Copying chunk %s..." % ((cx, cz),)
                else:
                    for i in self.level.copyBlocksFromIter(self.undoLevel, self.undoLevel.bounds, self.undoLevel.sourcePoint, biomes=True):

# 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

            sch = showProgress("Recording undo...", level.extractZipSchematicIter(box), cancel=True)
        else:
            sch = level.extractZipSchematic(box)
        if sch == "Cancel":
            raise Cancel
        if sch:
            sch.sourcePoint = box.origin

        return sch


    # represents a single undoable operation
    def perform(self, recordUndo=True):
        " Perform the operation. Record undo information if recordUndo"

    def undo(self):
        """ Undo the operation. Ought to leave the Operation in a state where it can be performed again.
            Default implementation copies all chunks in undoLevel back into level. Non-chunk-based operations
            should override this."""

        if self.undoLevel:

            def _undo():
                yield 0, 0, "Undoing..."
                if hasattr(self.level, 'copyChunkFrom'):
                    for i, (cx, cz) in enumerate(self.undoLevel.allChunks):
                        self.level.copyChunkFrom(self.undoLevel, cx, cz)
                        yield i, self.undoLevel.chunkCount, "Copying chunk %s..." % ((cx, cz),)
                else:
                    for i in self.level.copyBlocksFromIter(self.undoLevel, self.undoLevel.bounds, self.undoLevel.sourcePoint, biomes=True):

                        yield i, self.undoLevel.chunkCount, "Copying..."