text:
import modules
import os, sys, multiprocessing
import settings
import shutil
import pdlibs
import topo_sort, parmap

options = None

def _transitive_op_core(op, module, excludes):
    """
    Remove all non-source dirs
    """
    if module in excludes:
        return
    op(module)
    excludes.append(module)

    # recursive transitive_op all dep modules
    map(lambda x : _transitive_op_core(op, x, excludes), modules.find_direct_dependencies(module))

def _get_srcs_below_dir(dir, ext = None):
    srcs = []
    for root, dirs, files in os.walk(dir):
        srcs = srcs + map(lambda y : root + '/' + y, filter(lambda x : ext is None or x.endswith(ext), files))
    return srcs

def _is_derived_out_of_date(src, derived):
    if not os.path.exists(derived):
        return True
    src_time = os.stat(src).st_mtime
    derived_time = os.stat(derived).st_mtime
    return src_time > derived_time

def _is_class_out_of_date(src):
    class_file = src.replace(settings.java_src, settings.class_output).replace('.java', '.class')
    return _is_derived_out_of_date(src,class_file)

def _compile(mod, src_dir, resource_dir, class_output):
    module = modules.mod_name_mapping[mod]

    if not os.path.exists(class_output):
        os.makedirs(class_output)

    # copy resources files such as .properties
    if os.path.exists(resource_dir):
        # if there are out-of-date resource files in build target dir, clean buld dir and copy all resources
        # to the build directory. This is to simplify the build logic
        rsrcs = _get_srcs_below_dir(resource_dir)
        rsrcs = filter(lambda x : _is_derived_out_of_date(x, x.replace(settings.resource_src, settings.class_output)), rsrcs)
        if len(rsrcs) > 0:
            print 'Resource files out of date, deleting all in %s and rebulding' % class_output
            # delete target class dir if any
            if os.path.exists(class_output):
                shutil.rmtree(class_output)
            shutil.copytree(resource_dir, class_output)

    classpath = modules.get_class_path_for_mod(mod)
    if len(classpath) > 0 :
        classpath = '-cp ' + classpath

    # if there are properties and XML config files in src, copy them to classes
    props = _get_srcs_below_dir(src_dir, '.properties') + _get_srcs_below_dir(src_dir, '.xml')
    props = filter(lambda x : _is_derived_out_of_date(x, x.replace(src_dir, settings.class_output)), props)
    if len(props) > 0:
        for prop in props:
            path = prop[len(src_dir):]
            dest = class_output + path
            if options.verbose:
                print 'Copying to ' + dest
            # check dir exists
            dest_dir = dest[:dest.rfind(os.sep)]
            if not os.path.exists(dest_dir):
                os.makedirs(dest_dir)
            shutil.copyfile(prop, dest)

    java_srcs = _get_srcs_below_dir(src_dir, '.java')
    java_srcs = filter(  _is_class_out_of_date, java_srcs)
    if len(java_srcs) == 0:
        print '------------------- \n No Java source code in %s need to be recompiled since they are all up-to-date' % mod
        return

    # compile .java's that are obsolete wrt their corresponding .class files
    print '--------------------- \n Compiling %s ' % mod

    cmd = 'javac -g -encoding utf-8  %s -d %s %s' % (classpath, class_output,  ' '.join(java_srcs))
    if options.verbose:
        print cmd

    if not options.dry_run:
        ok = os.system(cmd)
        if ok != 0:
            print ' ##### Failed to compile module %s ' % mod
            sys.exit(ok)

def _src_compile(mod):
    resource_dir = mod + os.sep + settings.resource_src
    _compile(mod, settings.src_dir(mod), resource_dir, settings.class_dir(mod))

def _test_src_compile(mod):
    resource_dir = mod + os.sep + settings.resource_src
    _compile(mod, settings.test_src_dir(mod), resource_dir, settings.test_class_dir(mod))

def build(mod,  *args, **dict_p):
    """
    Compile a module, recursively compile all other modules this module depends on first in the correct order
    """
    dep_relations, all_mods, dummy = modules.collect_dependencies(mod)
    all_mods.add(mod)
    if not options.disable_transitive_dependencies:
        sorted_mods = topo_sort.topological_sort(all_mods, dep_relations)
        if isinstance(sorted_mods, tuple):
            loop = sorted_mods[1]
            raise Exception('Sorry a circular dependency is found in modules, the loop : %s ' %   "->".join(loop))
        sorted_mods.reverse()

        if options.verbose:
            print '+----------------------- Building %s ----------------------------------------------------- ' % mod
            print '| all modules related to %s : %s' % (mod, ", ".join(sorted_mods))
            print '| pairwise dependencies : %s' %  ",  ".join( map(lambda (x,y) : x +" -> " + y,  dep_relations) )

    else:
        sorted_mods = [mod]
    if options.verbose:
        print '| compiling all modules in this order: ', sorted_mods
        print '+---------------------------------------------------------------------------------------------'

    # See which moduls can be built in parallel,
    map(_src_compile, sorted_mods)
    map(_test_src_compile, sorted_mods)

def run(module, main_class, *args, **dict_p):
    # ensure module has already been compiled
    build(module)
    print 'Running Java class %s in module %s with args %s and %s \n' % (main_class, module, args, str(dict_p))
    classpath = modules.get_class_path_for_mod(module)
    # assume any named args are JVM options
    java = 'java '
    if len(dict_p) > 0:
        for (key, val) in dict_p.items():
            if key == 'extra_class_path':
                classpath = classpath + ':' + val
            elif key == 'run_libs' : # extra run time only libraries
                for lib in val.split(','):
                    classpath = classpath + ':' + ':'.join(pdlibs.lib_jar_files[lib])
            elif key[:2] == '-D':
                java = java +  key + '=' +  val + ' '
            else:
                java = java + ('-X' + key) + val + ' '
    cmd = java  + ' -cp ' + classpath + " "  + main_class + ' ' + ' '.join(args)
    print cmd
    ok = os.system(cmd)
    if ok != 0:
        raise Exception(' ##### Failed to run class %s for module %s, have you built the module first? ' % (main_class, module))

def gwt_compile(job):
    """
    web_module: where the GWT compile output should go into
    gwt_src_module: where is the GWT source code
    """
    (web_module, (gwt_src_module, entry_class), dict_p) = job
    cores = 1 # parallelize not at browser permutation level, but GWT module level
    jvm_mem = '500m'
    gwt_style = 'OBF'
    print 'args', dict_p
    if len(dict_p) > 0:
        for (key, val) in dict_p.items():
            if key == 'mx':
                jvm_mem = val
            elif key == 'style':
                gwt_style = val

    run(gwt_src_module,  'com.google.gwt.dev.Compiler', '-style ' + gwt_style, '-war ' + settings.war_dir(web_module) + os.sep + 'gwt -localWorkers ' + str(cores), entry_class, mx=jvm_mem, extra_class_path=settings.src_dir(gwt_src_module) )

def build_gwts(module_name, *args, **dict_p):
    """
    module_name: the web module which should define list of gwt modules in  its build file
    """
    build(module_name)
    module = modules.mod_name_mapping[module_name]
    if hasattr(module, 'gwt_modules'):
        cores = multiprocessing.cpu_count()
        params = [ (module_name, gwt_mod, dict_p) for gwt_mod in module.gwt_modules]
        parmap.parmap(gwt_compile, cores, params)

def _jar(module,  *args, **dict_p):
    print 'Creating %s.jar in %s/%s' % (module, module, settings.jar_output)
    cls_dir = settings.class_dir(module)
    if not os.path.exists(cls_dir):
        print '##### No classes found in module build directory %s, unable to create jar. Maybe you need to run the build task ("-t build") first? ' % settings.class_dir(module)
        #sys.exit(1)
        return
    # delete java and javax package from cls_dir if any
    if os.path.exists(os.path.join(cls_dir, 'java')):
        shutil.rmtree(os.path.join(cls_dir, 'java'))
    if os.path.exists(os.path.join(cls_dir, 'javax')):
        shutil.rmtree(os.path.join(cls_dir, 'javax'))

    if not os.path.exists(settings.jar_dir(module)):
        os.makedirs(settings.jar_dir(module))

    jar_file = '%s/%s.jar' % (settings.jar_dir(module), module)

    cmd = 'jar cf %s -C %s .' % (jar_file, cls_dir)
    print cmd
    ok = os.system(cmd)
    if ok != 0:
        print ' ##### Failed to package jar file for module %s ' % (module)
        sys.exit(ok)

def jar_all(module):
    """
    Jar the module and all its dependent modules recursively
    """
    build(module)
    _transitive_op_core(_jar, module, [])

def clean_local(module):
    print 'Clean all (classes , jars ...) under module %s' % module
    for cdir in settings.clean_dirs(module):
        if os.path.exists(cdir):
            shutil.rmtree(cdir)

def clean(module, *args, **dict_p):
    _transitive_op_core(clean_local, module, [])

def junit(module,  *args, **dict_p):
    # assume module has already been compiled
    test_class = args[0]
    print ' Running test %s in module %s\n' % (test_class, module)
    run(module, 'junit.textui.TestRunner', test_class,\
        extra_class_path=settings.test_class_dir(module), \
        **dict_p)

def war_jars(module, web_root_dir=settings.web_root):
    """
    build all jars of dependent modules and copy to buid/war/WEB-INF/lib
    """
    web_root = module + os.path.sep + web_root_dir
    if not os.path.isdir(web_root):
        print ' ####  The web root dir %s is not an existing directory ' % web_root
        return

    if not options.disable_transitive_dependencies:
        build(module)
        jar_all(module)

    # verify all dependent module/library jars have been built/exist
    all_jars = modules.get_class_path_for_mod(module, jar_only = True)
    web_inf_jars = all_jars.split(':')
    for jar_file in web_inf_jars:
        if not os.path.exists(jar_file):
            print "Jar file required for building WAR does not exist : %s, Rebuilding %s.jar and all its dependent module jars. " % (jar_file, module)
            jar_all(module)

    web_inf_lib_dir =  settings.war_dir(module) + os.path.sep + 'WEB-INF' + os.path.sep + 'lib'
    if not os.path.isdir(web_inf_lib_dir):
        os.makedirs(web_inf_lib_dir)

    print '----- Prepare jars in the war file '
    print 'These jars will be copied into the WEB-INF/lib directory :', web_inf_jars
    for jar_file in web_inf_jars:
        shutil.copyfile(jar_file, web_inf_lib_dir + os.path.sep + os.path.basename(jar_file))

def war_web_content(module, web_root_dir = settings.web_root):
    """
    web_root_dir: root folder of the web files (HTML JSP etc)
    Will prepare all files in the war staging dir, including the jars , short of zip up the final .war file
    """
    # verify web root
    if web_root_dir is None:
        web_root_dir = settings.web_root
    web_root = module + os.path.sep + web_root_dir

    # create the staging directory for WAR
    war_staging_dir = settings.war_dir(module)
    if os.path.exists(war_staging_dir):
        print ' ---- deleting staging dir %s' % war_staging_dir
        shutil.rmtree(war_staging_dir)
    # copy all jars to WEB-INF/lib
    print '----- Copy all files under %s to staging dir %s ' % (web_root , war_staging_dir)
    shutil.copytree(web_root, war_staging_dir)
    # copy the web inf jars
    war_jars(module, web_root_dir)

def pack_war(module,  web_root_dir=settings.web_root):
    war_file = module + os.path.sep + settings.war_output + os.path.sep + module + '.war'
    war_staging_dir = settings.war_dir(module)
    cmd = 'jar cf %s -C %s .' % (war_file, war_staging_dir)
    print cmd
    ok = os.system(cmd)
    if ok != 0:
        print ' ##### Failed to package jar file for module %s ' % (module)
        sys.exit(ok)
    else:
        print ' ----- Successfully built %s ' % war_file

def war(module, *args, **dict_p):
    """
    create a war file where all the dependent module and library jars are put under WEB-INF/lib

    web_root root folder of the web files (HTML JSP etc)
    """
    war_web_content(module)
    pack_war(module)

def gwt_war(module, *args, **dict_p):
    """
    """
    war_web_content(module)
    build_gwts(module, args,dict_p)
    pack_war(module)

redpajama_set_name: RedPajamaGithub


text:
  <title>Animations</title>

    <button icon pause primary (click)="pause($event)">
      Pause
      <icon pause></icon>
    </button>
    <button icon play secondary (click)="play($event)">
      Play
      <icon play></icon>
    </button>


text:
/**
 * NavigationBar
 * @flow
 */
import React, {Component, PropTypes} from 'react';

import {
    StyleSheet,
    Navigator,
    Platform,
    TouchableOpacity,
    Image,
    StatusBar,
    Text,
    View,
    Dimensions
} from 'react-native'

const NAV_BAR_HEIGHT_IOS = 44;
const NAV_BAR_HEIGHT_ANDROID = 44;
const STATUS_BAR_HEIGHT = 20;

const {width, height} = Dimensions.get('window');

const ButtonShape = {
    title: PropTypes.string.isRequired,
    style: PropTypes.any,
    handler: PropTypes.func,
};

const StatusBarShape = {
    barStyle: PropTypes.oneOf(['light-content', 'default',]),
    networkActivityIndicatorVisible: PropTypes.bool,
    showHideTransition:PropTypes.oneOf(['fade', 'slide']),
    hidden: PropTypes.bool,
    translucent: PropTypes.bool,
    backgroundColor: PropTypes.string,
    animated:PropTypes.bool
};

export default class NavigationBar extends Component {

    static propTypes = {
        style: View.propTypes.style,
        titleLayoutStyle:View.propTypes.style,
        navigator: PropTypes.object,
        leftButtonTitle: PropTypes.string,
        popEnabled: PropTypes.bool,
        onLeftButtonClick: PropTypes.func,
        backgroundImageUri:PropTypes.string,
        title: PropTypes.string,
        titleView: PropTypes.element,
        hide: PropTypes.bool,
        statusBar: PropTypes.shape(StatusBarShape),
        rightButton: PropTypes.oneOfType([
            PropTypes.shape(ButtonShape),
            PropTypes.element,
        ]),
        leftButton: PropTypes.oneOfType([
            PropTypes.shape(ButtonShape),
            PropTypes.element,
        ]),

    }

    static defaultProps = {
        statusBar: {
            barStyle: 'default',
            hidden: false,
            translucent:false,
            animated:false,
        },
    }

    constructor(props) {

        super(props);

        var isIPhoneX = false;
        var marginBottom = 0;
        var titlePaddingTop = 22;
        var navHeight = 76;
        var imageHeight = 0;
        var imageBgTextPaddingRight = 0;
        var isImageBg = false;
        if (this.props.backgroundImageUri){
            isImageBg = true;
        }else {
            isImageBg = false;
        }

        if(height === 812){

            isIPhoneX = true;

            if(isImageBg){
                navHeight = 132;
                titlePaddingTop = 30;
                marginBottom= 34;
                imageHeight = 88;
            }else {
                navHeight = 300;
                titlePaddingTop = 54;
                marginBottom= 16;
                imageHeight = 0;
            }

            if(this.props.leftButton){
                imageBgTextPaddingRight = 22;
            }else {
                imageBgTextPaddingRight = 0;
            }

        }else{
            isIPhoneX = false;
            marginBottom = 8;

            if(isImageBg){
                imageHeight = 64;
                titlePaddingTop = 16;
            }else {
                titlePaddingTop = 26;
                imageHeight = 0;
            }

            navHeight = 64;

            if(this.props.leftButton){
                imageBgTextPaddingRight = 28;
            }else {
                imageBgTextPaddingRight = 0;
            }

        }

        this.state = {
            popEnabled: true,
            hide: false,
            marginBottom:marginBottom,
            isIPhoneX:isIPhoneX,
            titlePaddingTop:titlePaddingTop,
            navHeight:navHeight,
            imageHeight:imageHeight,
            imageBgTextPaddingRight:imageBgTextPaddingRight
        };

    }

    getButtonElement(data = {}, style) {

        var paddingTop = null;
        var paddingBottom = null;
        if(this.props.backgroundImageUri){

            if (this.state.isIPhoneX){
                paddingTop = 36;
                paddingBottom = 0;

            }else {

                paddingTop = 16;
                paddingBottom = 0;
            }

        }else {
            paddingTop = 0;
            paddingBottom = 6;
        }

        return (
            <View style={[styles.navBarButton,{paddingTop:paddingTop,paddingBottom:paddingBottom}]}>
                {(!!data.props) ? data : (
                    <NavBarButton
                        title={data.title}
                        style={[data.style, style,]}
                        tintColor={data.tintColor}
                        handler={data.handler}/>
                )}
            </View>
        );
    }

    render() {

        //背景是个图片
        if(this.props.backgroundImageUri){

            //状态栏
            this.statusBar = null;
            //背景图片
            this.titleView = <View
                style={{height: Platform.OS === 'ios' ? this.state.navHeight : 44}}>
                <Image
                    source={{uri:this.props.backgroundImageUri}}
                    style={{width:width,
                            height: Platform.OS === 'ios' ? this.state.imageHeight : 44,
                            flexDirection: 'row',
                            alignItems: 'center',
                            justifyContent: 'space-between',
                            resizeMode:Image.resizeMode.stretch,

                    }}

                >
                    {this.getButtonElement(this.props.leftButton)}
                    <Text style={[styles.title,{paddingTop:this.state.titlePaddingTop,paddingRight:this.state.imageBgTextPaddingRight,backgroundColor:'transparent',marginLeft: 8},{fontWeight: 'bold'}]} ellipsizeMode="head" numberOfLines={1} >{this.props.title}</Text>
                    {this.getButtonElement(this.props.rightButton, {marginRight: 8})}
                </Image>
            </View>

            this.content = this.props.hide ? null :
                <View style={styles.navBar}>
                    <View style={[styles.navImageBarContainer,this.props.titleLayoutStyle]}>
                        {this.titleView}
                    </View>
                </View>;

        }else {
            //背景没有图片,只有颜色
            let bgColor = this.props.style.backgroundColor?this.props.style.backgroundColor:'transparent'

            this.statusBar = (!this.props.statusBar.hidden)?
                <View style={styles.statusBar}>
                    <StatusBar {...this.props.statusBar} barStyle="light-content" style={[styles.statusBar,{backgroundColor:bgColor}]}/>
                </View>: null;

            this.titleView = this.props.titleView ? this.props.titleView :
                <Text style={[styles.title,{paddingBottom:10}]} ellipsizeMode="head" numberOfLines={1} >{this.props.title}</Text>;

            this.content = this.props.hide ? null :
                <View style={styles.navBar}>
                    {this.getButtonElement(this.props.leftButton)}
                    <View style={[styles.navBarTitleContainer,this.props.titleLayoutStyle]}>
                        {this.titleView}
                    </View>
                    {this.getButtonElement(this.props.rightButton, {marginRight: 8})}
                </View>;
        }

        return (

            <View style={[styles.container, this.props.style,{marginBottom:this.state.marginBottom}]}>
                {this.statusBar}
                {this.content}
            </View>

        )
    }
}
class NavBarButton extends Component {
    render() {
        const {style, tintColor, margin, title, handler} = this.props;

        return (
            <TouchableOpacity style={styles.navBarButton} onPress={handler}>
                <View style={style}>
                    <Text style={[styles.title, {color: tintColor,},]}>{title}</Text>
                </View>
            </TouchableOpacity>
        );
    }

    static propTypes = {
        style: PropTypes.oneOfType([
            PropTypes.object,
            PropTypes.array,
        ]),
        tintColor: PropTypes.string,
        title: PropTypes.string,
        handler: PropTypes.func,
    };

    static defaultProps = {
        style: {},
        title: '',
        tintColor: '#0076FF',
        onPress: () => ({}),
    };
}

const styles = StyleSheet.create({

    container: {

    },

    navBar: {
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between',
        height: Platform.OS === 'ios' ? NAV_BAR_HEIGHT_IOS : NAV_BAR_HEIGHT_ANDROID,
    },
    navBarTitleContainer: {
        alignItems: 'center',
        justifyContent: 'center',
        position: 'absolute',

        left: 40,
        top: 0,
        right: 40,
        bottom: 0,
    },

    navImageBarContainer:{
        alignItems: 'center',
        justifyContent: 'flex-start',
        position: 'absolute',
        left: 0,
        top: 0,
        right: 0,
        bottom: 0,
    },

    title: {
        fontSize: 20,
        color: 'white',
        fontFamily:'Helvetica',
        fontWeight:'100'
    },
    navBarButton: {
        alignItems: 'center',
    },
    statusBar: {
        height: Platform.OS === 'ios' ? STATUS_BAR_HEIGHT:0,

    },
})


text:
package com.capstone.cudaf.ultratravel.analytics;

public enum ActionType {
    CLICK_CONTACT("CLICK_CONTACT"),
    CLICK_RESERVATION("CLICK_RESERVATION"),
    CLICK_CITY("CLICK_CITY"),
    CLICK_CITY_MORE("CLICK_CITY_MORE"),
    CLICK_BUSINESS_LIST("CLICK_BUSINESS_LIST"),
    CLICK_MAP_VIEW("CLICK_MAP_VIEW"),
    CLICK_BUSINESS_ITEM("CLICK_BUSINESS_ITEM");

    private final String actionType;

    ActionType(String actionType) {
        this.actionType = actionType;
    }

    public String getActionType() {
        return this.actionType;
    }

}


text:
package com.microsoft.azure.batch.protocol.models;

import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Specifies a file upload destination within an Azure blob storage container.
 */
public class OutputFileBlobContainerDestination {
    /**
     * The destination blob or virtual directory within the Azure Storage
     * container.
     * If filePattern refers to a specific file (i.e. contains no wildcards),
     * then path is the name of the blob to which to upload that file. If
     * filePattern contains one or more wildcards (and therefore may match
     * multiple files), then path is the name of the blob virtual directory
     * (which is prepended to each blob name) to which to upload the file(s).
     * If omitted, file(s) are uploaded to the root of the container with a
     * blob name matching their file name.
     */
    @JsonProperty(value = "path")
    private String path;

    /**
     * The URL of the container within Azure Blob Storage to which to upload
     * the file(s).
     * If not using a managed identity, the URL must include a Shared Access
     * Signature (SAS) granting write permissions to the container.
     */
    @JsonProperty(value = "containerUrl", required = true)
    private String containerUrl;

    /**
     * The reference to the user assigned identity to use to access Azure Blob
     * Storage specified by containerUrl.
     * The identity must have write access to the Azure Blob Storage container.
     */
    @JsonProperty(value = "identityReference")
    private ComputeNodeIdentityReference identityReference;

    /**
     * A list of name-value pairs for headers to be used in uploading output
     * files.
     * These headers will be specified when uploading files to Azure Storage.
     * Official document on allowed headers when uploading blobs:
     * https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob#request-headers-all-blob-types.
     */
    @JsonProperty(value = "uploadHeaders")
    private List<HttpHeader> uploadHeaders;

    /**
     * Get if filePattern refers to a specific file (i.e. contains no wildcards), then path is the name of the blob to which to upload that file. If filePattern contains one or more wildcards (and therefore may match multiple files), then path is the name of the blob virtual directory (which is prepended to each blob name) to which to upload the file(s). If omitted, file(s) are uploaded to the root of the container with a blob name matching their file name.
     *
     * @return the path value
     */
    public String path() {
        return this.path;
    }

    /**
     * Set if filePattern refers to a specific file (i.e. contains no wildcards), then path is the name of the blob to which to upload that file. If filePattern contains one or more wildcards (and therefore may match multiple files), then path is the name of the blob virtual directory (which is prepended to each blob name) to which to upload the file(s). If omitted, file(s) are uploaded to the root of the container with a blob name matching their file name.
     *
     * @param path the path value to set
     * @return the OutputFileBlobContainerDestination object itself.
     */
    public OutputFileBlobContainerDestination withPath(String path) {
        this.path = path;
        return this;
    }

    /**
     * Get if not using a managed identity, the URL must include a Shared Access Signature (SAS) granting write permissions to the container.
     *
     * @return the containerUrl value
     */
    public String containerUrl() {
        return this.containerUrl;
    }

    /**
     * Set if not using a managed identity, the URL must include a Shared Access Signature (SAS) granting write permissions to the container.
     *
     * @param containerUrl the containerUrl value to set
     * @return the OutputFileBlobContainerDestination object itself.
     */
    public OutputFileBlobContainerDestination withContainerUrl(String containerUrl) {
        this.containerUrl = containerUrl;
        return this;
    }

    /**
     * Get the identity must have write access to the Azure Blob Storage container.
     *
     * @return the identityReference value
     */
    public ComputeNodeIdentityReference identityReference() {
        return this.identityReference;
    }

    /**
     * Set the identity must have write access to the Azure Blob Storage container.
     *
     * @param identityReference the identityReference value to set
     * @return the OutputFileBlobContainerDestination object itself.
     */
    public OutputFileBlobContainerDestination withIdentityReference(ComputeNodeIdentityReference identityReference) {
        this.identityReference = identityReference;
        return this;
    }

    /**
     * Get these headers will be specified when uploading files to Azure Storage. Official document on allowed headers when uploading blobs: https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob#request-headers-all-blob-types.
     *
     * @return the uploadHeaders value
     */
    public List<HttpHeader> uploadHeaders() {
        return this.uploadHeaders;
    }

    /**
     * Set these headers will be specified when uploading files to Azure Storage. Official document on allowed headers when uploading blobs: https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob#request-headers-all-blob-types.
     *
     * @param uploadHeaders the uploadHeaders value to set
     * @return the OutputFileBlobContainerDestination object itself.
     */
    public OutputFileBlobContainerDestination withUploadHeaders(List<HttpHeader> uploadHeaders) {
        this.uploadHeaders = uploadHeaders;
        return this;
    }

}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
    <meta name="author" content="Jacopo Urbani">
    <meta name="description" content="VLog">

    <link href="main.css" rel="stylesheet" type="text/css">
    <link href="d3/radial.css" rel="stylesheet" type="text/css">

    <title>VLog</title>

VLog

            <button type="button" href="#leftcolumnblock" class="nav-toggle">Hide Content</button>

Memory Monitor

Occupied RAM: / MB

Refresh rate (ms): <input id="refreshRate" size="5" text="1000" value="1000" onchange="setRefresh(refreshMem);">

Command line:

Details EDB predicates

Details current program

                <input type="button" id="buttonSizeIDBs" value="Get size IDB tables" onclick="get_size_IDBs();" />

        <form name="setup" method="post" id="setup">

Rules

                        <textarea id="rulebox" name="rules" rows="30">
</textarea>

                        Load from file: <input type="file" id="filerule" onchange="loadfile(this, 'rulebox')">

Queries to prematerialize <button type="button" href="#tableQueries" class="nav-toggle">Show Content</button>

                        <textarea id="premat" name="queries" rows="7">
</textarea>

                        Load from file: <input type="file" id="queryrule" onchange="loadfile(this, 'premat')">

                        Auto premat. <input id="automat" name="automat" type="checkbox" onclick="disablepremat()">

                        <input type="button" onclick="setupProgram();" id="buttonSetup" name="submit" value="Load Rules"> <input type="button" onclick="launchMat();" id="buttonMat" name="submit" value="Launch Materialization">

        </form>


text:
#
# Copyright (C) 2015 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

import mako.template
import sys

class type(object):
   def __init__(self, c_type, union_field, glsl_type):
      self.c_type = c_type
      self.union_field = union_field
      self.glsl_type = glsl_type

class type_signature_iter(object):
   """Basic iterator for a set of type signatures.  Various kinds of sequences of
   types come in, and an iteration of type_signature objects come out.

   """

   def __init__(self, source_types, num_operands):
      """Initialize an iterator from a sequence of input types and a number
      operands.  This is for signatures where all the operands have the same
      type and the result type of the operation is the same as the input type.

      """
      self.dest_type = None
      self.source_types = source_types
      self.num_operands = num_operands
      self.i = 0

   def __init__(self, dest_type, source_types, num_operands):
      """Initialize an iterator from a result tpye, a sequence of input types and a
      number operands.  This is for signatures where all the operands have the
      same type but the result type of the operation is different from the
      input type.

      """
      self.dest_type = dest_type
      self.source_types = source_types
      self.num_operands = num_operands
      self.i = 0

   def __iter__(self):
      return self

   def next(self):
      if self.i < len(self.source_types):
         i = self.i
         self.i += 1

         if self.dest_type is None:
            dest_type = self.source_types[i]
         else:
            dest_type = self.dest_type

         return (dest_type, self.num_operands * (self.source_types[i],))
      else:
         raise StopIteration()

uint_type = type("unsigned", "u", "GLSL_TYPE_UINT")
int_type = type("int", "i", "GLSL_TYPE_INT")
uint64_type = type("uint64_t", "u64", "GLSL_TYPE_UINT64")
int64_type = type("int64_t", "i64", "GLSL_TYPE_INT64")
float_type = type("float", "f", "GLSL_TYPE_FLOAT")
double_type = type("double", "d", "GLSL_TYPE_DOUBLE")
bool_type = type("bool", "b", "GLSL_TYPE_BOOL")

all_types = (uint_type, int_type, float_type, double_type, uint64_type, int64_type, bool_type)
numeric_types = (uint_type, int_type, float_type, double_type, uint64_type, int64_type)
signed_numeric_types = (int_type, float_type, double_type, int64_type)
integer_types = (uint_type, int_type, uint64_type, int64_type)
real_types = (float_type, double_type)

# This template is for operations that can have operands of a several
# different types, and each type may or may not has a different C expression.
# This is used by most operations.
constant_template_common = mako.template.Template("""\
   case ${op.get_enum_name()}:
      for (unsigned c = 0; c < op[0]->type->components(); c++) {
         switch (op[0]->type->base_type) {
    % for dst_type, src_types in op.signatures():
         case ${src_types[0].glsl_type}:
            data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types)};
            break;
    % endfor
         default:
            unreachable("invalid type");
         }
      }
      break;""")

# This template is for binary operations that can operate on some combination
# of scalar and vector operands.
constant_template_vector_scalar = mako.template.Template("""\
   case ${op.get_enum_name()}:
    % if "mixed" in op.flags:
        % for i in xrange(op.num_operands):
      assert(op[${i}]->type->base_type == ${op.source_types[0].glsl_type} ||
            % for src_type in op.source_types[1:-1]:
             op[${i}]->type->base_type == ${src_type.glsl_type} ||
            % endfor
             op[${i}]->type->base_type == ${op.source_types[-1].glsl_type});
        % endfor
    % else:
      assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
    % endif
      for (unsigned c = 0, c0 = 0, c1 = 0;
           c < components;
           c0 += c0_inc, c1 += c1_inc, c++) {

         switch (op[0]->type->base_type) {
    % for dst_type, src_types in op.signatures():
         case ${src_types[0].glsl_type}:
            data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types, ("c0", "c1", "c2"))};
            break;
    % endfor
         default:
            unreachable("invalid type");
         }
      }
      break;""")

# This template is for multiplication.  It is unique because it has to support
# matrix * vector and matrix * matrix operations, and those are just different.
constant_template_mul = mako.template.Template("""\
   case ${op.get_enum_name()}:
      /* Check for equal types, or unequal types involving scalars */
      if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix())
          || op0_scalar || op1_scalar) {
         for (unsigned c = 0, c0 = 0, c1 = 0;
              c < components;
              c0 += c0_inc, c1 += c1_inc, c++) {

            switch (op[0]->type->base_type) {
    % for dst_type, src_types in op.signatures():
            case ${src_types[0].glsl_type}:
               data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types, ("c0", "c1", "c2"))};
               break;
    % endfor
            default:
               unreachable("invalid type");
            }
         }
      } else {
         assert(op[0]->type->is_matrix() || op[1]->type->is_matrix());

         /* Multiply an N-by-M matrix with an M-by-P matrix.  Since either
          * matrix can be a GLSL vector, either N or P can be 1.
          *
          * For vec*mat, the vector is treated as a row vector.  This
          * means the vector is a 1-row x M-column matrix.
          *
          * For mat*vec, the vector is treated as a column vector.  Since
          * matrix_columns is 1 for vectors, this just works.
          */
         const unsigned n = op[0]->type->is_vector()
            ? 1 : op[0]->type->vector_elements;
         const unsigned m = op[1]->type->vector_elements;
         const unsigned p = op[1]->type->matrix_columns;
         for (unsigned j = 0; j < p; j++) {
            for (unsigned i = 0; i < n; i++) {
               for (unsigned k = 0; k < m; k++) {
                  if (op[0]->type->base_type == GLSL_TYPE_DOUBLE)
                     data.d[i+n*j] += op[0]->value.d[i+n*k]*op[1]->value.d[k+m*j];
                  else
                     data.f[i+n*j] += op[0]->value.f[i+n*k]*op[1]->value.f[k+m*j];
               }
            }
         }
      }
      break;""")

# This template is for operations that are horizontal and either have only a
# single type or the implementation for all types is identical.  That is, the
# operation consumes a vector and produces a scalar.
constant_template_horizontal_single_implementation = mako.template.Template("""\
   case ${op.get_enum_name()}:
      data.${op.dest_type.union_field}[0] = ${op.c_expression['default']};
      break;""")

# This template is for operations that are horizontal and do not assign the
# result.  The various unpack operations are examples.
constant_template_horizontal_nonassignment = mako.template.Template("""\
   case ${op.get_enum_name()}:
      ${op.c_expression['default']};
      break;""")

# This template is for binary operations that are horizontal.  That is, the
# operation consumes a vector and produces a scalar.
constant_template_horizontal = mako.template.Template("""\
   case ${op.get_enum_name()}:
      switch (op[0]->type->base_type) {
    % for dst_type, src_types in op.signatures():
      case ${src_types[0].glsl_type}:
         data.${dst_type.union_field}[0] = ${op.get_c_expression(src_types)};
         break;
    % endfor
      default:
         unreachable("invalid type");
      }
      break;""")

# This template is for ir_binop_vector_extract.
constant_template_vector_extract = mako.template.Template("""\
   case ${op.get_enum_name()}: {
      const int c = CLAMP(op[1]->value.i[0], 0,
                          (int) op[0]->type->vector_elements - 1);

      switch (op[0]->type->base_type) {
    % for dst_type, src_types in op.signatures():
      case ${src_types[0].glsl_type}:
         data.${dst_type.union_field}[0] = op[0]->value.${src_types[0].union_field}[c];
         break;
    % endfor
      default:
         unreachable("invalid type");
      }
      break;
   }""")

# This template is for ir_triop_vector_insert.
constant_template_vector_insert = mako.template.Template("""\
   case ${op.get_enum_name()}: {
      const unsigned idx = op[2]->value.u[0];

      memcpy(&data, &op[0]->value, sizeof(data));

      switch (this->type->base_type) {
    % for dst_type, src_types in op.signatures():
      case ${src_types[0].glsl_type}:
         data.${dst_type.union_field}[idx] = op[1]->value.${src_types[0].union_field}[0];
         break;
    % endfor
      default:
         unreachable("invalid type");
      }
      break;
   }""")

# This template is for ir_quadop_vector.
constant_template_vector = mako.template.Template("""\
   case ${op.get_enum_name()}:
      for (unsigned c = 0; c < this->type->vector_elements; c++) {
         switch (this->type->base_type) {
    % for dst_type, src_types in op.signatures():
         case ${src_types[0].glsl_type}:
            data.${dst_type.union_field}[c] = op[c]->value.${src_types[0].union_field}[0];
            break;
    % endfor
         default:
            unreachable("invalid type");
         }
      }
      break;""")

# This template is for ir_triop_lrp.
constant_template_lrp = mako.template.Template("""\
   case ${op.get_enum_name()}: {
      assert(op[0]->type->base_type == GLSL_TYPE_FLOAT ||
             op[0]->type->base_type == GLSL_TYPE_DOUBLE);
      assert(op[1]->type->base_type == GLSL_TYPE_FLOAT ||
             op[1]->type->base_type == GLSL_TYPE_DOUBLE);
      assert(op[2]->type->base_type == GLSL_TYPE_FLOAT ||
             op[2]->type->base_type == GLSL_TYPE_DOUBLE);

      unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
      for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) {
         switch (this->type->base_type) {
    % for dst_type, src_types in op.signatures():
         case ${src_types[0].glsl_type}:
            data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types, ("c", "c", "c2"))};
            break;
    % endfor
         default:
            unreachable("invalid type");
         }
      }
      break;
   }""")

# This template is for ir_triop_csel.  This expression is really unique
# because not all of the operands are the same type, and the second operand
# determines the type of the expression (instead of the first).
constant_template_csel = mako.template.Template("""\
   case ${op.get_enum_name()}:
      for (unsigned c = 0; c < components; c++) {
         switch (this->type->base_type) {
    % for dst_type, src_types in op.signatures():
         case ${src_types[1].glsl_type}:
            data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types)};
            break;
    % endfor
         default:
            unreachable("invalid type");
         }
      }
      break;""")

vector_scalar_operation = "vector-scalar"
horizontal_operation = "horizontal"
types_identical_operation = "identical"
non_assign_operation = "nonassign"
mixed_type_operation = "mixed"

class operation(object):
   def __init__(self, name, num_operands, printable_name = None, source_types = None, dest_type = None, c_expression = None, flags = None, all_signatures = None):
      self.name = name
      self.num_operands = num_operands

      if printable_name is None:
         self.printable_name = name
      else:
         self.printable_name = printable_name

      self.all_signatures = all_signatures

      if source_types is None:
         self.source_types = tuple()
      else:
         self.source_types = source_types

      self.dest_type = dest_type

      if c_expression is None:
         self.c_expression = None
      elif isinstance(c_expression, str):
         self.c_expression = {'default': c_expression}
      else:
         self.c_expression = c_expression

      if flags is None:
         self.flags = frozenset()
      elif isinstance(flags, str):
         self.flags = frozenset([flags])
      else:
         self.flags = frozenset(flags)

   def get_enum_name(self):
      return "ir_{0}op_{1}".format(("un", "bin", "tri", "quad")[self.num_operands-1], self.name)

   def get_template(self):
      if self.c_expression is None:
         return None

      if horizontal_operation in self.flags:
         if non_assign_operation in self.flags:
            return constant_template_horizontal_nonassignment.render(op=self)
         elif types_identical_operation in self.flags:
            return constant_template_horizontal_single_implementation.render(op=self)
         else:
            return constant_template_horizontal.render(op=self)

      if self.num_operands == 2:
         if self.name == "mul":
            return constant_template_mul.render(op=self)
         elif self.name == "vector_extract":
            return constant_template_vector_extract.render(op=self)
         elif vector_scalar_operation in self.flags:
            return constant_template_vector_scalar.render(op=self)
      elif self.num_operands == 3:
         if self.name == "vector_insert":
            return constant_template_vector_insert.render(op=self)
         elif self.name == "lrp":
            return constant_template_lrp.render(op=self)
         elif self.name == "csel":
            return constant_template_csel.render(op=self)
      elif self.num_operands == 4:
         if self.name == "vector":
            return constant_template_vector.render(op=self)

      return constant_template_common.render(op=self)

   def get_c_expression(self, types, indices=("c", "c", "c")):
      src0 = "op[0]->value.{0}[{1}]".format(types[0].union_field, indices[0])
      src1 = "op[1]->value.{0}[{1}]".format(types[1].union_field, indices[1]) if len(types) >= 2 else "ERROR"
      src2 = "op[2]->value.{0}[{1}]".format(types[2].union_field, indices[2]) if len(types) >= 3 else "ERROR"
      src3 = "op[3]->value.{0}[c]".format(types[3].union_field) if len(types) >= 4 else "ERROR"

      expr = self.c_expression[types[0].union_field] if types[0].union_field in self.c_expression else self.c_expression['default']

      return expr.format(src0=src0,
                         src1=src1,
                         src2=src2,
                         src3=src3)

   def signatures(self):
      if self.all_signatures is not None:
         return self.all_signatures
      else:
         return type_signature_iter(self.dest_type, self.source_types, self.num_operands)

ir_expression_operation = [
   operation("bit_not", 1, printable_name="~", source_types=integer_types, c_expression="~ {src0}"),
   operation("logic_not", 1, printable_name="!", source_types=(bool_type,), c_expression="!{src0}"),
   operation("neg", 1, source_types=numeric_types, c_expression={'u': "-((int) {src0})", 'default': "-{src0}"}),
   operation("abs", 1, source_types=signed_numeric_types, c_expression={'i': "{src0} < 0 ? -{src0} : {src0}", 'f': "fabsf({src0})", 'd': "fabs({src0})", 'i64': "{src0} < 0 ? -{src0} : {src0}"}),
   operation("sign", 1, source_types=signed_numeric_types, c_expression={'i': "({src0} > 0) - ({src0} < 0)", 'f': "float(({src0} > 0.0F) - ({src0} < 0.0F))", 'd': "double(({src0} > 0.0) - ({src0} < 0.0))", 'i64': "({src0} > 0) - ({src0} < 0)"}),
   operation("rcp", 1, source_types=real_types, c_expression={'f': "1.0F / {src0}", 'd': "1.0 / {src0}"}),
   operation("rsq", 1, source_types=real_types, c_expression={'f': "1.0F / sqrtf({src0})", 'd': "1.0 / sqrt({src0})"}),
   operation("sqrt", 1, source_types=real_types, c_expression={'f': "sqrtf({src0})", 'd': "sqrt({src0})"}),
   operation("exp", 1, source_types=(float_type,), c_expression="expf({src0})"),         # Log base e on gentype
   operation("log", 1, source_types=(float_type,), c_expression="logf({src0})"),         # Natural log on gentype
   operation("exp2", 1, source_types=(float_type,), c_expression="exp2f({src0})"),
   operation("log2", 1, source_types=(float_type,), c_expression="log2f({src0})"),

   # Float-to-integer conversion.
   operation("f2i", 1, source_types=(float_type,), dest_type=int_type, c_expression="(int) {src0}"),
   # Float-to-unsigned conversion.
   operation("f2u", 1, source_types=(float_type,), dest_type=uint_type, c_expression="(unsigned) {src0}"),
   # Integer-to-float conversion.
   operation("i2f", 1, source_types=(int_type,), dest_type=float_type, c_expression="(float) {src0}"),
   # Float-to-boolean conversion
   operation("f2b", 1, source_types=(float_type,), dest_type=bool_type, c_expression="{src0} != 0.0F ? true : false"),
   # Boolean-to-float conversion
   operation("b2f", 1, source_types=(bool_type,), dest_type=float_type, c_expression="{src0} ? 1.0F : 0.0F"),
   # int-to-boolean conversion
   operation("i2b", 1, source_types=(uint_type, int_type), dest_type=bool_type, c_expression="{src0} ? true : false"),
   # Boolean-to-int conversion
   operation("b2i", 1, source_types=(bool_type,), dest_type=int_type, c_expression="{src0} ? 1 : 0"),
   # Unsigned-to-float conversion.
   operation("u2f", 1, source_types=(uint_type,), dest_type=float_type, c_expression="(float) {src0}"),
   # Integer-to-unsigned conversion.
   operation("i2u", 1, source_types=(int_type,), dest_type=uint_type, c_expression="{src0}"),
   # Unsigned-to-integer conversion.
   operation("u2i", 1, source_types=(uint_type,), dest_type=int_type, c_expression="{src0}"),
   # Double-to-float conversion.
   operation("d2f", 1, source_types=(double_type,), dest_type=float_type, c_expression="{src0}"),
   # Float-to-double conversion.
   operation("f2d", 1, source_types=(float_type,), dest_type=double_type, c_expression="{src0}"),
   # Double-to-integer conversion.
   operation("d2i", 1, source_types=(double_type,), dest_type=int_type, c_expression="{src0}"),
   # Integer-to-double conversion.
   operation("i2d", 1, source_types=(int_type,), dest_type=double_type, c_expression="{src0}"),
   # Double-to-unsigned conversion.
   operation("d2u", 1, source_types=(double_type,), dest_type=uint_type, c_expression="{src0}"),
   # Unsigned-to-double conversion.
   operation("u2d", 1, source_types=(uint_type,), dest_type=double_type, c_expression="{src0}"),
   # Double-to-boolean conversion.
   operation("d2b", 1, source_types=(double_type,), dest_type=bool_type, c_expression="{src0} != 0.0"),
   # 'Bit-identical int-to-float "conversion"
   operation("bitcast_i2f", 1, source_types=(int_type,), dest_type=float_type, c_expression="bitcast_u2f({src0})"),
   # 'Bit-identical float-to-int "conversion"
   operation("bitcast_f2i", 1, source_types=(float_type,), dest_type=int_type, c_expression="bitcast_f2u({src0})"),
   # 'Bit-identical uint-to-float "conversion"
   operation("bitcast_u2f", 1, source_types=(uint_type,), dest_type=float_type, c_expression="bitcast_u2f({src0})"),
   # 'Bit-identical float-to-uint "conversion"
   operation("bitcast_f2u", 1, source_types=(float_type,), dest_type=uint_type, c_expression="bitcast_f2u({src0})"),
   # Bit-identical u64-to-double "conversion"
   operation("bitcast_u642d", 1, source_types=(uint64_type,), dest_type=double_type, c_expression="bitcast_u642d({src0})"),
   # Bit-identical i64-to-double "conversion"
   operation("bitcast_i642d", 1, source_types=(int64_type,), dest_type=double_type, c_expression="bitcast_i642d({src0})"),
   # Bit-identical double-to_u64 "conversion"
   operation("bitcast_d2u64", 1, source_types=(double_type,), dest_type=uint64_type, c_expression="bitcast_d2u64({src0})"),
   # Bit-identical double-to-i64 "conversion"
   operation("bitcast_d2i64", 1, source_types=(double_type,), dest_type=int64_type, c_expression="bitcast_d2i64({src0})"),
   # i64-to-i32 conversion
   operation("i642i", 1, source_types=(int64_type,), dest_type=int_type, c_expression="{src0}"),
   # ui64-to-i32 conversion
   operation("u642i", 1, source_types=(uint64_type,), dest_type=int_type, c_expression="{src0}"),
   operation("i642u", 1, source_types=(int64_type,), dest_type=uint_type, c_expression="{src0}"),
   operation("u642u", 1, source_types=(uint64_type,), dest_type=uint_type, c_expression="{src0}"),
   operation("i642b", 1, source_types=(int64_type,), dest_type=bool_type, c_expression="{src0} != 0"),
   operation("i642f", 1, source_types=(int64_type,), dest_type=float_type, c_expression="{src0}"),
   operation("u642f", 1, source_types=(uint64_type,), dest_type=float_type, c_expression="{src0}"),
   operation("i642d", 1, source_types=(int64_type,), dest_type=double_type, c_expression="{src0}"),
   operation("u642d", 1, source_types=(uint64_type,), dest_type=double_type, c_expression="{src0}"),
   operation("i2i64", 1, source_types=(int_type,), dest_type=int64_type, c_expression="{src0}"),
   operation("u2i64", 1, source_types=(uint_type,), dest_type=int64_type, c_expression="{src0}"),
   operation("b2i64", 1, source_types=(bool_type,), dest_type=int64_type, c_expression="{src0}"),
   operation("f2i64", 1, source_types=(float_type,), dest_type=int64_type, c_expression="{src0}"),
   operation("d2i64", 1, source_types=(double_type,), dest_type=int64_type, c_expression="{src0}"),
   operation("i2u64", 1, source_types=(int_type,), dest_type=uint64_type, c_expression="{src0}"),
   operation("u2u64", 1, source_types=(uint_type,), dest_type=uint64_type, c_expression="{src0}"),
   operation("f2u64", 1, source_types=(float_type,), dest_type=uint64_type, c_expression="{src0}"),
   operation("d2u64", 1, source_types=(double_type,), dest_type=uint64_type, c_expression="{src0}"),
   operation("u642i64", 1, source_types=(uint64_type,), dest_type=int64_type, c_expression="{src0}"),
   operation("i642u64", 1, source_types=(int64_type,), dest_type=uint64_type, c_expression="{src0}"),

   # Unary floating-point rounding operations.
   operation("trunc", 1, source_types=real_types, c_expression={'f': "truncf({src0})", 'd': "trunc({src0})"}),
   operation("ceil", 1, source_types=real_types, c_expression={'f': "ceilf({src0})", 'd': "ceil({src0})"}),
   operation("floor", 1, source_types=real_types, c_expression={'f': "floorf({src0})", 'd': "floor({src0})"}),
   operation("fract", 1, source_types=real_types, c_expression={'f': "{src0} - floorf({src0})", 'd': "{src0} - floor({src0})"}),
   operation("round_even", 1, source_types=real_types, c_expression={'f': "_mesa_roundevenf({src0})", 'd': "_mesa_roundeven({src0})"}),

   # Trigonometric operations.
   operation("sin", 1, source_types=(float_type,), c_expression="sinf({src0})"),
   operation("cos", 1, source_types=(float_type,), c_expression="cosf({src0})"),

   # Partial derivatives.
   operation("dFdx", 1, source_types=(float_type,), c_expression="0.0f"),
   operation("dFdx_coarse", 1, printable_name="dFdxCoarse", source_types=(float_type,), c_expression="0.0f"),
   operation("dFdx_fine", 1, printable_name="dFdxFine", source_types=(float_type,), c_expression="0.0f"),
   operation("dFdy", 1, source_types=(float_type,), c_expression="0.0f"),
   operation("dFdy_coarse", 1, printable_name="dFdyCoarse", source_types=(float_type,), c_expression="0.0f"),
   operation("dFdy_fine", 1, printable_name="dFdyFine", source_types=(float_type,), c_expression="0.0f"),

   # Floating point pack and unpack operations.
   operation("pack_snorm_2x16", 1, printable_name="packSnorm2x16", source_types=(float_type,), dest_type=uint_type, c_expression="pack_2x16(pack_snorm_1x16, op[0]->value.f[0], op[0]->value.f[1])", flags=horizontal_operation),
   operation("pack_snorm_4x8", 1, printable_name="packSnorm4x8", source_types=(float_type,), dest_type=uint_type, c_expression="pack_4x8(pack_snorm_1x8, op[0]->value.f[0], op[0]->value.f[1], op[0]->value.f[2], op[0]->value.f[3])", flags=horizontal_operation),
   operation("pack_unorm_2x16", 1, printable_name="packUnorm2x16", source_types=(float_type,), dest_type=uint_type, c_expression="pack_2x16(pack_unorm_1x16, op[0]->value.f[0], op[0]->value.f[1])", flags=horizontal_operation),
   operation("pack_unorm_4x8", 1, printable_name="packUnorm4x8", source_types=(float_type,), dest_type=uint_type, c_expression="pack_4x8(pack_unorm_1x8, op[0]->value.f[0], op[0]->value.f[1], op[0]->value.f[2], op[0]->value.f[3])", flags=horizontal_operation),
   operation("pack_half_2x16", 1, printable_name="packHalf2x16", source_types=(float_type,), dest_type=uint_type, c_expression="pack_2x16(pack_half_1x16, op[0]->value.f[0], op[0]->value.f[1])", flags=horizontal_operation),
   operation("unpack_snorm_2x16", 1, printable_name="unpackSnorm2x16", source_types=(uint_type,), dest_type=float_type, c_expression="unpack_2x16(unpack_snorm_1x16, op[0]->value.u[0], &data.f[0], &data.f[1])", flags=frozenset((horizontal_operation, non_assign_operation))),
   operation("unpack_snorm_4x8", 1, printable_name="unpackSnorm4x8", source_types=(uint_type,), dest_type=float_type, c_expression="unpack_4x8(unpack_snorm_1x8, op[0]->value.u[0], &data.f[0], &data.f[1], &data.f[2], &data.f[3])", flags=frozenset((horizontal_operation, non_assign_operation))),
   operation("unpack_unorm_2x16", 1, printable_name="unpackUnorm2x16", source_types=(uint_type,), dest_type=float_type, c_expression="unpack_2x16(unpack_unorm_1x16, op[0]->value.u[0], &data.f[0], &data.f[1])", flags=frozenset((horizontal_operation, non_assign_operation))),
   operation("unpack_unorm_4x8", 1, printable_name="unpackUnorm4x8", source_types=(uint_type,), dest_type=float_type, c_expression="unpack_4x8(unpack_unorm_1x8, op[0]->value.u[0], &data.f[0], &data.f[1], &data.f[2], &data.f[3])", flags=frozenset((horizontal_operation, non_assign_operation))),
   operation("unpack_half_2x16", 1, printable_name="unpackHalf2x16", source_types=(uint_type,), dest_type=float_type, c_expression="unpack_2x16(unpack_half_1x16, op[0]->value.u[0], &data.f[0], &data.f[1])", flags=frozenset((horizontal_operation, non_assign_operation))),

   # Bit operations, part of ARB_gpu_shader5.
   operation("bitfield_reverse", 1, source_types=(uint_type, int_type), c_expression="bitfield_reverse({src0})"),
   operation("bit_count", 1, source_types=(uint_type, int_type), dest_type=int_type, c_expression="_mesa_bitcount({src0})"),
   operation("find_msb", 1, source_types=(uint_type, int_type), dest_type=int_type, c_expression={'u': "find_msb_uint({src0})", 'i': "find_msb_int({src0})"}),
   operation("find_lsb", 1, source_types=(uint_type, int_type), dest_type=int_type, c_expression="find_msb_uint({src0} & -{src0})"),

   operation("saturate", 1, printable_name="sat", source_types=(float_type,), c_expression="CLAMP({src0}, 0.0f, 1.0f)"),

   # Double packing, part of ARB_gpu_shader_fp64.
   operation("pack_double_2x32", 1, printable_name="packDouble2x32", source_types=(uint_type,), dest_type=double_type, c_expression="memcpy(&data.d[0], &op[0]->value.u[0], sizeof(double))", flags=frozenset((horizontal_operation, non_assign_operation))),
   operation("unpack_double_2x32", 1, printable_name="unpackDouble2x32", source_types=(double_type,), dest_type=uint_type, c_expression="memcpy(&data.u[0], &op[0]->value.d[0], sizeof(double))", flags=frozenset((horizontal_operation, non_assign_operation))),

   operation("frexp_sig", 1),
   operation("frexp_exp", 1),

   operation("noise", 1),

   operation("subroutine_to_int", 1),

   # Interpolate fs input at centroid
   #
   # operand0 is the fs input.
   operation("interpolate_at_centroid", 1),

   # Ask the driver for the total size of a buffer block.
   # operand0 is the ir_constant buffer block index in the linked shader.
   operation("get_buffer_size", 1),

   # Calculate length of an unsized array inside a buffer block.
   # This opcode is going to be replaced in a lowering pass inside
   # the linker.
   #
   # operand0 is the unsized array's ir_value for the calculation
   # of its length.
   operation("ssbo_unsized_array_length", 1),

   # ARB_shader_ballot operations
   operation("ballot", 1, source_types=(bool_type,), dest_type=uint64_type),
   operation("read_first_invocation", 1),

   # Vote among threads on the value of the boolean argument.
   operation("vote_any", 1),
   operation("vote_all", 1),
   operation("vote_eq", 1),

   # 64-bit integer packing ops.
   operation("pack_int_2x32", 1, printable_name="packInt2x32", source_types=(int_type,), dest_type=int64_type, c_expression="memcpy(&data.i64[0], &op[0]->value.i[0], sizeof(int64_t))", flags=frozenset((horizontal_operation, non_assign_operation))),
   operation("pack_uint_2x32", 1, printable_name="packUint2x32", source_types=(uint_type,), dest_type=uint64_type, c_expression="memcpy(&data.u64[0], &op[0]->value.u[0], sizeof(uint64_t))", flags=frozenset((horizontal_operation, non_assign_operation))),
   operation("unpack_int_2x32", 1, printable_name="unpackInt2x32", source_types=(int64_type,), dest_type=int_type, c_expression="memcpy(&data.i[0], &op[0]->value.i64[0], sizeof(int64_t))", flags=frozenset((horizontal_operation, non_assign_operation))),
   operation("unpack_uint_2x32", 1, printable_name="unpackUint2x32", source_types=(uint64_type,), dest_type=uint_type, c_expression="memcpy(&data.u[0], &op[0]->value.u64[0], sizeof(uint64_t))", flags=frozenset((horizontal_operation, non_assign_operation))),

   operation("add", 2, printable_name="+", source_types=numeric_types, c_expression="{src0} + {src1}", flags=vector_scalar_operation),
   operation("sub", 2, printable_name="-", source_types=numeric_types, c_expression="{src0} - {src1}", flags=vector_scalar_operation),
   # "Floating-point or low 32-bit integer multiply."
   operation("mul", 2, printable_name="*", source_types=numeric_types, c_expression="{src0} * {src1}"),
   operation("imul_high", 2),       # Calculates the high 32-bits of a 64-bit multiply.
   operation("div", 2, printable_name="/", source_types=numeric_types, c_expression={'u': "{src1} == 0 ? 0 : {src0} / {src1}", 'i': "{src1} == 0 ? 0 : {src0} / {src1}", 'u64': "{src1} == 0 ? 0 : {src0} / {src1}", 'i64': "{src1} == 0 ? 0 : {src0} / {src1}", 'default': "{src0} / {src1}"}, flags=vector_scalar_operation),

   # Returns the carry resulting from the addition of the two arguments.
   operation("carry", 2),

   # Returns the borrow resulting from the subtraction of the second argument
   # from the first argument.
   operation("borrow", 2),

   # Either (vector % vector) or (vector % scalar)
   #
   # We don't use fmod because it rounds toward zero; GLSL specifies the use
   # of floor.
   operation("mod", 2, printable_name="%", source_types=numeric_types, c_expression={'u': "{src1} == 0 ? 0 : {src0} % {src1}", 'i': "{src1} == 0 ? 0 : {src0} % {src1}", 'f': "{src0} - {src1} * floorf({src0} / {src1})", 'd': "{src0} - {src1} * floor({src0} / {src1})", 'u64': "{src1} == 0 ? 0 : {src0} % {src1}", 'i64': "{src1} == 0 ? 0 : {src0} % {src1}"}, flags=vector_scalar_operation),

   # Binary comparison operators which return a boolean vector.
   # The type of both operands must be equal.
   operation("less", 2, printable_name="<", source_types=numeric_types, dest_type=bool_type, c_expression="{src0} < {src1}"),
   operation("greater", 2, printable_name=">", source_types=numeric_types, dest_type=bool_type, c_expression="{src0} > {src1}"),
   operation("lequal", 2, printable_name="<=", source_types=numeric_types, dest_type=bool_type, c_expression="{src0} <= {src1}"),
   operation("gequal", 2, printable_name=">=", source_types=numeric_types, dest_type=bool_type, c_expression="{src0} >= {src1}"),
   operation("equal", 2, printable_name="==", source_types=all_types, dest_type=bool_type, c_expression="{src0} == {src1}"),
   operation("nequal", 2, printable_name="!=", source_types=all_types, dest_type=bool_type, c_expression="{src0} != {src1}"),

   # Returns single boolean for whether all components of operands[0]
   # equal the components of operands[1].
   operation("all_equal", 2, source_types=all_types, dest_type=bool_type, c_expression="op[0]->has_value(op[1])", flags=frozenset((horizontal_operation, types_identical_operation))),

   # Returns single boolean for whether any component of operands[0]
   # is not equal to the corresponding component of operands[1].
   operation("any_nequal", 2, source_types=all_types, dest_type=bool_type, c_expression="!op[0]->has_value(op[1])", flags=frozenset((horizontal_operation, types_identical_operation))),

   # Bit-wise binary operations.
   operation("lshift", 2, printable_name="<<", source_types=integer_types, c_expression="{src0} << {src1}", flags=frozenset((vector_scalar_operation, mixed_type_operation))),
   operation("rshift", 2, printable_name=">>", source_types=integer_types, c_expression="{src0} >> {src1}", flags=frozenset((vector_scalar_operation, mixed_type_operation))),
   operation("bit_and", 2, printable_name="&", source_types=integer_types, c_expression="{src0} & {src1}", flags=vector_scalar_operation),
   operation("bit_xor", 2, printable_name="^", source_types=integer_types, c_expression="{src0} ^ {src1}", flags=vector_scalar_operation),
   operation("bit_or", 2, printable_name="|", source_types=integer_types, c_expression="{src0} | {src1}", flags=vector_scalar_operation),

   operation("logic_and", 2, printable_name="&&", source_types=(bool_type,), c_expression="{src0} && {src1}"),
   operation("logic_xor", 2, printable_name="^^", source_types=(bool_type,), c_expression="{src0} != {src1}"),
   operation("logic_or", 2, printable_name="||", source_types=(bool_type,), c_expression="{src0} || {src1}"),

   operation("dot", 2, source_types=real_types, c_expression={'f': "dot_f(op[0], op[1])", 'd': "dot_d(op[0], op[1])"}, flags=horizontal_operation),
   operation("min", 2, source_types=numeric_types, c_expression="MIN2({src0}, {src1})", flags=vector_scalar_operation),
   operation("max", 2, source_types=numeric_types, c_expression="MAX2({src0}, {src1})", flags=vector_scalar_operation),

   operation("pow", 2, source_types=(float_type,), c_expression="powf({src0}, {src1})"),

   # Load a value the size of a given GLSL type from a uniform block.
   #
   # operand0 is the ir_constant uniform block index in the linked shader.
   # operand1 is a byte offset within the uniform block.
   operation("ubo_load", 2),

   # Multiplies a number by two to a power, part of ARB_gpu_shader5.
   operation("ldexp", 2,
             all_signatures=((float_type, (float_type, int_type)),
                             (double_type, (double_type, int_type))),
             c_expression={'f': "ldexpf_flush_subnormal({src0}, {src1})",
                           'd': "ldexp_flush_subnormal({src0}, {src1})"}),

   # Extract a scalar from a vector
   #
   # operand0 is the vector
   # operand1 is the index of the field to read from operand0
   operation("vector_extract", 2, source_types=all_types, c_expression="anything-except-None"),

   # Interpolate fs input at offset
   #
   # operand0 is the fs input
   # operand1 is the offset from the pixel center
   operation("interpolate_at_offset", 2),

   # Interpolate fs input at sample position
   #
   # operand0 is the fs input
   # operand1 is the sample ID
   operation("interpolate_at_sample", 2),

   # ARB_shader_ballot operation
   operation("read_invocation", 2),

   # Fused floating-point multiply-add, part of ARB_gpu_shader5.
   operation("fma", 3, source_types=real_types, c_expression="{src0} * {src1} + {src2}"),

   operation("lrp", 3, source_types=real_types, c_expression={'f': "{src0} * (1.0f - {src2}) + ({src1} * {src2})", 'd': "{src0} * (1.0 - {src2}) + ({src1} * {src2})"}),

   # Conditional Select
   #
   # A vector conditional select instruction (like ?:, but operating per-
   # component on vectors).
   #
   # See also lower_instructions_visitor::ldexp_to_arith
   operation("csel", 3,
             all_signatures=zip(all_types, zip(len(all_types) * (bool_type,), all_types, all_types)),
             c_expression="{src0} ? {src1} : {src2}"),

   operation("bitfield_extract", 3,
             all_signatures=((int_type, (uint_type, int_type, int_type)),
                             (int_type, (int_type, int_type, int_type))),
             c_expression={'u': "bitfield_extract_uint({src0}, {src1}, {src2})",
                           'i': "bitfield_extract_int({src0}, {src1}, {src2})"}),

   # Generate a value with one field of a vector changed
   #
   # operand0 is the vector
   # operand1 is the value to write into the vector result
   # operand2 is the index in operand0 to be modified
   operation("vector_insert", 3, source_types=all_types, c_expression="anything-except-None"),

   operation("bitfield_insert", 4,
             all_signatures=((uint_type, (uint_type, uint_type, int_type, int_type)),
                             (int_type, (int_type, int_type, int_type, int_type))),
             c_expression="bitfield_insert({src0}, {src1}, {src2}, {src3})"),

   operation("vector", 4, source_types=all_types, c_expression="anything-except-None"),
]

if __name__ == "__main__":
   copyright = """/*
 * Copyright (C) 2010 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */
"""
   enum_template = mako.template.Template(copyright + """
enum ir_expression_operation {
% for item in values:
   ${item.get_enum_name()},
% endfor

   /* Sentinels marking the last of each kind of operation. */
% for item in lasts:
   ir_last_${("un", "bin", "tri", "quad")[item.num_operands - 1]}op = ${item.get_enum_name()},
% endfor
   ir_last_opcode = ir_quadop_${lasts[3].name}
};""")

   strings_template = mako.template.Template(copyright + """
const char *const ir_expression_operation_strings[] = {
% for item in values:
   "${item.printable_name}",
% endfor
};

const char *const ir_expression_operation_enum_strings[] = {
% for item in values:
   "${item.name}",
% endfor
};""")

   constant_template = mako.template.Template("""\
   switch (this->operation) {
% for op in values:
    % if op.c_expression is not None:
${op.get_template()}

    % endif
% endfor
   default:
      /* FINISHME: Should handle all expression types. */
      return NULL;
   }
""")

   if sys.argv[1] == "enum":
      lasts = [None, None, None, None]
      for item in reversed(ir_expression_operation):
         i = item.num_operands - 1
         if lasts[i] is None:
            lasts[i] = item

      print(enum_template.render(values=ir_expression_operation,
                                 lasts=lasts))
   elif sys.argv[1] == "strings":
      print(strings_template.render(values=ir_expression_operation))
   elif sys.argv[1] == "constant":
      print(constant_template.render(values=ir_expression_operation))


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>Python: module colour</title>

<big><big>colour</big></big>	index
g:\lichtenstein art final\01_sourcecode\colour.py

<tt>Module containing common colour related tasks. This module is frequently

used in conjunction with PIL projects.

The idea behind this module is to contain colour related functions which

are used when creating images. This is very much a WIP module and will

be added to as I implement more features necessary for any image or PIL

related projects.

Currently, most of the functions in this module work with RGB colours and

not any other types. This will be a feature I will add to the module as

it becomes necessary, adding HSV, RGBA, HEX and PIL worded colours. The

functions included in the module are for checking if an RGB value is valid,

to unflatten a list of RGB values as well as flatten them, to calculate the

luminosity of a colour from it's RGB elements, and also average an a list

of RGB colours.

Here are some examples of how the code works:

    >>> valRGB = (23, 234, 120)

    >>> luminosity(valRGB)

    180.91059999999999

    >>> invRGB = (256,90,123) #Colours only go up to 255

    >>> invRGB2 = (9,0,23.66) #RGB colours can't be float values

    >>> invRGB3 = "(50,100,24)" #String value. Only accept list or tuple

    >>> invRGB4 = (21,200,125,78) #Contains 4 values, only 3 in RGB

    >>> for rgb in (valRGB,invRGB,invRGB2,invRGB3,invRGB4):

    ...     try:

    ...             rgb_check(rgb)

    ...     except ValueError as e:

    ...             e.args[0]

    ...

    "'(256, 90, 123)' can only have an int value between 0 to 255"

    "'(9, 0, 23.66)' rgb can only be integer values, not floats"

    "'(50,100,24)' is not a list or tuple"

    "'(21, 200, 125, 78)' is not 3 numbers long"

    >>> colours = (136,234,90),(32,9,21),(40,39,21),(20,255,78)

    >>> flatCols = rgb_flatten(colours)

    >>> flatCols

    [136, 234, 90, 32, 9, 21, 40, 39, 21, 20, 255, 78]

    >>> rgb_unflatten(flatCols)

    [(136, 234, 90), (32, 9, 21), (40, 39, 21), (20, 255, 78)]

    >>> average_colours(colours)

    (57, 134, 52)

    >>>

To test/execute the examples in the module documentation make sure that

you have imported the colour module and do the following:

import doctest

nfail, ntests = doctest.testmod(colour)</tt>

<big>Modules</big>

<tt>      </tt>

struct

<big>Functions</big>

<tt>      </tt>

average_colours(colList)

<tt>Calculates the average colour from a list of RGB colours.

Parameters:

    colList [tuple][list] : A list of 3 tuple RGB values. Each of these

                            RGB values will be checked when the function

                            is run.

On Exit:

    Returns the average RGB value as a 3 tuple value in the format (R,G,B).</tt>

hex2rgb(hx)

<tt>Used to convert a string HEX colour to RGB format.

Parameters:

    hx [str] : The HEX colour code.

On Exit:

    Returns the RGB colours in a tuple with the values like (R,G,B).</tt>

luminosity(rgb, rcoeff=0.21260000000000001, gcoeff=0.71519999999999995, bcoeff=0.0722)

<tt>Calculates the Luminosity of an RGB value dependent on the RGB

coefficiants.

Parameters:

    rgb [list][tuple][int] : Can either be an RGB value or a single int

                             value representing a 3 tuple greyscale colour.

    rcoeff [float]         : The Red channel luminosity colour coefficient.

    gcoeff [float]         : The Green channel luminosity colour coefficient.

    bcoeff [float]         : The Blue channel luminosity colour coefficient.

On Exit:

    Returns a float of the luminosity of the colour, ranging from 0 to 255.</tt>

rgb2hex(r, g, b)

<tt>Used to convert an RGB colour to HEX format for use with Tkinter.

Parameters:

    r [int] : The value of the red channel.

    g [int] : The value of the green channel.

    b [int] : The value of the blue channel.

On Exit:

    Returns a string HEX colour code for the RGB colour.</tt>

rgb_check(rgb)

<tt>Used to check if the value 'rgb' is a valid RGB value.

Parameters:

    rgb [tuple][list][int] : A three tuple list containing the Red, Green

                             and Blue values of the RGB colour. Also

                             accepts a single int value for greyscale

                             colours, assuming that all the RGB values

                             are that one value.

On Exit:

    Will either raise a ValueError, explaining the problem with the RGB

    colour or will pass with no raised error.</tt>

rgb_flatten(rgbCols)

<tt>Converts a list of grouped RGB values into a single list of RGB values.

Parameters:

    rgbCols [list][tuple] : A list of grouped, 3 tuple RGB values.

On Exit:

    Separates every RGB value into a single list of RGB values.</tt>

rgb_unflatten(rgbCols)

<tt>Converts a list of separated RGB values into a 3 tuple groups of (R,G,B)

Parameters:

    rgbCols [list][tuple] : A list of separate R,G,B values all being ints.

On Exit:

    Combines and groups every 3 values into it's own tuple and returns a

    complete list of grouped RGB values.</tt>


text:
require 'rspec'
require '07_joins_exercises'

describe "JOIN exercises" do
  describe "ford_films" do
    it "selects films in which actor Harrison Ford played" do
      expect(ford_films).to contain_exactly(
        ["Frantic"],
        ["Mosquito Coast, The"],
        ["Random Hearts"],
        ["Regarding Henry"],
        ["Presumed Innocent"],
        ["Witness"],
        ["Raiders of the Lost Ark"],
        ["Indiana Jones and the Temple of Doom"],
        ["Patriot Games"],
        ["Fugitive, The"],
        ["Indiana Jones and the Last Crusade"],
        ["Star Wars: Episode V - The Empire Strikes Back"],
        ["Star Wars: Episode VI - Return of the Jedi"],
        ["Clear and Present Danger"],
        ["Star Wars"],
        ["Blade Runner"],
        ["Apocalypse Now"],
        ["Air Force One"],
        ["Devil's Own, The"],
        ["Sabrina"],
        ["American Graffiti"],
        ["Six Days Seven Nights"],
        ["Conversation, The"],
        ["What Lies Beneath"],
        ["Working Girl"]
      )
    end
  end

  describe "ford_supporting_films" do
    it "selects films in which Harrison Ford played but did not lead" do
      expect(ford_supporting_films).to contain_exactly(
        ["Star Wars: Episode V - The Empire Strikes Back"],
        ["Star Wars: Episode VI - Return of the Jedi"],
        ["Star Wars"],
        ["Apocalypse Now"],
        ["American Graffiti"],
        ["Conversation, The"]
      )
    end
  end

  describe "films_and_stars_from_sixty_two" do
    it "lists the titles and stars of all 1962 films" do
      expect(films_and_stars_from_sixty_two).to contain_exactly(
        ["Dr. No", "Sean Connery"],
        ["Cape Fear", "Gregory Peck"],
        ["To Kill a Mockingbird", "Gregory Peck"],
        ["What Ever Happened to Baby Jane?", "Bette Davis"],
        ["Music Man, The", "Robert Preston (I)"]
      )
    end
  end

  describe "travoltas_busiest_years" do
    it "selects the year and number of movies of John Travolta's busy years" do
      expect(travoltas_busiest_years).to contain_exactly(
        ["1996", "2"],
        ["1998", "2"]
      )
    end
  end

  describe "andrews_films_and_leads" do
    it "selects the titles and lead actors of films Julie Andrews played in" do
      expect(andrews_films_and_leads).to contain_exactly(
        ["10", "Dudley Moore"],
        ["Sound of Music, The", "Julie Andrews"],
        ["Victor/Victoria", "Julie Andrews"]
      )
    end
  end

  describe "prolific_actors" do
    it "selects and orders the actors who have had more than 15 starring roles" do
      expect(prolific_actors).to eq([
        ["Al Pacino"],
        ["Arnold Schwarzenegger"],
        ["Clint Eastwood"],
        ["Harrison Ford"],
        ["Robert De Niro"],
        ["Robin Williams"],
        ["Sean Connery"],
        ["Sylvester Stallone"],
        ["Tom Hanks"]
      ])
    end
  end

  describe "films_by_cast_size" do
    it "selects 1978 films and orders by cast size" do
      expect(films_by_cast_size).to eq([
        ["Death on the Nile", "12"],
        ["Capricorn One", "11"],
        ["Foul Play", "11"],
        ["Heaven Can Wait", "11"],
        ["Animal House", "9"],
        ["Boys from Brazil, The", "9"],
        ["Midnight Express", "9"],
        ["Superman", "9"],
        ["Watership Down", "9"],
        ["Deer Hunter, The", "8"],
        ["Grease", "8"],
        ["Halloween", "8"],
        ["Attack of the Killer Tomatoes!", "7"],
        ["Coma", "7"],
        ["Damien: Omen II", "7"],
        ["Days of Heaven", "6"],
        ["Up in Smoke", "6"],
        ["Dawn of the Dead", "5"]
      ])
    end
  end

  describe "colleagues_of_garfunkel" do
    it "selects actors who have worked with Art Garfunkel" do
      expect(colleagues_of_garfunkel).to contain_exactly(
        ["Jon Voight"],
        ["Orson Welles"],
        ["Martin Sheen"],
        ["Richard Benjamin"],
        ["Martin Balsam"],
        ["Alan Arkin"],
        ["Bob Balaban"],
        ["Anthony Perkins"],
        ["Jack Gilford"],
        ["Buck Henry"],
        ["Norman Fell"],
        ["Bob Newhart"],
        ["Bill Paxton"],
        ["Kurtwood Smith"],
        ["Julian Sands"],
        ["Sherilyn Fenn"]
      )
    end
  end
end


text:
var Promise, fs, os, path, yeomanResolver, _;

Promise = require('bluebird');

fs = Promise.promisifyAll(require('fs'));

_ = require('lodash');

os = require('os');

path = require('path');

yeomanResolver = require('yeoman-environment/lib/resolver');

/**
 * @summary Get node_modules paths
 * @function
 * @protected
 *
 * @returns {String[]} node_modules paths
 *
 * @example
 * paths = resolver.getNodeModulesPaths()
 */

exports.getNodeModulesPaths = function() {
  var paths;
  paths = yeomanResolver.getNpmPaths();
  paths.push(path.resolve(require.resolve('nplugm'), '..', '..', '..'));
  if (os.platform() !== 'win32') {
    paths.unshift('/usr/local/lib/node_modules');
  }
  if (process.env.NVM_BIN != null) {
    paths.unshift(path.resolve(process.env.NVM_BIN, '..', 'lib', 'node_modules'));
  }
  return paths;
};

/**
 * @summary Lookup installed npm modules
 * @function
 * @protected
 *
 * @returns {Promise<String[]>} installed plugins
 *
 * @example
 * resolver.lookup().then (plugins) ->
 * 	for plugin in plugins
 * 		console.log(plugin)
 */

exports.lookup = function() {
  return Promise["try"](exports.getNodeModulesPaths).filter(function(directory) {
    return fs.existsSync(directory);
  }).map(function(directory) {
    return fs.readdirAsync(directory).filter(function(file) {
      return fs.existsSync(path.join(directory, file, 'package.json'));
    });
  }).then(_.flatten).then(_.uniq);
};


text:
ActionController::Routing::Routes.draw do |map|

  map.with_options({  :path_prefix => 'wiki',
                      :name_prefix => 'wiki_',
                      :controller => 'wiki' }) do |wiki|

    wiki.edit      ':lang/*page/edit',              :action => 'edit',
                                                    :conditions => { :method => :get }
    wiki.preview   ':lang/*page/preview',           :action => 'preview',
                                                    :conditions => { :method => :post }
    wiki.versions  ':lang/*page/versions',          :action => 'versions',
                                                    :conditions => { :method => :get }
    wiki.blame     ':lang/*page/blame',             :action => 'blame',
                                                    :conditions => { :method => :get }
    wiki.connect   ':lang/',                        :action => 'show',
                                                    :conditions => { :method => :get },
                                                    :page => ['index']
    wiki.page      ':lang/*page.:format',           :action => 'show',
                                                    :conditions => { :method => :get }
    wiki.connect   ':lang/*page.:format',           :action => 'update',
                                                    :conditions => { :method => :post }

  end
end


text:
from .base_option import BaseOption
from nativeconfig.exceptions import DeserializationError, ValidationError

class FloatOption(BaseOption):
    """
    FloatOption represents Python float in config.

    """

    def __init__(self, name, **kwargs):
        """
        Accepts all the arguments of BaseConfig except choices.
        """
        super().__init__(name, **kwargs)

    def deserialize(self, raw_value):
        try:
            value = float(raw_value)
        except ValueError:
            raise DeserializationError("unable to deserialize '{}' into float".format(raw_value), raw_value, self.name)
        else:
            return value

    def deserialize_json(self, json_value):
        value = super().deserialize_json(json_value)

        if value is not None:
            if not isinstance(value, float):
                raise DeserializationError("'{}' is not a JSON float".format(json_value), json_value, self.name)
            else:
                return float(value)
        else:
            return None

    def validate(self, python_value):
        super().validate(python_value)

        if not isinstance(python_value, float):
            raise ValidationError("'{}' must be a float".format(python_value), python_value, self.name)