Helper function to create card formatters.
197363
function (format) {
	return function (card) {
		card = getCode(card);
		if (!card)
			return undefined;
		card--;
		return format({rank: card >> 2, suit: card & 3});
	};
}
675298
def create_date_formats():
    """"""
    # European style:
    base_formats = ['%d %m %Y', '%d %m %y', '%Y %m %d']
    # US style:
    base_formats += ['%m %d %Y', '%m %d %y', '%Y %m %d']
    # Things with words in
    base_formats += ['%d %b %Y', '%d %B %Y']

    date_formats = []
    for separator in ('-', '.', '/', ' '):
        for date_format in base_formats:
            date_formats.append((date_format.replace(' ', separator)))

    datetime_formats = []
    time_formats = ('%H:%M%Z', '%H:%M:%S', '%H:%M:%S%Z', '%H:%M%z',
                    '%H:%M:%S%z')

    for date_format in date_formats:
        for time_format in time_formats:
            for separator in ('', 'T', ' '):
                datetime_formats.append(date_format + separator + time_format)

    return tuple(date_formats), tuple(datetime_formats)
1114162
def format_help(help):
    """"""
    help = help.replace('Options:', str(crayons.black('Options:', bold=True)))

    help = help.replace('Usage: pinax', str('Usage: {0}'.format(crayons.black('pinax', bold=True))))

    help = help.replace('  start', str(crayons.green('  start', bold=True)))
    help = help.replace('  apps', str(crayons.yellow('  apps', bold=True)))
    help = help.replace('  demos', str(crayons.yellow('  demos', bold=True)))
    help = help.replace('  projects', str(crayons.yellow('  projects', bold=True)))
    help = help.replace('  themes', str(crayons.yellow('  themes', bold=True)))
    help = help.replace('  tools', str(crayons.yellow('  tools', bold=True)))

    additional_help = \
        """Usage Examples:
Create new project based on Pinax 'account' starter project:
$ {0}

Create new project based on development version of 'blog' starter project
$ {6}

View all Pinax starter projects:
$ {1}

View all Pinax demo projects:
$ {2}

View all Pinax apps:
$ {3}

View all Pinax tools:
$ {4}

View all Pinax themes:
$ {5}

Commands:""".format(
            crayons.red('pinax start account my_project'),
            crayons.red('pinax projects'),
            crayons.red('pinax demos'),
            crayons.red('pinax apps'),
            crayons.red('pinax tools'),
            crayons.red('pinax themes'),
            crayons.red('pinax start --dev blog my_project')
        )

    help = help.replace('Commands:', additional_help)

    return help
270144
def rect(opts = {})
      range = Args::CardRange.new(opts[:range], deck_size: size)
      box   = Args::Box.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
      draw  = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
      trans  = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
      range.each { |i| @cards[i].rect(box[i], draw[i], trans[i]) }
    end
439903
def _format_table(fmt, headers, rows, colwidths, colaligns, is_multiline):
    """"""
    lines = []
    hidden = fmt.with_header_hide if (headers and fmt.with_header_hide) else []
    pad = fmt.padding
    headerrow = fmt.headerrow

    padded_widths = [(w + 2 * pad) for w in colwidths]
    if is_multiline:
        pad_row = lambda row, _: row  # do it later, in _append_multiline_row
        append_row = partial(_append_multiline_row, pad=pad)
    else:
        pad_row = _pad_row
        append_row = _append_basic_row

    padded_headers = pad_row(headers, pad)
    padded_rows = [pad_row(row, pad) for row in rows]

    if fmt.lineabove and "lineabove" not in hidden:
        _append_line(lines, padded_widths, colaligns, fmt.lineabove)

    if padded_headers:
        append_row(lines, padded_headers, padded_widths, colaligns, headerrow)
        if fmt.linebelowheader and "linebelowheader" not in hidden:
            _append_line(lines, padded_widths, colaligns, fmt.linebelowheader)

    if padded_rows and fmt.linebetweenrows and "linebetweenrows" not in hidden:
        # initial rows with a line below
        for row in padded_rows[:-1]:
            append_row(lines, row, padded_widths, colaligns, fmt.datarow)
            _append_line(lines, padded_widths, colaligns, fmt.linebetweenrows)
        # the last row without a line below
        append_row(lines, padded_rows[-1], padded_widths, colaligns, fmt.datarow)
    else:
        for row in padded_rows:
            append_row(lines, row, padded_widths, colaligns, fmt.datarow)

    if fmt.linebelow and "linebelow" not in hidden:
        _append_line(lines, padded_widths, colaligns, fmt.linebelow)

    return "\n".join(lines)
1029163
def format_help(self, ctx, formatter):
        
        self.format_usage(ctx, formatter)
        self.format_help_text(ctx, formatter)
        self.format_options(ctx, formatter)
        self.format_epilog(ctx, formatter)
519209
function generateFormatterExamples(formatterInfo, prereleaseVersion) {
    const output = ejs.render(cat("./templates/formatter-examples.md.ejs"), formatterInfo);
    let filename = "../eslint.github.io/docs/user-guide/formatters/index.md",
        htmlFilename = "../eslint.github.io/docs/user-guide/formatters/html-formatter-example.html";

    if (prereleaseVersion) {
        filename = filename.replace("/docs", `/docs/${prereleaseVersion}`);
        htmlFilename = htmlFilename.replace("/docs", `/docs/${prereleaseVersion}`);
        if (!test("-d", path.dirname(filename))) {
            mkdir(path.dirname(filename));
        }
    }

    output.to(filename);
    formatterInfo.formatterResults.html.result.to(htmlFilename);
}
1282877
function formatDeckAsShortCards(deck) {
    var newDeck = {
        _id: deck._id,
        name: deck.name,
        username: deck.username,
        lastUpdated: deck.lastUpdated,
        faction: { name: deck.faction.name, value: deck.faction.value }
    };

    if (deck.agenda) {
        newDeck.agenda = { code: deck.agenda.code };
    }

    newDeck.bannerCards = (deck.bannerCards || []).map(function (card) {
        return { code: card.code };
    });
    newDeck.drawCards = formatCards(deck.drawCards || []);
    newDeck.plotCards = formatCards(deck.plotCards || []);
    newDeck.rookeryCards = formatCards(deck.rookeryCards || []);

    return newDeck;
}
750207
def apply(self, styler):
        """"""
        return styler.format(self.formatter, *self.args, **self.kwargs)
1335722
def _generate_ngram_row_template(self, labels):
        """"""
        cells = ['<td>{ngram}</td>']
        for label in labels:
            cells.append('<td>{{{}}}</td>'.format(label))
        return '\n'.join(cells)
439117
def make_formatter(self, width, padding, alignment, overflow=None):
        
        if overflow is None:
            overflow = self.overflow_default
        if overflow == 'clip':
            overflower = lambda x: [x.clip(width, self.table.cliptext)]
        elif overflow == 'wrap':
            overflower = lambda x: x.wrap(width)
        elif overflow == 'preformatted':
            overflower = lambda x: x.split('\n')
        else:
            raise RuntimeError("Unexpected overflow mode: %r" % overflow)
        align = self.get_aligner(alignment, width)
        pad = self.get_aligner('center', width + padding)
        return lambda value: [pad(align(x)) for x in overflower(value)]
1012811
@NonNull
    protected List<LayoutHelper> transformCards(@Nullable List<L> cards, final @NonNull List<C> data,
                                                @NonNull List<Pair<Range<Integer>, L>> rangeCards) {
        if (cards == null || cards.size() == 0) {
            return new LinkedList<>();
        }


        int lastPos = data.size();
        List<LayoutHelper> helpers = new ArrayList<>(cards.size());
        for (int i = 0, size = cards.size(); i < size; i++) {
            L card = cards.get(i);

            if (card == null) continue;

            final String ctype = getCardStringType(card);
            List<C> items = getItems(card);
            if (items == null) {
                // skip card null
                continue;
            }

            data.addAll(items);

            // calculate offset to set ranges
            int offset = lastPos;
            lastPos += items.size();
            // include [x, x) for empty range, upper are not included in range
            rangeCards.add(Pair.create(Range.create(offset, lastPos), card));

            // get layoutHelper for this card
            LayoutBinder<L> binder = mCardBinderResolver.create(ctype);
            LayoutHelper helper = binder.getHelper(ctype, card);


            if (helper != null) {
                helper.setItemCount(items.size());
                helpers.add(helper);
            }
        }

        return helpers;
    }
1371253
private function buildFormatterList()
    {
        if (!$this->isObject(self::$formatters)) {
            $formatters = new ArrayObject([]);
            foreach (self::$formatters as $fk => $fv) {
                $formatters->key($fk, new ArrayObject($fv));
            }
            self::$formatters = $formatters;
        }
    }
936324
def _load_formatters(module_name):
    """"""
    mod = __import__(module_name, None, None, ['__all__'])
    for formatter_name in mod.__all__:
        cls = getattr(mod, formatter_name)
        _formatter_cache[cls.name] = cls
405106
def _createscratch(self, shape=1):
        """"""
        self._scratch = record.FieldArray(shape, dtype=[(p, float)
            for p in self.inputs])
40903
function (cards) {
		var res = deckSize + 1;
		for (var c = 0; c < cards.length; c++)
			res = evaluator[res + getCode(cards[c])];
		if (cards.length < 7)
			res = evaluator[res];
		return {name: hands[res >> 12], value: res};
	}
364806
def copy(self):
        """"""
        d = {}
        for att in (
                'deck',
                'idx',
                'ud',
                'foreground_source',
                'foreground_color',
                'foreground_image',
                'foreground_texture',
                'background_source',
                'background_color',
                'background_image',
                'background_texture',
                'outline_color',
                'content_outline_color',
                'foreground_outline_color',
                'art_outline_color',
                'art_source',
                'art_color',
                'art_image',
                'art_texture',
                'show_art',
                'headline_text',
                'headline_markup',
                'headline_font_name',
                'headline_font_size',
                'headline_color',
                'midline_text',
                'midline_markup',
                'midline_font_name',
                'midline_font_size',
                'midline_color',
                'footer_text',
                'footer_markup',
                'footer_font_name',
                'footer_font_size',
                'footer_color',
                'text',
                'text_color',
                'markup',
                'font_name',
                'font_size'
        ):
            v = getattr(self, att)
            if v is not None:
                d[att] = v
        return Card(**d)