Return the most recent date on which action_type occurred.
        Action spec is a dictionary of key-value attrs to match.
770533
def _bytype(self, action_type, action_spec=None):
        ''''''
        for action in reversed(self.bill['actions']):
            if action_type in action['type']:
                for k, v in action_spec.items():
                    if action[k] == v:
                        yield action
774680
def get_event_action(cls) -> Optional[str]:
        
        if not cls.actor:
            return None
        return event_context.get_event_action(cls.event_type)
589723
def most_recent(self):
        
        if not self.instance:
            raise TypeError(
                "Can't use most_recent() without a {} instance.".format(
                    self.model._meta.object_name
                )
            )
        tmp = []
        excluded_fields = getattr(self.model, "_history_excluded_fields", [])

        for field in self.instance._meta.fields:
            if field.name in excluded_fields:
                continue
            if isinstance(field, models.ForeignKey):
                tmp.append(field.name + "_id")
            else:
                tmp.append(field.name)
        fields = tuple(tmp)
        try:
            values = self.get_queryset().values_list(*fields)[0]
        except IndexError:
            raise self.instance.DoesNotExist(
                "%s has no historical record." % self.instance._meta.object_name
            )
        return self.instance.__class__(*values)
749565
def action_handler_adapter(handler_cls: type, action_name: str) -> Callable:
    

    if not hasattr(handler_cls(), action_name):
        message = "{0} does'nt have attr:{1}".format(handler_cls, action_name)
        raise ValueError(message)

    def wsgiapp(environ, start_response):
        """ inner app """
        handler = handler_cls()
        return getattr(handler, action_name)(environ, start_response)
    return wsgiapp
950266
def action_attr(attr_name):
    

    def action_attr(_value, context, **_params):
        value = getattr(context["action"], attr_name)
        return _attr(value)

    return action_attr
975083
def action_scope(self, action_fluents: Sequence[tf.Tensor]) -> Dict[str, TensorFluent]:
        '''
        '''
        return dict(zip(self.rddl.domain.action_fluent_ordering, action_fluents))
1303475
def _last(self, **spec):
        
        for record in self._entries(spec).order_by(orm.desc(model.Entry.local_date),
                                                   orm.desc(model.Entry.id))[:1]:
            return entry.Entry(record)
        return None
338070
def currentAction( self ):
        
        if ( not self._actionGroup ):
            return None
            
        for act in self._actionGroup.actions():
            if ( act.isChecked() ):
                return act
        return None
643756
def p_recent(self, kind, cur_p='', with_catalog=True, with_date=True):
        '''
        
        '''
        if cur_p == '':
            current_page_number = 1
        else:
            current_page_number = int(cur_p)

        current_page_number = 1 if current_page_number < 1 else current_page_number

        pager_num = int(MPost.total_number(kind) / CMS_CFG['list_num'])
        kwd = {
            'pager': '',
            'title': 'Recent posts.',
            'with_catalog': with_catalog,
            'with_date': with_date,
            'kind': kind,
            'current_page': current_page_number,
            'post_count': MPost.get_counts(),
            'router': config.router_post[kind],
        }
        self.render('admin/post_ajax/post_list.html',
                    kwd=kwd,
                    view=MPost.query_recent(num=20, kind=kind),
                    infos=MPost.query_pager_by_slug(
                        kind=kind,
                        current_page_num=current_page_number
                    ),
                    format_date=tools.format_date,
                    userinfo=self.userinfo,
                    cfg=CMS_CFG, )
602415
def get_rel_desc(instance, key, action):
    
    descs = instance.__jsonapi_rel_desc__.get(key, {})
    if action == RelationshipActions.GET:
        check_permission(instance, key, Permissions.VIEW)
        return descs.get(action, lambda x: getattr(x, key))
    elif action == RelationshipActions.APPEND:
        check_permission(instance, key, Permissions.CREATE)
        return descs.get(action, lambda x, v: getattr(x, key).append(v))
    elif action == RelationshipActions.SET:
        check_permission(instance, key, Permissions.EDIT)
        return descs.get(action, lambda x, v: setattr(x, key, v))
    else:
        check_permission(instance, key, Permissions.DELETE)
        return descs.get(action, lambda x, v: getattr(x, key).remove(v))
1267922
def action_get(key=None):
    """"""
    cmd = ['action-get']
    if key is not None:
        cmd.append(key)
    cmd.append('--format=json')
    action_data = json.loads(subprocess.check_output(cmd).decode('UTF-8'))
    return action_data
1071347
def get_last_rate_limit_info(self, action, method):
        
        method = method.upper()
        if (action in self.last_rate_limit_info and method in self.last_rate_limit_info[action]):
            return self.last_rate_limit_info[action][method]

        return None
991754
def get_es_action_item(data_item, action_settings, es_type, id_field=None):
    '''  '''

    action_item = dict.copy(action_settings)
    if id_field is not None:
        id_val = first(list(get_dict_key(data_item, id_field)))
        if id_val is not None:
            action_item['_id'] = id_val
    elif data_item.get('id'):
        if data_item['id'].startswith("%s/" % action_settings['_index']):
            action_item['_id'] = "/".join(data_item['id'].split("/")[2:])
        else:
            action_item['_id'] = data_item['id']
    if data_item.get('data'):
        action_item['_source'] = data_item['data']
    else:
        action_item['_source'] = data_item
    action_item['_type'] = es_type
    return action_item
1317693
def _parse_action(self, action, current_time):
        
        if action.action_type == 'research':
            name = mgz.const.TECHNOLOGIES[action.data.technology_type]
            self._research[action.data.player_id].append({
                'technology': name,
                'timestamp': _timestamp_to_time(action.timestamp)
            })
        elif action.action_type == 'build':
            self._build[action.data.player_id].append({
                'building': mgz.const.UNITS[action.data.building_type],
                'timestamp': _timestamp_to_time(current_time),
                'coordinates': {'x': action.data.x, 'y': action.data.y}
            })
        elif action.action_type == 'queue':
            for _ in range(0, int(action.data.number)):
                self._queue.append({
                    'unit': mgz.const.UNITS[action.data.unit_type],
                    'timestamp': _timestamp_to_time(current_time)
                })
28373
public <T extends Action> T getAction(Class<T> type) {
        // Shortcut: if the persisted list has one, return it.
        for (Action a : getActions()) {
            if (type.isInstance(a)) {
                return type.cast(a);
            }
        }
        // Otherwise check transient factories.
        for (TransientActionFactory<?> taf : TransientActionFactory.factoriesFor(getClass(), type)) {
            for (Action a : createFor(taf)) {
                if (type.isInstance(a)) {
                    return type.cast(a);
                }
            }
        }
        return null;
    }
930828
def get_action_params(controller, action)
      comment_lines = get_action_comments(controller, action)

      comments_raw = []
      has_param = false
      comment_lines.each do |line|
        if line.match(/\s*#\s*@param/) # @param id required Integer blah blah
          has_param = true
          comments_raw << ''
        end
        if has_param
          line = line.gsub(/\A\s*#\s*@param/, '')
          line = line.gsub(/\A\s*#\s*/, '').strip

          comments_raw.last << "\n" unless comments_raw.last.blank?
          comments_raw.last << line
        end
      end

      comments = []
      comments_raw.each do |comment|
        match_data = comment.match(/(?<name>[a-z0-9A-Z_\[\]]+)?\s*(?<required>#{PARAM_IMPORTANCES.join('|')})?\s*(?<type>#{PARAM_TYPES.join('|')})?\s*(?<description>.*)/m)

        if match_data
          comments << {
            name: match_data[:name],
            required: match_data[:required],
            type: match_data[:type],
            description: match_data[:description]
          }
        else
          comments << { description: comment }
        end
      end

      comments
    end
1073147
def _get_action_type(self, action):
        '''
        
        '''
        action_name = next(iter(action or {'': None}))
        if ':' not in action_name:
            action_name = '{}:{}'.format(self.CALL_TYPE, action_name)

        return action_name.split(':')[0] or None