Exemplo n.º 1
0
    def do(self, thisdoc):
        """Do the data paste."""

        import commandinterpreter

        # write data into a temporary document
        tempdoc = doc.Document()
        # interpreter to create datasets
        interpreter = commandinterpreter.CommandInterpreter(tempdoc)
        interpreter.runFile(self.data)

        # list of pasted datasets
        self.newds = []

        # now transfer datasets to existing document
        for name, ds in sorted(tempdoc.data.iteritems()):

            # get new name
            if name not in thisdoc.data:
                newname = name
            else:
                for idx in count(2):
                    newname = '%s_%s' % (name, idx)
                    if newname not in thisdoc.data:
                        break

            thisdoc.setData(newname, ds)
            self.newds.append(newname)
Exemplo n.º 2
0
 def __init__(self, doc):
     root = '/Windows/%i/Document' % DBusInterface._ctr
     vzdbus.Object.__init__(self, vzdbus.sessionbus, root)
     self.index = DBusInterface._ctr
     DBusInterface._ctr += 1
     self.cmdinter = commandinterpreter.CommandInterpreter(doc)
     self.ci = self.cmdinter.interface
Exemplo n.º 3
0
    def restart(self):
        self.registers = {
            "AX": 0,
            "BX": 0,
            "CX": 0,
            "DX": 0,
            "SP": 1024,
            "BP": 1024,
            "SI": 0,
            "DI": 0,
            "PC": 0
        }
        """Z: zero flag, S: sign flag, O: overflow flag, C: carry flag,
        A: auxillary flag, P: parity flag, D: direction flag, I: interrupt"""
        self.flags = {
            "Z": False,
            "S": False,
            "O": False,
            "C": False,
            "A": False,
            "P": False,
            "D": False,
            "I": False
        }

        self.path = "~"
        self.lookupTable = {}
        self.LIST_TYPE = type([])
        self.localVars = {}
        self.lastLine = -1
        self.stack = []
        self.openFiles = [0, 0, 0]
        self.breakPoints = []
        self.DATA = {}
        self.BSS = {}
        self.effectiveBSSandDATALocation = {}
        self.codeBounds = [-1, -1]
        self.running = False
        self.ran = False
        self.runningAll = False
        self.waitingForChar = False
        self.inBuffer = ""

        self.addressSpace = [chr(0) for _ in range(1024)]

        self.jumpLocation = -1

        as88 = commandinterpreter.CommandInterpreter(self)

        self.commandArgs = as88.getCommandArgs()
        self.do = as88.getFunctionTable()
Exemplo n.º 4
0
    def do(self, document):
        """Do the import."""

        import commandinterpreter

        # get document to keep track of changes for undo/redo
        document.batchHistory(self)

        # fire up interpreter to read file
        interpreter = commandinterpreter.CommandInterpreter(document)
        try:
            interpreter.runFile(open(self.filename))
        except:
            document.batchHistory(None)
            raise
Exemplo n.º 5
0
    def do(self, document):
        """Do the import."""

        import commandinterpreter

        index = self.index

        # get document to keep track of changes for undo/redo
        document.batchHistory(self)

        # fire up interpreter to read file
        interpreter = commandinterpreter.CommandInterpreter(document)
        parentwidget = document.resolveFullWidgetPath(self.parentpath)

        lines = self.mimedata.split('\n')
        numwidgets = int(lines[0])

        # get types, names and number of lines for widgets
        types = lines[1:1 + 4 * numwidgets:4]
        names = lines[2:2 + 4 * numwidgets:4]
        names = [eval(name) for name in names]
        if self.newnames is not None:
            names = self.newnames
        # paths = lines[3:3+4*numwidgets:4] (not required here)
        widgetslines = lines[4:4 + 4 * numwidgets:4]
        widgetslines = [int(x) for x in widgetslines]

        newwidgets = []
        widgetline = 1 + 4 * numwidgets
        try:
            for wtype, name, numline in izip(types, names, widgetslines):
                thisparent = doc.getSuitableParent(wtype, parentwidget)

                if thisparent is None:
                    raise RuntimeError, "Cannot find suitable parent for pasting"

                # override name if it exists already
                if name in thisparent.childnames:
                    name = None

                # make new widget
                widget = document.applyOperation(
                    operations.OperationWidgetAdd(thisparent,
                                                  wtype,
                                                  autoadd=False,
                                                  name=name,
                                                  index=index))
                newwidgets.append(widget)

                # run generating commands
                interpreter.interface.currentwidget = widget
                for line in lines[widgetline:widgetline + numline]:
                    interpreter.run(line)

                if index >= 0:
                    index += 1

                # move to next widget
                widgetline += numline

        except Exception:
            document.batchHistory(None)
            raise

        # stop batching changes
        document.batchHistory(None)
        return newwidgets