Beispiel #1
0
    async def runCmdOpts(self, opts):
        '''
        Perform the command actions. Must be implemented by Cmd implementers.

        Args:
            opts (dict): Options dictionary.

        '''
        raise s_exc.NoSuchImpl(mesg='runCmdOpts must be implemented by subclasses.',
                               name='runCmdOpts')
Beispiel #2
0
def iterdata(fd, close_fd=True, **opts):
    '''
    Iterate through the data provided by a file like object.

    Optional parameters may be used to control how the data
    is deserialized.

    Examples:
        The following example show use of the iterdata function.::

            with open('foo.csv','rb') as fd:
                for row in iterdata(fd, format='csv', encoding='utf8'):
                    dostuff(row)

    Args:
        fd (file) : File like object to iterate over.
        close_fd (bool) : Default behavior is to close the fd object.
                          If this is not true, the fd will not be closed.
        **opts (dict): Ingest open directive.  Causes the data in the fd
                       to be parsed according to the 'format' key and any
                       additional arguments.

    Yields:
        An item to process. The type of the item is dependent on the format
        parameters.
    '''
    fmt = opts.get('format', 'lines')
    fopts = fmtopts.get(fmt, {})

    # set default options for format
    for opt, val in fopts.items():
        opts.setdefault(opt, val)

    ncod = opts.get('encoding')
    if ncod is not None:
        fd = codecs.getreader(ncod)(fd)

    fmtr = fmtyielders.get(fmt)
    if fmtr is None:
        raise s_exc.NoSuchImpl(name=fmt, knowns=fmtyielders.keys())

    for item in fmtr(fd, opts):
        yield item

    if close_fd:
        fd.close()
Beispiel #3
0
 def indx(self, norm):  # pragma: no cover
     '''
     Return the property index bytes for the given *normalized* value.
     '''
     name = self.__class__.__name__
     raise s_exc.NoSuchImpl(name='%s.indx' % name)
Beispiel #4
0
 async def _setRulrInfo(self,
                        name,
                        valu,
                        gateiden=None):  # pragma: no cover
     raise s_exc.NoSuchImpl(mesg='Subclass must implement _setRulrInfo')
Beispiel #5
0
 async def _onRulesEdit(self, mesg):  # pragma: no cover
     raise s_exc.NoSuchImpl(mesg='HiveIden subclasses must implement _onRulesEdit',
                            name='_onRulesEdit')
Beispiel #6
0
 async def execStormCmd(self, runt, genr):
     ''' Abstract base method '''
     raise s_exc.NoSuchImpl('Subclass must implement execStormCmd')
     for item in genr:
         yield item
Beispiel #7
0
 async def data_received(self, chunk):
     raise s_exc.NoSuchImpl(
         mesg='data_received must be implemented by subclasses.',
         name='data_received')
Beispiel #8
0
 def _saveAuthData(self):  # pragma: no cover
     raise s_exc.NoSuchImpl(
         name='_saveAuthData',
         mesg='_saveAuthData not implemented by AuthBase')
Beispiel #9
0
 async def compute(self, path):
     raise s_exc.NoSuchImpl(name=f'{self.__class__.__name__}.compute()')
Beispiel #10
0
 def getCondEval(self, runt):
     raise s_exc.NoSuchImpl(name=f'{self.__class__.__name__}.evaluate()')
Beispiel #11
0
 def _flush(self):  # pragma: no cover
     raise s_exc.NoSuchImpl(name='_flush')
Beispiel #12
0
 def _resize(self, size):  # pragma: no cover
     raise s_exc.NoSuchImpl(name='_resize')
Beispiel #13
0
 def _writeoff(self, offs, byts):  # pragma: no cover
     raise s_exc.NoSuchImpl(name='_writeoff')
Beispiel #14
0
 def _readoff(self, offs, size):  # pragma: no cover
     raise s_exc.NoSuchImpl(name='_readoff')
Beispiel #15
0
 async def delete(self):  # pragma: no cover
     raise s_exc.NoSuchImpl(mesg='GateRuler subclasses must implement delete')