find all the valid cards on this deck,
       filtering out cards which don't play nice with deck issue mode
343882
def find_all_valid_cards(provider: Provider, deck: Deck) -> Generator:
    ''''''

    # validate_card_issue_modes must recieve a full list of cards, not batches
    unfiltered = (card for batch in get_card_bundles(provider, deck) for card in batch)

    for card in validate_card_issue_modes(deck.issue_mode, list(unfiltered)):
        yield card
290311
function() {
    var valid = false;
    var destroy = true;
    var target = this;
    Crafty('Card').each(function() {
      if (this.intersect(target.x + target.w + game.config.cardBuffer, target.y, target.w, target.h) ||
          this.intersect(target.x - target.w - game.config.cardBuffer, target.y, target.w, target.h) ||
          this.intersect(target.x, target.y + target.h + game.config.cardBuffer, target.w, target.h) ||
          this.intersect(target.x, target.y - target.h - game.config.cardBuffer, target.w, target.h)
        ) {
        valid = true;
        destroy = false;
      }
      if (this.intersect(target.x, target.y, target.w, target.h)) {
        destroy = false;
      }
    });
    if (valid) {
      this.used = false;
    }
    else if (destroy) {
      this.destroy();
      var currentTarget = this;
      game.targets = _.reject(game.targets, function(thisTarget) { return _.isEqual(thisTarget, currentTarget); });
    }
  }
352897
def find_all_valid_decks(provider: Provider, deck_version: int,
                         prod: bool=True) -> Generator:
    '''
    
    '''

    pa_params = param_query(provider.network)

    if prod:
        p2th = pa_params.P2TH_addr
    else:
        p2th = pa_params.test_P2TH_addr

    if isinstance(provider, RpcNode):
        deck_spawns = (provider.getrawtransaction(i, 1)
                       for i in find_deck_spawns(provider))

    else:
        try:
            deck_spawns = (provider.getrawtransaction(i, 1) for i in
                           provider.listtransactions(p2th))
        except TypeError as err:  # it will except if no transactions are found on this P2TH
            raise EmptyP2THDirectory(err)

    with concurrent.futures.ThreadPoolExecutor(max_workers=2) as th:
        for result in th.map(deck_parser, ((provider, rawtx, deck_version, p2th) for rawtx in deck_spawns)):
            if result:
                yield result
1254851
def filter_flags(parsed_flags, valid_flags):
    """"""
    def valid_argv(argv):
        """Figures out if a flag parsed from the flagfile matches a flag in
        the command about to be run."""
        flagname_match = FLAG_RE.match(argv)
        if not flagname_match:
            return True
        flagname = flagname_match.group()
        return flagname in valid_flags
    return list(filter(valid_argv, parsed_flags))
830280
def remove_not_valid_selections(self):
        
        value = [v for v in self.get_value() if self.valid_selection(v)]
        self.set_value(value)
1031839
def remove_invalid_fields(self, queryset, fields, view):
        

        valid_orderings = []
        invalid_orderings = []

        # for each field sent down from the query param,
        # determine if its valid or invalid
        for term in fields:
            stripped_term = term.lstrip('-')
            # add back the '-' add the end if necessary
            reverse_sort_term = '' if len(stripped_term) is len(term) else '-'
            ordering = self.ordering_for(stripped_term, view)

            if ordering:
                valid_orderings.append(reverse_sort_term + ordering)
            else:
                invalid_orderings.append(term)

        return valid_orderings, invalid_orderings
1161378
def _filter_records(self, records, rtype=None, name=None, content=None, identifier=None):  # pylint: disable=too-many-arguments,no-self-use
        
        if not records:
            return []
        if identifier is not None:
            LOGGER.debug('Filtering %d records by id: %s', len(records), identifier)
            records = [record for record in records if record['id'] == identifier]
        if rtype is not None:
            LOGGER.debug('Filtering %d records by type: %s', len(records), rtype)
            records = [record for record in records if record['type'] == rtype]
        if name is not None:
            LOGGER.debug('Filtering %d records by name: %s', len(records), name)
            if name.endswith('.'):
                name = name[:-1]
            records = [record for record in records if name == record['name']]
        if content is not None:
            LOGGER.debug('Filtering %d records by content: %s', len(records), content.lower())
            records = [record for record in records if
                       record['content'].lower() == content.lower()]
        return records
628647
def filter_errors(errors, select=None, ignore=None, **params):
    
    select = select or []
    ignore = ignore or []

    for e in errors:
        for s in select:
            if e.number.startswith(s):
                yield e
                break
        else:
            for s in ignore:
                if e.number.startswith(s):
                    break
            else:
                yield e
719143
def validate_deckspawn_p2th(provider: Provider, rawtx: dict, p2th: str) -> bool:
    '''
    '''

    try:
        vout = rawtx["vout"][0]["scriptPubKey"].get("addresses")[0]
    except TypeError:
        '''TypeError: 'NoneType' object is not subscriptable error on some of the deck spawns.'''
        raise InvalidDeckSpawn("Invalid Deck P2TH.")

    if not vout == p2th:
        raise InvalidDeckSpawn("InvalidDeck P2TH.")

    return True
670738
function (playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options) 
    {
        // If exactComposition isn't set, no override
        if (options.strategyComplexity != "exactComposition")
        {
            return null;
        }

        // Now look at strategies based on game options
        if ((options.numberOfDecks == 2) && (!options.hitSoft17)) 
        {
            return TwoDeckStandSoft17(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options);
        }
    }
295351
def get_deck(self):
        
        trace = self.get_trace()

        # Find decks in trace, prepend with [None] in case nothing was found
        res = [None] + [item for item in trace if isinstance(item, Deck)]

        # Pop last (and hopefully only Deck) or None if there is no deck
        return res.pop()
669823
def card_names_and_ids(self):
        """"""
        b = Board(self.client, self.board_id)
        cards = b.getCards()
        card_names_and_ids = [(unidecode(c.name), c.id) for c in cards]
        return card_names_and_ids
828025
function query(q) {
  var filter = Object.keys(q);
  var isValid;
  var valid;
  var val;

  return this.reduce((list, ps) => {
    isValid = filter.every(key => {
      val = q[key];
      valid = true;

      if (typeof val === 'string') {
        if (val.indexOf('<') > -1) {
          valid = ps[key] < cleanValue(val, '<');
        }

        if (valid && val.indexOf('>') > -1) {
          valid = ps[key] > cleanValue(val, '>');
        }

        if (valid && val.indexOf('~') > -1) {
          valid = ps[key].indexOf(q[key].replace('~', '')) > -1;
        }
      } else {
        valid = ps[key] === val;
      }

      return valid;
    });

    if (isValid) list.push(ps);

    return list;
  }, []);
}
508986
def filter(filters = {})
      all.select do |rule|
        [:country, :type].each do |condition|
          break false if filters[condition] && filters[condition] != rule[condition]
          true
        end
      end
    end
424141
def on_decks(self, *args):
        
        if None in (
                self.canvas,
                self.decks,
                self.deck_x_hint_offsets,
                self.deck_y_hint_offsets
        ):
            Clock.schedule_once(self.on_decks, 0)
            return
        self.clear_widgets()
        decknum = 0
        for deck in self.decks:
            cardnum = 0
            for card in deck:
                if not isinstance(card, Card):
                    raise TypeError("You must only put Card in decks")
                if card not in self.children:
                    self.add_widget(card)
                if card.deck != decknum:
                    card.deck = decknum
                if card.idx != cardnum:
                    card.idx = cardnum
                cardnum += 1
            decknum += 1
        if len(self.deck_x_hint_offsets) < len(self.decks):
            self.deck_x_hint_offsets = list(self.deck_x_hint_offsets) + [0] * (
                len(self.decks) - len(self.deck_x_hint_offsets)
            )
        if len(self.deck_y_hint_offsets) < len(self.decks):
            self.deck_y_hint_offsets = list(self.deck_y_hint_offsets) + [0] * (
                len(self.decks) - len(self.deck_y_hint_offsets)
            )
        self._trigger_layout()
649260
def deck_issue_mode(proto: DeckSpawnProto) -> Iterable[str]:
    ''''''

    if proto.issue_mode == 0:
        yield "NONE"
        return

    for mode, value in proto.MODE.items():
        if value > proto.issue_mode:
            continue
        if value & proto.issue_mode:
            yield mode
947240
def filter(request)
      found_field = request.every(@field).any? { |value| @value === value.to_s }
      return nil if !found_field && @mode == :select
      return nil if found_field && @mode == :reject
      request
    end