<commit_before>var formidable = require('formidable')
  , util = require('util')
  , im = require('imagemagick')
  , fs = require('fs')
  , path = require('path')
  , mime = require('mime')
  , cloudfiles = require('cloudfiles')
  , http  = require('http')
  , url   = require('url')

var config_file = '../imager-example.json'
  , config = {}
  , client = undefined
  , container = undefined
  , uploaddir = undefined
  , storage_type = undefined
  , scope = undefined
  , cdnUri = undefined
  , uploadedFiles = []


var Imager = exports = module.exports = function Imager(options) {
  config_file = (typeof options['config_file'] === 'undefined') ? config_file : options['config_file']
  storage_type = options['storage']
  this.loadConfig(config_file)
  this.localFiles = false

  // throw an error if the rackspace auth settings are not defined
  if ( typeof (config['storage']['rs']) == 'undefined' )
    throw new TypeError("No storage defined in Imager config")

  for(storage in config['storage']) {
    this[storage + 'Setup'](config['storage'][storage])
  }
}


Imager.prototype = {

    url: function(file, version, callback) {
      var _file = this.genFileName( file, version )
      return this[storage_type + 'Url'](_file, callback)
    }

  , rsUrl: function(file, callback) {
      // authenticate your rackspace account
      client.setAuth(function() {
        // get the container
        client.getContainer(container, true, function (err, c) {
          // if there is any error, pass the error to the callback
          if (err) callback(err)
          // pass the url to the callback
          callback(null, c.cdnUri+'/'+file)
        })
      })
    }

  , genFileName: function(file, version) {
      return version + '_' + file
    }

  , remove: function(files, callback, _scope) {
      scope = (arguments.length == 3) ? _scope : undefined
      var self = this

      if (typeof(files) === 'string') {
        // remove the single file
        removeVariants(files)
      }
      else if (Array.isArray(files)) {
        // remove all the files in the given array
        try {
          files.forEach(function (file) {
            removeVariants(file)
          })
        }
        catch (e) {
          callback(e)
        }
      }
      else {
        // throw an error
        callback(new Error('You should pass a single file or an array of files'))
      }

      function removeVariants (file) {
        var _variants = self.setupVariants()
          , _resize = _variants['resize']
          , _crop = _variants['crop']

        // remove each variant specified in the resize settings
        for(version in _resize) {
          self[storage_type + 'Remove']( self.genFileName( file, version ),  function(err) {
            if (err) return callback(err)
          })
        }

        // remove each variant specified in the crop settings
        for(version in _crop) {
          self[storage_type + 'Remove']( self.genFileName( file, version ),  function(err) {
            if(err) return callback(err)
          })
        }
      }

      callback(null)
    }

  , rsRemove: function(file, callback) {
      // authenticate your rackspace account
      client.setAuth(function() {
        // get the container
        client.getContainer(container, true, function (err, c) {
          if (err) return callback(err)
          // remove the file from container
          c.removeFile(file, function(err){
            if (err) return callback(err)
            console.log('removed')
          })
        })
      })
    }

  , upload: function(req, callback, _scope) {<commit_msg>continue processing, don't return the err<commit_after>var formidable = require('formidable')
  , util = require('util')
  , im = require('imagemagick')
  , fs = require('fs')
  , path = require('path')
  , mime = require('mime')
  , cloudfiles = require('cloudfiles')
  , http  = require('http')
  , url   = require('url')

var config_file = '../imager-example.json'
  , config = {}
  , client = undefined
  , container = undefined
  , uploaddir = undefined
  , storage_type = undefined
  , scope = undefined
  , cdnUri = undefined
  , uploadedFiles = []


var Imager = exports = module.exports = function Imager(options) {
  config_file = (typeof options['config_file'] === 'undefined') ? config_file : options['config_file']
  storage_type = options['storage']
  this.loadConfig(config_file)
  this.localFiles = false

  // throw an error if the rackspace auth settings are not defined
  if ( typeof (config['storage']['rs']) == 'undefined' )
    throw new TypeError("No storage defined in Imager config")

  for(storage in config['storage']) {
    this[storage + 'Setup'](config['storage'][storage])
  }
}


Imager.prototype = {

    url: function(file, version, callback) {
      var _file = this.genFileName( file, version )
      return this[storage_type + 'Url'](_file, callback)
    }

  , rsUrl: function(file, callback) {
      // authenticate your rackspace account
      client.setAuth(function() {
        // get the container
        client.getContainer(container, true, function (err, c) {
          // if there is any error, pass the error to the callback
          if (err) callback(err)
          // pass the url to the callback
          callback(null, c.cdnUri+'/'+file)
        })
      })
    }

  , genFileName: function(file, version) {
      return version + '_' + file
    }

  , remove: function(files, callback, _scope) {
      scope = (arguments.length == 3) ? _scope : undefined
      var self = this

      if (typeof(files) === 'string') {
        // remove the single file
        removeVariants(files)
      }
      else if (Array.isArray(files)) {
        // remove all the files in the given array
        try {
          files.forEach(function (file) {
            removeVariants(file)
          })
        }
        catch (e) {
          callback(e)
        }
      }
      else {
        // throw an error
        callback(new Error('You should pass a single file or an array of files'))
      }

      function removeVariants (file) {
        var _variants = self.setupVariants()
          , _resize = _variants['resize']
          , _crop = _variants['crop']

        // remove each variant specified in the resize settings
        for(version in _resize) {
          self[storage_type + 'Remove']( self.genFileName( file, version ),  function(err) {
            if (err) return callback(err)
          })
        }

        // remove each variant specified in the crop settings
        for(version in _crop) {
          self[storage_type + 'Remove']( self.genFileName( file, version ),  function(err) {
            if(err) return callback(err)
          })
        }
      }

      callback(null)
    }

  , rsRemove: function(file, callback) {
      // authenticate your rackspace account
      client.setAuth(function() {
        // get the container
        client.getContainer(container, true, function (err, c) {
          if (err) return callback(err)
          // remove the file from container
          c.removeFile(file, function(err){
            if (err) console.log(err)
            console.log('removed')
          })
        })
      })
    }

  , upload: function(req, callback, _scope) {
{'fraction_non_alphanumeric': 0.12228335625859697, 'fraction_numerical': 0.0002751031636863824, 'mean_word_length': 2.2811371841155235, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4460100', 'n_tokens_mistral': 2090, 'n_tokens_neox': 2042, 'n_words': 566}