_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q19400
ItModule.bruteVersionStr
train
def bruteVersionStr(self, valu): ''' Brute force the version out of a string. Args: valu (str): String to attempt to get version information for. Notes: This first attempts to parse strings using the it:semver normalization before attempting to extra...
python
{ "resource": "" }
q19401
chopurl
train
def chopurl(url): ''' A sane "stand alone" url parser. Example: info = chopurl(url) ''' ret = {} if url.find('://') == -1: raise s_exc.BadUrl(':// not found in [{}]!'.format(url)) scheme, remain = url.split('://', 1) ret['scheme'] = scheme.lower() # carve query pa...
python
{ "resource": "" }
q19402
HashSet.eatfd
train
def eatfd(self, fd): ''' Consume all the bytes from a file like object. Example: hset = HashSet() hset.eatfd(fd) ''' fd.seek(0) byts = fd.read(10000000) while byts: self.update(byts) byts = fd.read(10000000) ...
python
{ "resource": "" }
q19403
HashSet.update
train
def update(self, byts): ''' Update all the hashes in the set with the given bytes. ''' self.size += len(byts) [h[1].update(byts) for h in self.hashes]
python
{ "resource": "" }
q19404
claim
train
def claim(typ, **info): ''' Add an entry to the provenance stack for the duration of the context ''' stack = s_task.varget('provstack') if len(stack) > 256: # pragma: no cover raise s_exc.RecursionLimitHit(mesg='Hit global recursion limit') stack.push(typ, **info) try: yi...
python
{ "resource": "" }
q19405
dupstack
train
def dupstack(newtask): ''' Duplicate the current provenance stack onto another task ''' stack = s_task.varget('provstack') s_task.varset('provstack', stack.copy(), newtask)
python
{ "resource": "" }
q19406
ProvStor.getProvStack
train
def getProvStack(self, iden: bytes): ''' Returns the provenance stack given the iden to it ''' retn = self.slab.get(iden, db=self.db) if retn is None: return None return s_msgpack.un(retn)
python
{ "resource": "" }
q19407
ProvStor.provStacks
train
def provStacks(self, offs, size): ''' Returns a stream of provenance stacks at the given offset ''' for _, iden in self.provseq.slice(offs, size): stack = self.getProvStack(iden) if stack is None: continue yield (iden, stack)
python
{ "resource": "" }
q19408
ProvStor.getProvIden
train
def getProvIden(self, provstack): ''' Returns the iden corresponding to a provenance stack and stores if it hasn't seen it before ''' iden = _providen(provstack) misc, frames = provstack # Convert each frame back from (k, v) tuples to a dict dictframes = [(typ, {k...
python
{ "resource": "" }
q19409
ProvStor.commit
train
def commit(self): ''' Writes the current provenance stack to storage if it wasn't already there and returns it Returns (Tuple[bool, str, List[]]): Whether the stack was not cached, the iden of the prov stack, and the provstack ''' providen, provstack = get() ...
python
{ "resource": "" }
q19410
SlabSeqn.save
train
def save(self, items): ''' Save a series of items to a sequence. Args: items (tuple): The series of items to save into the sequence. Returns: The index of the first item ''' rows = [] indx = self.indx size = 0 tick = s_co...
python
{ "resource": "" }
q19411
SlabSeqn.nextindx
train
def nextindx(self): ''' Determine the next insert offset according to storage. Returns: int: The next insert offset. ''' indx = 0 with s_lmdbslab.Scan(self.slab, self.db) as curs: last_key = curs.last_key() if last_key is not None: ...
python
{ "resource": "" }
q19412
SlabSeqn.iter
train
def iter(self, offs): ''' Iterate over items in a sequence from a given offset. Args: offs (int): The offset to begin iterating from. Yields: (indx, valu): The index and valu of the item. ''' startkey = s_common.int64en(offs) for lkey, l...
python
{ "resource": "" }
q19413
SlabSeqn.rows
train
def rows(self, offs): ''' Iterate over raw indx, bytes tuples from a given offset. ''' lkey = s_common.int64en(offs) for lkey, byts in self.slab.scanByRange(lkey, db=self.db): indx = s_common.int64un(lkey) yield indx, byts
python
{ "resource": "" }
q19414
near
train
def near(point, dist, points): ''' Determine if the given point is within dist of any of points. Args: point ((float,float)): A latitude, longitude float tuple. dist (int): A distance in mm ( base units ) points (list): A list of latitude, longitude float tuples to compare against. ...
python
{ "resource": "" }
q19415
SumoLogic.search_metrics
train
def search_metrics(self, query, fromTime=None, toTime=None, requestedDataPoints=600, maxDataPoints=800): '''Perform a single Sumo metrics query''' def millisectimestamp(ts): '''Convert UNIX timestamp to milliseconds''' if ts > 10**12: ts = ts/(10**(len(str(ts))-13...
python
{ "resource": "" }
q19416
CardConnectionDecorator.connect
train
def connect(self, protocol=None, mode=None, disposition=None): """call inner component connect""" self.component.connect(protocol, mode, disposition)
python
{ "resource": "" }
q19417
translateprotocolmask
train
def translateprotocolmask(protocol): """Translate CardConnection protocol mask into PCSC protocol mask.""" pcscprotocol = 0 if None != protocol: if CardConnection.T0_protocol & protocol: pcscprotocol |= SCARD_PROTOCOL_T0 if CardConnection.T1_protocol & protocol: pcscp...
python
{ "resource": "" }
q19418
translateprotocolheader
train
def translateprotocolheader(protocol): """Translate protocol into PCSC protocol header.""" pcscprotocol = 0 if None != protocol: if CardConnection.T0_protocol == protocol: pcscprotocol = SCARD_PCI_T0 if CardConnection.T1_protocol == protocol: pcscprotocol = SCARD_PCI_...
python
{ "resource": "" }
q19419
PCSCCardConnection.connect
train
def connect(self, protocol=None, mode=None, disposition=None): """Connect to the card. If protocol is not specified, connect with the default connection protocol. If mode is not specified, connect with SCARD_SHARE_SHARED.""" CardConnection.connect(self, protocol) pcscpr...
python
{ "resource": "" }
q19420
PCSCCardConnection.disconnect
train
def disconnect(self): """Disconnect from the card.""" # when __del__() is invoked in response to a module being deleted, # e.g., when execution of the program is done, other globals referenced # by the __del__() method may already have been deleted. # this causes CardConnection....
python
{ "resource": "" }
q19421
PCSCCardConnection.getATR
train
def getATR(self): """Return card ATR""" CardConnection.getATR(self) if None == self.hcard: raise CardConnectionException('Card not connected') hresult, reader, state, protocol, atr = SCardStatus(self.hcard) if hresult != 0: raise CardConnectionException( ...
python
{ "resource": "" }
q19422
PCSCCardConnection.doTransmit
train
def doTransmit(self, bytes, protocol=None): """Transmit an apdu to the card and return response apdu. @param bytes: command apdu to transmit (list of bytes) @param protocol: the transmission protocol, from CardConnection.T0_protocol, CardConnection.T1_protocol, or Ca...
python
{ "resource": "" }
q19423
PCSCCardConnection.doControl
train
def doControl(self, controlCode, bytes=[]): """Transmit a control command to the reader and return response. controlCode: control command bytes: command data to transmit (list of bytes) return: response are the response bytes (if any) """ CardConnection.doCo...
python
{ "resource": "" }
q19424
PCSCCardConnection.doGetAttrib
train
def doGetAttrib(self, attribId): """get an attribute attribId: Identifier for the attribute to get return: response are the attribute byte array """ CardConnection.doGetAttrib(self, attribId) hresult, response = SCardGetAttrib(self.hcard, attribId) if hresult ...
python
{ "resource": "" }
q19425
pcscdiag.OnExpandAll
train
def OnExpandAll(self): """ expand all nodes """ root = self.tree.GetRootItem() fn = self.tree.Expand self.traverse(root, fn) self.tree.Expand(root)
python
{ "resource": "" }
q19426
pcscdiag.traverse
train
def traverse(self, traverseroot, function, cookie=0): """ recursivly walk tree control """ if self.tree.ItemHasChildren(traverseroot): firstchild, cookie = self.tree.GetFirstChild(traverseroot) function(firstchild) self.traverse(firstchild, function, cookie) ...
python
{ "resource": "" }
q19427
module_path
train
def module_path(): """ This will get us the program's directory, even if we are frozen using py2exe. From WhereAmI page on py2exe wiki.""" if we_are_frozen(): return os.path.dirname( unicode(sys.executable, sys.getfilesystemencoding())) return os.path.dirname(unicode(__file__, ...
python
{ "resource": "" }
q19428
CardConnection.getAttrib
train
def getAttrib(self, attribId): """return the requested attribute @param attribId: attribute id like SCARD_ATTR_VENDOR_NAME """ Observable.setChanged(self) Observable.notifyObservers(self, CardConnectionEvent( ...
python
{ "resource": "" }
q19429
PyroReader.createConnection
train
def createConnection(self): """Return a card connection thru a remote reader.""" uri = self.reader.createConnection() return Pyro.core.getAttrProxyForURI(uri)
python
{ "resource": "" }
q19430
SampleAPDUManagerPanel.OnActivateCard
train
def OnActivateCard(self, card): """Called when a card is activated by double-clicking on the card or reader tree control or toolbar. In this sample, we just connect to the card on the first activation.""" SimpleSCardAppEventObserver.OnActivateCard(self, card) self.feedbacktext.Se...
python
{ "resource": "" }
q19431
SimpleSCardApp.OnInit
train
def OnInit(self): """Create and display application frame.""" self.frame = SimpleSCardAppFrame( self.appname, self.apppanel, self.appstyle, self.appicon, self.pos, self.size) self.frame.Show(True) self.SetTopWindow(s...
python
{ "resource": "" }
q19432
PyroNameServer.getShutdownArgs
train
def getShutdownArgs(self): """return command line arguments for shutting down the server; this command line is built from the name server startup arguments.""" shutdownArgs = [] if self.host: shutdownArgs += ['-h', self.host] if self.bcport: shutdo...
python
{ "resource": "" }
q19433
PyroNameServer.stop
train
def stop(self): """Shutdown pyro naming server.""" args = self.getShutdownArgs() + ['shutdown'] Pyro.nsc.main(args) self.join()
python
{ "resource": "" }
q19434
Card.createConnection
train
def createConnection(self): """Return a CardConnection to the Card object.""" readerobj = None if isinstance(self.reader, Reader): readerobj = self.reader elif type(self.reader) == str: for reader in readers(): if self.reader == str(reader): ...
python
{ "resource": "" }
q19435
pcscinnerreadergroups.getreadergroups
train
def getreadergroups(self): """ Returns the list of smartcard reader groups.""" innerreadergroups.getreadergroups(self) hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) if hresult != 0: raise EstablishContextException(hresult) hresult, readers = SCardListRe...
python
{ "resource": "" }
q19436
pcscinnerreadergroups.addreadergroup
train
def addreadergroup(self, newgroup): """Add a reader group""" hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) if 0 != hresult: raise error( 'Failed to establish context: ' + \ SCardGetErrorMessage(hresult)) try: hresult ...
python
{ "resource": "" }
q19437
parseFeatureRequest
train
def parseFeatureRequest(response): """ Get the list of Part10 features supported by the reader. @param response: result of CM_IOCTL_GET_FEATURE_REQUEST commmand @rtype: list @return: a list of list [[tag1, value1], [tag2, value2]] """ features = [] while (len(response) > 0): tag = ...
python
{ "resource": "" }
q19438
hasFeature
train
def hasFeature(featureList, feature): """ return the controlCode for a feature or None @param feature: feature to look for @param featureList: feature list as returned by L{getFeatureRequest()} @return: feature value or None """ for f in featureList: if f[0] == feature or Features[...
python
{ "resource": "" }
q19439
getPinProperties
train
def getPinProperties(cardConnection, featureList=None, controlCode=None): """ return the PIN_PROPERTIES structure @param cardConnection: L{CardConnection} object @param featureList: feature list as returned by L{getFeatureRequest()} @param controlCode: control code for L{FEATURE_IFD_PIN_PROPERTIES} ...
python
{ "resource": "" }
q19440
RemoteReader.createConnection
train
def createConnection(self): """Return a card connection thru the reader.""" connection = RemoteCardConnection(self.readerobj.createConnection()) daemon = PyroDaemon.PyroDaemon() uri = daemon.connect(connection) return uri
python
{ "resource": "" }
q19441
RemoteReaderServer.update
train
def update(self, observable, actions): """Called when a local reader is added or removed. Create remote pyro reader objects for added readers. Delete remote pyro reader objects for removed readers.""" (addedreaders, removedreaders) = actions for reader in addedreaders: ...
python
{ "resource": "" }
q19442
ReaderMonitor.addObserver
train
def addObserver(self, observer): """Add an observer.""" Observable.addObserver(self, observer) # If self.startOnDemand is True, the reader monitoring # thread only runs when there are observers. if self.startOnDemand: if 0 < self.countObservers(): if ...
python
{ "resource": "" }
q19443
ReaderMonitor.deleteObserver
train
def deleteObserver(self, observer): """Remove an observer.""" Observable.deleteObserver(self, observer) # If self.startOnDemand is True, the reader monitoring # thread is stopped when there are no more observers. if self.startOnDemand: if 0 == self.countObservers(): ...
python
{ "resource": "" }
q19444
ulist.__remove_duplicates
train
def __remove_duplicates(self, _other): """Remove from other items already in list.""" if not isinstance(_other, type(self)) \ and not isinstance(_other, type(list)) \ and not isinstance(_other, type([])): other = [_other] else: other = list(_other) ...
python
{ "resource": "" }
q19445
APDUTracerPanel.update
train
def update(self, cardconnection, ccevent): '''CardConnectionObserver callback.''' apduline = "" if 'connect' == ccevent.type: apduline += 'connecting to ' + cardconnection.getReader() elif 'disconnect' == ccevent.type: apduline += 'disconnecting from ' + cardcon...
python
{ "resource": "" }
q19446
synchronize
train
def synchronize(klass, names=None): """Synchronize methods in the given class. Only synchronize the methods whose names are given, or all methods if names=None.""" # basestring does not exist on Python 3 try: basestring except NameError: basestring = (str, bytes) if isinsta...
python
{ "resource": "" }
q19447
ExclusiveTransmitCardConnection.lock
train
def lock(self): '''Lock card with SCardBeginTransaction.''' component = self.component while True: if isinstance( component, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection): hresult = SCardBeginTransaction(component.hcard...
python
{ "resource": "" }
q19448
ExclusiveTransmitCardConnection.unlock
train
def unlock(self): '''Unlock card with SCardEndTransaction.''' component = self.component while True: if isinstance( component, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection): hresult = SCardEndTransaction(component.hcard,...
python
{ "resource": "" }
q19449
ExclusiveTransmitCardConnection.transmit
train
def transmit(self, bytes, protocol=None): '''Gain exclusive access to card during APDU transmission for if this decorator decorates a PCSCCardConnection.''' data, sw1, sw2 = CardConnectionDecorator.transmit( self, bytes, protocol) return data, sw1, sw2
python
{ "resource": "" }
q19450
ReaderFactory.createReader
train
def createReader(clazz, readername): """Static method to create a reader from a reader clazz. @param clazz: the reader class name @param readername: the reader name """ if not clazz in ReaderFactory.factories: ReaderFactory.factories[clazz] = get_class(clazz).Fa...
python
{ "resource": "" }
q19451
ReaderComboBox.update
train
def update(self, observable, handlers): """Toolbar ReaderObserver callback that is notified when readers are added or removed.""" addedreaders, removedreaders = handlers for reader in addedreaders: item = self.Append(str(reader)) self.SetClientData(item, reader) ...
python
{ "resource": "" }
q19452
Session.sendCommandAPDU
train
def sendCommandAPDU(self, command): """Send an APDU command to the connected smartcard. @param command: list of APDU bytes, e.g. [0xA0, 0xA4, 0x00, 0x00, 0x02] @return: a tuple (response, sw1, sw2) where response is the APDU response sw1, sw2 are the two status ...
python
{ "resource": "" }
q19453
ErrorCheckingChain.next
train
def next(self): """Returns next error checking strategy.""" # Where this link is in the chain: location = self.chain.index(self) if not self.end(): return self.chain[location + 1]
python
{ "resource": "" }
q19454
ErrorCheckingChain.addFilterException
train
def addFilterException(self, exClass): """Add an exception filter to the error checking chain. @param exClass: the exception to exclude, e.g. L{smartcard.sw.SWExceptions.WarningProcessingException} A filtered exception will not be raised when the sw1,sw2 conditions that would...
python
{ "resource": "" }
q19455
PCSCReader.addtoreadergroup
train
def addtoreadergroup(self, groupname): """Add reader to a reader group.""" hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) if 0 != hresult: raise EstablishContextException(hresult) try: hresult = SCardIntroduceReader(hcontext, self.name, self.name) ...
python
{ "resource": "" }
q19456
PCSCReader.removefromreadergroup
train
def removefromreadergroup(self, groupname): """Remove a reader from a reader group""" hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) if 0 != hresult: raise EstablishContextException(hresult) try: hresult = SCardRemoveReaderFromGroup(hcontext, self.na...
python
{ "resource": "" }
q19457
TreeAndUserPanelPanel.ActivateCard
train
def ActivateCard(self, card): """Activate a card.""" if not hasattr(card, 'connection'): card.connection = card.createConnection() if None != self.parent.apdutracerpanel: card.connection.addObserver(self.parent.apdutracerpanel) card.connection.connect(...
python
{ "resource": "" }
q19458
TreeAndUserPanelPanel.DeactivateCard
train
def DeactivateCard(self, card): """Deactivate a card.""" if hasattr(card, 'connection'): card.connection.disconnect() if None != self.parent.apdutracerpanel: card.connection.deleteObserver(self.parent.apdutracerpanel) delattr(card, 'connection') ...
python
{ "resource": "" }
q19459
TreeAndUserPanelPanel.OnActivateReader
train
def OnActivateReader(self, event): """Called when the user activates a reader in the tree.""" item = event.GetItem() if item: itemdata = self.readertreepanel.readertreectrl.GetItemPyData(item) if isinstance(itemdata, smartcard.Card.Card): self.ActivateCard...
python
{ "resource": "" }
q19460
TreeAndUserPanelPanel.OnCardRightClick
train
def OnCardRightClick(self, event): """Called when user right-clicks a node in the card tree control.""" item = event.GetItem() if item: itemdata = self.readertreepanel.cardtreectrl.GetItemPyData(item) if isinstance(itemdata, smartcard.Card.Card): self.sele...
python
{ "resource": "" }
q19461
TreeAndUserPanelPanel.OnSelectCard
train
def OnSelectCard(self, event): """Called when the user selects a card in the tree.""" item = event.GetItem() if item: itemdata = self.readertreepanel.cardtreectrl.GetItemPyData(item) if isinstance(itemdata, smartcard.Card.Card): self.dialogpanel.OnSelectCa...
python
{ "resource": "" }
q19462
TreeAndUserPanelPanel.OnSelectReader
train
def OnSelectReader(self, event): """Called when the user selects a reader in the tree.""" item = event.GetItem() if item: itemdata = self.readertreepanel.readertreectrl.GetItemPyData(item) if isinstance(itemdata, smartcard.Card.Card): self.dialogpanel.OnSe...
python
{ "resource": "" }
q19463
SimpleSCardAppFrame.OnReaderComboBox
train
def OnReaderComboBox(self, event): """Called when the user activates a reader in the toolbar combo box.""" cb = event.GetEventObject() reader = cb.GetClientData(cb.GetSelection()) if isinstance(reader, smartcard.reader.Reader.Reader): self.treeuserpanel.dialogpanel.OnActivate...
python
{ "resource": "" }
q19464
get_func
train
def get_func(fullFuncName): """Retrieve a function object from a full dotted-package name.""" # Parse out the path, module, and function lastDot = fullFuncName.rfind(u".") funcName = fullFuncName[lastDot + 1:] modPath = fullFuncName[:lastDot] aMod = get_mod(modPath) aFunc = getattr(aMod, f...
python
{ "resource": "" }
q19465
PCSCCardRequest.getReaderNames
train
def getReaderNames(self): """Returns the list or PCSC readers on which to wait for cards.""" # get inserted readers hresult, pcscreaders = SCardListReaders(self.hcontext, []) if 0 != hresult and SCARD_E_NO_READERS_AVAILABLE != hresult: raise ListReadersException(hresult) ...
python
{ "resource": "" }
q19466
PCSCCardRequest.waitforcardevent
train
def waitforcardevent(self): """Wait for card insertion or removal.""" AbstractCardRequest.waitforcardevent(self) presentcards = [] evt = threading.Event() # for non infinite timeout, a timer will signal the end of the time-out if INFINITE == self.timeout: tim...
python
{ "resource": "" }
q19467
strToGUID
train
def strToGUID(s): """Converts a GUID string into a list of bytes. >>> strToGUID('{AD4F1667-EA75-4124-84D4-641B3B197C65}') [103, 22, 79, 173, 117, 234, 36, 65, 132, 212, 100, 27, 59, 25, 124, 101] """ dat = uuid.UUID(hex=s) if isinstance(dat.bytes_le, str): # Python 2 dat = [ord(...
python
{ "resource": "" }
q19468
GUIDToStr
train
def GUIDToStr(g): """Converts a GUID sequence of bytes into a string. >>> GUIDToStr([103,22,79,173, 117,234, 36,65, ... 132, 212, 100, 27, 59, 25, 124, 101]) '{AD4F1667-EA75-4124-84D4-641B3B197C65}' """ try: dat = uuid.UUID(bytes_le=bytes(g)) except: dat = uuid....
python
{ "resource": "" }
q19469
ATRCardType.matches
train
def matches(self, atr, reader=None): """Returns true if the atr matches the masked CardType atr. @param atr: the atr to chek for matching @param reader: the reader (optional); default is None When atr is compared to the CardType ATR, matches returns true if and only if CardT...
python
{ "resource": "" }
q19470
SamplePanel.OnActivateReader
train
def OnActivateReader(self, reader): """Called when a reader is activated by double-clicking on the reader tree control or toolbar.""" SimpleSCardAppEventObserver.OnActivateReader(self, reader) self.feedbacktext.SetLabel('Activated reader: ' + repr(reader))
python
{ "resource": "" }
q19471
SamplePanel.OnDeactivateCard
train
def OnDeactivateCard(self, card): """Called when a card is deactivated in the reader tree control or toolbar.""" SimpleSCardAppEventObserver.OnActivateCard(self, card) self.feedbacktext.SetLabel('Deactivated card: ' + repr(card))
python
{ "resource": "" }
q19472
ATR.getSupportedProtocols
train
def getSupportedProtocols(self): """Returns a dictionnary of supported protocols.""" protocols = {} for td in self.TD: if td is not None: strprotocol = "T=%d" % (td & 0x0F) protocols[strprotocol] = True if not self.hasTD[0]: protoco...
python
{ "resource": "" }
q19473
ATR.dump
train
def dump(self): """Dump the details of an ATR.""" for i in range(0, len(self.TA)): if self.TA[i] is not None: print("TA%d: %x" % (i + 1, self.TA[i])) if self.TB[i] is not None: print("TB%d: %x" % (i + 1, self.TB[i])) if self.TC[i] is n...
python
{ "resource": "" }
q19474
CardTreeCtrl.OnAddCards
train
def OnAddCards(self, addedcards): """Called when a card is inserted. Adds a smart card to the smartcards tree.""" parentnode = self.root for cardtoadd in addedcards: childCard = self.AppendItem(parentnode, toHexString(cardtoadd.atr)) self.SetItemText(childCard, to...
python
{ "resource": "" }
q19475
CardTreeCtrl.OnRemoveCards
train
def OnRemoveCards(self, removedcards): """Called when a card is removed. Removes a card from the tree.""" parentnode = self.root for cardtoremove in removedcards: (childCard, cookie) = self.GetFirstChild(parentnode) while childCard.IsOk(): if self....
python
{ "resource": "" }
q19476
ReaderTreeCtrl.AddATR
train
def AddATR(self, readernode, atr): """Add an ATR to a reader node.""" capchild = self.AppendItem(readernode, atr) self.SetPyData(capchild, None) self.SetItemImage( capchild, self.cardimageindex, wx.TreeItemIcon_Normal) self.SetItemImage( capchild, self.car...
python
{ "resource": "" }
q19477
ReaderTreeCtrl.OnAddCards
train
def OnAddCards(self, addedcards): """Called when a card is inserted. Adds the smart card child to the reader node.""" self.mutex.acquire() try: parentnode = self.root for cardtoadd in addedcards: (childReader, cookie) = self.GetFirstChild(parentnod...
python
{ "resource": "" }
q19478
ReaderTreeCtrl.OnAddReaders
train
def OnAddReaders(self, addedreaders): """Called when a reader is inserted. Adds the smart card reader to the smartcard readers tree.""" self.mutex.acquire() try: parentnode = self.root for readertoadd in addedreaders: # is the reader already here?...
python
{ "resource": "" }
q19479
ReaderTreeCtrl.OnRemoveCards
train
def OnRemoveCards(self, removedcards): """Called when a card is removed. Removes the card from the tree.""" self.mutex.acquire() try: parentnode = self.root for cardtoremove in removedcards: (childReader, cookie) = self.GetFirstChild(parentnode) ...
python
{ "resource": "" }
q19480
ReaderTreeCtrl.OnRemoveReaders
train
def OnRemoveReaders(self, removedreaders): """Called when a reader is removed. Removes the reader from the smartcard readers tree.""" self.mutex.acquire() try: parentnode = self.root for readertoremove in removedreaders: (childReader, cookie) = sel...
python
{ "resource": "" }
q19481
CardAndReaderTreePanel.OnDestroy
train
def OnDestroy(self, event): """Called on panel destruction.""" # deregister observers if hasattr(self, 'cardmonitor'): self.cardmonitor.deleteObserver(self.cardtreecardobserver) if hasattr(self, 'readermonitor'): self.readermonitor.deleteObserver(self.readertreere...
python
{ "resource": "" }
q19482
ExclusiveConnectCardConnection.connect
train
def connect(self, protocol=None, mode=None, disposition=None): '''Disconnect and reconnect in exclusive mode PCSCCardconnections.''' CardConnectionDecorator.connect(self, protocol, mode, disposition) component = self.component while True: if isinstance(component, ...
python
{ "resource": "" }
q19483
build_module
train
def build_module(name, objs, doc='', source=None, mode='ignore'): """Create a module from imported objects. Parameters ---------- name : str New module name. objs : dict Dictionary of the objects (or their name) to import into the module, keyed by the name they will take in the cr...
python
{ "resource": "" }
q19484
base_flow_index
train
def base_flow_index(q, freq='YS'): r"""Base flow index Return the base flow index, defined as the minimum 7-day average flow divided by the mean flow. Parameters ---------- q : xarray.DataArray Rate of river discharge [m³/s] freq : str, optional Resampling frequency Returns ...
python
{ "resource": "" }
q19485
cold_spell_duration_index
train
def cold_spell_duration_index(tasmin, tn10, window=6, freq='YS'): r"""Cold spell duration index Number of days with at least six consecutive days where the daily minimum temperature is below the 10th percentile. Parameters ---------- tasmin : xarray.DataArray Minimum daily temperature. ...
python
{ "resource": "" }
q19486
cold_spell_days
train
def cold_spell_days(tas, thresh='-10 degC', window=5, freq='AS-JUL'): r"""Cold spell days The number of days that are part of a cold spell, defined as five or more consecutive days with mean daily temperature below a threshold in °C. Parameters ---------- tas : xarrray.DataArray Mean dai...
python
{ "resource": "" }
q19487
daily_pr_intensity
train
def daily_pr_intensity(pr, thresh='1 mm/day', freq='YS'): r"""Average daily precipitation intensity Return the average precipitation over wet days. Parameters ---------- pr : xarray.DataArray Daily precipitation [mm/d or kg/m²/s] thresh : str precipitation value over which a day is...
python
{ "resource": "" }
q19488
maximum_consecutive_dry_days
train
def maximum_consecutive_dry_days(pr, thresh='1 mm/day', freq='YS'): r"""Maximum number of consecutive dry days Return the maximum number of consecutive days within the period where precipitation is below a certain threshold. Parameters ---------- pr : xarray.DataArray Mean daily precipit...
python
{ "resource": "" }
q19489
daily_freezethaw_cycles
train
def daily_freezethaw_cycles(tasmax, tasmin, freq='YS'): r"""Number of days with a diurnal freeze-thaw cycle The number of days where Tmax > 0℃ and Tmin < 0℃. Parameters ---------- tasmax : xarray.DataArray Maximum daily temperature [℃] or [K] tasmin : xarray.DataArray Minimum daily...
python
{ "resource": "" }
q19490
daily_temperature_range
train
def daily_temperature_range(tasmax, tasmin, freq='YS'): r"""Mean of daily temperature range. The mean difference between the daily maximum temperature and the daily minimum temperature. Parameters ---------- tasmax : xarray.DataArray Maximum daily temperature values [℃] or [K] tasmin : x...
python
{ "resource": "" }
q19491
daily_temperature_range_variability
train
def daily_temperature_range_variability(tasmax, tasmin, freq="YS"): r"""Mean absolute day-to-day variation in daily temperature range. Mean absolute day-to-day variation in daily temperature range. Parameters ---------- tasmax : xarray.DataArray Maximum daily temperature values [℃] or [K] ...
python
{ "resource": "" }
q19492
extreme_temperature_range
train
def extreme_temperature_range(tasmax, tasmin, freq='YS'): r"""Extreme intra-period temperature range. The maximum of max temperature (TXx) minus the minimum of min temperature (TNn) for the given time period. Parameters ---------- tasmax : xarray.DataArray Maximum daily temperature values [℃...
python
{ "resource": "" }
q19493
freshet_start
train
def freshet_start(tas, thresh='0 degC', window=5, freq='YS'): r"""First day consistently exceeding threshold temperature. Returns first day of period where a temperature threshold is exceeded over a given number of days. Parameters ---------- tas : xarray.DataArray Mean daily temperature...
python
{ "resource": "" }
q19494
frost_days
train
def frost_days(tasmin, freq='YS'): r"""Frost days index Number of days where daily minimum temperatures are below 0℃. Parameters ---------- tasmin : xarray.DataArray Minimum daily temperature [℃] or [K] freq : str, optional Resampling frequency Returns ------- xarray.D...
python
{ "resource": "" }
q19495
growing_season_length
train
def growing_season_length(tas, thresh='5.0 degC', window=6, freq='YS'): r"""Growing season length. The number of days between the first occurrence of at least six consecutive days with mean daily temperature over 5℃ and the first occurrence of at least six consecutive days with mean daily temperatu...
python
{ "resource": "" }
q19496
heat_wave_frequency
train
def heat_wave_frequency(tasmin, tasmax, thresh_tasmin='22.0 degC', thresh_tasmax='30 degC', window=3, freq='YS'): # Dev note : we should decide if it is deg K or C r"""Heat wave frequency Number of heat waves over a given period. A heat wave is defined as an event where the mini...
python
{ "resource": "" }
q19497
heat_wave_index
train
def heat_wave_index(tasmax, thresh='25.0 degC', window=5, freq='YS'): r"""Heat wave index. Number of days that are part of a heatwave, defined as five or more consecutive days over 25℃. Parameters ---------- tasmax : xarrray.DataArray Maximum daily temperature [℃] or [K] thresh : str ...
python
{ "resource": "" }
q19498
heat_wave_max_length
train
def heat_wave_max_length(tasmin, tasmax, thresh_tasmin='22.0 degC', thresh_tasmax='30 degC', window=3, freq='YS'): # Dev note : we should decide if it is deg K or C r"""Heat wave max length Maximum length of heat waves over a given period. A heat wave is defined as an event whe...
python
{ "resource": "" }
q19499
heating_degree_days
train
def heating_degree_days(tas, thresh='17.0 degC', freq='YS'): r"""Heating degree days Sum of degree days below the temperature threshold at which spaces are heated. Parameters ---------- tas : xarray.DataArray Mean daily temperature [℃] or [K] thresh : str Threshold temperature on w...
python
{ "resource": "" }