text:
<!DOCTYPE html>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>ibeis.algo.preproc.old_chip_preproc — ibeis 1.5.2 documentation</title>

    <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />

    <link rel="top" title="ibeis 1.5.2 documentation" href="../../../../index.html"/>
        <link rel="up" title="ibeis.algo.preproc" href="../preproc.html"/>

             ibeis

                1.5.2

  <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>

ibeis package

        ibeis

Docs »

Module code »

ibeis »

ibeis.algo »

ibeis.algo.preproc »

ibeis.algo.preproc.old_chip_preproc

Source code for ibeis.algo.preproc.old_chip_preproc

# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from six.moves import zip, range, filter  # NOQA
from os.path import exists, relpath
import utool as ut
import vtool as vt
import functools

# TODO in template version
#def read_chip_fpath(ibs, cid_list, **kwargs):
#    """ T_ExternFileGetter """
#    cfpath_list = ibs.get_chip_fpath(cid_list, **kwargs)
#    # --- generalize params
#    rowid_list = cid_list
#    readfunc = vt.imread
#    fpath_list = cfpath_list
#    # --- generalize func
#    """
#    # a missing external resource should delete its rowid from its native table
#    # it is the parents responcibility to recompute the desired child
#    # configuration.
#    """
#    data_list = ut.alloc_nones(len(fpath_list))
#    failed_index_list = []
#    for index, fpath in enumerate(fpath_list):
#        try:
#            data = readfunc(fpath)
#            data_list[index] = data
#        except IOError:
#            failed_index_list.append(index)
#    failed_rowids    = ut.take(rowid_list, failed_index_list)
#    failed_fpaths    = ut.take(fpath_list, failed_index_list)
#    exists_list      = [exists(fpath) for fpath in failed_fpaths]
#    missing_rowids   = ut.compress(failed_rowids, exists_list)  # NOQA
#    corrupted_rowids = ut.filterfalse_items(failed_rowids, exists_list)  # NOQA
#    # FINISHME

#--------------------------
# OLD FUNCTIONALITY TO DEPRICATE
#--------------------------

[docs]def compute_or_read_annotation_chips(ibs, aid_list, ensure=True, config2_=None,
                                     verbose=False, eager=True):
    r"""
    SUPER HACY FUNCTION. NEED TO DEPRICATE

    ----------------------
    Found 1 line(s) in 'ibeis/algo/preproc/preproc_chip.py':
    preproc_chip.py :  25 |def compute_or_read_annotation_chips(ibs, aid_list,
    ensure=True):
    ----------------------
    Found 1 line(s) in 'ibeis/control/manual_chip_funcs.py':
    manual_chip_funcs.py : 313 |    chip_list =
    preproc_chip.compute_or_read_annotation_chips(ibs, aid_list, ensure=ensure)

    """
    if ensure:
        try:
            ut.assert_all_not_None(aid_list, 'aid_list')
        except AssertionError as ex:
            ut.printex(ex, key_list=['aid_list'])
            raise
    nTotal = len(aid_list)
    cfpath_list = make_annot_chip_fpath_list(ibs, aid_list, config2_=config2_)
    mk_cpath_iter = functools.partial(ut.ProgressIter, cfpath_list,
                                      nTotal=nTotal, enabled=verbose, freq=100)
    try:
        if ensure:
            cfpath_iter = mk_cpath_iter(lbl='reading ensured chips')
            chip_list = [vt.imread(cfpath) for cfpath in cfpath_iter]
            #for cfpath in cfpath_iter:
            #    yield vt.imread(cfpath)
        else:
            cfpath_iter = mk_cpath_iter(lbl='reading existing chips')
            chip_list = [None if cfpath is None else vt.imread(cfpath) for cfpath in cfpath_iter]
            #for cfpath in cfpath_iter:
            #    yield None if cfpath is None else vt.imread(cfpath)
    except IOError as ex:
        if not ut.QUIET:
            ut.printex(ex, '[preproc_chip] Handing Exception: ', iswarning=True)
        ibs.add_annot_chips(aid_list)
        try:
            cfpath_iter = mk_cpath_iter(lbl='reading fallback1 chips')
            chip_list = [vt.imread(cfpath) for cfpath in cfpath_iter]
        except IOError:
            print('[preproc_chip] cache must have been deleted from disk')
            # TODO: WE CAN SEARCH FOR NON EXISTANT PATHS HERE AND CALL
            # ibs.delete_annot_chips
            compute_and_write_chips_lazy(ibs, aid_list)
            # Try just one more time
            cfpath_iter = mk_cpath_iter(lbl='reading fallback2 chips')
            chip_list = [vt.imread(cfpath) for cfpath in cfpath_iter]

    return chip_list

[docs]def compute_and_write_chips_lazy(ibs, aid_list, config2_=None):
    r"""
    Spanws compute chip procesess if a chip does not exist on disk

    DEPRICATE

    This is regardless of if it exists in the SQL database

    Args:
        ibs (IBEISController):
        aid_list (list):
    """
    if ut.VERBOSE:
        print('[preproc_chip] compute_and_write_chips_lazy')
    # Mark which aid's need their chips computed
    cfpath_list = make_annot_chip_fpath_list(ibs, aid_list, config2_=config2_)
    missing_flags = [not exists(cfpath) for cfpath in cfpath_list]
    invalid_aids = ut.compress(aid_list, missing_flags)
    if ut.VERBOSE:
        print('[preproc_chip] %d / %d chips need to be computed' %
              (len(invalid_aids), len(aid_list)))
    chip_result_list = list(compute_and_write_chips(ibs, invalid_aids))
    chip_fpath_list = ut.get_list_column(chip_result_list, 0)
    return chip_fpath_list

#  ^^ OLD FUNCS ^^

[docs]def compute_or_read_chip_images(ibs, cid_list, ensure=True, config2_=None):
    """Reads chips and tries to compute them if they do not exist

    Args:
        ibs (IBEISController):
        cid_list (list):
        ensure (bool):

    Returns:
        chip_list

    CommandLine:
        python -m ibeis.algo.preproc.preproc_chip --test-compute_or_read_chip_images

    Example:
        >>> # SLOW_DOCTEST
        >>> from ibeis.algo.preproc.preproc_chip import *  # NOQA
        >>> from ibeis.algo.preproc import preproc_chip
        >>> import numpy as np
        >>> ibs, aid_list = testdata_ibeis()
        >>> cid_list = ibs.get_annot_chip_rowids(aid_list, ensure=True)
        >>> chip_list = compute_or_read_chip_images(ibs, cid_list)
        >>> result = np.array(list(map(np.shape, chip_list))).sum(0).tolist()
        >>> print(result)
        [1434, 2274, 12]

    Example:
        >>> # SLOW_DOCTEST
        >>> from ibeis.algo.preproc.preproc_chip import *  # NOQA
        >>> import numpy as np
        >>> ibs, aid_list = testdata_ibeis()
        >>> cid_list = ibs.get_annot_chip_rowids(aid_list, ensure=True)
        >>> # Do a bad thing. Remove from disk without removing from sql
        >>> on_delete(ibs, cid_list)
        >>> # Now compute_or_read_chip_images should catch the bad thing
        >>> # we did and correct for it.
        >>> chip_list = compute_or_read_chip_images(ibs, cid_list)
        >>> result = np.array(list(map(np.shape, chip_list))).sum(0).tolist()
        >>> print(result)
        [1434, 2274, 12]
    """
    cfpath_list = ibs.get_chip_fpath(cid_list)
    try:
        if ensure:
            try:
                ut.assert_all_not_None(cid_list, 'cid_list')
            except AssertionError as ex:
                ut.printex(ex, key_list=['cid_list'])
                raise
            else:
                chip_list = [vt.imread(cfpath) for cfpath in cfpath_list]
        else:
            chip_list = [None if cfpath is None else vt.imread(cfpath) for cfpath in cfpath_list]
    except IOError as ex:
        if not ut.QUIET:
            ut.printex(ex, '[preproc_chip] Handing Exception: ', iswarning=True)
        # Remove bad annotations from the sql database
        aid_list = ibs.get_chip_aids(cid_list)
        valid_list    = [cid is not None for cid in cid_list]
        valid_aids    = ut.compress(aid_list, valid_list)
        valid_cfpaths = ut.compress(cfpath_list, valid_list)
        invalid_aids  = ut.filterfalse_items(valid_aids, map(exists, valid_cfpaths))
        ibs.delete_annot_chips(invalid_aids)
        # Try readding things
        new_cid_list = ibs.add_annot_chips(aid_list)
        cfpath_list = ibs.get_chip_fpath(new_cid_list)
        chip_list = [vt.imread(cfpath) for cfpath in cfpath_list]
    return chip_list

[docs]def generate_chip_properties(ibs, aid_list, config2_=None):
    r"""
    Computes parameters for SQLController adding

    computes chips if they do not exist.
    generates values for add_annot_chips sqlcommands

    Args:
        ibs (IBEISController):
        aid_list (list):
        config2_ (QueryParams):

    CommandLine:
        python -m ibeis.algo.preproc.preproc_chip --test-generate_chip_properties

    Example:
        >>> # ENABLE DOCTEST
        >>> from ibeis.algo.preproc.preproc_chip import *  # NOQA
        >>> from os.path import basename
        >>> import ibeis
        >>> ibs = ibeis.opendb('testdb1')
        >>> aid_list = ibs.get_valid_aids()[0:1]
        >>> params_iter = generate_chip_properties(ibs, aid_list)
        >>> params_list = list(params_iter)
        >>> (chip_uri, width, height,) = params_list[0]
        >>> fname_ = ut.regex_replace('auuid=.*_CHIP', 'auuid={uuid}_CHIP', chip_uri)
        >>> result = (fname_, width, height)
        >>> print(result)
        ('chip_avuuid=8687dcb6-1f1f-fdd3-8b72-8f36f9f41905_CHIP(sz450).png', 545, 372)

        ('chip_aid=1_auuid={uuid}_CHIP(sz450).png', 545, 372)
    """
    try:
        # the old function didn't even call this
        print('[generate_chip_properties] Requested params for %d chips ' % (len(aid_list)))
        chip_dir = ibs.get_chipdir()
        chip_result_list = compute_and_write_chips(ibs, aid_list, config2_=config2_)
        for chip_result, aid in zip(chip_result_list, aid_list):
            cfpath, width, height = chip_result
            chip_uri = relpath(cfpath, chip_dir)
            # Can be made faster by getting size from generator
            #pil_chip = vt.open_pil_image(cfpath)
            #width, height = pil_chip.size
            if ut.DEBUG2:
                print('Yeild Chip Param: aid=%r, cpath=%r' % (aid, cfpath))
            yield (chip_uri, width, height,)
    except IOError as ex:
        ut.printex(ex, 'ERROR IN PREPROC CHIPS')

#---------------
# Chip computing
#---------------

[docs]def gen_chip(tup):
    r"""
    Parallel worker. Crops chip out of an image, applies filters, etc

    THERE MAY BE AN ERROR IN HERE DUE TO IMWITE BEING INSIDE A PARALLEL FUNCTION
    BUT IT MAY BE SOMETHING ELSE?

    Either way we probably shouldn't call imwrite inside here
    """
    #print('generating chip')
    cfpath, gfpath, bbox, theta, new_size, filter_list = tup
    chipBGR = vt.compute_chip(gfpath, bbox, theta, new_size, filter_list)
    #if DEBUG:
    #print('write chip: %r' % cfpath)
    height, width = chipBGR.shape[0:2]
    vt.imwrite(cfpath, chipBGR)
    return cfpath, width, height

[docs]def gen_chip2(tup):
    r"""
    Parallel worker. Crops chip out of an image, applies filters, etc
    """
    #print('generating chip')
    cfpath, gfpath, bbox, theta, new_size, filter_list = tup
    chipBGR = vt.compute_chip(gfpath, bbox, theta, new_size, filter_list)
    #if DEBUG:
    #print('write chip: %r' % cfpath)
    height, width = chipBGR.shape[0:2]
    #vt.imwrite(cfpath, chipBGR)
    return chipBGR, cfpath, width, height

[docs]def get_filter_list(chipcfg_dict):
    from vtool import image_filters as gfilt_tool
    filter_list = []
    if chipcfg_dict.get('adapteq'):
        filter_list.append(gfilt_tool.adapteq_fn)
    if chipcfg_dict.get('histeq'):
        filter_list.append(gfilt_tool.histeq_fn)
    #if chipcfg_dict.get('maxcontrast'):
        #filter_list.append(maxcontr_fn)
    #if chipcfg_dict.get('rank_eq'):
        #filter_list.append(rankeq_fn)
    #if chipcfg_dict.get('local_eq'):
        #filter_list.append(localeq_fn)
    if chipcfg_dict.get('grabcut'):
        filter_list.append(gfilt_tool.grabcut_fn)
    return filter_list

[docs]def compute_and_write_chips(ibs, aid_list, config2_=None):
    r"""
    Starts the compute chip process

    Args:
        ibs (IBEISController):  ibeis controller object
        aid_list (list):  list of annotation rowids
        config2_ (dict): (default = None)

    CommandLine:
        python -m ibeis.algo.preproc.preproc_chip --test-compute_and_write_chips

    FIXME: THERE IS A FREEZE THAT HAPPENS HERE
        ./reset_dbs.py
        python -m ibeis.expt.harness --exec-precompute_test_configuration_features -t custom --expt-preload

    Example:
        >>> # SLOW_DOCTEST
        >>> from ibeis.algo.preproc.preproc_chip import *  # NOQA
        >>> from os.path import basename
        >>> config2_ = None
        >>> ibs, aid_list = testdata_ibeis()
        >>> # delete chips
        >>> ibs.delete_annot_chips(aid_list)
        >>> # ensure they were deleted
        >>> cid_list = ibs.get_annot_chip_rowids(aid_list, ensure=False)
        >>> assert all([cid is None for cid in cid_list]), 'should be gone'
        >>> chip_result_list = list(compute_and_write_chips(ibs, aid_list))
        >>> cfpath_list = ut.get_list_column(chip_result_list, 0)
        >>> cfname_list = ut.lmap(basename, cfpath_list)
        >>> print(cfname_list)
        >>> # cids should still be None. IBEIS does not know we computed chips
        >>> cid_list = ibs.get_annot_chip_rowids(aid_list, ensure=False)
        >>> assert all([cid is None for cid in cid_list]), 'should be gone'
        >>> # Now this function should have been executed again implictly
        >>> cid_list = ibs.get_annot_chip_rowids(aid_list, ensure=True)
        >>> assert ibs.get_chip_fpath(cid_list) == cfpath_list, 'should be what we had before'

    Ignore:
        >>> from ibeis.algo.preproc.preproc_chip import *  # NOQA
        from os.path import basename
        import ibeis
        ibs = ibeis.opendb('GZ_Master1')
        aid_list = [1915]
        extract_chip_from_img(imgBGR, bbox, theta, new_size)
        gfpath_list = ibs.get_annot_image_paths(aid_list)
        bbox_list   = ibs.get_annot_bboxes(aid_list)
        theta_list  = ibs.get_annot_thetas(aid_list)
        bbox_size_list = ut.get_list_column(bbox_list, [2, 3])
        newsize_list = vt.get_scaled_sizes_with_area(target_area, bbox_size_list)
        gfpath = gfpath_list[0]
        img = vt.imread(gfpath)
        dim_size = 450
        dim_size = 500
        target_area = dim_size ** 2
        bbox = bbox_list[0]
        theta = theta_list[0]
        new_size = newsize_list[0]
        #new_size = bbox[2:4]
        chipBGR = vt.compute_chip(gfpath, bbox, theta, new_size, {})
        import plottool as pt
        print('chipBGR.shape = %r' % (chipBGR.shape,))
        print('chipBGR.shape = %r' % (np.sqrt(np.prod(chipBGR.shape[0:2])),))
        pt.imshow(chipBGR, fnum=1)
        pt.imshow(img, fnum=2)
        pt.iup()
        pt.present()

    """
    ut.ensuredir(ibs.get_chipdir())
    # CONFIG INFO
    # Get chip configuration information
    if config2_ is not None:
        chip_cfg_dict  = config2_.get('chip_cfg_dict')
        dim_size = config2_.get('dim_size')
        assert dim_size is not None
        assert chip_cfg_dict is not None
    else:
        # use ibs if config2_ is None
        dim_size = ibs.cfg.chip_cfg.dim_size
        chip_cfg_dict = ibs.cfg.chip_cfg.to_dict()
    # Get chip dest information (output path),
    # source information (image, annotation_bbox, theta)
    # Get how big to resize each chip, etc...
    nChips = len(aid_list)
    filter_list = get_filter_list(chip_cfg_dict)
    cfpath_list = make_annot_chip_fpath_list(ibs, aid_list, config2_=config2_)
    gfpath_list = ibs.get_annot_image_paths(aid_list)
    bbox_list   = ibs.get_annot_bboxes(aid_list)
    theta_list  = ibs.get_annot_thetas(aid_list)
    #target_area = dim_size ** 2
    bbox_size_list = ut.get_list_column(bbox_list, [2, 3])

    scale_func_dict = {
        'width': vt.get_scaled_size_with_width,
        'root_area': vt.get_scaled_size_with_area,
    }
    resize_dim = chip_cfg_dict['resize_dim']
    scale_func = scale_func_dict[resize_dim]
    if resize_dim == 'root_area':
        target_dim_size = dim_size ** 2
    else:
        target_dim_size = dim_size
    newsize_list = [scale_func(target_dim_size, w, h) for (w, h) in bbox_size_list]

    #newsize_list = vt.get_scaled_sizes_with_area(target_area, bbox_size_list)
    invalid_aids = [aid for aid, (w, h) in zip(aid_list, bbox_size_list) if w == 0 or h == 0]
    filtlist_iter = (filter_list for _ in range(nChips))
    # Check for invalid chips
    if len(invalid_aids) > 0:
        msg = ("REMOVE INVALID (BAD WIDTH AND/OR HEIGHT) AIDS TO COMPUTE AND WRITE CHIPS")
        msg += ("INVALID AIDS: %r" % (invalid_aids, ))
        print(msg)
        raise Exception(msg)
    # Define "Asynchronous" generator
    arg_iter = zip(cfpath_list, gfpath_list, bbox_list, theta_list,
                            newsize_list, filtlist_iter)
    arg_list = list(arg_iter)
    #ut.embed()
    # We have to force serial here until we can figure out why parallel chip
    # generation causes a freeze
    # utool has a unstable test that reproduces this reliably (BECAUSE OF
    # CV2.WARP_AFFINE WITH BIG OUTPUT)
    if ut.VERBOSE:
        print('Computing %d chips' % (len(cfpath_list)))

    DO_IMWRITE_IN_WORKER = False
    if DO_IMWRITE_IN_WORKER:
        # Compute and write chips in asychronous process
        chip_result_iter = ut.util_parallel.generate(gen_chip, arg_list,
                                                     ordered=True,
                                                     force_serial=True,
                                                     freq=10)
        #chip_result_list = list(chip_result_iter)
        for _ in chip_result_iter:
            yield _
    else:
        # Compute chips in asychronous process. Write here
        chip_result_iter = ut.util_parallel.generate(gen_chip2, arg_list,
                                                     ordered=True,
                                                     force_serial=True,
                                                     freq=10)
        #chip_result_list = []
        for chipBGR, cfpath, width, height in chip_result_iter:
            vt.imwrite(cfpath, chipBGR)
            del chipBGR
            yield (cfpath, width, height)
    #print(ut.util_parallel.__POOL__)
    if not ut.VERBOSE:
        print('Done computing chips')
    #return chip_result_list

[docs]def on_delete(ibs, cid_list, config2_=None):
    r"""
    Cleans up chips on disk.  Called on delete from sql controller.

    CommandLine:
        python -m ibeis.algo.preproc.preproc_chip --test-on_delete

    Example:
        >>> # ENABLE_DOCTEST
        >>> from ibeis.algo.preproc.preproc_chip import *  # NOQA
        >>> from ibeis.algo.preproc import preproc_chip
        >>> ibs, aid_list = preproc_chip.testdata_ibeis()
        >>> cid_list = ibs.get_annot_chip_rowids(aid_list, ensure=True)
        >>> ut.assert_eq(len(ut.filter_Nones(cid_list)), len(cid_list), var1_name='nchips')
        >>> # Run test function
        >>> nRemoved1 = preproc_chip.on_delete(ibs, cid_list)
        >>> ut.assert_eq(nRemoved1, len(cid_list), var1_name='nRemoved1', var2_name='target')
        >>> nRemoved2 = preproc_chip.on_delete(ibs, cid_list)
        >>> ut.assert_eq(nRemoved2, 0, var1_name='nRemoved2', var2_name='target')
        >>> # We have done a bad thing at this point. SQL still thinks chips exist
        >>> cid_list2 = ibs.get_annot_chip_rowids(aid_list, ensure=False)
        >>> ibs.delete_chips(cid_list2)
    """
    chip_fpath_list = ibs.get_chip_fpath(cid_list)
    nRemoved = ut.remove_existing_fpaths(chip_fpath_list, lbl='chips')
    return nRemoved

#---------------
# Chip filenames
#---------------

[docs]def make_annot_chip_fpath_list(ibs, aid_list, config2_=None):
    chipdir = ibs.get_chipdir()
    chip_uri_list = make_annot_chip_uri_list(ibs, aid_list, config2_=config2_)
    cfpath_list = [ut.unixjoin(chipdir, chip_uri) for chip_uri in chip_uri_list]
    return cfpath_list

[docs]def make_annot_chip_uri_list(ibs, aid_list, config2_=None):
    r"""
    Build chip file paths based on the current IBEIS configuration

    A chip depends on the chip config and the parent annotation's bounding box.
    (and technically the parent image (should we put that in the file path?)

    Args:
        ibs (IBEISController):
        aid_list (list):
        suffix (None):

    Returns:
        cfpath_list

    Example:
        >>> # ENABLE_DOCTEST
        >>> from ibeis.algo.preproc.preproc_chip import *  # NOQA
        >>> from os.path import basename
        >>> ibs, aid_list = testdata_ibeis()
        >>> aid_list = aid_list[0:1]
        >>> chip_uri_list = make_annot_chip_uri_list(ibs, aid_list)
        >>> #fname = '\n'.join(map(basename, cfpath_list))
        >>> fname = '\n'.join(chip_uri_list)
        >>> result = fname
        >>> print(result)
        chip_avuuid=8687dcb6-1f1f-fdd3-8b72-8f36f9f41905_CHIP(sz450).png

    chip_aid=1_bbox=(0,0,1047,715)_theta=0.0tau_gid=1_CHIP(sz450).png
    """
    cfname_fmt = get_chip_fname_fmt(ibs, config2_=config2_)
    annot_visual_uuid_list  = ibs.get_annot_visual_uuids(aid_list)
    cfname_list = [cfname_fmt.format(avuuid=avuuid) for avuuid in annot_visual_uuid_list]
    return cfname_list

[docs]def get_chip_fname_fmt(ibs, config2_=None):
    r"""Returns format of chip file names

    Args:
        ibs (IBEISController):

    Returns:
        cfname_fmt

    Example:
        >>> # ENABLE_DOCTEST
        >>> from ibeis.algo.preproc.preproc_chip import *  # NOQA
        >>> from ibeis.algo.preproc import preproc_chip
        >>> ibs, aid_list = preproc_chip.testdata_ibeis()
        >>> cfname_fmt = get_chip_fname_fmt(ibs)
        >>> result = cfname_fmt
        >>> print(result)
        chip_avuuid={avuuid}_CHIP(sz450).png

    chip_aid=%d_bbox=%s_theta=%s_gid=%d_CHIP(sz450).png
    """
    if config2_ is not None:
        chip_cfgstr = config2_.get('chip_cfgstr')
        assert chip_cfgstr is not None
    else:
        chip_cfgstr = ibs.cfg.chip_cfg.get_cfgstr()   # algo settings cfgstr
    chip_ext = ibs.cfg.chip_cfg['chipfmt']  # png / jpeg (BUGS WILL BE INTRODUCED IF THIS CHANGES)
    suffix = chip_cfgstr + chip_ext
    # Chip filenames are a function of annotation_rowid and cfgstr
    # TODO: Use annot uuids, use verts info as well
    #cfname_fmt = ('aid_%d' + suffix)
    #cfname_fmt = ''.join(['chip_auuid_%s' , suffix])
    #cfname_fmt = ''.join(['chip_aid=%d_auuid=%s' , suffix])
    # TODO: can use visual_uuids instead
    #cfname_fmt = ''.join(['chip_aid=%d_bbox=%s_theta=%s_gid=%d' , suffix])
    cfname_fmt = ''.join(['chip_avuuid={avuuid}' , suffix])
    return cfname_fmt

#-------------
# Testing
#-------------

[docs]def testdata_ibeis():
    r"""testdata function """
    import ibeis
    ibs = ibeis.opendb('testdb1')
    aid_list = ibs.get_valid_aids()[0::4]
    return ibs, aid_list

        © Copyright 2016, Jon Crall.

  Built with Sphinx using a theme provided by Read the Docs.


text:
<?php
namespace Doctrineum\Tests\Scalar\Helpers;

use Granam\ScalarEnum\ScalarEnum;

class TestInvalidScalarEnumValue extends ScalarEnum
{

    protected static function convertToEnumFinalValue($value)
    {
        // intentionally no conversion at all
        return $value;
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace Ojs\JournalBundle\Event\JournalContact;

final class JournalContactEvents
{
    const LISTED = 'ojs.journal_contact.list';

    const PRE_CREATE = 'ojs.journal_contact.pre_create';

    const POST_CREATE = 'ojs.journal_contact.post_create';

    const PRE_UPDATE = 'ojs.journal_contact.pre_update';

    const POST_UPDATE = 'ojs.journal_contact.post_update';

    const PRE_DELETE = 'ojs.journal_contact.pre_delete';

    const POST_DELETE = 'ojs.journal_contact.post_delete';
}


text:
<?php

namespace NucleusHub\CmsBundle\Services;

use Lsw\ApiCallerBundle\Caller\LoggingApiCaller;
use Lsw\ApiCallerBundle\Call\HttpPost;

class UserService
{

    /**
    * @var LoggingApiCaller
    */
    protected $api_caller;

    public function __construct(LoggingApiCaller $apiCaller) {

        $this->api_caller = $apiCaller;
    }

    public function authenticate($username, $password){

        $url = 'http://api.propiet.com/v1/user/auth';
        $parameters = array('request'=>'{"username":"'.$username.'","password":"'.$password.'"}');
        $output = $this->api_caller->call(new HttpPost($url, $parameters));
        $userData = json_decode($output, true);
        if($userData['response']['success'] == true){
            $userData['response']['data']['user_password'] = $password;
        }
        return $userData['response']['data'];
    }

    public function getUser($username){

        $url = 'http://api.propiet.com/v1/user/me';
        $parameters = array('request'=>'{"username":"'.$username.'"}');
        $output = $this->api_caller->call(new HttpPost($url, $parameters));

        $userData = json_decode($output, true);

        return $userData['response']['data'];
    }

    public function updateProfile($formData, $apiKey){

        $url = 'http://api.propiet.com/v1/user/update';
        $formData = json_encode($formData);

        $parameters = array('request'=>'{"data":'.$formData.'}',
            'k'=>$apiKey);

        $output = $this->api_caller->call(new HttpPost($url, $parameters));

        $data = json_decode($output, true);
        if($data['response']['success'] == true){
           $response = $data['response'];
        } else {
            $response = $data['response']['error'];
        }
        return $response;
    }

    public function updatePassword($formData, $apiKey){

        $url = 'http://api.propiet.com/v1/user/chpwd';
        $formData = json_encode($formData);

        $parameters = array('request'=>'{"data":'.$formData.'}',
            'k'=>$apiKey);

        $output = $this->api_caller->call(new HttpPost($url, $parameters));

        $data = json_decode($output, true);
        if($data['response']['success'] == true){
           $response = $data['response'];
        } else {
            $response = $data['response']['error'];
        }
        return $response;
    }

    public function register(array $userData){

        $url = 'http://api.propiet.com/v1/user/add';
        $parameters = array(
            'request'=>'{"data":'.json_encode($userData).'}',
            'k' => '5696476e19bcb1459dd9d63ddfdba957f290ff74');

        $output = $this->api_caller->call(new HttpPost($url, $parameters));

        $userData = json_decode($output, true);

        return $userData['response'];
    }

    public function activate(array $userData){

        $url = 'http://api.propiet.com/v1/user/activate';
        $parameters = array(
            'request'=>'{"data":'.json_encode($userData).'}',
            'k' => '5696476e19bcb1459dd9d63ddfdba957f290ff74');

        $output = $this->api_caller->call(new HttpPost($url, $parameters));

        $userData = json_decode($output, true);

        return $userData['response'];
    }

    public function forgotPassword(array $userData){

        $url = 'http://api.propiet.com/v1/user/forgot_password';
        $parameters = array(
            'request'=>'{"data":'.json_encode($userData).'}',
            'k' => '5696476e19bcb1459dd9d63ddfdba957f290ff74');

        $output = $this->api_caller->call(new HttpPost($url, $parameters));

        $userData = json_decode($output, true);

        return $userData['response'];
    }

    public function contactAgent(array $userData){

        $url = 'http://api.propiet.com/v1/user/contact_agent';
        $parameters = array(
            'request'=>'{"data":'.json_encode($userData).'}',
            'k' => '5696476e19bcb1459dd9d63ddfdba957f290ff74');

        $output = $this->api_caller->call(new HttpPost($url, $parameters));

        $userData = json_decode($output, true);

        return $userData['response'];
    }

    public function sellAgent(array $userData){

        $url = 'http://api.propiet.com/v1/user/sell_agent';
        $parameters = array(
            'request'=>'{"data":'.json_encode($userData).'}',
            'k' => '5696476e19bcb1459dd9d63ddfdba957f290ff74');

        $output = $this->api_caller->call(new HttpPost($url, $parameters));

        $userData = json_decode($output, true);

        return $userData['response'];
    }

}


text:
/// <reference path="jquery-1.7.1.min.js" />

//State for knowing if we display desktop or tablet size...
var state = null;

//List of functions to call when the resize event is triggered.
var resizeCallbacks = $.Callbacks();

////////////////////////////////////////////////////
// Document ready
////////////////////////////////////////////////////

//Document ready
$(document).ready(function () {
    //Caclulate menu info...
    menuInfo.Init();
    searchBlocks.Init();

    //Add functions to the list of callbacks...
    resizeCallbacks.add(ShowHideDropDownMenu);
    resizeCallbacks.add(SetLeftColumnToBottom);
    resizeCallbacks.add(menuInfo.OnResize);
    resizeCallbacks.add(searchBlocks.OnResize);
    resizeCallbacks.add(moveCalendar);
    resizeCallbacks.add(MoveSuLogo);
    resizeCallbacks.add(SwitchLeftAndMainSectionsForStartB);

    //Create a dropdown menu from the regular menu (to avoid duplicated code)
    createDropDownFromRegularMenu();

    resizeCallbacks.fire();

    $(window).resize(function () {
        resizeCallbacks.fire();
    });

});

//////////////////////////////////////////////////////////////////
// Switch positions for the left column and the main column to
// make the left column appear under the main column.
//////////////////////////////////////////////////////////////////
//TODO: See if we can do this without javascript.
var SwitchLeftAndMainSectionsForStartB = function () {
    if ($('body').hasClass('start_b')) { // Only for start_b
        if ($("body").width() <= 600) {
          $("#left-column").insertAfter("#main-news");
        }
        else {
            $("#main-news").insertAfter("#left-column");
        }
    }
};

//////////////////////////////////////////////////////////////////
// Move the Su logo on top of the department name
//////////////////////////////////////////////////////////////////
//TODO: See if we can do this without javascript.
var MoveSuLogo = function () {
    if ($("body").width() <= 660) {
      $(".head-left").insertAfter($(".head-right"));
      $(".head-right").css("float", "left");
    }
    else {
      $(".head-right").insertAfter($(".head-left"));
      $(".head-right").css("float", "right");
    }
};

//////////////////////////////////////////////////////////////////
// Aligns the menu to the bottom
//////////////////////////////////////////////////////////////////
var SetLeftColumnToBottom = function () {
    if ($("body").width() <= 700) {
        //Set a offset to get a better look
        var bottom = 14;

        //Only add height if the element was found.
        var topLinksHeight = $('.top-links-320 > .top-links').height();

        if (topLinksHeight !== null)
            bottom += topLinksHeight;
        var footerHeight = $('.footer').height();

        if (footerHeight !== null)
            bottom += footerHeight;
        //Move element...

        $('.left-column').css('bottom', bottom + 'px');

        bottom = $('.left-column').height();
        //Move object with class main-column so that the menu does not cover it.
       $(".main-column").css('padding-bottom', bottom + 'px');
    }
    else {
        $(".main-column").css('padding-bottom', '0px');
    }
};

//////////////////////////////////////////////////////////////////
// Moves the calendar below the carousel (and back if needed)
//////////////////////////////////////////////////////////////////
var calenderParent = null;
var indexInParent = -1;

var moveCalendar = function () {

    if ($('body').hasClass('start_b')) {
        if (calenderParent == null) {
            indexInParent = $('.calendar-col').parent().children().index($('.calendar-col'));
            calenderParent = $('.calendar-col').parent();
        }

        //Only move if width is smaller than 615 and current state is tablet (or the state is null = just entered page)
        if ($("body").width() <= 615 && (state === 'tablet' || state === null)) {
            state = 'phone'

            if ($('.calendar-col').length === 1)
                $('.calendar-col').insertAfter('.carouselWrapper');

        }
        //Only move if width larger than 615 and current state is phone (or the state is null = just entered page)
        if ($("body").width() > 615 && (state === 'phone' || state === null)) {
            state = 'tablet';
            if ($('.calendar-col').length === 1) {
                $('.calendar-col').insertBefore(calenderParent.children().get(indexInParent));
            }
        }
    }
}

//////////////////////////////////////////////////////////////////
// Hides/Shows the dynamically created dropdown and regular menu.
//////////////////////////////////////////////////////////////////
var ShowHideDropDownMenu = function () {
    //Tablet or Desktop? Only check if state has changed
    if ($("body").width() <= 660 && (state === 'desktop' || state === null)) {
        state = 'tablet';
        $('#HeadRowMenu').hide();
        $('.head-row-right').hide();
        $('.nav320Wrapper').show();
    }
    if ($("body").width() > 660 && (state === 'tablet' || state === null)) {
        state = 'desktop';
        $('#HeadRowMenu').show();
        $('.head-row-right').show();
        $('.nav320Wrapper').hide();
    }
};

//////////////////////////////////////////////////////////////////
// Creates a dropdown from the regular menu,
// to be showed in smaller width...
// The HTML created reflects the dropdown menu from the POC.
//////////////////////////////////////////////////////////////////
var createDropDownFromRegularMenu = function () {

    //Build some markup with the correct classes, id´s etc...

    var searchForm = document.getElementById('FormHeadSearch');
    var searchLink = searchForm? searchForm.getAttribute('action'): "javascript:nop"; // fallback (for not breaking everything)
    var searchSubmit = document.getElementById('BtnHeadSearch');
    var searchSubmitText = searchSubmit? searchSubmit.getAttribute('value') : ""; // fallback (for not breaking everything)
    var startLink = document.getElementById('startLinkId');
    var startLinkPath = startLink? startLink.getAttribute('href') : "javascript:nop"; // fallback (for not breaking everything)

    var nav320Wrapper = $('
').addClass('nav320Wrapper');
    var nav320WrapperInner = $('
').addClass('nav320WrapperInner');
    var nav320Home = $('
').addClass('link-wrapper-nav320').append($('').addClass('home-link').append(''));
    var nav320Search = $('
').addClass('link-wrapper-nav320 search-link').append($('').append('').text(searchSubmitText));
    var jumpWrapper = $('
').addClass('jumpWrapper');
    var select = $('<select>').addClass('jump').attr('name', 'jumpMenu').attr('id', 'jumpMenu');
    var form = $('<form>').attr('id', 'form').attr('action', '').attr('name', 'form');

    //Build them in the correct order
    nav320Wrapper.append(nav320WrapperInner);
    nav320WrapperInner.append(form);
    form.append(nav320Home).append(jumpWrapper).append(nav320Search);
    jumpWrapper.append(select);

    //Transform the menu into a dropdown
    var menuitems = $('#HeadRowMenu > li');
    var menuOption = $('<option>').attr('value', '#').text('Meny');
    select.append(menuOption);
    $.each(menuitems, function (ix, val) {
        var href = $('a', menuitems[ix]).attr('href');
        var active = $(menuitems[ix]).hasClass('active');
        var text = $(menuitems[ix]).text();

        var option = $('<option>').attr('value', href).text(text);
        if (active){
            option.addClass('selected');
            option.attr('selected', 'selected');
        }
        select.append(option);
    });

    //When the ménu is changed, navigate to the selection...
    select.change(function () {
        window.location = $(this).val();
    });
    //Insert the menu at the correct location in the page.
    nav320Wrapper.insertAfter($(".head-row"));

    // If chrome then disable webkit-appearance SUPP9-1822
    if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1){
       $('jumpMenu').css("-webkit-appearance", "none");
    }

};

var searchBlocks = (function () {
    var _private = {

        active: false,
        eventsOn: false,

        Init: function () {
            if ($(".content-block .search-result").length > 0) {
                this.active = true;
                $(".content-block .search-result").parents(".content-block").addClass("active-search-result-block");
                $(".search-overview").parents(".content-block").addClass("active-search-result-block");
            } else {

            }
        },

        OnResize: function () {

            if (this.active) {
                if ($("body").width() <= 600) {
                    if (this.eventsOn == false) {

                        $(".active-search-result-block h2").click(function () {
                            $(this).parent().find(".content-block-inner").toggle();
                            $(this).parent().find(".content-block-link.link-left").toggle();
                        });

                        $(".active-search-result-block .content-block-inner").hide();
                        $(".active-search-result-block .content-block-link").hide();
                        this.eventsOn = true;
                    }
                } else {

                    if (this.eventsOn) {
                        $(".active-search-result-block h2").unbind("click");
                        $(".active-search-result-block .content-block-inner").show();
                        $(".active-search-result-block .content-block-link").show();
                        this.eventsOn = false;
                    }
                }
            }
        }

    };
    return {
        Init: function () { _private.Init(); },
        OnResize: function () { _private.OnResize(); }
    };
})();

//////////////////////////////////////////////////////////////////
// Menu... under development!
//////////////////////////////////////////////////////////////////

var lockHandler = function(event){
    event.preventDefault();
}

var menuInfo = (function () {
    var _private = {

        //INTERNA VARIABLER
        containerWidth: 0,
        maxNegMargin: 0,
        parentContainerWidth: 0,

        targetList: null,

        active: false,
        eventsOn: false,
        touchOffsetX: 0,

        moveRight: function (speed) {

            var currentPosition = parseInt(this.targetList.css("left").replace("px", ""));
            currentPosition -= speed;

            if (currentPosition <= this.maxNegMargin) {
                currentPosition = this.maxNegMargin;
                $("div.arrowButton.next").addClass("disabled");
            }

            $("div.arrowButton.back").removeClass("disabled");

            this.targetList.css("left", currentPosition + "px");
        },

        moveLeft: function (speed) {

            var currentPosition = parseInt(this.targetList.css("left").replace("px", ""));
            currentPosition += speed;

            if (currentPosition >= 0) {
                currentPosition = 0;
                $("div.arrowButton.back").addClass("disabled");
            }

            $("div.arrowButton.next").removeClass("disabled");

            this.targetList.css("left", currentPosition + "px");
        },

        initializeCarousel: function () {

            //HÄMTA REFERENSER
            this.targetList = $(".content-block.shortcuts.carousel .content-block-inner ul.block-user-groups");
        },

        calculateWidth: function () {
            //CALCULATE WIDTH
            var tmpWidth = 0;
            this.targetList.find("li").each(function () {
                tmpWidth += $(this).outerWidth(true) + 1;
            });

            this.containerWidth = tmpWidth;
            this.targetList.css("width", this.containerWidth + "px");

            this.parentContainerWidth = this.targetList.parent().width();
        },

        restorePositions: function () {
            this.targetList.css("left", "0px");
            $("div.arrowButton.back").addClass("disabled");
            $("div.arrowButton.next").removeClass("disabled");
        },

        registerEvents: function () {

            //CLICK EVENTS
            $("div.arrowButton.next").click(function (e) {
                e.preventDefault();
                menuInfo.MoveRight(10);
            });

            $("div.arrowButton.back").click(function (e) {
                e.preventDefault();
                menuInfo.MoveLeft(10);
            });

            //CLICK HOLD EVENTS

            $('div.arrowButton.next').mousedown(function () {
                timeoutId = setInterval(function () { menuInfo.MoveRight(20); }, 50);
            }).bind('mouseup mouseleave', function () {
                clearInterval(timeoutId);
            });

            $('div.arrowButton.back').mousedown(function () {
                timeoutId = setInterval(function () { menuInfo.MoveLeft(20); }, 50);
            }).bind('mouseup mouseleave', function () {
                clearInterval(timeoutId);
            });

            //TOUCH EVENTS

            this.targetList.bind('touchstart', function (e) {
                var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
                this.touchOffsetX = touch.pageX;

                document.bind("ontouchmove", lockHandler);

            });

            this.targetList.bind('touchend', function (e) {
                this.touchOffsetX = 0;

                document.unbind("ontouchmove", lockHandler);
            });

            this.targetList.bind('touchmove', function (e) {
                e.preventDefault();
                var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
                if ((this.touchOffsetX - touch.pageX) > 0) {
                    menuInfo.MoveRight(20)
                } else if ((this.touchOffsetX - touch.pageX) < 0) {
                    menuInfo.MoveLeft(20)
                }
            });

            $('div.arrowButton.next').bind('touchstart', function (e) {
                e.preventDefault();
                var frontInterval = setInterval(function () { menuInfo.MoveRight(15); }, 50);

                $('div.arrowButton.next').bind('touchend', function (e) {
                    e.preventDefault();
                    clearInterval(frontInterval);
                });
            });

            $('div.arrowButton.back').bind('touchstart', function (e) {
                e.preventDefault();
                var backInterval = setInterval(function () { menuInfo.MoveLeft(15); }, 50);

                $('div.arrowButton.back').bind('touchend', function (e) {
                    e.preventDefault();
                    clearInterval(backInterval);
                });
            });

        },

        unregisterEvents: function () {
            $("div.arrowButton.next").unbind("click");
            $("div.arrowButton.next").unbind("mousedown");
            $("div.arrowButton.next").unbind("mouseup");
            $("div.arrowButton.next").unbind("mouseleave");

            $("div.arrowButton.next").unbind("touchstart");
            $("div.arrowButton.next").unbind("touchend");

            $("div.arrowButton.back").unbind("click");
            $("div.arrowButton.back").unbind("mousedown");
            $("div.arrowButton.back").unbind("mouseup");
            $("div.arrowButton.back").unbind("mouseleave");

            $("div.arrowButton.back").unbind("touchstart");
            $("div.arrowButton.back").unbind("touchend");

            this.targetList.unbind("touchstart");
            this.targetList.unbind("ontouchmove");
            this.targetList.unbind("touchend");
        },

        onResize: function () {

            if ($("body").width() <= 800) {
                if (this.active == false) {
                    this.active = true;
                    this.initializeCarousel();
                }

                this.calculateWidth();

                if (this.containerWidth >= this.parentContainerWidth) {
                    //REGISTER EVENTS
                    if (!this.eventsOn) {
                        this.registerEvents();
                        this.eventsOn = true;
                        $(".content-block.shortcuts.carousel").addClass("active");
                    }

                    this.restorePositions();

                    this.maxNegMargin = (this.parentContainerWidth - this.containerWidth);

                } else {
                    if ($(".content-block.shortcuts.carousel").hasClass("active")) {
                        $(".content-block.shortcuts.carousel").removeClass("active");
                    }
                    if (this.eventsOn) {
                        this.unregisterEvents();
                        this.eventsOn = false;
                    }
                }
            } else {
                if (this.active == true) {
                    this.targetList.css("width", "auto");
                    this.active = false;
                }
            }

        },
        init: function () {

        }
    };
    return {
        Init: function () { _private.init(); },
        OnResize: function () { _private.onResize(); },
        MoveRight: function (speed) { _private.moveRight(speed); },
        MoveLeft: function (speed) { _private.moveLeft(speed); }
    };
})();


text:
SYNONYM

#### According to
Index Fungorum

#### Published in
Ber. naturw. Augsburg 26: 140 (1881)

#### Original name
Agaricus conferendus Britzelm.

### Remarks
null


text:
package edu.usc.softarch.disco.gui;

import java.io.File;
import java.io.FileFilter;
import javax.swing.*;
import javax.swing.filechooser.*;

/**
 * XML file filter singleton.
 * This singleton is a filter used to filter results, either in a Swing
 * file chooser dialog or when generating a list of File objects.
 *
 * When applied, this filter will select only files with a '.xml'
 * file extension.
 *
 * @author Trevor Johns <tjohns@usc.edu>
 * @version $Rev: 128 $
 */
public class XMLFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter
{
    /** Singleton instance. */
    private static XMLFilter ref;

    /**
     * Class constructor.
     * Declared private to prevent manual instantiation.
     * Use {@link #getXMLFilter()} instead.
     */
    private XMLFilter ()
    {
        // Intentionally left blank to enforce singleton rules
    }

    /**
     * Public singleton constructor.
     * Use this static method to obtain an instance of the
     * singleton associated with this class.
     *
     * WARNING: This is not thread safe.
     */
    public static XMLFilter getXMLFilter ()
    {
      if (ref == null)
          // it's ok, we can call this constructor
          ref = new XMLFilter();
      return ref;
    }

    /**
     * Clone protection method.
     * Overrides {@link Object#clone()} to make sure that a seperate
     * instance of the singleton cannot be created.
     */
    public Object clone() throws CloneNotSupportedException
    {
      throw new CloneNotSupportedException();
    }

    /**
     * Tests a file to see if it should be filtered or not.
     *
     * @param f The file to be tested.
     * @return true if the file's extension is '.xml'
     */
    public boolean accept(File f)
    {
        if (f.isDirectory()) {
            return true;
        }

        String extension = getExtension(f);
        if (extension != null) {
            if (extension.equals("xml")) {
                    return true;
            } else {
                return false;
            }
        }

        return false;
    }

    /**
     * Returns a description of the filter. This result is usually displayed in a
     * file chooser drop down menu to select what types of files to display.
     *
     * @return The description of the filter.
     */
    public String getDescription ()
    {
        return "XML Files";
    }

    /**
     * Private method to deterine the extension of a file.
     *
     * @param f The file to inspect.
     * @return The file extension of the inspected file, not including the leading period.
     */
    private static String getExtension (File f)
    {
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i+1).toLowerCase();
        }
        return ext;
    }
}


text:
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { createStore, bindActionCreators } from 'redux'
import FontAwesome from 'react-fontawesome'

import * as helpers from '../helpers'
import * as uiActions from '../services/ui/actions'

class Thumbnail extends React.Component{

	constructor(props) {
		super(props);
	}

	// TODO: ascertain whether this is improving or hindering performance
	// The UI appears to work perfectly fine without this
	shouldComponentUpdate(nextProps, nextState){

		// no images at all, and we already know it
		if (!nextProps.image && !this.props.image && !nextProps.images && !this.props.images) return false

		// image changed
		if( !this.props.image && nextProps.image ) return true
		if( this.props.image && nextProps.image ) return true
		if( this.props.image != nextProps.image ) return true

		// images array changed
		if( typeof(this.props.images) === 'undefined' && nextProps.images ) return true
		if( this.props.images && typeof(nextProps.images) === 'undefined' ) return true
		if( this.props.images.length != nextProps.images.length ) return true

		// image item changed
		var size = 'medium'
		var images = helpers.sizedImages( nextProps.images )
		if( this.props.size ) size = this.props.size
		if( this.props.images[size] != images[size] ) return true

		return false
	}

	mapImageSizes( props = this.props ){

		// no images
		if( !this.props.image && !this.props.images ){
			return require('../../assets/no-image.svg')

		// single image
		}else if( this.props.image ){
			return this.props.image

		// multiple images
		}else if( this.props.images && this.props.images.length > 0 ){
			var images = helpers.sizedImages( this.props.images )
			var size = 'medium'
			if( this.props.size ) size = this.props.size
			return images[size]
		}
	}

	zoom(e, image){
		e.preventDefault()
		this.props.uiActions.openModal('image_zoom', {url: image} )
	}

	render(){
		var image = this.mapImageSizes()
		var style = { backgroundImage: 'url("'+image+'")' }
		var class_name = 'thumbnail '+this.props.size;
		if( this.props.circle ) class_name += ' circle';
		if( this.props.className ) class_name += ' '+this.props.className;

		var zoom_icon = null
		if (this.props.canZoom){
			zoom_icon =  this.zoom(e,image)}><FontAwesome name="search" />
		}

		return (

				{zoom_icon}

		);
	}
}

const mapStateToProps = (state, ownProps) => {
	return {}
}

const mapDispatchToProps = (dispatch) => {
	return {
		uiActions: bindActionCreators(uiActions, dispatch)
	}
}

export default connect(mapStateToProps, mapDispatchToProps)(Thumbnail)


text:
[TOC]

# Chromium Integration with ResultDB

ResultDB is a LUCI service for storing and retrieving test results. See also
its [public source] and [Google internal documentation]. As of Q4 2021, all
tests on Chrome/Chromium builders have their test results uploaded to ResultDB,
and nearly all pass-fail decisions on the builders are based on these results.
Consequently, any JSON output from a test no longer has little to no impact on
the results of the bots. (For example, if a test's JSON say that there was a
failure but this isn't similarly reflected in ResultDB, then the build _will not
fail._

However, the JSON output can still have an indirect effect on builds. See
[below](#uses-of-the-legacy-json) for more details.

## ResultDB API & ResultSink

All test harnesses are responsible for uploading their results to ResultDB. This
is most easily done via ResultSink (see [internal documentation]). ResultSink is
a local HTTP server that proxies requests to ResultDB's backend. It can be
launched via the `rdb stream ...` command and listens on a port specified in a
file pointed to by the `LUCI_CONTEXT` environment variable. This server
currently runs in the background on all test bots.

On a machine with the server running, a test can report its results to ResultDB
by making JSON-formatted RPCs to the local HTTP ResultSink server. See
[ResultSink's API] for more details.

## ResultSink integration/wrappers within Chromium

There are several libraries used within Chromium that have ResultSink
integration:

- **Web Tests**: Blink's web tests upload their results through ResultSink via
  [test_result_sink.py].

- **typ**: Typ is a testing library used by performance benchmarks and GPU
  tests. It integrates with ResultSink in [result_sink.py].

- **//build/util/lib/results/**: [//build/util/lib/results/] contains a generic
  wrapper around ResultSink. This is used by both the Android and ChromeOS test
  runners to upload their results to ResultDB.

- **iOS test runner**: The iOS test runner has its own ResultSink integration in
  [result_sink_util.py].

- **result_adapter**: Most remaining tests use the `result_adapter` tool. See
  below for more details.

## result_adapter

[result_adapter] is a command-line tool that wraps a test invocation and will
automatically convert the test's output JSON to the ResultSink format and
uploads those results to ResultDB via ResultSink. Known JSON formats include:

- `gtest` for the JSON generated by running GTests using the support code in
  //base/test/launcher/, specifically the `SaveSummaryAsJSON` function in
  [test_results_tracker.h].

- `json` for the JSON format described in [json_test_results_format.md]. Tests
  that can generate this type of JSON include Blink web tests and typ-supported
  tests.

Though it eased the migration of results into ResultDB, using result_adapter has
a few drawbacks:

- result_adapter uploads all results at once after the test invocation exits.
  If the test execution crashes partway through, ResultDB will not track any of
  the results that were successfully produced.

- result_adapter is limited by the JSON format of the test. It would be unable
  to use any new or advanced feature in ResultDB.

Consequently, it's preferred when possible for new test types and new test
harnesses to integrate with ResultSink directly rather than using
result_adapter. But if circumstances make integration difficult (e.g. we don't
have access to the test harness implementation) result_adapter can be needed.

### Specifying integration in //testing/buildbot/

The *.pyl spec files in [//testing/buildbot/] control what tests a given bot
runs. These testing specs also control how result_adapter is used. By default, a
`isolated_scripts` test will have result_adapter added using the `json`
output format, and a `gtest_tests` test will have result_adapter added using the
`gtest` output format. This can be overwritten using the
`has_native_resultdb_integration` [mixin] which will disable result_adapter for
that test. Additionally, a custom `result_format` can be specified for a test to
overwrite the expected format of the JSON: [example].

## Uses of the legacy JSON

Although the JSON output of tests don't have an immediate effect on builds,
they can still impact pass/fail decisions. This happens during the exoneration
phase of the build which determines if a test failure was introduced by the
CL-under-test or if the failure is also present on ToT. This is accomplished by
an RPC to [FindIt], which is a service that tracks failures across bots. Rather
than using ResultDB, FindIt uses the [legacy test results app] as its source of
truth for test results, and this app uses the results in a test's JSON.
Consequently, the JSON output of tests can still have an effect on builds, just
in an indirect way.

Migration/replacement [efforts] for this phase of the build are underway.

[public source]: https://source.chromium.org/chromium/infra/infra/+/main:go/src/go.chromium.org/luci/resultdb/
[Google internal documentation]: http://shortn/_bTdqm8VDXz
[internal documentation]: http://shortn/_zAbl5fa84c
[ResultSink's API]: https://source.chromium.org/chromium/infra/infra/+/main:go/src/go.chromium.org/luci/resultdb/sink/proto/v1/sink.proto;drc=54f060e7452368ff982d9c66f2c1001bf4fa7394;l=24
[test_result_sink.py]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/tools/blinkpy/web_tests/controllers/test_result_sink.py
[result_sink.py]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/catapult/third_party/typ/typ/result_sink.py
[//build/util/lib/results/]: https://source.chromium.org/chromium/chromium/src/+/main:build/util/lib/results/
[result_sink_util.py]: https://source.chromium.org/chromium/chromium/src/+/main:ios/build/bots/scripts/result_sink_util.py
[result_adapter]: https://source.chromium.org/chromium/infra/infra/+/main:go/src/infra/tools/result_adapter/
[test_results_tracker.h]: https://source.chromium.org/chromium/chromium/src/+/main:base/test/launcher/test_results_tracker.h;drc=96020cfd447cb285acfa1a96c37a67ed22fa2499;l=83
[json_test_results_format.md]: json_test_results_format.md
[//testing/buildbot/]: https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/
[mixin]: https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/mixins.pyl;drc=d0985a69618056e95d64b48803ca90e3ae6a6c77;l=453
[example]: https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/test_suites.pyl;drc=9ef43df31342fb0fc854de5233b7170039028bc1;l=1499
[FindIt]: https://chromium.googlesource.com/infra/infra/+/main/appengine/findit/README.md
[efforts]: https://crbug.com/1243747
[legacy test results app]: https://test-results.appspot.com/


text:
Teiler Presentation
-------------------

Description: Presentation about my program Teiler given at Lawrence Coders

August 16, 2014


text:
import Ionicons from '@expo/vector-icons/build/Ionicons';
import * as Contacts from 'expo-contacts';
import * as ImagePicker from 'expo-image-picker';
import * as Linking from 'expo-linking';
import * as React from 'react';
import { Platform, RefreshControl, StyleSheet, Text, TouchableOpacity, View } from 'react-native';

import HeaderContainerRight from '../../components/HeaderContainerRight';
import HeaderIconButton from '../../components/HeaderIconButton';
import Colors from '../../constants/Colors';
import usePermissions from '../../utilities/usePermissions';
import ContactDetailList, { DetailListItem } from './ContactDetailList';
import * as ContactUtils from './ContactUtils';
import ContactsAvatar from './ContactsAvatar';

const isIos = Platform.OS === 'ios';

async function getPermissionAsync() {
  const { status } = await ImagePicker.getMediaLibraryPermissionsAsync();
  if (status !== 'granted') {
    Linking.openSettings();
    return false;
  }
  return true;
}

export default function ContactDetailScreen(props: any) {
  React.useLayoutEffect(() => {
    props.navigation.setOptions({
      title: 'Contacts',
      headerRight: () => (
        <HeaderContainerRight>
          <HeaderIconButton
            name="md-share"
            onPress={async () => {
              Contacts.shareContactAsync(props.route.params.id, 'Call me :]');
            }}
          />
          <HeaderIconButton
            name="md-open"
            onPress={async () => {
              await Contacts.presentFormAsync(props.route.params.id);
              // tslint:disable-next-line no-console
              console.log('the native contact form has been closed');
            }}
          />
          {isIos && (
            <HeaderIconButton
              name="md-copy"
              onPress={async () => {
                await ContactUtils.cloneAsync(props.route.params.id);
                props.navigation.goBack();
              }}
            />
          )}
        </HeaderContainerRight>
      ),
    });
  }, [props.navigation]);

  const [permission] = usePermissions(Contacts.requestPermissionsAsync);

  if (!permission) {
    return (
      <View style={styles.permissionContainer}>
        <Text>No Contact Permission</Text>
      </View>
    );
  }

  return <ContactDetailView navigation={props.navigation} route={props.route} />;
}

function ContactDetailView({
  navigation,
  route: {
    params: { id },
  },
}: any) {
  const [contact, setContact] = React.useState<Contacts.Contact | null>(null);
  const [refreshing, setRefreshing] = React.useState(false);

  const loadAsync = async () => {
    setRefreshing(true);
    const contact = await Contacts.getContactByIdAsync(id);
    setContact(contact ?? null);
    setRefreshing(false);
  };

  const deleteAsync = async () => {
    try {
      await Contacts.removeContactAsync(id);
      navigation.goBack();
    } catch ({ message }) {
      // tslint:disable-next-line no-console
      console.error(message);
    }
  };

  const jobTitle = React.useMemo<string | null>(() => {
    if (!contact) return null;
    const { jobTitle, department } = contact;
    if (!jobTitle || !department) {
      return jobTitle ?? department ?? null;
    }
    return `${jobTitle} - ${department}`;
  }, [contact]);

  const subtitles = React.useMemo<string[]>(() => {
    if (!contact) return [];

    return [
      contact.phoneticFirstName,
      contact.nickname,
      contact.maidenName,
      jobTitle,
      contact.company,
    ].filter(Boolean) as string[];
  }, [jobTitle, contact]);

  const links = React.useMemo<any[]>(() => {
    if (!contact) return [];

    const phone = ContactUtils.getPrimary<Contacts.PhoneNumber>(contact.phoneNumbers ?? []);
    const email = ContactUtils.getPrimary<Contacts.Email>(contact.emails ?? []);

    return [
      { icon: 'text', text: 'message', format: 'sms', uri: phone?.number },
      { icon: 'call', text: 'call', format: 'tel', uri: phone?.number },
      { icon: 'videocam', text: 'video', format: 'facetime', uri: email?.email },
      { icon: 'mail', text: 'mail', format: 'mailto', uri: email?.email },
      { icon: 'cash', text: 'pay', format: 'shoebox', uri: email?.email },
    ];
  }, [contact]);

  const items = React.useMemo<
    {
      title: string;
      data: DetailListItem[];
    }[]
  >(() => {
    if (!contact) return [];

    const items = [];
    for (const key of Object.keys(contact)) {
      const value = (contact as any)[key];
      if (Array.isArray(value) && value.length > 0) {
        const data = value.map((item) => {
          let transform: Partial<DetailListItem> = {};
          switch (key) {
            case Contacts.Fields.Relationships:
              transform = {
                value: item.name,
              };
              break;
            case Contacts.Fields.PhoneNumbers:
              transform = {
                value: item.number,
                onPress: () => Linking.openURL(`tel:${item.number}`),
              };
              break;
            case Contacts.Fields.SocialProfiles:
              transform = {
                value: item.username,
                label: item.label || item.localizedService,
              };
              break;
            case Contacts.Fields.UrlAddresses:
              transform = {
                value: item.url,
                onPress: () => {
                  const webUrl = item.url.indexOf('://') === -1 ? 'http://' + item.url : item.url;

                  // tslint:disable-next-line no-console
                  console.log('open', item.url, webUrl);
                  Linking.openURL(webUrl);
                },
              };
              break;
            case Contacts.Fields.Dates:
              transform = {
                value: ContactUtils.parseDate(item).toDateString(),
              };
              break;
            case Contacts.Fields.Emails:
              transform = {
                value: item.email,
                onPress: () => Linking.openURL(encodeURI(`mailto:${item.email}`)),
              };
              break;
            case Contacts.Fields.Addresses:
              {
                const address = ContactUtils.parseAddress(item);
                const targetUriAdress = encodeURI(address);
                transform = {
                  value: address,
                  onPress: () =>
                    Linking.openURL(
                      Platform.select<string>({
                        ios: `http://maps.apple.com/maps?daddr=${targetUriAdress}`,
                        default: `http://maps.google.com/maps?daddr=${targetUriAdress}`,
                      })
                    ),
                };
              }
              break;
            case Contacts.Fields.InstantMessageAddresses:
              transform = {
                value: item.username,
              };
              break;
            default:
              break;
          }
          return {
            type: key,
            ...item,
            ...transform,
          };
        });
        items.push({
          title: ContactUtils.parseKey(key),
          data,
        });
      }
    }
    return items;
  }, [contact]);

  const onPressImage = async () => {
    if (!isIos) {
      return;
    }
    _selectPhoto();
  };

  React.useEffect(() => {
    loadAsync();
  }, []);

  const _setNewPhoto = async (uri: string) => {
    // console.log(this.id, this.state.contact, uri);
    try {
      await Contacts.updateContactAsync({
        [Contacts.Fields.ID]: id,
        [Contacts.Fields.Image]: uri,
      } as any);
    } catch ({ message }) {
      // tslint:disable-next-line no-console
      console.error(message);
    }

    loadAsync();
  };

  const _selectPhoto = async () => {
    const permission = await getPermissionAsync();
    if (!permission) {
      return;
    }
    const result = await ImagePicker.launchImageLibraryAsync({
      allowsEditing: true,
      aspect: [4, 3],
    });

    if (!result.cancelled) {
      _setNewPhoto(result.uri);
    }
  };

  const renderListHeaderComponent = () => {
    return (
      <View style={styles.header}>
        <View style={{ alignItems: 'center', marginBottom: 8 }}>
          <ContactsAvatar
            style={styles.image}
            onPress={onPressImage}
            name={contact?.name ?? ''}
            image={contact?.image?.uri}
          />
          <Text style={styles.name}>{contact?.name}</Text>

          {subtitles.map((subtitle, index) => (
            <Text key={index} style={styles.subtitle}>
              {subtitle}
            </Text>
          ))}
        </View>
        <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
          {links.map((linkedItem, index) => (
            <LinkedButton {...linkedItem} key={index} />
          ))}
        </View>
      </View>
    );
  };

  const renderListFooterComponent = () => (
    <Text onPress={deleteAsync} style={styles.footer}>
      Delete Contact
    </Text>
  );

  if (!contact) {
    return <View />;
  }

  return (
    <View style={styles.container}>
      <ContactDetailList
        refreshControl={<RefreshControl refreshing={refreshing} onRefresh={loadAsync} />}
        ListFooterComponent={renderListFooterComponent}
        ListHeaderComponent={renderListHeaderComponent}
        sections={items}
      />
    </View>
  );
}

function LinkedButton({
  text,
  icon,
  uri,
  format,
}: {
  uri?: string | null;
  format: string;
  text: string;
  icon: string;
}) {
  const enabled = !!uri;
  const color = enabled ? 'white' : 'gray';
  const backgroundColor = enabled ? Colors.tintColor : 'transparent';

  const onPress = () => Linking.openURL(`${format}:${encodeURIComponent(uri ?? '')}`);

  return (
    <TouchableOpacity disabled={!enabled} onPress={onPress}>
      <View
        style={[
          styles.linkButton,
          {
            backgroundColor,
          },
        ]}>
        <Ionicons name={`ios-${icon}` as any} size={20} color={color} />
      </View>
      <Text style={[styles.linkButtonText, { color: backgroundColor }]}>{text}</Text>
    </TouchableOpacity>
  );
}

const styles = StyleSheet.create({
  button: {
    marginVertical: 10,
  },
  container: {
    flex: 1,
    alignItems: 'stretch',
  },
  contactRow: {
    marginBottom: 12,
  },
  image: {
    marginVertical: 16,
  },
  name: {
    fontSize: 24,
    textAlign: 'center',
    marginBottom: 6,
  },
  subtitle: {
    opacity: 0.8,
    textAlign: 'center',
    fontSize: 16,
    marginBottom: 2,
  },
  linkButton: {
    width: 40,
    height: 40,
    borderRadius: 20,
    marginBottom: 4,
    borderWidth: StyleSheet.hairlineWidth,
    borderColor: 'rgba(0,0,0,0.1)',

    justifyContent: 'center',
    alignItems: 'center',
  },
  linkButtonText: {
    fontSize: 10,
    textAlign: 'center',
  },
  footer: {
    width: '100%',
    padding: 24,
    textAlign: 'center',
    justifyContent: 'center',
    alignItems: 'center',
    color: 'red',
  },
  header: {
    paddingHorizontal: 36,
    paddingVertical: 16,
    flex: 1,
    alignItems: 'stretch',
    backgroundColor: Colors.greyBackground,
  },
  permissionContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});


text:
package org.apache.cassandra.db;

import java.io.File;
import java.io.FileFilter;
import java.io.IOError;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.Longs;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.cassandra.config.*;
import org.apache.cassandra.db.compaction.LeveledManifest;
import org.apache.cassandra.io.FSError;
import org.apache.cassandra.io.FSWriteError;
import org.apache.cassandra.io.util.FileUtils;
import org.apache.cassandra.io.sstable.*;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.Pair;

/**
 * Encapsulate handling of paths to the data files.
 *
 * The directory layout is the following:
 *   /<path_to_data_dir>/ks/cf1/ks-cf1-hb-1-Data.db
 *                         /cf2/ks-cf2-hb-1-Data.db
 *                         ...
 *
 * In addition, more that one 'root' data directory can be specified so that
 * <path_to_data_dir> potentially represents multiple locations.
 * Note that in the case of multiple locations, the manifest for the leveled
 * compaction is only in one of the location.
 *
 * Snapshots (resp. backups) are always created along the sstables thare are
 * snapshoted (resp. backuped) but inside a subdirectory named 'snapshots'
 * (resp. backups) (and snapshots are furter inside a subdirectory of the name
 * of the snapshot).
 *
 * This class abstracts all those details from the rest of the code.
 */
public class Directories
{
    private static final Logger logger = LoggerFactory.getLogger(Directories.class);

    public static final String BACKUPS_SUBDIR = "backups";
    public static final String SNAPSHOT_SUBDIR = "snapshots";
    public static final String SECONDARY_INDEX_NAME_SEPARATOR = ".";

    public static final DataDirectory[] dataFileLocations;
    static
    {
        String[] locations = DatabaseDescriptor.getAllDataFileLocations();
        dataFileLocations = new DataDirectory[locations.length];
        for (int i = 0; i < locations.length; ++i)
            dataFileLocations[i] = new DataDirectory(new File(locations[i]));
    }

    private final String tablename;
    private final String cfname;
    private final File[] sstableDirectories;

    public static Directories create(String tablename, String cfname)
    {
        int idx = cfname.indexOf(SECONDARY_INDEX_NAME_SEPARATOR);
        if (idx > 0)
            // secondary index, goes in the same directory than the base cf
            return new Directories(tablename, cfname, cfname.substring(0, idx));
        else
            return new Directories(tablename, cfname, cfname);
    }

    private Directories(String tablename, String cfname, String directoryName)
    {
        this.tablename = tablename;
        this.cfname = cfname;
        this.sstableDirectories = new File[dataFileLocations.length];
        for (int i = 0; i < dataFileLocations.length; ++i)
            sstableDirectories[i] = new File(dataFileLocations[i].location, join(tablename, directoryName));

        if (!StorageService.instance.isClientMode())
        {
            for (File dir : sstableDirectories)
            {
                try
                {
                    FileUtils.createDirectory(dir);
                }
                catch (FSError e)
                {
                    // don't just let the default exception handler do this, we need the create loop to continue
                    logger.error("Failed to create {} directory", dir);
                    FileUtils.handleFSError(e);
                }
            }
        }
    }

    /**
     * Returns SSTable location which is inside given data directory.
     *
     * @param dataDirectory
     * @return SSTable location
     */
    public File getLocationForDisk(DataDirectory dataDirectory)
    {
        for (File dir : sstableDirectories)
        {
            if (dir.getAbsolutePath().startsWith(dataDirectory.location.getAbsolutePath()))
                return dir;
        }
        return null;
    }

    public File getDirectoryForNewSSTables()
    {
        File path = getWriteableLocationAsFile();

        // Requesting GC has a chance to free space only if we're using mmap and a non SUN jvm
        if (path == null
            && (DatabaseDescriptor.getDiskAccessMode() == Config.DiskAccessMode.mmap || DatabaseDescriptor.getIndexAccessMode() == Config.DiskAccessMode.mmap)
            && !FileUtils.isCleanerAvailable())
        {
            logger.info("Forcing GC to free up disk space.  Upgrade to the Oracle JVM to avoid this");
            StorageService.instance.requestGC();
            // retry after GCing has forced unmap of compacted SSTables so they can be deleted
            // Note: GCInspector will do this already, but only sun JVM supports GCInspector so far
            SSTableDeletingTask.rescheduleFailedTasks();
            try
            {
                Thread.sleep(10000);
            }
            catch (InterruptedException e)
            {
                throw new AssertionError(e);
            }
            path = getWriteableLocationAsFile();
        }

        return path;
    }

    public File getWriteableLocationAsFile()
    {
        return getLocationForDisk(getWriteableLocation());
    }

    /**
     * @return a non-blacklisted directory with the most free space and least current tasks.
     *
     * @throws IOError if all directories are blacklisted.
     */
    public DataDirectory getWriteableLocation()
    {
        List<DataDirectory> candidates = new ArrayList<DataDirectory>();

        // pick directories with enough space and so that resulting sstable dirs aren't blacklisted for writes.
        for (DataDirectory dataDir : dataFileLocations)
        {
            if (BlacklistedDirectories.isUnwritable(getLocationForDisk(dataDir)))
                continue;
            candidates.add(dataDir);
        }

        if (candidates.isEmpty())
            throw new IOError(new IOException("All configured data directories have been blacklisted as unwritable for erroring out"));

        // sort directories by free space, in _descending_ order.
        Collections.sort(candidates);

        // sort directories by load, in _ascending_ order.
        Collections.sort(candidates, new Comparator<DataDirectory>()
        {
            public int compare(DataDirectory a, DataDirectory b)
            {
                return a.currentTasks.get() - b.currentTasks.get();
            }
        });

        return candidates.get(0);
    }

    public static File getSnapshotDirectory(Descriptor desc, String snapshotName)
    {
        return getOrCreate(desc.directory, SNAPSHOT_SUBDIR, snapshotName);
    }

    public static File getBackupsDirectory(Descriptor desc)
    {
        return getOrCreate(desc.directory, BACKUPS_SUBDIR);
    }

    public SSTableLister sstableLister()
    {
        return new SSTableLister();
    }

    public static class DataDirectory implements Comparable<DataDirectory>
    {
        public final File location;
        public final AtomicInteger currentTasks = new AtomicInteger();
        public final AtomicLong estimatedWorkingSize = new AtomicLong();

        public DataDirectory(File location)
        {
            this.location = location;
        }

        /**
         * @return estimated available disk space for bounded directory,
         * excluding the expected size written by tasks in the queue.
         */
        public long getEstimatedAvailableSpace()
        {
            // Load factor of 0.9 we do not want to use the entire disk that is too risky.
            return location.getUsableSpace() - estimatedWorkingSize.get();
        }

        public int compareTo(DataDirectory o)
        {
            // we want to sort by free space in descending order
            return -1 * Longs.compare(getEstimatedAvailableSpace(), o.getEstimatedAvailableSpace());
        }
    }

    public class SSTableLister
    {
        private boolean skipTemporary;
        private boolean includeBackups;
        private boolean onlyBackups;
        private int nbFiles;
        private final Map<Descriptor, Set<Component>> components = new HashMap<Descriptor, Set<Component>>();
        private boolean filtered;
        private String snapshotName;

        public SSTableLister skipTemporary(boolean b)
        {
            if (filtered)
                throw new IllegalStateException("list() has already been called");
            skipTemporary = b;
            return this;
        }

        public SSTableLister includeBackups(boolean b)
        {
            if (filtered)
                throw new IllegalStateException("list() has already been called");
            includeBackups = b;
            return this;
        }

        public SSTableLister onlyBackups(boolean b)
        {
            if (filtered)
                throw new IllegalStateException("list() has already been called");
            onlyBackups = b;
            includeBackups = b;
            return this;
        }

        public SSTableLister snapshots(String sn)
        {
            if (filtered)
                throw new IllegalStateException("list() has already been called");
            snapshotName = sn;
            return this;
        }

        public Map<Descriptor, Set<Component>> list()
        {
            filter();
            return ImmutableMap.copyOf(components);
        }

        public List<File> listFiles()
        {
            filter();
            List<File> l = new ArrayList<File>(nbFiles);
            for (Map.Entry<Descriptor, Set<Component>> entry : components.entrySet())
            {
                for (Component c : entry.getValue())
                {
                    l.add(new File(entry.getKey().filenameFor(c)));
                }
            }
            return l;
        }

        private void filter()
        {
            if (filtered)
                return;

            for (File location : sstableDirectories)
            {
                if (BlacklistedDirectories.isUnreadable(location))
                    continue;

                if (snapshotName != null)
                {
                    new File(location, join(SNAPSHOT_SUBDIR, snapshotName)).listFiles(getFilter());
                    continue;
                }

                if (!onlyBackups)
                    location.listFiles(getFilter());

                if (includeBackups)
                    new File(location, BACKUPS_SUBDIR).listFiles(getFilter());
            }
            filtered = true;
        }

        private FileFilter getFilter()
        {
            // Note: the prefix needs to include cfname + separator to distinguish between a cfs and it's secondary indexes
            final String sstablePrefix = tablename + Component.separator + cfname + Component.separator;
            return new FileFilter()
            {
                // This function always return false since accepts adds to the components map
                public boolean accept(File file)
                {
                    // we are only interested in the SSTable files that belong to the specific ColumnFamily
                    if (file.isDirectory() || !file.getName().startsWith(sstablePrefix))
                        return false;

                    Pair<Descriptor, Component> pair = SSTable.tryComponentFromFilename(file.getParentFile(), file.getName());
                    if (pair == null)
                        return false;

                    if (skipTemporary && pair.left.temporary)
                        return false;

                    Set<Component> previous = components.get(pair.left);
                    if (previous == null)
                    {
                        previous = new HashSet<Component>();
                        components.put(pair.left, previous);
                    }
                    previous.add(pair.right);
                    nbFiles++;
                    return false;
                }
            };
        }
    }

    public File tryGetLeveledManifest()
    {
        for (File dir : sstableDirectories)
        {
            File manifestFile = new File(dir, cfname + LeveledManifest.EXTENSION);
            if (manifestFile.exists())
            {
                logger.debug("Found manifest at {}", manifestFile);
                return manifestFile;
            }
        }
        logger.debug("No level manifest found");
        return null;
    }

    public File getOrCreateLeveledManifest()
    {
        File manifestFile = tryGetLeveledManifest();
        if (manifestFile == null)
            manifestFile = new File(sstableDirectories[0], cfname + LeveledManifest.EXTENSION);
        return manifestFile;
    }

    public void snapshotLeveledManifest(String snapshotName)
    {
        File manifest = tryGetLeveledManifest();
        if (manifest != null)
        {
            File snapshotDirectory = getOrCreate(manifest.getParentFile(), SNAPSHOT_SUBDIR, snapshotName);
            File target = new File(snapshotDirectory, manifest.getName());
            FileUtils.createHardLink(manifest, target);
        }
    }

    public boolean snapshotExists(String snapshotName)
    {
        for (File dir : sstableDirectories)
        {
            File snapshotDir = new File(dir, join(SNAPSHOT_SUBDIR, snapshotName));
            if (snapshotDir.exists())
                return true;
        }
        return false;
    }

    public void clearSnapshot(String snapshotName)
    {
        // If snapshotName is empty or null, we will delete the entire snapshot directory
        String tag = snapshotName == null ? "" : snapshotName;
        for (File dir : sstableDirectories)
        {
            File snapshotDir = new File(dir, join(SNAPSHOT_SUBDIR, tag));
            if (snapshotDir.exists())
            {
                if (logger.isDebugEnabled())
                    logger.debug("Removing snapshot directory " + snapshotDir);
                FileUtils.deleteRecursive(snapshotDir);
            }
        }
    }

    // The snapshot must exist
    public long snapshotCreationTime(String snapshotName)
    {
        for (File dir : sstableDirectories)
        {
            File snapshotDir = new File(dir, join(SNAPSHOT_SUBDIR, snapshotName));
            if (snapshotDir.exists())
                return snapshotDir.lastModified();
        }
        throw new RuntimeException("Snapshot " + snapshotName + " doesn't exist");
    }

    private static File getOrCreate(File base, String... subdirs)
    {
        File dir = subdirs == null || subdirs.length == 0 ? base : new File(base, join(subdirs));
        if (dir.exists())
        {
            if (!dir.isDirectory())
                throw new AssertionError(String.format("Invalid directory path %s: path exists but is not a directory", dir));
        }
        else if (!dir.mkdirs() && !(dir.exists() && dir.isDirectory()))
        {
            throw new FSWriteError(new IOException("Unable to create directory " + dir), dir);
        }
        return dir;
    }

    private static String join(String... s)
    {
        return StringUtils.join(s, File.separator);
    }

    /**
     * To check if sstables needs migration, we look at the System directory.
     * If it does not contain a directory for the schema cfs, we'll attempt a sstable
     * migration.
     *
     * Note that it is mostly harmless to try a migration uselessly, except
     * maybe for some wasted cpu cycles.
     */
    public static boolean sstablesNeedsMigration()
    {
        if (StorageService.instance.isClientMode())
            return false;

        boolean hasSystemKeyspace = false;
        for (DataDirectory dir : dataFileLocations)
        {
            File systemDir = new File(dir.location, Table.SYSTEM_KS);
            hasSystemKeyspace |= (systemDir.exists() && systemDir.isDirectory());
            File statusCFDir = new File(systemDir, SystemTable.SCHEMA_KEYSPACES_CF);
            if (statusCFDir.exists())
                return false;
        }
        if (!hasSystemKeyspace)
            // This is a brand new node.
            return false;

        // Check whether the migration might create too long a filename
        int longestLocation = -1;
        for (DataDirectory loc : dataFileLocations)
            longestLocation = Math.max(longestLocation, FileUtils.getCanonicalPath(loc.location).length());

        // Check that migration won't error out halfway through from too-long paths.  For Windows, we need to check
        // total path length <= 255 (see http://msdn.microsoft.com/en-us/library/aa365247.aspx and discussion on CASSANDRA-2749);
        // elsewhere, we just need to make sure filename is <= 255.
        for (KSMetaData ksm : Schema.instance.getTableDefinitions())
        {
            String ksname = ksm.name;
            for (Map.Entry<String, CFMetaData> entry : ksm.cfMetaData().entrySet())
            {
                String cfname = entry.getKey();

                // max path is roughly (guess-estimate) <location>/ksname/cfname/snapshots/1324314347102-somename/ksname-cfname-tmp-hb-65536-Statistics.db
                if (System.getProperty("os.name").startsWith("Windows")
                    && longestLocation + (ksname.length() + cfname.length()) * 2 + 63 > 255)
                {
                    throw new RuntimeException(String.format("Starting with 1.1, keyspace names and column family " +
                                                             "names must be less than %s characters long. %s/%s doesn't" +
                                                             " respect that restriction. Please rename your " +
                                                             "keyspace/column families to respect that restriction " +
                                                             "before updating.", Schema.NAME_LENGTH, ksname, cfname));
                }

                if (ksm.name.length() + cfname.length() + 28 > 255)
                {
                    throw new RuntimeException("Starting with 1.1, the keyspace name is included in data filenames.  For "
                                               + ksm.name + "/" + cfname + ", this puts you over the largest possible filename of 255 characters");
                }
            }
        }

        return true;
    }

    /**
     * Move sstables from the pre-#2749 layout to their new location/names.
     * This involves:
     *   - moving each sstable to their CF specific directory
     *   - rename the sstable to include the keyspace in the filename
     *
     * Note that this also move leveled manifests, snapshots and backups.
     */
    public static void migrateSSTables()
    {
        logger.info("Upgrade from pre-1.1 version detected: migrating sstables to new directory layout");

        for (DataDirectory dir : dataFileLocations)
        {
            if (!dir.location.exists() || !dir.location.isDirectory())
                continue;

            File[] ksDirs = dir.location.listFiles();
            if (ksDirs != null)
            {
                for (File ksDir : ksDirs)
                {
                    if (!ksDir.isDirectory())
                        continue;

                    File[] files = ksDir.listFiles();
                    if (files != null)
                    {
                        for (File file : files)
                            migrateFile(file, ksDir, null);
                    }

                    migrateSnapshots(ksDir);
                    migrateBackups(ksDir);
                }
            }
        }
    }

    private static void migrateSnapshots(File ksDir)
    {
        File snapshotDir = new File(ksDir, SNAPSHOT_SUBDIR);
        if (!snapshotDir.exists())
            return;

        File[] snapshots = snapshotDir.listFiles();
        if (snapshots != null)
        {
            for (File snapshot : snapshots)
            {
                if (!snapshot.isDirectory())
                    continue;

                File[] files = snapshot.listFiles();
                if (files != null)
                {
                    for (File f : files)
                        migrateFile(f, ksDir, join(SNAPSHOT_SUBDIR, snapshot.getName()));
                }
                if (!snapshot.delete())
                    logger.info("Old snapsot directory {} not deleted by migraation as it is not empty", snapshot);
            }
        }
        if (!snapshotDir.delete())
            logger.info("Old directory {} not deleted by migration as it is not empty", snapshotDir);
    }

    private static void migrateBackups(File ksDir)
    {
        File backupDir = new File(ksDir, BACKUPS_SUBDIR);
        if (!backupDir.exists())
            return;

        File[] files = backupDir.listFiles();
        if (files != null)
        {
            for (File f : files)
                migrateFile(f, ksDir, BACKUPS_SUBDIR);
        }
        if (!backupDir.delete())
            logger.info("Old directory {} not deleted by migration as it is not empty", backupDir);
    }

    private static void migrateFile(File file, File ksDir, String additionalPath)
    {
        if (file.isDirectory())
            return;

        try
        {
            String name = file.getName();
            boolean isManifest = name.endsWith(LeveledManifest.EXTENSION);
            int separatorIndex = name.indexOf(Component.separator);

            if (isManifest || (separatorIndex >= 0))
            {
                String cfname = isManifest
                              ? getCfNameFromManifest(name)
                              : name.substring(0, separatorIndex);

                int idx = cfname.indexOf(SECONDARY_INDEX_NAME_SEPARATOR); // idx > 0 => secondary index
                String dirname = idx > 0 ? cfname.substring(0, idx) : cfname;
                File destDir = getOrCreate(ksDir, dirname, additionalPath);

                File destFile = new File(destDir, isManifest ? name : ksDir.getName() + Component.separator + name);
                logger.debug(String.format("[upgrade to 1.1] Moving %s to %s", file, destFile));
                FileUtils.renameWithConfirm(file, destFile);
            }
            else
            {
                logger.warn("Found unrecognized file {} while migrating sstables from pre 1.1 format, ignoring.", file);
            }
        }
        catch (Exception e)
        {
            throw new RuntimeException(String.format("Failed migrating file %s from pre 1.1 format.", file.getPath()), e);
        }
    }

    private static String getCfNameFromManifest(String name)
    {
        String withoutExt = name.substring(0, name.length() - LeveledManifest.EXTENSION.length());
        return withoutExt.endsWith("-old") || withoutExt.endsWith("-tmp")
                ? withoutExt.substring(0, withoutExt.length() - 4)
                : withoutExt;
    }

    // Hack for tests, don't use otherwise
    static void overrideDataDirectoriesForTest(String loc)
    {
        for (int i = 0; i < dataFileLocations.length; ++i)
            dataFileLocations[i] = new DataDirectory(new File(loc));
    }

    // Hack for tests, don't use otherwise
    static void resetDataDirectoriesAfterTest()
    {
        String[] locations = DatabaseDescriptor.getAllDataFileLocations();
        for (int i = 0; i < locations.length; ++i)
            dataFileLocations[i] = new DataDirectory(new File(locations[i]));
    }
}


text:
<?php

namespace cms\routes\Account\actions;

/**
 * Action for users to change their profile text
 */
class ChangeProfile extends \rakelley\jhframe\classes\FormAction implements
    \rakelley\jhframe\interfaces\ITakesParameters
{
    use \rakelley\jhframe\traits\TakesParameters;

    /**
     * UserAccount repo instance
     * @var object
     */
    private $userAccount;

    /**
     * @param \cms\routes\Account\views\ProfileForm                $view
     * @param \rakelley\jhframe\interfaces\services\IFormValidator $validator
     * @param \main\repositories\UserAccount                       $userAccount
     */
    function __construct(
        \cms\routes\Account\views\ProfileForm $view,
        \rakelley\jhframe\interfaces\services\IFormValidator $validator,
        \main\repositories\UserAccount $userAccount
    ) {
        $this->userAccount = $userAccount;

        parent::__construct($validator, $view);
    }

    /**
     * {@inheritdoc}
     * @see \rakelley\jhframe\interfaces\action\IAction::Proceed()
     * @return void
     */
    public function Proceed()
    {
        $this->userAccount->setProfile($this->parameters['username'],
                                       $this->input['profile']);
    }
}