How to use the swat.cas.results.CASResults function in swat

To help you get started, we’ve selected a few swat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sassoftware / python-swat / swat / cas / connection.py View on Github external
response / connection pair for each iteration can be used.
        responsefunc : callable, optional
            Callback function that is called for each response
        resultfunc : callable, optional
            Callback function that is called for each result

        Returns
        -------
        CASResults
            If no callback functions were supplied.
        any
            If a callback function is supplied, the result of that function
            is returned.

        '''
        results = CASResults()
        results.messages = messages = []
        results.updateflags = updateflags = set()
        results.session = self._session
        results.sessionname = self._name
        events = results.events
        idx = 0
        resultdata = None
        responsedata = None

        try:
            for response, conn in riter:

                if response.disposition.status_code == RETRY_ACTION_CODE:
                    raise SWATCASActionRetry(response.disposition.status)

                if responsefunc is not None:
github sassoftware / python-swat / swat / cas / results.py View on Github external
def __getattr__(self, name):
        if name in self:
            return self[name]
        return super(CASResults, self).__getattribute__(name)
github sassoftware / python-swat / swat / cas / results.py View on Github external
If inplace == True

        '''
        if 'ByGroupSet1.ByGroupInfo' in self:
            keyfmt = 'ByGroupSet%(set)s.%(name)s'
        else:
            keyfmt = '%(name)s'

        tables = collections.OrderedDict()
        delkeys = []
        info_re = re.compile(r'^(?:ByGroupSet\d+\.)?ByGroupInfo')
        tbl_re = re.compile(r'^(?:ByGroupSet(\d+)\.)?ByGroup(\d+)\.(.+?)$')

        out = self
        if not inplace:
            out = CASResults()

        for key, value in six.iteritems(self):
            if info_re.match(key):
                if inplace:
                    delkeys.append(key)
                continue

            tblmatch = tbl_re.match(key)
            if tblmatch:
                tables.setdefault(keyfmt % dict(set=tblmatch.group(1),
                                                name=tblmatch.group(3)), []).append(value)
                if inplace:
                    delkeys.append(key)
                else:
                    out[keyfmt % dict(set=tblmatch.group(1),
                                      name=tblmatch.group(3))] = None
github sassoftware / python-swat / swat / cas / connection.py View on Github external
resultdata = None
        responsedata = None

        try:
            for response, conn in riter:

                if response.disposition.status_code == RETRY_ACTION_CODE:
                    raise SWATCASActionRetry(response.disposition.status)

                if responsefunc is not None:
                    responsedata = responsefunc(response, conn, responsedata)
                    continue

                # Action was restarted by the server
                if 'action-restart' in response.updateflags:
                    results = CASResults()
                    results.messages = messages = []
                    results.updateflags = updateflags = set()
                    results.session = self._session
                    results.sessionname = self._name
                    events = results.events
                    idx = 0
                    continue

                # CASTable parameters
                caslib = None
                tablename = None
                castable = None

                for key, value in response:

                    if resultfunc is not None:
github sassoftware / python-swat / swat / cas / results.py View on Github external
>>> print(out.get_set(1))

        Return the second By group set objects

        >>> print(out.get_set(2))

        Returns
        -------
        :class:`CASResults`

        '''
        if 'ByGroupSet1.ByGroupInfo' not in self:
            raise IndexError('There are no By group sets defined.')

        out = CASResults()
        prefix = 'ByGroupSet%s.' % num
        for key, value in six.iteritems(self):
            if key.startswith(prefix):
                out[key.replace(prefix, '', 1)] = value

        if out:
            return out

        raise IndexError('No By group set matched the given index.')
github sassoftware / python-swat / swat / cas / results.py View on Github external
self = _self_

        if 'ByGroupSet1.ByGroupInfo' in self:
            raise IndexError('Multiple By group sets are defined, use get_set to '
                             'to select a By group set first.')

        # Convert list of positionals to a scalar
        if name:
            name = name[0]

        if not isinstance(name, (tuple, list)):
            name = tuple([name])
        else:
            name = tuple(name)

        out = CASResults()

        bykey = []

        def set_bykey(attrs):
            ''' Locate By variable keys '''
            if bykey:
                return bykey
            i = 1
            while True:
                if 'ByVar%s' % i not in attrs:
                    break
                bykey.append(attrs['ByVar%s' % i])
                i = i + 1
            return bykey

        for key, value in six.iteritems(self):