Beispiel #1
0
    def __init__(self,
                 widget,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 items=None,
                 editable=False,
                 orientation='horizontal',
                 callback=None):

        widgetState.__init__(self, widget, label, includeInReports)
        QComboBox.__init__(self, self.controlArea)

        if displayLabel:
            self.hb = widgetBox(self.controlArea, orientation=orientation)
            widgetLabel(self.hb, label)
            self.hb.layout().addWidget(self)
            self.hasLabel = True
        else:
            self.controlArea.layout().addWidget(self)
            self.hasLabel = False
        self.label = label

        self.items = OrderedDict()
        self.setEditable(editable)

        if items:
            self.addItems(items)

        if callback:
            QObject.connect(self, SIGNAL('activated(int)'), callback)
Beispiel #2
0
    def __init__(self,filename='INCAR'):
        OrderedDict.__init__(self)

        self.filename = filename

        # if the INCAR file does not exist, we create it:
        if not os.path.exists(filename):
               f = open(filename, 'w')
               f.close()

        f = open(filename,'r')
        incarString = f.read()
        f.close()

        incarlist = []

        for data, dataStart, dataEnd in assignment.scanString(incarString):
            incarlist.append(data)
            continue

        # The OrteredDict is populated from the incarlist created above.
        for item in incarlist:
            key = item[0]
            val = item[1:]
            # We call the OrderedDict __setitem__ to avoid updating the file at this point
            OrderedDict.__setitem__(self, key, val)
            continue
Beispiel #3
0
	def __init__(self, parent, name):
		# Parent is the Triggers object that created this one.
		# name is a unique name for this trigger.
		self.parent = parent
		self.name = name
		self.matches = OrderedDict()
		self.actions = OrderedDict()
Beispiel #4
0
    def upgrade( self ):
        warnings = OrderedDict()
        do_warn = False
        for vn, upgs in self.upgrades.items():
            warnings[vn] = []

            for u in upgs:
                for upg in self.expand(u):
                    try:
                        old = self.get_item( upg['old'] )
                    except:
                        # OK: deprecated item not found
                        pass
                    else:
                        msg = self.show_keys(upg['old'])
                        if upg['new']:
                            msg += ' -> ' + self.show_keys(upg['new'])
                        else:
                            upg['new'] = upg['old']
                        msg += " - " + upg['cvt'].describe()
                        warnings[vn].append( msg )
                        do_warn = True
                        self.del_item( upg['old'] )
                        if upg['cvt'].describe() != "DELETED (OBSOLETE)":
                            self.put_item( upg['new'], upg['cvt'].convert(old) )
        if do_warn and self.verbose:
            print >> sys.stderr, "WARNING: deprecated items were automatically upgraded in '" + self.descr + "':"
            for vn,msgs in warnings.items():
                for m in msgs:
                    print >> sys.stderr, " * (" + vn + ")", m
Beispiel #5
0
def loadCode(saveCode):
    try:
        saveCode = saveCode.split(' ')
        orderedCards = OrderedDict(sorted(allCards.items(), key=lambda t: t[0]))
        i = 0
        cards = bin(int(saveCode[0]))
        #Trim binary 0b
        cards = cards[2:]
        #if there are missing leading digits
        while len(cards) < 4:
            cards = "0" + cards
        while cards:
            if cards[0].isdigit():
                if int(cards[0]):
                    card = orderedCards.items()[i]
                    deck[card[0]] = card[1]
                    if card[0] in looseCards:
                        del looseCards[card[0]]
            i += 1
            cards = cards[1:]
        model.name = saveCode[1]
        model.char = "char" + saveCode[2]
        return True
    except:
        return False
Beispiel #6
0
def m_override(target, sparse):
    """Override items in a target pdict. Target keys must already exist
    unless there is a "__MANY__" placeholder in the right position."""
    if not sparse:
        target = OrderedDict()
        return
    for key, val in sparse.items():
        if isinstance(val, dict):
            if key not in target:
                if '__MANY__' in target:
                    target[key] = OrderedDict()
                    replicate(target[key], target['__MANY__'])
                else:
                    # TODO - validation prevents this, but handle properly for completeness.
                    raise Exception(
                        "parsec dict override: no __MANY__ placeholder")
            m_override(target[key], val)
        else:
            if key not in target:
                if '__MANY__' in target:
                    if isinstance(val, list):
                        target[key] = val[:]
                    else:
                        target[key] = val
                else:
                    # TODO - validation prevents this, but handle properly for completeness.
                    raise Exception(
                        "parsec dict override: no __MANY__ placeholder")
            if isinstance(val, list):
                target[key] = val[:]
            else:
                target[key] = val
Beispiel #7
0
 def __init__(self, cutflow):
     if isinstance(cutflow, CutflowDecision):
         self._cutflow = OrderedDict(cutflow._cutflow)
     else:
         self._cutflow = OrderedDict(cutflow)
     #just need functions and flags for this
     for key in self._cutflow.keys():
         self._cutflow[key] = self._cutflow[key][:2] + [False]
Beispiel #8
0
 def __init__( self, cfg, spec, descr, verbose=True ):
     """Store the config dict to be upgraded if necessary."""
     self.cfg = cfg
     self.spec = spec
     self.descr = descr
     self.verbose = verbose
     # upgrades must be ordered in case several act on the same item
     self.upgrades = OrderedDict()
Beispiel #9
0
 def __init__(self,cutflow):
     if isinstance(cutflow,CutflowDecision):
         self._cutflow = OrderedDict(cutflow._cutflow)
     else:
         self._cutflow = OrderedDict(cutflow)
     #just need functions and flags for this
     for key in self._cutflow.keys():
         self._cutflow[key] =  self._cutflow[key][:2] + [False]
Beispiel #10
0
class CutflowDecision:
    def __init__(self, cutflow):
        if isinstance(cutflow, CutflowDecision):
            self._cutflow = OrderedDict(cutflow._cutflow)
        else:
            self._cutflow = OrderedDict(cutflow)
        #just need functions and flags for this
        for key in self._cutflow.keys():
            self._cutflow[key] = self._cutflow[key][:2] + [False]
        #print self._cutflow

    def __getitem__(self, idx):
        return self._cutflow[idx][-1]

    def __call__(self, event, index=-1):
        #print 'object index:',index
        for item in self._cutflow.itervalues():
            args = []
            for arg in item[1]:
                argv = getattr(event, arg)
                if index > -1 and not isinstance(argv,
                                                 (int, float, bool, long)):
                    args.append(argv[index])
                else:
                    args.append(argv)
            #print index, item[1], args
            #print 'calling %s with values:'%(item[0]),args
            item[-1] = bool(item[0](*tuple(args)))

    def __nonzero__(self):
        for item in self._cutflow.itervalues():
            if not item[-1]:
                return False
        return True

    #take the modulus of the current value of the cut
    def __mod__(self, cuts):
        for key, item in self._cutflow.iteritems():
            if key not in cuts and not item[-1]:
                return False
        return True

    #cuts is a list of names or an ordereddict
    def __sub__(self, cuts):
        cutflow = []
        if isinstance(cuts, (list, OrderedDict)):
            for key in self._cutflow.keys():
                if key not in cuts:
                    cutflow.append([key, [self._cutflow[key]]])
        return CutflowDecision(cutflow)

    #cuts is a list as mentioned in the class comment or an ordered dict
    def __add__(self, cuts):
        cutflow = OrderDict(self._cutflow)
        if isinstance(cuts, (list, OrderedDict)):
            cutflow += OrderedDict(cuts)
        return CutflowDecision(cutflow)
Beispiel #11
0
    def __init__(self,
                 widget,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 buttons=None,
                 toolTips=None,
                 setChecked=None,
                 orientation='vertical',
                 callback=None):

        if toolTips and len(toolTips) != len(buttons):
            raise RuntimeError(
                _('Number of buttons and toolTips must be equal'))

        QWidget.__init__(self, widget)
        widgetState.__init__(self, widget, label, includeInReports)

        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)

        self.controlArea.layout().addWidget(self)

        if displayLabel:
            self.box = groupBox(self.controlArea,
                                label=label,
                                orientation=orientation)
            # self.layout().addWidget(self.box)
        else:
            self.box = widgetBox(self.controlArea, orientation=orientation)

        # if orientation=='vertical':
        # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
        # QSizePolicy.MinimumExpanding))
        # else:
        # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        # QSizePolicy.Preferred))

        self.label = label
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        self.buttons.setExclusive(False)
        if buttons:
            self.addButtons(buttons)

        # if buttons:
        # for i,b in zip(range(len(buttons)),buttons):
        # w = QCheckBox(b,self.box)
        # if toolTips:
        # w.setToolTip(toolTips[i])
        # self.buttons.addButton(w,i)
        # self.box.layout().addWidget(w)

        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'),
                            callback)
        if setChecked:
            self.setChecked(setChecked)
Beispiel #12
0
    def __init__(self,
                 widget,
                 value=None,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 orientation='vertical',
                 selectionMode=QAbstractItemView.SingleSelection,
                 enableDragDrop=0,
                 dragDropCallback=None,
                 dataValidityCallback=None,
                 sizeHint=None,
                 callback=None,
                 toolTip=None,
                 items=None,
                 *args):

        widgetState.__init__(self, widget, label, includeInReports)
        QListWidget.__init__(self, *args)
        self.label = label
        self.widget = self.controlArea
        if displayLabel:
            self.hb = groupBox(self.controlArea,
                               label=label,
                               orientation=orientation)

        else:
            self.hb = widgetBox(self.controlArea, orientation=orientation)

        self.hb.layout().addWidget(self)
        self.ogValue = value
        self.ogLabels = label
        self.enableDragDrop = enableDragDrop
        self.dragDopCallback = dragDropCallback
        self.dataValidityCallback = dataValidityCallback
        if not sizeHint:
            self.defaultSizeHint = QSize(150, 100)
        else:
            self.defaultSizeHint = sizeHint
        self.setSelectionMode(selectionMode)
        if enableDragDrop:
            self.setDragEnabled(1)
            self.setAcceptDrops(1)
            self.setDropIndicatorShown(1)
            #self.setDragDropMode(QAbstractItemView.DragDrop)

            self.dragStartPosition = 0
        if toolTip:
            self.setToolTip(toolTip)

        self.listItems = OrderedDict()
        if items:
            self.addItems(items)

        if callback:
            QObject.connect(self, SIGNAL('itemClicked(QListWidgetItem*)'),
                            callback)
Beispiel #13
0
class CutflowDecision:
    def __init__(self,cutflow):
        if isinstance(cutflow,CutflowDecision):
            self._cutflow = OrderedDict(cutflow._cutflow)
        else:
            self._cutflow = OrderedDict(cutflow)
        #just need functions and flags for this
        for key in self._cutflow.keys():
            self._cutflow[key] =  self._cutflow[key][:2] + [False]
        #print self._cutflow

    def __getitem__(self,idx):
        return self._cutflow[idx][-1]
    
    def __call__(self,event,index=-1):
        #print 'object index:',index
        for item in self._cutflow.itervalues():
            args = []            
            for arg in item[1]:
                argv = getattr(event,arg)
                if index > -1 and not isinstance(argv,(int,float,bool,long)):
                    args.append(argv[index])
                else:
                    args.append(argv)
            #print index, item[1], args
            #print 'calling %s with values:'%(item[0]),args
            item[-1] = bool(item[0](*tuple(args)))
                
    def __nonzero__(self):
        for item in self._cutflow.itervalues():
            if not item[-1]:
                return False
        return True

    #take the modulus of the current value of the cut
    def __mod__(self,cuts):
        for key,item in self._cutflow.iteritems():
            if key not in cuts and not item[-1]:
                return False
        return True

    #cuts is a list of names or an ordereddict
    def __sub__(self,cuts):
        cutflow = []
        if isinstance(cuts,(list,OrderedDict)):            
            for key in self._cutflow.keys():
                if key not in cuts:
                    cutflow.append([key,[self._cutflow[key]]])
        return CutflowDecision(cutflow)

    #cuts is a list as mentioned in the class comment or an ordered dict
    def __add__(self,cuts):
        cutflow = OrderDict(self._cutflow)
        if isinstance(cuts,(list,OrderedDict)):            
            cutflow += OrderedDict(cuts)
        return CutflowDecision(cutflow)
Beispiel #14
0
    def __setitem__(self,name,value):
        '''modify the builtin setitem behavior so that everytime
        a parameter is added or changed the INCAR file is written out
        so it is always up to date.
        '''
        OrderedDict.__setitem__(self,name,value)

        if __debug__:
            print 'Updating after setting an item!'
        self.Write()
Beispiel #15
0
    def __setitem__(self, name, value):
        '''modify the builtin setitem behavior so that everytime
        a parameter is added or changed the INCAR file is written out
        so it is always up to date.
        '''
        OrderedDict.__setitem__(self, name, value)

        if __debug__:
            print 'Updating after setting an item!'
        self.Write()
Beispiel #16
0
    def __init__(self,filename='INCAR'):
        OrderedDict.__init__(self)

        self.filename = filename
        
        if not os.path.exists(filename):
            return

        f = open(filename,'r')
    
        lines = f.readlines()
        f.close()

        for line in lines:
    
            line = line.strip()
            if len(line) == 0:
                #empty line, ignore it
                continue
            
            #strip out comments.  on finding one, i chop off
            #everything to the right of the # sign
            # this mainly happens when reading in other peoples files
            # we never put comments in the input file when auto-generating them.
            if '#' in line:
                i = line.index('#')
                line = line[0:i]
                                
            if '=' not in line:
                #not a keyword=value line
                # we can ignore the line
                continue

            elif ';' in line:
                #need to split up the line
                keyvals = line.split(';')
                for keyval in keyvals:
                    if '=' in keyval:
                        #make sure it is key=val
                        fields = keyval.split('=')
                        if len(fields) != 2:
                            raise Exception, 'key=val split did not give 2 fields:',keyval

                        key = fields[0]
                        val = fields[1]
                        self[key]=val
            else:
                fields = line.split('=')
                if len(fields) != 2:
                    raise Exception, 'key=val split did not give 2 fields:',keyval
        
                key = fields[0]
                val = fields[1]
                self[key]=val
Beispiel #17
0
    def __init__(self, filename='INCAR'):
        OrderedDict.__init__(self)

        self.filename = filename

        if not os.path.exists(filename):
            return

        f = open(filename, 'r')

        lines = f.readlines()
        f.close()

        for line in lines:

            line = line.strip()
            if len(line) == 0:
                #empty line, ignore it
                continue

            #strip out comments.  on finding one, i chop off
            #everything to the right of the # sign
            # this mainly happens when reading in other peoples files
            # we never put comments in the input file when auto-generating them.
            if '#' in line:
                i = line.index('#')
                line = line[0:i]

            if '=' not in line:
                #not a keyword=value line
                # we can ignore the line
                continue

            elif ';' in line:
                #need to split up the line
                keyvals = line.split(';')
                for keyval in keyvals:
                    if '=' in keyval:
                        #make sure it is key=val
                        fields = keyval.split('=')
                        if len(fields) != 2:
                            raise Exception, 'key=val split did not give 2 fields:', keyval

                        key = fields[0]
                        val = fields[1]
                        self[key] = val
            else:
                fields = line.split('=')
                if len(fields) != 2:
                    raise Exception, 'key=val split did not give 2 fields:', keyval

                key = fields[0]
                val = fields[1]
                self[key] = val
Beispiel #18
0
    def __init__(self,
                 spec,
                 upgrader=None,
                 write_proc=False,
                 tvars=[],
                 tvars_file=None):

        self.sparse = OrderedDict()
        self.dense = OrderedDict()
        self.upgrader = upgrader
        self.tvars = tvars
        self.tvars_file = tvars_file
        self.write_proc = write_proc
        self.checkspec(spec)
        self.spec = spec
Beispiel #19
0
        def process(groups, rows):
            columnsClean = [c.split()[-1] for c in groups[0]]
            if len(groups) == 1:
                return [
                    OrderedDict((col, r[col]) for col in columnsClean)
                    for r in rows
                ]
            g_col = columnsClean[0]
            output = []
            cur = None
            cur_rows = []

            def add_to_output():
                if len(cur_rows) > 0:
                    obj = OrderedDict(
                        (col, cur_rows[0][col]) for col in columnsClean)
                    obj['expand_list'] = process(groups[1:], cur_rows)
                    output.append(obj)

            for r in rows:
                if cur is None or r[g_col] != cur:
                    add_to_output()
                    cur_rows = []
                    cur = r[g_col]
                cur_rows.append(r)
            add_to_output()
            return output
Beispiel #20
0
 def __init__(self, widget, value=None, label=None, displayLabel=True, orientation='vertical', selectionMode=QAbstractItemView.SingleSelection, enableDragDrop = 0, dragDropCallback = None, dataValidityCallback = None, sizeHint = None, callback=None, items = None, *args, **kwargs):
     kwargs.setdefault('includeInReports', True)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,widget,label,**kwargs)
     QListWidget.__init__(self, *args)
     self.label = label
     self.widget = self.controlArea
     if displayLabel:
         self.hb = groupBox(self.controlArea,label=label,orientation=orientation)
         
     else:
         self.hb = widgetBox(self.controlArea,orientation=orientation)
         
     self.hb.layout().addWidget(self)
     self.ogValue = value
     self.ogLabels = label
     self.enableDragDrop = enableDragDrop
     self.dragDopCallback = dragDropCallback
     self.dataValidityCallback = dataValidityCallback
     self.defaultSizeHint = QSize(150,100)
     self.setSelectionMode(selectionMode)
     if enableDragDrop:
         self.setDragEnabled(1)
         self.setAcceptDrops(1)
         self.setDropIndicatorShown(1)
         #self.setDragDropMode(QAbstractItemView.DragDrop)
         
         self.dragStartPosition = 0
     
     self.listItems = OrderedDict()
     if items:
         self.addItems(items)
     
     if callback:
         QObject.connect(self, SIGNAL('itemClicked(QListWidgetItem*)'), callback)
Beispiel #21
0
    def __init__(self,widget,label = None, displayLabel= True, setChecked=False,
    orientation='vertical',callback = None, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,**kwargs)
        

        self.controlArea.layout().addWidget(self)

        self.box = widgetBox(self.controlArea,orientation=orientation)
        
        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        QSizePolicy.Preferred))
        
        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
            
        self.label = label
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        self.buttons.setExclusive(False)
        self.addButton('TRUE', label)


        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)
        if setChecked:
            self.setChecked('TRUE')
Beispiel #22
0
    def __init__(self,widget,label=None, displayLabel=True, 
    items=None, editable=False, orientation='horizontal',callback = None,**kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget,label,**kwargs)
        QComboBox.__init__(self,self.controlArea)
        
        if displayLabel:
            self.hb = widgetBox(self.controlArea,orientation=orientation)
            lb = widgetLabel(self.hb, label)
            self.hb.layout().addWidget(self)
            self.hasLabel = True
            self.hb.layout().setAlignment(lb,Qt.AlignRight)
            lb.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        else:
            self.controlArea.layout().addWidget(self)
            self.hasLabel = False
        self.label = label
        
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
        
        self.items = OrderedDict()
        self.setEditable(editable)

        if items:
            self.addItems(items)

        if callback:
            QObject.connect(self, SIGNAL('activated(int)'), callback)
Beispiel #23
0
    def __init__( self, name, rtdefs, rtover, run_mode ):
        if re.search( '[^0-9a-zA-Z_\.]', name ):
            # dot for namespace syntax (NOT USED).
            # regex [\w] allows spaces.
            raise DefinitionError, "ERROR: Illegal task name: " + name

        rtcfg = {}
        replicate( rtcfg, rtdefs.odict()  ) # copy [runtime] default dict
        override( rtcfg, rtover )    # override with suite [runtime] settings

        self.run_mode = run_mode
        self.rtconfig = rtcfg

        # some defaults
        self.intercycle = False
        self.cycling = False
        self.asyncid_pattern = None
        self.modifiers = []
        self.is_coldstart = False
        self.cyclers = []

        self.follow_on_task = None
        self.clocktriggered_offset = None
        self.namespace_hierarchy = []
        # triggers[0,6] = [ A, B:1, C(T-6), ... ]
        self.triggers = OrderedDict()
        # cond[6,18] = [ '(A & B)|C', 'C | D | E', ... ]
        self.cond_triggers = OrderedDict()
        self.outputs = [] # list of explicit internal outputs; change to
                          # OrderedDict() if need to vary per cycle.
        self.loose_prerequisites = [] # asynchronous tasks

        self.name = name
        self.type = 'free'
Beispiel #24
0
 def get_raw(self, query):
     raw = list(self.conn.execute(query))
     columns = raw[0].keys() if len(raw) > 0 else []
     columns = [
         c.replace('"', '') for c in columns
     ]  #sqlite weirdly returns the quotes around columns sometimes?
     return [OrderedDict(zip(columns, r)) for r in raw]
Beispiel #25
0
def n_minus_one(tree, sel):
    result = OrderedDict(sel)
    for key in sel.keys():
        result[key] = apply_selection_except(
            tree, sel, key, False)  # don't save n-1 info in cut table
    #print 'n-1 result:', result
    return result
Beispiel #26
0
def _orderData(data):
    data_o = OrderedDict()
    attrs_list = ("id", "version", "timestamp", "uid", "user", "changeset", "lat", "lon")
    for a in attrs_list:
        if a in data:
            data_o[a] = data[a]
    return data_o
Beispiel #27
0
    def __init__(self, *args, **kwargs):
        tmt.EclipseProject.__init__(self, *args, **kwargs)
        tmt.WinstoneServer = self
        self.main = "net.gnehzr.tnoodle.server.TNoodleServer"
        self.argv = ['--nobrowser', '--consoleLevel=INFO']

        # Winstone does all of these things =(.
        self.ignoredWarnings += ['unchecked']
        self.ignoredWarnings += ['deprecation']
        self.ignoredWarnings += ['serial']
        self.ignoredWarnings += ['dep-ann']
        self.ignoredWarnings += ['rawtypes']

        # It is important that when we iterate through the plugins
        # in topological sorted order. This way if B uses A, B can clobber
        # A's settings.
        self.plugins = OrderedDict()
Beispiel #28
0
def replicate(target, source):
    """
    Replicate source *into* target. Source elements need not exist in
    target already, so source overrides common elements in target and
    otherwise adds elements to it.
    """
    if not source:
        target = OrderedDict()
        return
    for key, val in source.items():
        if isinstance(val, dict):
            if key not in target:
                target[key] = OrderedDict()
            replicate(target[key], val)
        elif isinstance(val, list):
            target[key] = val[:]
        else:
            target[key] = val
Beispiel #29
0
def _populate_spec_defaults( defs, spec ):
    """Populate a nested dict with default values from a spec."""
    for key,val in spec.items():
        if isinstance( val, dict ):
            if key not in defs:
                defs[key] = OrderedDict()
            _populate_spec_defaults( defs[key], spec[key] )
        else:
            defs[key] = spec[key].args['default']
Beispiel #30
0
 def getentries(self):
     entries = OrderedDict()
     for name in self.listdir():
         if isinstance(name, tuple):
             name, subnode = name
         else:
             subnode = None
         entries[name] = subnode
     return entries
Beispiel #31
0
def addsect(cfig, sname, parents):
    """Add a new section to a nested dict."""
    for p in parents:
        # drop down the parent list
        cfig = cfig[p]
    if sname in cfig:
        # this doesn't warrant a warning unless contained items are repeated
        if cylc.flags.verbose:
            print 'Section already encountered: ' + itemstr(parents + [sname])
    else:
        cfig[sname] = OrderedDict()
Beispiel #32
0
class KeymapGroup:
  def __init__(self, name):
    self.name = name
    self.subgroups = OrderedDict()

  def getAllKeys(self):
    allKeys = []
    for keys in self.subgroups.itervalues():
      for key in keys:
        allKeys.append(key)
    return allKeys
Beispiel #33
0
    def __init__(self,widget,label=None, displayLabel=True, includeInReports=True,
    buttons=None,toolTips = None, setChecked = None,
    orientation='vertical',callback = None, **args):
        
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,includeInReports,**args)
        
        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.label = label
        

        if displayLabel:
            self.box = groupBox(self.controlArea,label=label,orientation=orientation)
            self.controlArea.layout().addWidget(self.box)
        else:
            self.box = widgetBox(self.controlArea,orientation=orientation)

        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
        
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        if buttons:
            self.addButtons(buttons)

        # for i,b in zip(range(len(buttons)),buttons):
            # w = QRadioButton(b)
            # if toolTips:
                # w.setToolTip(toolTips[i])
            # self.buttons.addButton(w)
            # self.box.layout().addWidget(w)

        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)

        if setChecked:
            self.setChecked(setChecked)
Beispiel #34
0
 def updateRedRItems(self):
     ## we go through all of the items and remake the items OrderedDict
     newDict = OrderedDict()
     for r in range(self.count()):
         t = unicode(self.itemAt(r).text())  # get the text of the item
         if t not in self.listItems.values():
             newDict[t] = t
         else:
             for i, ov in self.listItems.items():
                 if ov == t:
                     newDict[i] = ov
     self.listItems = newDict
Beispiel #35
0
def poverride(target, sparse):
    """Override items in a target pdict, target sub-dicts must already exist."""
    if not sparse:
        target = OrderedDict()
        return
    for key, val in sparse.items():
        if isinstance(val, dict):
            poverride(target[key], val)
        elif isinstance(val, list):
            target[key] = val[:]
        else:
            target[key] = val
Beispiel #36
0
def addsect(cfig, sname, parents, verbose):
    """Add a new section to a nested dict."""
    for p in parents:
        # drop down the parent list
        cfig = cfig[p]
    if sname in cfig:
        # this doesn't warrant a warning unless contained items are repeated
        if verbose:
            print 'Section [' + ']['.join(parents +
                                          [sname]) + '] already encountered'
    else:
        cfig[sname] = OrderedDict()
Beispiel #37
0
	def __init__(self, *args, **kwargs):
		tmt.EclipseProject.__init__(self, *args, **kwargs)
		tmt.WinstoneServer = self
		self.main = "net.gnehzr.tnoodle.server.TNoodleServer"
		self.argv = [ '--nobrowser', '--consoleLevel=INFO' ]

		# Winstone does all of these things =(.
		self.ignoredWarnings += [ 'unchecked' ]
		self.ignoredWarnings += [ 'deprecation' ]
		self.ignoredWarnings += [ 'serial' ]
		self.ignoredWarnings += [ 'dep-ann' ]
		self.ignoredWarnings += [ 'rawtypes' ]


        # It is important that when we iterate through the plugins
        # in topological sorted order. This way if B uses A, B can clobber
        # A's settings.
		self.plugins = OrderedDict()
    def __init__(self,widget,label=None, displayLabel=True, buttons=None,toolTips = None, setChecked = None,
    orientation='vertical',callback = None,**kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,**kwargs)
        
        
        self.label = label
        

        if displayLabel:
            self.box = groupBox(self.controlArea,label=label,orientation=orientation)
            self.controlArea.layout().addWidget(self.box)
        else:
            self.box = widgetBox(self.controlArea,orientation=orientation)

        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        QSizePolicy.Preferred))
        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
        
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        if buttons:
            self.addButtons(buttons)

        # for i,b in zip(range(len(buttons)),buttons):
            # w = QRadioButton(b)
            # if toolTips:
                # w.setToolTip(toolTips[i])
            # self.buttons.addButton(w)
            # self.box.layout().addWidget(w)

        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)

        if setChecked:
            self.setChecked(setChecked)
Beispiel #39
0
 def getentries(self, node):
     if isinstance(node, dict):
         return node
     try:
         if not self.USE_DIR_CACHE:
             raise KeyError
         return self.dircache[node]
     except KeyError:
         entries = OrderedDict()
         if hasattr(node, 'listdir'):
             for name in node.listdir():
                 if isinstance(name, tuple):
                     name, subnode = name
                 else:
                     subnode = None
                 entries[name] = subnode
         if self.USE_DIR_CACHE:
             self.dircache[node] = entries
         return entries
Beispiel #40
0
Datei: h.py Projekt: kybin/h
	def initStruct(self):
		self.struct = OrderedDict([
			('root', self.rootpath),
			('show'	, ''),
			('work'	, 'work'),
			# -------------------------------------------------
			# these levels could deleted depends on show struct
			('seq'	, ''),
			('scene', ''),
			('shot'	, ''),
			# -------------------------------------------------
			('run', 'scenes'),
			('task'	, ''),
			('rev'	, '')
			])
		self.head = 'root'
		self.showStruct = set(['seq', 'scene', 'shot'])
		self.bypassStruct = ['work','run']
		self.printStruct = ['show', 'seq', 'scene', 'shot', 'task', 'rev']
Beispiel #41
0
def load_single(FILE,
                SPEC,
                descr,
                upgrader=None,
                do_expand=False,
                verbose=True,
                strict=False):
    """
    Parse, upgrade, validate, combine, and expand a single parsec config file.
    If FILE fails to parse or validate just fall back on spec defaults.
    """
    cfg = OrderedDict()
    try:
        cfg = parse(FILE)
    except FileNotFoundError, x:
        if strict:
            raise
        # not an error - may be relying on defaults
        pass
Beispiel #42
0
    def __init__(self, name, comment=None, Child=None, strict=True):
        """
        @param name: The name for this group.  An argument could be made for making the group itself name-agnostic and only giving it a name upon registration with another group, but that would cripple unregistered groups.

        @param comment: A helpful comment indicating the usage/meaning of a particular group.  This comment will be written to configuration files and used as the help text of the optparse OptionParser the group can generate.

        @param Child: A callable (usually a class) which, if not None, will be used in the get() method to create a requested child rather than raising KeyError.
        """
        # All of these are prefixed with underscores so they won't conflict with
        # registered children.
        if name.startswith('_'):
            raise ValueError(
                'Names beginning with an underscore are forbidden: %r' % name)
        self._name = name
        self._parent = None
        self._Child = Child
        self._strict = strict
        self._comment = comment
        self._children = OrderedDict()
Beispiel #43
0
    def __init__(self,widget,label = None, displayLabel= True, buttons = None,toolTips = None, setChecked=None,
    orientation='vertical',callback = None, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        """Constructor, common parameters will be widget, label, buttons (a list or list-tuple of key values for buttons), toolTips (a list of toolTips for the buttons), and setChecked (a list of keys to check from the buttons)"""
        if toolTips and len(toolTips) != len(buttons):
            raise RuntimeError(_('Number of buttons and toolTips must be equal'))
 
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,**kwargs)
        

        self.controlArea.layout().addWidget(self)

        if displayLabel:
            self.box = groupBox(self.controlArea,label=label,orientation=orientation)
            # self.layout().addWidget(self.box)
        else:
            self.box = widgetBox(self.controlArea,orientation=orientation)
        
        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        QSizePolicy.Preferred))
        
        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
            
        self.label = label
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        self.buttons.setExclusive(False)
        if buttons:
            self.addButtons(buttons)


        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)
        if setChecked:
            self.setChecked(setChecked)
Beispiel #44
0
 def connect(self, nodeName, cxn):
     print 'Connect: %s' % nodeName
     self.cxn = cxn
     self.ctxt = self.cxn.context()
     self.nodeName = nodeName
     
     # state variables of this object
     self.status = 'Missing Devices'
     self.setCurrent = Value(NaN, 'A')
     self.voltageLimit = VOLTAGE_LIMIT_DEFAULT
     self.temperatureOverride = False    # if True, ignore temperature checks
     self.sensingMode = True
     
     # devices we must link to
     self.devs = OrderedDict()
     self.devs[POWER] = {'server' : None, 'values': [NaN] * len(POWER_SETTINGS), 'status': 'not initialized', 'settings': POWER_SETTINGS, 'extras': ['output']}
     self.devs[DMM] = {'server' : None, 'values': [NaN] * len(DMM_SETTINGS), 'status': 'not initialized', 'settings': DMM_SETTINGS, 'gpib address': 24, 'init funcs': ['configure_voltage']}
     self.devs[DC] = {'server' : None, 'values': [NaN] * len(DC_SETTINGS), 'status': 'not initialized', 'settings': DC_SETTINGS, 'extras': ['output', 'persistent_switch_mode', 'persistent_switch_time_elapsed']}
     self.devs[TEMPERATURE] = {'server': None, 'values': [NaN] * len(TEMPERATURE_SETTINGS), 'status': 'not initialized', 'settings': TEMPERATURE_SETTINGS, 'flatten': True, 'pickOneValue': 1}
     self.devs[DMM2] = {'server': None, 'values': [NaN] * len(DMM2_SETTINGS), 'status': 'not initialized', 'settings': DMM2_SETTINGS, 'gpib address': 27,}
     
     
     # Persistent Switch
     self.psHeated = None            # T/F for switch heated or not
     self.psCurrent = NaN * A        # current when switch was cooled/closed
     self.psTime = 0                 # time since switch state was last changed
     self.psRequestedState = None    # None=leave as is, T = heated, F = cooled
     self.psStatus = 'Not started'
     
     # DV logging stuff
     self.dv = None
     self.dvName = None
     self.dvRecordDelay = 5 # record every X seconds
     self.dvLastTimeRecorded = 0
     self.dvStatus = 'Not started'
     
     # the main loop stuff
     self.timeInterval = 0.2
     self.loop = LoopingCall(self.mainLoop)
     self.loopDone = self.loop.start(self.timeInterval, now=True)
     print 'loop started'
 def __init__(self, fn=""):
     OrderedDict.__init__(self)
     _DpkgDatalist.__init__(self, fn)
    all.update(ISO19115p2)
    all.update(ISO19139)
    all.update(SANS1878)
    all.update(COMMON)
    return all

STANDARDS_LOOKUP = {'iso19115': 'ISO19115', 'iso19115p2': 'ISO19115p2' ,
                    'dc': 'DublinCore', 'dublincore' : 'DublinCore',
                   'iso19139': 'ISO19139', 'eml': 'EML',
                   'sans1878': 'SANS1878', 'common': 'COMMON'}

STANDARD_TO_XPATH = {"ISO19115":"iso19115", "DublinCore":"dc",
                               "ISO19139":"iso19139", "SANS1878":"sans1878",
                                "EML":"eml", "COMMON":"common", "ISO19115p2":"iso19115p2"}

SANS1878 = OrderedDict()
SANS1878["sans1878_DatasetTitle"] = "//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString/text()"
SANS1878["sans1878_DatasetReferenceDate"] = "//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:DateTime/text()"
SANS1878["sans1878_DatasetResponsibleParty"] = "//gmd:contact/gmd:CI_ResponsibleParty/gmd:individualName/gco:CharacterString/text()"
SANS1878["sans1878_DatasetResponsiblePartyOrganization"] = "//gmd:contact/gmd:CI_ResponsibleParty/gmd:organisationName/gco:CharacterString/text()"
SANS1878["sans1878_DatasetResponsiblePartyPosition"] = "//gmd:contact/gmd:CI_ResponsibleParty/gmd:positionName/gco:CharacterString/text()"         
SANS1878["sans1878_DatasetLanguage"] = "//gmd:language/gco:CharacterString/text()" 
SANS1878["sans1878_DatasetCharacterSet"] = "//gmd:characterSet/gmd:MD_CharacterSetCode/@codeListValue" 
SANS1878["sans1878_DatasetTopicCategory"] = "//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:topicCategory/gmd:MD_TopicCategoryCode/text()"
SANS1878["sans1878_DatasetScale"] = "//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:spatialResolution/gmd:MD_Resolution/gmd:equivalentScale/gmd:MD_RepresentativeFraction/gmd:denominator/gco:Integer/text()" 
SANS1878["sans1878_DatasetAbstract"] = "//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString/text()" 
SANS1878["sans1878_DatasetFormatName"] = "//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceFormat/gmd:MD_Format/gmd:name/gco:CharacterString/text()" 
SANS1878["sans1878_DatasetFormatVersion"] = "//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceFormat/gmd:MD_Format/gmd:version/gco:CharacterString/text()"
        
SANS1878["sans1878_SpatialWest"] = "//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:westBoundLongitude/gco:Decimal/text()" 
SANS1878["sans1878_SpatialSouth"] = "//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:southBoundLatitude/gco:Decimal/text()" 
Beispiel #47
0
class checkBox(widgetState,QWidget):
    def __init__(self,widget,label = None, displayLabel= True, buttons = None,toolTips = None, setChecked=None,
    orientation='vertical',callback = None, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        """Constructor, common parameters will be widget, label, buttons (a list or list-tuple of key values for buttons), toolTips (a list of toolTips for the buttons), and setChecked (a list of keys to check from the buttons)"""
        if toolTips and len(toolTips) != len(buttons):
            raise RuntimeError(_('Number of buttons and toolTips must be equal'))
 
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,**kwargs)
        

        self.controlArea.layout().addWidget(self)

        if displayLabel:
            self.box = groupBox(self.controlArea,label=label,orientation=orientation)
            # self.layout().addWidget(self.box)
        else:
            self.box = widgetBox(self.controlArea,orientation=orientation)
        
        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        QSizePolicy.Preferred))
        
        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
            
        self.label = label
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        self.buttons.setExclusive(False)
        if buttons:
            self.addButtons(buttons)


        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)
        if setChecked:
            self.setChecked(setChecked)

    def addButtons(self,buttons):
        """Internal function to add buttons.  Can be called by end developer but should be extensively tested to ensure the desired functionality"""
        if type(buttons) in [dict,OrderedDict]:
            for k,v in buttons.items():
                self.addButton(k,v)
        elif type(buttons) in [list]:
            if len(buttons) > 0 and type(buttons[0]) is tuple:
                for k,v in buttons:
                    self.addButton(k,v)
            else:
                for v in buttons:
                    self.addButton(v,v)

            # redRLog.log(redRLog.REDRCORE,redRLog.DEBUG,_('In radioButtons should not use list'))
        else:
            raise Exception(_('In radioButtons, addButtons takes a list, dict or OrderedDict'))

    def addButton(self,id, text,toolTip=None):
        """Internal function called by addButtons"""
        self.items[id] = text
        w = QCheckBox(text)
        if toolTip:
            w.setToolTip(toolTip)
        self.buttons.addButton(w,self.items.keys().index(id))
        self.box.layout().addWidget(w)
                    
    def setSizePolicy(self, h,w):
        # self.controlArea.setSizePolicy(h,w)
        # QWidget.setSizePolicy(self,h,w)
        self.box.setSizePolicy(h,w)
            
    def setChecked(self,ids,logical = True):
        """Sets the keys listed in ids to checked"""
        for i in self.buttons.buttons():
            id = self.buttons.id(i)
            if unicode(self.items.keys()[id]) in ids: i.setChecked(logical)
            else: i.setChecked(not logical)
    
    def checkAll(self):
        """Checks all of the buttons"""
        for i in self.buttons.buttons():
            i.setChecked(True)
    def uncheckAll(self):
        """Unchecks all of the buttons"""
        for i in self.buttons.buttons():
            i.setChecked(False)
    def clear(self):
        """Removes all buttons from the widget.  Should be called before an end developer calls addButtons"""
        self.items = {}
        for i in self.buttons.buttons():
            self.buttons.removeButton(i)
            
    def getChecked(self):
        """Returns a list of checked button's labels"""
        return self.getCheckedItems().values()
        
    def getCheckedIds(self):
        """Returns a list of checked button's IDs"""
        return self.getCheckedItems().keys()
        
    def getCheckedItems(self):
        """Returns a dict of checked keys and labels"""
        checked = {}
        for i in self.buttons.buttons():
            id = self.buttons.id(i)
            if i.isChecked(): checked[self.items.keys()[id]] = self.items[self.items.keys()[id]]
        return checked
    def getUncheckedItems(self):
        """Returns a dict of unchecked keys and labels"""
        checked = {}
        for i in self.buttons.buttons():
            id = self.buttons.id(i)
            if not i.isChecked(): checked[self.items.keys()[id]] = self.items[self.items.keys()[id]]
        return checked
    def getUnchecked(self):
        """Same as getChecked but reversed"""
        return self.getUncheckedItems.values()
    def getUncheckedIds(self):
        """Same as getCheckedIds but reversed"""
        return self.getUncheckedItems.keys()
    
    def buttonAt(self,ind):
        """Returns the button at a given index"""
        return unicode(self.buttons.button(ind).text())
                
    def getSettings(self):
        """Called by :mod:`widgetSettings` to get settings"""
        #print _('radioButtons getSettings') + self.getChecked()
        r = {'items':self.items, 'checked': self.getCheckedIds()}
        return r
    def loadSettings(self,data):
        """Called by :mod:`widgetSettings` to set settings"""
        #print _('radioButtons loadSettings') + data
        #self.addButtons(data['items'])
        self.setChecked(data['checked'])
        
    def getReportText(self, fileDir):
        """Returns report text for report generator"""
        selected = self.getChecked()

        if len(selected):
            text='Checked: ' + ', '.join(selected)
        else:
            text= _('Nothing Checked')
        r = {self.widgetName:{'includeInReports': self.includeInReports, 'text': text}}
        return r
def getMergedStandards():
    """
    @summary: returns a dictionary containing all listed standards
    """
    all = OrderedDict()
    all.update(SANS1878)
    all.update(EML)
    all.update(DublinCore)
    all.update(ISO19115)
    all.update(ISO19115p2)
    all.update(ISO19139)
    all.update(SANS1878)
    all.update(COMMON)
    return all
Beispiel #49
0
class upgrader( object ):
    """Handles upgrading of deprecated config values."""

    def __init__( self, cfg, spec, descr, verbose=True ):
        """Store the config dict to be upgraded if necessary."""
        self.cfg = cfg
        self.spec = spec
        self.descr = descr
        self.verbose = verbose
        # upgrades must be ordered in case several act on the same item
        self.upgrades = OrderedDict()

    def deprecate( self, vn, oldkeys, newkeys=None, cvtr=None ):
        if vn not in self.upgrades:
            self.upgrades[vn] = []
        if cvtr is None:
            cvtr = converter( lambda x: x, "value unchanged" ) # identity
        self.upgrades[vn].append( 
                {
                    'old' : oldkeys,
                    'new' : newkeys,
                    'cvt' : cvtr 
                    }
                )

    def obsolete( self, vn, oldkeys, newkeys=None ):
        if vn not in self.upgrades:
            self.upgrades[vn] = []
        cvtr = converter( lambda x: x, "DELETED (OBSOLETE)" ) # identity
        self.upgrades[vn].append( 
                {
                    'old' : oldkeys,
                    'new' : newkeys,
                    'cvt' : cvtr 
                    }
                )

    def get_item( self, keys ):
        item = self.cfg
        for key in keys:
            item = item[key]
        return item

    def put_item( self, keys, val ):
        item = self.cfg
        for key in keys[:-1]:
            if key not in item:
                item[key] = {} 
            item = item[key]
        item[keys[-1]] = val

    def del_item( self, keys ):
        item = self.cfg
        for key in keys[:-1]:
            item = item[key]
        del item[keys[-1]]

    def show_keys( self, keys ):
        return '[' + ']['.join(keys) + ']'

    def expand( self, upg ):
        """Expands __MANY__ items."""
        if '__MANY__' not in upg['old']:
            return [upg]
        if upg['old'].count( '__MANY__' ) > 1:
            print >> sys.stderr, upg['old']
            raise UpgradeError( "Multiple simultaneous __MANY__ not supported" )
        exp_upgs = []
        pre = []
        post = []
        many = []
        i = -1
        okeys = upg['old']
        for k in okeys:
            i += 1
            if k == "__MANY__":
                pre = okeys[:i]
                post = okeys[i+1:]
                tmp = self.spec
                for j in pre:
                    tmp = tmp[j]
                many = tmp.keys()
                break
        if not many:
            exp_upgs.append( upg )
        else:
            i = -1
            nkeys = upg['new']
            npre = []
            npost = []
            for k in nkeys:
                i += 1
                if k == "__MANY__":
                    npre = nkeys[:i]
                    npost = nkeys[i+1:]
            if not npre or not npost:
                raise UpgradeError('ERROR: __MANY__ mismatch')
            for m in many:
                exp_upgs.append( {
                    'old' : pre + [m] + post,
                    'new' : npre + [m] + npost,
                    'cvt' : upg['cvt']
                    })
        return exp_upgs

    def upgrade( self ):
        warnings = OrderedDict()
        do_warn = False
        for vn, upgs in self.upgrades.items():
            warnings[vn] = []

            for u in upgs:
                for upg in self.expand(u):
                    try:
                        old = self.get_item( upg['old'] )
                    except:
                        # OK: deprecated item not found
                        pass
                    else:
                        msg = self.show_keys(upg['old'])
                        if upg['new']:
                            msg += ' -> ' + self.show_keys(upg['new'])
                        else:
                            upg['new'] = upg['old']
                        msg += " - " + upg['cvt'].describe()
                        warnings[vn].append( msg )
                        do_warn = True
                        self.del_item( upg['old'] )
                        if upg['cvt'].describe() != "DELETED (OBSOLETE)":
                            self.put_item( upg['new'], upg['cvt'].convert(old) )
        if do_warn and self.verbose:
            print >> sys.stderr, "WARNING: deprecated items were automatically upgraded in '" + self.descr + "':"
            for vn,msgs in warnings.items():
                for m in msgs:
                    print >> sys.stderr, " * (" + vn + ")", m
Beispiel #50
0
 def __init__( self, cfg, descr ):
     """Store the config dict to be upgraded if necessary."""
     self.cfg = cfg
     self.descr = descr
     # upgrades must be ordered in case several act on the same item
     self.upgrades = OrderedDict()
Beispiel #51
0
 def clear(self):
     """Removes all items from the comboBox"""
     QComboBox.clear(self)
     self.items = OrderedDict()
Beispiel #52
0
class taskdef(object):
    def __init__( self, name ):
        if re.search( '[^0-9a-zA-Z_\.]', name ):
            # dot for namespace syntax (NOT USED).
            # regex [\w] allows spaces.
            raise DefinitionError, "ERROR: Illegal task name: " + name

        self.name = name
        self.type = 'free'
        self.job_submit_method = None
        self.job_submission_shell = None
        self.job_submit_command_template = None
        self.job_submit_log_directory = None
        self.job_submit_share_directory = None
        self.job_submit_work_directory = None
        self.manual_messaging = False
        self.modifiers = []
        self.asyncid_pattern = None
        self.cycling = False
        self.is_coldstart = False

        self.remote_host = None
        self.owner = None
        self.remote_shell_template = None
        self.remote_cylc_directory = None
        self.remote_suite_directory = None
        self.remote_log_directory = None

        self.reset_timer = False
        self.event_handlers = {}
        self.timeouts = {}
        self.resurrectable = False

        self.intercycle = False
        self.cyclers = []
        self.logfiles = []
        self.description = ['Task description has not been completed' ]

        self.follow_on_task = None

        self.clocktriggered_offset = None

        # triggers[0,6] = [ A, B:1, C(T-6), ... ]
        self.triggers = OrderedDict()
        # cond[6,18] = [ '(A & B)|C', 'C | D | E', ... ]
        self.cond_triggers = OrderedDict()

        self.outputs = [] # list of explicit internal outputs; change to
                          # OrderedDict() if need to vary per cycle.

        self.loose_prerequisites = [] # asynchronous tasks

        self.command = None
        self.retry_delays = deque()
        self.precommand = None
        self.postcommand = None
        self.initial_scripting = None
        self.enviro_scripting = None
        self.ssh_messaging = False

        self.environment = OrderedDict()  # var = value
        self.directives  = OrderedDict()  # var = value

        self.namespace_hierarchy = []

        self.sim_mode_run_length = None
        self.fail_in_sim_mode = False

    def add_trigger( self, trigger, cycler ):
        if cycler not in self.triggers:
            self.triggers[ cycler ] = []
        self.triggers[cycler].append(trigger)

    def add_conditional_trigger( self, triggers, exp, cycler ):
        if cycler not in self.cond_triggers:
            self.cond_triggers[ cycler ] = []
        self.cond_triggers[ cycler ].append( [triggers,exp] )

    def add_to_valid_cycles( self, cyclr ):
            if len( self.cyclers ) == 0:
                self.cyclers = [cyclr]
            else:
                self.cyclers.append( cyclr )

    def time_trans( self, strng, hours=False ):
        # Time unit translation.
        # THIS IS NOT CURRENTLY USED, but may be useful in the future.
        # translate a time of the form:
        #  x sec, y min, z hr
        # into float MINUTES or HOURS,

        if not re.search( '^\s*(.*)\s*min\s*$', strng ) and \
            not re.search( '^\s*(.*)\s*sec\s*$', strng ) and \
            not re.search( '^\s*(.*)\s*hr\s*$', strng ):
                print >> sys.stderr, "ERROR: missing time unit on " + strng
                sys.exit(1)

        m = re.search( '^\s*(.*)\s*min\s*$', strng )
        if m:
            [ mins ] = m.groups()
            if hours:
                return str( float( mins / 60.0 ) )
            else:
                return str( float(mins) )

        m = re.search( '^\s*(.*)\s*sec\s*$', strng )
        if m:
            [ secs ] = m.groups()
            if hours:
                return str( float(secs)/3600.0 )
            else:
                return str( float(secs)/60.0 )

        m = re.search( '^\s*(.*)\s*hr\s*$', strng )
        if m:
            [ hrs ] = m.groups()
            if hours:
                #return str( float(hrs) )
                return float(hrs)
            else:
                #return str( float(hrs)*60.0 )
                return float(hrs)*60.0

    def get_task_class( self ):
        # return a task proxy class definition, to be used for
        # instantiating objects of this particular task class.
        base_types = []
        for foo in self.modifiers + [self.type]:
            # __import__() keyword args were introduced in Python 2.5
            #mod = __import__( 'cylc.task_types.' + foo, fromlist=[foo] )
            mod = __import__( 'cylc.task_types.' + foo, globals(), locals(), [foo] )
            base_types.append( getattr( mod, foo ) )

        tclass = type( self.name, tuple( base_types), dict())
        tclass.name = self.name        # TO DO: NOT NEEDED, USED class.__name__
        tclass.instance_count = 0
        tclass.upward_instance_count = 0
        tclass.description = self.description

        tclass.elapsed_times = []
        tclass.mean_total_elapsed_time = None

        tclass.event_handlers = self.event_handlers
        tclass.timeouts = self.timeouts
        tclass.reset_timer =self.reset_timer

        tclass.resurrectable = self.resurrectable

        tclass.remote_host = self.remote_host
        tclass.owner = self.owner
        tclass.remote_shell_template = self.remote_shell_template
        tclass.remote_cylc_directory = self.remote_cylc_directory
        tclass.remote_suite_directory = self.remote_suite_directory
        tclass.remote_log_directory = self.remote_log_directory

        tclass.job_submit_method = self.job_submit_method
        tclass.job_submission_shell = self.job_submission_shell
        tclass.job_submit_command_template = self.job_submit_command_template
        tclass.job_submit_log_directory = self.job_submit_log_directory
        tclass.job_submit_share_directory = self.job_submit_share_directory
        tclass.job_submit_work_directory = self.job_submit_work_directory
        tclass.manual_messaging = self.manual_messaging

        tclass.intercycle = self.intercycle
        tclass.follow_on = self.follow_on_task

        tclass.namespace_hierarchy = self.namespace_hierarchy

        def tclass_add_prerequisites( sself, startup, cycler, tag  ):

            # NOTE: Task objects hold all triggers defined for the task
            # in all cycling graph sections in this data structure:
            #     self.triggers[cycler] = [list of triggers for this cycler]
            # The list of triggers associated with cyclerX will only be
            # used by a particular task if the task's cycle time is a
            # valid member of cyclerX's sequence of cycle times.

            # 1) non-conditional triggers
            pp = plain_prerequisites( sself.id )
            sp = plain_prerequisites( sself.id )
            lp = loose_prerequisites( sself.id )
            for cyc in self.triggers:
                for trig in self.triggers[ cyc ]:
                    if trig.startup and not startup:
                            continue
                    if trig.cycling and not cyc.valid( ct(sself.tag) ):
                        # This trigger is not used in current cycle.
                        # (see NOTE just above)
                        ##DEBUGGING:
                        ##print >> sys.stderr, sself.name + ': this trigger not used for', sself.tag + ':'
                        ##print >> sys.stderr, ' ', trig.get(sself.tag, cyc)
                        continue
                    # NOTE that if we need to check validity of async
                    # tags, async tasks can appear in cycling sections
                    # in which case cyc.valid( at(sself.tag)) will fail.
                    if trig.async_repeating:
                        lp.add( trig.get( tag, cycler ))
                    else:
                        if trig.suicide:
                            sp.add( trig.get( tag, cycler ))
                        else:
                            pp.add( trig.get( tag, cycler ))
            sself.prerequisites.add_requisites( pp )
            sself.prerequisites.add_requisites( lp )
            sself.suicide_prerequisites.add_requisites( sp )

            # 2) conditional triggers
            for cyc in self.cond_triggers.keys():
                for ctrig, exp in self.cond_triggers[ cyc ]:
                    foo = ctrig.keys()[0]
                    if ctrig[foo].startup and not startup:
                        continue
                    if ctrig[foo].cycling and not cyc.valid( ct(sself.tag)):
                        # This trigger is not valid for current cycle.
                        # (see NOTE just above)
                        ##DEBUGGING:
                        ##print >> sys.stderr, sself.name + ': this trigger not used for', sself.tag + ':'
                        ##print >> sys.stderr, ' ', trig.get(sself.tag, cyc)
                        continue
                    # NOTE that if we need to check validity of async
                    # tags, async tasks can appear in cycling sections
                    # in which case cyc.valid( at(sself.tag)) will fail.
                    cp = conditional_prerequisites( sself.id )
                    for label in ctrig:
                        trig = ctrig[label]
                        cp.add( trig.get( tag, cycler ), label )
                    cp.set_condition( exp )
                    if ctrig[foo].suicide:
                        sself.suicide_prerequisites.add_requisites( cp )
                    else:
                        sself.prerequisites.add_requisites( cp )

        tclass.add_prerequisites = tclass_add_prerequisites

        # class init function
        def tclass_init( sself, start_tag, initial_state, stop_c_time=None, startup=False ):

            sself.cycon = container.cycon( self.cyclers )
            if self.cycling: # and startup:
                # adjust only needed at start-up but it does not hurt to
                # do it every time as after the first adjust we're already
                # on-cycle.
                sself.tag = sself.cycon.initial_adjust_up( start_tag )
            else:
                sself.tag = start_tag

            sself.c_time = sself.tag

            sself.id = sself.name + '%' + sself.tag

            sself.asyncid_pattern = self.asyncid_pattern

            sself.initial_scripting = self.initial_scripting
            sself.enviro_scripting = self.enviro_scripting
            sself.ssh_messaging = self.ssh_messaging

            sself.command = self.command

            sself.sim_mode_run_length = self.sim_mode_run_length
            sself.fail_in_sim_mode = self.fail_in_sim_mode

            # deepcopy retry delays: the deque gets pop()'ed in the task
            # proxy objects, which is no good if all instances of the
            # same task class reference the original deque!
            sself.retry_delays = deepcopy(self.retry_delays)

            sself.precommand = self.precommand
            sself.postcommand = self.postcommand

            if 'clocktriggered' in self.modifiers:
                sself.real_time_delay =  float( self.clocktriggered_offset )

            # prerequisites
            sself.prerequisites = prerequisites()
            sself.suicide_prerequisites = prerequisites()
            sself.add_prerequisites( startup, sself.cycon, sself.tag )

            sself.logfiles = logfiles()
            for lfile in self.logfiles:
                sself.logfiles.add_path( lfile )

            # outputs
            sself.outputs = outputs( sself.id )
            for outp in self.outputs:
                msg = outp.get( sself.tag )
                if not sself.outputs.exists( msg ):
                    sself.outputs.add( msg )
            sself.outputs.register()

            sself.env_vars = OrderedDict()
            for var in self.environment:
                val = self.environment[ var ]
                sself.env_vars[ var ] = val

            sself.directives = OrderedDict()
            for var in self.directives:
                val = self.directives[ var ]
                sself.directives[ var ] = val

            if 'catchup_clocktriggered' in self.modifiers:
                catchup_clocktriggered.__init__( sself )

            if stop_c_time:
                # cycling tasks with a final cycle time set
                super( sself.__class__, sself ).__init__( initial_state, stop_c_time )
            else:
                # TO DO: TEMPORARY HACK FOR ASYNC
                sself.stop_c_time = '99991231230000'
                super( sself.__class__, sself ).__init__( initial_state )

            sself.reconfigure_me = False
            sself.is_coldstart = self.is_coldstart

        tclass.__init__ = tclass_init

        return tclass
Beispiel #53
0
class comboBox(QComboBox,widgetState):
    def __init__(self,widget,label=None, displayLabel=True, 
    items=None, editable=False, orientation='horizontal',callback = None,**kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget,label,**kwargs)
        QComboBox.__init__(self,self.controlArea)
        
        if displayLabel:
            self.hb = widgetBox(self.controlArea,orientation=orientation)
            lb = widgetLabel(self.hb, label)
            self.hb.layout().addWidget(self)
            self.hasLabel = True
            self.hb.layout().setAlignment(lb,Qt.AlignRight)
            lb.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        else:
            self.controlArea.layout().addWidget(self)
            self.hasLabel = False
        self.label = label
        
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
        
        self.items = OrderedDict()
        self.setEditable(editable)

        if items:
            self.addItems(items)

        if callback:
            QObject.connect(self, SIGNAL('activated(int)'), callback)
    def getSettings(self):            
        """Standard getSettings"""
        r = {'items':self.items,
             'current':self.currentIndex()}
        return r
    
    def loadSettings(self,data):
        """Standard loadSettings"""
        # print _('in comboBox load')
        # print data

        self.update(data.get('items', []))
        if data.get('current', None) != None:
            self.setCurrentIndex(data['current'])
    
    def currentId(self):
        """Returns the current ID"""
        try:
            return self.items.keys()[self.currentIndex()]
        except:
            return None
    def currentItem(self):
        """Returns the current key value pair"""
        return {self.items.keys()[self.currentIndex()]:self.items.values()[self.currentIndex()]}
    def setCurrentId(self,id):
        """Sets the current ID, the ID's value will apear in the comboBox"""
        try:
            self.setCurrentIndex(self.items.keys().index(id))
        except:
            pass
    def addItems(self,items):
        """Adds items to the comboBox, new items will appear after old ones"""
        if type(items) in [dict,OrderedDict]:
            for k,v in items.items():
                self.addItem(k,v)
        elif type(items) in [list]:
            if len(items) > 0 and type(items[0]) is tuple:
                for k,v in items:
                    self.addItem(k,v)
            else:
                for v in items:
                    self.addItem(v,v)
            # redRLog.log(redRLog.REDRCORE,redRLog.DEBUG,_('In listBox should not use list'))
        else:
            raise Exception(_('In comboBox, addItems takes a list, dict or OrderedDict'))
    
    def update(self, items):
        """Clears the comboBox and adds new items, sets the current ID to the previously selected ID if found in the items"""
        current = self.currentId()
        self.clear()
        self.addItems(items)
        self.setCurrentId(current)
        
    def clear(self):
        """Removes all items from the comboBox"""
        QComboBox.clear(self)
        self.items = OrderedDict()
    def addItem(self,id,item):
        """Adds a single item"""
        QComboBox.addItem(self,item)
        self.items[id] = item
            
    def getReportText(self, fileDir):
        """Standard getReportText"""
        r = {self.widgetName:{'includeInReports': self.includeInReports, 'text': self.currentText()}}
        #return '%s set to %s' % (self.label, self.currentText())
        return r
Beispiel #54
0
    def __init__( self, name ):
        if re.search( '[^0-9a-zA-Z_\.]', name ):
            # dot for namespace syntax (NOT USED).
            # regex [\w] allows spaces.
            raise DefinitionError, "ERROR: Illegal task name: " + name

        self.name = name
        self.type = 'free'
        self.job_submit_method = None
        self.job_submission_shell = None
        self.job_submit_command_template = None
        self.job_submit_log_directory = None
        self.job_submit_share_directory = None
        self.job_submit_work_directory = None
        self.manual_messaging = False
        self.modifiers = []
        self.asyncid_pattern = None
        self.cycling = False
        self.is_coldstart = False

        self.remote_host = None
        self.owner = None
        self.remote_shell_template = None
        self.remote_cylc_directory = None
        self.remote_suite_directory = None
        self.remote_log_directory = None

        self.reset_timer = False
        self.event_handlers = {}
        self.timeouts = {}
        self.resurrectable = False

        self.intercycle = False
        self.cyclers = []
        self.logfiles = []
        self.description = ['Task description has not been completed' ]

        self.follow_on_task = None

        self.clocktriggered_offset = None

        # triggers[0,6] = [ A, B:1, C(T-6), ... ]
        self.triggers = OrderedDict()
        # cond[6,18] = [ '(A & B)|C', 'C | D | E', ... ]
        self.cond_triggers = OrderedDict()

        self.outputs = [] # list of explicit internal outputs; change to
                          # OrderedDict() if need to vary per cycle.

        self.loose_prerequisites = [] # asynchronous tasks

        self.command = None
        self.retry_delays = deque()
        self.precommand = None
        self.postcommand = None
        self.initial_scripting = None
        self.enviro_scripting = None
        self.ssh_messaging = False

        self.environment = OrderedDict()  # var = value
        self.directives  = OrderedDict()  # var = value

        self.namespace_hierarchy = []

        self.sim_mode_run_length = None
        self.fail_in_sim_mode = False
Beispiel #55
0
class TFCheckBox(widgetState,QWidget):
    def __init__(self,widget,label = None, displayLabel= True, setChecked=False,
    orientation='vertical',callback = None, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,**kwargs)
        

        self.controlArea.layout().addWidget(self)

        self.box = widgetBox(self.controlArea,orientation=orientation)
        
        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        QSizePolicy.Preferred))
        
        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
            
        self.label = label
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        self.buttons.setExclusive(False)
        self.addButton('TRUE', label)


        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)
        if setChecked:
            self.setChecked('TRUE')

    def addButton(self,id, text):
        """Internal function that adds the TRUE button.  Please use the checkBox widget if you want to do this"""
        self.items[id] = text
        w = QCheckBox(text)
        self.buttons.addButton(w,self.items.keys().index(id))
        self.box.layout().addWidget(w)
                    
    def setSizePolicy(self, h,w):
        # self.controlArea.setSizePolicy(h,w)
        # QWidget.setSizePolicy(self,h,w)
        self.box.setSizePolicy(h,w)
            
    def setChecked(self,ids):
        for i in self.buttons.buttons():
            id = self.buttons.id(i)
            if unicode(self.items.keys()[id]) in ids: i.setChecked(True)
            else: i.setChecked(False)
        
    def checked(self):
        """Returns a string of either TRUE if checked or FALSE if not checked.  Formatted for direct addition into an R string call."""
        if 'TRUE' in self.getCheckedIds(): return 'TRUE'
        else: return 'FALSE'

    def getChecked(self):
        return self.getCheckedItems().values()
        # checked = []
        # for i in self.buttons.buttons():
            # if i.isChecked(): checked.append(unicode(i.text()))
        # return checked
    def getCheckedIds(self):
        return self.getCheckedItems().keys()
        # checked = []
        # for i in self.buttons.buttons():
            # if i.isChecked(): checked.append(self.items.keys()[i.id()])
        # return checked
        
    def getCheckedItems(self):
        checked = {}
        for i in self.buttons.buttons():
            id = self.buttons.id(i)
            if i.isChecked(): checked[self.items.keys()[id]] = self.items[self.items.keys()[id]]
        return checked
        
    def getUnchecked(self):
        unChecked = []
        for i in self.buttons.buttons():
            if not i.isChecked(): unChecked.append(unicode(i.text()))
        return unChecked
    
    def buttonAt(self,ind):
        return unicode(self.buttons.button(ind).text())
                
    def getSettings(self):
        #print _('radioButtons getSettings') + self.getChecked()
        r = {'items':self.items, 'checked': self.getCheckedIds()}
        return r
    def loadSettings(self,data):
        #print _('radioButtons loadSettings') + data
        #self.addButtons(data['items'])
        self.setChecked(data['checked'])
        
    def getReportText(self, fileDir):
        selected = self.getChecked()

        if len(selected):
            text='Checked: ' + ', '.join(selected)
        else:
            text= _('Nothing Checked')
        r = {self.widgetName:{'includeInReports': self.includeInReports, 'text': text}}
        # print '@@@@@@@@@@@@@@@@@@@@@@@', r
        #t = 'The following items were checked in %s:\n\n%s\n\n' % (self.label, self.getChecked())
        return r
Beispiel #56
0
 def __init__(self, name):
   self.name = name
   self.subgroups = OrderedDict()
Beispiel #57
0
def get_defaults( spec ):
    """Return a nested dict of default values from a parsec spec."""
    defs = OrderedDict()
    _populate_spec_defaults( defs, spec )
    return defs
Beispiel #58
0
class Project(tmt.EclipseProject):
	def __init__(self, *args, **kwargs):
		tmt.EclipseProject.__init__(self, *args, **kwargs)
		tmt.WinstoneServer = self
		self.main = "net.gnehzr.tnoodle.server.TNoodleServer"
		self.argv = [ '--nobrowser', '--consoleLevel=INFO' ]

		# Winstone does all of these things =(.
		self.ignoredWarnings += [ 'unchecked' ]
		self.ignoredWarnings += [ 'deprecation' ]
		self.ignoredWarnings += [ 'serial' ]
		self.ignoredWarnings += [ 'dep-ann' ]
		self.ignoredWarnings += [ 'rawtypes' ]


        # It is important that when we iterate through the plugins
        # in topological sorted order. This way if B uses A, B can clobber
        # A's settings.
		self.plugins = OrderedDict()

	def configure(self):
		tmt.EclipseProject.configure(self)

		self.nonJavaResourceDeps |= tmt.glob(self.srcResource, '.*$', relativeTo=self.srcResource)
		for f in xmlFileTypes:
			self.nonJavaResourceDeps -= tmt.glob(self.srcResource, "%s$" % f, relativeTo=self.srcResource)

		self.nonJavaSrcDeps |= tmt.glob(self.src, '.*\\.properties$', relativeTo=self.src)
		self.nonJavaSrcDeps |= tmt.glob(self.src, '.*\\.xsd$', relativeTo=self.src)
		self.nonJavaSrcDeps |= tmt.glob(self.src, '.*\\.dtd$', relativeTo=self.src)

	def addPlugin(self, project, needsDb=False):
		project.main = self.main
		project.argv = self.argv

		self.plugins[project.name] = project
		project.needsDb = needsDb

		notDotfile = lambda dirname: not dirname.startswith(".")
		def wrapCompile(ogCompile):
			def newCompile(self):
				if ogCompile(self):
					assert self.webContent
					for dirpath, dirnames, filenames in os.walk(self.webContent):
						dirnames[:] = filter(notDotfile, dirnames) # Note that we're modifying dirnames in place

						if "WEB-INF" in dirnames:
							dirnames.remove("WEB-INF")
						for filename in filter(notDotfile, filenames):
							path = os.path.normpath(os.path.join(dirpath, filename))
							pathRelToWebContent = relpath(path, self.webContent)
							name = join(tmt.WinstoneServer.binResource, "webapps", "ROOT", pathRelToWebContent)
							linkParent = os.path.dirname(name)
							if not os.path.exists(linkParent):
								os.makedirs(linkParent)
							else:
								assert os.path.isdir(linkParent)
							tmt.createSymlinkIfNotExistsOrStale(relpath(path, linkParent), name)
					tmt.WinstoneServer.mungeXmlFiles(topLevelWebProject=self)
			return newCompile
		project.__class__.compile = wrapCompile(project.__class__.compile)

		def webContentDist(self):
			# We just compiled ourself, which caused a recompile
			# of winstone server, so there's no need to recompile it.
			# In fact, recompiling it would be bad, as it would nuke
			# our carefully constructed tnoodle_resources.
			tmt.WinstoneServer.dist(noRemake=True, implementationTitle=self.fullName)
			tmt.WinstoneServer.distJarFile()
			shutil.copy(tmt.WinstoneServer.distJarFile(), self.distJarFile())
		project.__class__.webContentDist = webContentDist

	def getWebappDir(self):
		webappsDir = join(self.binResource, "webapps")
		webappDir = join(webappsDir, "ROOT")
		return webappDir

	def compile(self):
		if tmt.EclipseProject.compile(self):
			if tmt.TmtProject.projects[tmt.args.project] == self:
                # No wrapped compile to call this for us
				self.mungeXmlFiles(topLevelWebProject=self)

			webappDir = self.getWebappDir()
			webappWebInfDir = join(webappDir, "WEB-INF")
			libDir = join(webappWebInfDir, 'lib')
			if not os.path.exists(libDir):
				os.makedirs(libDir)
			classesDir = join(webappWebInfDir, 'classes')
			if not os.path.exists(classesDir):
				os.makedirs(classesDir)

	def mungeXmlFiles(self, topLevelWebProject):
		for f in xmlFileTypes:
			deps = topLevelWebProject.getRecursiveDependenciesTopoSorted()

			webappDir = self.getWebappDir()
			webappWebInfDir = join(webappDir, "WEB-INF")
			if not os.path.isdir(webappWebInfDir):
				os.makedirs(webappWebInfDir)

			srcWebInfDir = join(self.srcResource, "webapps", "ROOT", "WEB-INF")
			xmlRoot = ET.parse(join(srcWebInfDir, f)).getroot()

			if self.needsDb():
				h2ConsoleServlet = """<?xml version="1.0" encoding="UTF-8"?>
<junk>
	<!-- H2 web console -->
	<servlet>
		<servlet-name>H2Console</servlet-name>
		<servlet-class>org.h2.server.web.WebServlet</servlet-class>
		<init-param>
			<param-name>properties</param-name>
			<param-value>null</param-value>
		</init-param>
		<!--
		<init-param>
			<param-name>webAllowOthers</param-name>
			<param-value></param-value>
		</init-param>
		<init-param>
			<param-name>trace</param-name>
			<param-value></param-value>
		</init-param>
		-->
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>InitializeH2Console</servlet-name>
		<servlet-class>net.gnehzr.tnoodle.server.InitializeH2Console</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>H2Console</servlet-name>
		<url-pattern>/h2/*</url-pattern>
	</servlet-mapping>
</junk>
"""
				root = ET.fromstring(h2ConsoleServlet)
				for child in reversed(root):
					xmlRoot.insert(0, child)

			for project in deps:
				if project in self.plugins.values():
					assert project.webContent
					pluginXmlFile = join(project.webContent, "WEB-INF", f)
					if not os.path.exists(pluginXmlFile):
						continue
					tree = ET.parse(pluginXmlFile)
					root = tree.getroot()
					for child in reversed(root):
						xmlRoot.insert(0, child)

			xmlFile = join(webappWebInfDir, f)
			xmlFileOut = open(xmlFile, 'w')

			ET.register_namespace("", "http://java.sun.com/xml/ns/javaee")

			xmlFileOut.write(ET.tostring(xmlRoot))
			xmlFileOut.close()

	def needsDb(self):
		if getattr(tmt.args, "project", None) is None:
			# None may not yet be a key in tmt.TmtProject.projects,
			# we just hack around this by unconditionally returning True here.
			return True
		webProject = tmt.TmtProject.projects[tmt.args.project]
		if webProject == self:
			return True
		deps = webProject.getRecursiveDependenciesTopoSorted(exclude=set([self]))

		for project in deps:
			if project in self.plugins.values():
				if project.needsDb:
					return True

		return False

	def getJars(self, includeCompileTimeOnlyDependencies=False):
		jars = tmt.EclipseProject.getJars(self, includeCompileTimeOnlyDependencies=includeCompileTimeOnlyDependencies)
		if self.needsDb():
			jars.append(tmt.TmtProject.projects['h2-1.3.169.jar'])

		return jars

	def tweakJarFile(self, jar):
        # We don't necessarily want all the plugins in self.plugins to load here,
        # we only want the ones that the project we're currently building somehow
        # depends on.
		webProject = tmt.TmtProject.projects[tmt.args.project]

		# Out jar file already contains everything needed to start up winstone.
		# All the contents of tnoodle_resources are there too (including webroot).
		# The problem is that even after compiling, webroot/WEB-INF/lib/ and
		# webroot/WEB-INF/classes/ are still unpopulated, so simply jarring it up
		# isn't good enough. Here we populate classes/ and lib/. To do so, we need
		# all of the things that webProject depends on, EXCEPT for winstone (ourself).
		deps = webProject.getRecursiveDependenciesTopoSorted(exclude=set([self]))

		webInf = join("tnoodle_resources", "webapps", "ROOT", "WEB-INF")
		libDir = join(webInf, "lib")
		classesDir = join(webInf, "classes")
		for project in deps:
			assert project is not self
			if hasattr(project, "jarFile"):
				arcPath = join(libDir, basename(project.jarFile))
				jar.write(project.jarFile, arcPath)
			elif isinstance(project, tmt.EclipseProject):
				for dirpath, dirnames, filenames in os.walk(project.bin, followlinks=True):
					for name in filenames:
						if dirpath.startswith(join(project.bin, "tnoodle_resources")):
							destDir = ""
						else:
							destDir = classesDir
						path = join(dirpath, name)
						prefixLen = len(project.bin)
						if project.bin.endswith("/"):
							prefixLen += 1
						arcPath = join(destDir, path[prefixLen+1:])
						jar.write(path, arcPath)