<commit_before>//
// Flump - Copyright 2013 Flump Authors

package flump.display {

import flash.utils.ByteArray;

import flump.executor.Executor;
import flump.executor.Future;

/**
 * Loads zip files created by the flump exporter and parses them into Library instances.
 */
public class LibraryLoader
{
    /**
     * Loads a Library from the zip in the given bytes.
     *
     * @param bytes The bytes containing the zip
     *
     * @param executor The executor on which the loading should run. If not specified, it'll run on
     * a new single-use executor.
     *
     * @param scaleFactor the desired scale factor of the textures to load. If the Library contains
     * textures with multiple scale factors, loader will load the textures with the scale factor
     * closest to this value. If scaleFactor <= 0 (the default), Starling.contentScaleFactor will be
     * used.
     * @param generateMipMaps If true (defaults to false), flump will instruct Starling to generate
     * mip maps for all loaded textures. Scaling will look better if mipmaps are enabled, but there
     * is a loading time and memory usage penalty.
     *
     * @return a Future to use to track the success or failure of loading the resources out of the
     * bytes. If the loading succeeds, the Future's onSuccess will fire with an instance of
     * Library. If it fails, the Future's onFail will fire with the Error that caused the
     * loading failure.
     */
    public static function loadBytes (bytes :ByteArray, executor :Executor=null,
        scaleFactor :Number=-1, generateMipMaps :Boolean=false) :Future {
        return (executor || new Executor(1)).submit(
            new Loader(bytes, scaleFactor, generateMipMaps).load);
    }

    /**
     * Loads a Library from the zip at the given url.
     *
     * @param bytes The url where the zip can be found
     *
     * @param executor The executor on which the loading should run. If not specified, it'll run on
     * a new single-use executor.
     *
     * @param scaleFactor the desired scale factor of the textures to load. If the Library contains
     * textures with multiple scale factors, loader will load the textures with the scale factor
     * closest to this value. If scaleFactor <= 0 (the default), Starling.contentScaleFactor will be
     * used.
     * @param generateMipMaps If true (defaults to false), flump will instruct Starling to generate
     * mip maps for all loaded textures. Scaling will look better if mipmaps are enabled, but there
     * is a loading time and memory usage penalty.
     *
     * @return a Future to use to track the success or failure of loading the resources from the
     * url. If the loading succeeds, the Future's onSuccess will fire with an instance of
     * Library. If it fails, the Future's onFail will fire with the Error that caused the
     * loading failure.
     */
    public static function loadURL (url :String, executor :Executor=null,
        scaleFactor :Number=-1, generateMipMaps :Boolean=false) :Future {
        return (executor || new Executor(1)).submit(
            new Loader(url, scaleFactor, generateMipMaps).load);
    }

    /** @private */
    public static const LIBRARY_LOCATION :String = "library.json";
    /** @private */
    public static const MD5_LOCATION :String = "md5";
    /** @private */
    public static const VERSION_LOCATION :String = "version";

    /**
     * @private
     * The version produced and parsable by this version of the code. The version in a resources
     * zip must equal the version compiled into the parsing code for parsing to succeed.
     */
    public static const VERSION :String = "2";
}

}

import deng.fzip.FZip;<commit_msg>Move LibraryLoader to a builder pattern.<commit_after>//
// Flump - Copyright 2013 Flump Authors

package flump.display {

import flash.utils.ByteArray;

import flump.executor.Executor;
import flump.executor.Future;

/**
 * Loads zip files created by the flump exporter and parses them into Library instances.
 */
public class LibraryLoader
{
    /**
     * Loads a Library from the zip in the given bytes.
     *
     * @deprecated Use a new LibraryLoader with the builder pattern instead.
     *
     * @param bytes The bytes containing the zip
     *
     * @param executor The executor on which the loading should run. If not specified, it'll run on
     * a new single-use executor.
     *
     * @param scaleFactor the desired scale factor of the textures to load. If the Library contains
     * textures with multiple scale factors, loader will load the textures with the scale factor
     * closest to this value. If scaleFactor <= 0 (the default), Starling.contentScaleFactor will be
     * used.
     *
     * @return a Future to use to track the success or failure of loading the resources out of the
     * bytes. If the loading succeeds, the Future's onSuccess will fire with an instance of
     * Library. If it fails, the Future's onFail will fire with the Error that caused the
     * loading failure.
     */
    public static function loadBytes (bytes :ByteArray, executor :Executor=null,
        scaleFactor :Number=-1) :Future {
        return new LibraryLoader().setExecutor(executor).setScaleFactor(scaleFactor)
            .loadBytes(bytes);
    }

    /**
     * Loads a Library from the zip at the given url.
     *
     * @deprecated Use a new LibraryLoader with the builder pattern instead.
     *
     * @param url The url where the zip can be found
     *
     * @param executor The executor on which the loading should run. If not specified, it'll run on
     * a new single-use executor.
     *
     * @param scaleFactor the desired scale factor of the textures to load. If the Library contains
     * textures with multiple scale factors, loader will load the textures with the scale factor
     * closest to this value. If scaleFactor <= 0 (the default), Starling.contentScaleFactor will be
     * used.
     *
     * @return a Future to use to track the success or failure of loading the resources from the
     * url. If the loading succeeds, the Future's onSuccess will fire with an instance of
     * Library. If it fails, the Future's onFail will fire with the Error that caused the
     * loading failure.
     */
    public static function loadURL (url :String, executor :Executor=null,
        scaleFactor :Number=-1) :Future {
        return new LibraryLoader().setExecutor(executor).setScaleFactor(scaleFactor)
            .loadURL(url);
    }

    /**
     * Sets the executor instance to use with this loader.
     *
     * @param executor The executor on which the loading should run. If left null (the default),
     * it'll run on a new single-use executor.
     */
    public function setExecutor (executor :Executor) :LibraryLoader {
        _executor = executor;
        return this;
    }

    /**
     * Sets the scale factor value to use with this loader.
     *
     * @param scaleFactor the desired scale factor of the textures to load. If the Library contains
     * textures with multiple scale factors, loader will load the textures with the scale factor
     * closest to this value. If scaleFactor <= 0 (the default), Starling.contentScaleFactor will be
     * used.
     */
    public function setScaleFactor (scaleFactor :Number) :LibraryLoader {
        _scaleFactor = scaleFactor;
        return this;
    }

    /**
     * Sets the mip map generation for this loader.
     *
     * @param generateMipMaps If true (defaults to false), flump will instruct Starling to generate
     * mip maps for all loaded textures. Scaling will look better if mipmaps are enabled, but there
     * is a loading time and memory usage penalty.
     */
    public function setGenerateMipMaps (generateMipMaps :Boolean) :LibraryLoader {
        _generateMipMaps = generateMipMaps;
        return this;
    }

    /**
     * Loads a Library from the zip in the given bytes, using the settings configured in this
     * loader.
     *
     * @param bytes The bytes containing the zip
     */
    public function loadBytes (bytes :ByteArray) :Future {
        return (_executor || new Executor(1)).submit(
            new Loader(bytes, _scaleFactor, _generateMipMaps).load);
    }

    /**
     * Loads a Library from the zip at the given url, using the settings configured in this
     * loader.
     *
     * @param url The url where the zip can be found
     */
    public function loadURL (url :String) :Future {
        return (_executor || new Executor(1)).submit(
            new Loader(url, _scaleFactor, _generateMipMaps).load);
    }

    /** @private */
    public static const LIBRARY_LOCATION :String = "library.json";
    /** @private */
    public static const MD5_LOCATION :String = "md5";
    /** @private */
    public static const VERSION_LOCATION :String = "version";

    /**
     * @private
     * The version produced and parsable by this version of the code. The version in a resources
     * zip must equal the version compiled into the parsing code for parsing to succeed.
     */
    public static const VERSION :String = "2";

    protected var _executor :Executor;
    protected var _scaleFactor :Number = -1;
    protected var _generateMipMaps :Boolean = false;
}

}

import deng.fzip.FZip;
{'fraction_non_alphanumeric': 0.07097400496170855, 'fraction_numerical': 0.0030201704239024916, 'mean_word_length': 2.778321108394458, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '249024', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2410, 'n_words': 1119}