Code borrowed from StrictRedis so it can be fixed
353020
async def write(self):
        
        connection = self.connection
        commands = self.commands

        # We are going to clobber the commands with the write, so go ahead
        # and ensure that nothing is sitting there from a previous run.
        for c in commands:
            c.result = None

        # build up all commands into a single request to increase network perf
        # send all the commands and catch connection and timeout errors.
        try:
            await connection.send_packed_command(connection.pack_commands([c.args for c in commands]))
        except (ConnectionError, TimeoutError) as e:
            for c in commands:
                c.result = e
594363
function InvalidDerefInputError() {
    var instance = new Error("Deref can only be used with a non-primitive object from get, set, or call.");

    instance.name = "InvalidDerefInputError";

    if (Object.setPrototypeOf) {
        Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
    }

    if (Error.captureStackTrace) {
        Error.captureStackTrace(instance, InvalidDerefInputError);
    }

    return instance;
}
230178
function(code) {
    var modules = [];

    var lex = Espruino.Core.Utils.getLexer(code);
    var tok = lex.next();
    var state = 0;
    while (tok!==undefined) {
      if (state==0 && tok.str=="require") {
        state=1;
      } else if (state==1 && tok.str=="(") {
        state=2;
      } else if (state==2 && (tok.type=="STRING")) {
        state=0;
        var module = tok.value;
        if (!isBuiltIn(module) && modules.indexOf(module)<0)
          modules.push(module);
      } else
        state = 0;
      tok = lex.next();
    }

    return modules;
  }
964493
def rpc_fix_code(self, source, directory):
        
        source = get_source(source)
        return fix_code(source, directory)
1053744
def fixes=(fixes)
      raise TypeException unless fixes.is_a?(Array)
      fixes.each { |item|
        raise TypeException unless item.is_a?(StatModule::Fix)
        raise DuplicateElementException if @fixes.include?(item)
        @fixes.push(item)
      }
    end
1053696
function fixupCommand(options, callback) {
  if (!options.pmBaseDir) {
    if (fs.existsSync(path.resolve(options.cwd, '.strong-pm'))) {
      options.pmBaseDir = '.strong-pm';
    } else {
      options.pmBaseDir = '.';
    }
  }
  options.pmBaseDir = path.resolve(options.cwd, options.pmBaseDir);

  options.execpath = process.execPath;
  options.script = [
    require.resolve('../bin/sl-pm'),
    '--listen', options.pmPort,
    '--base', options.pmBaseDir,
    '--base-port', options.basePort,
    '--driver', options.driver,
  ].join(' ');

  return writeSeedEnvironment(options, callback);
}
148694
function compile(
  source,
  filename = '',
  includeModule = false,
  debugMode = false,
) {
  let res
  let resName
  let errors

  try {
    const [moduleName, bsCode, diagnosticErrors] = Retyped.compile(filename, source, debugMode)
    const fmtCode = format(bsCode)
    res = fmtCode
    resName = moduleName
    errors = diagnosticErrors
  } catch (e) {
    console.error(e)
    throw new Error(`${e[0][0]}`)
  }

  if (res.includes('SYNTAX ERROR>')) {
    throw new Error(res)
  }

  if (!includeModule) {
    return res
  } else {
    return {
      moduleName: resName,
      bsCode: res,
      diagnosticErrors: errors
    }
  }
}
23265
function forceCopy(fs, oldPath, newPath, callback) {
  fs.unlink(newPath, function(err) {
    if(err && err.code !== 'ENOENT') {
      return callback(err);
    }

    fs.readFile(oldPath, function(err, buf) {
      if(err) {
        return callback(err);
      }

      fs.writeFile(newPath, buf, callback);
    });
  });
}
109317
function parseForESLint(code, options) {
    const opts = options || {}
    if (!isHtmlFile(code, opts)) {
        return parseScript(code, opts)
    }
    return parseTemplate(code, opts)
}
31995
def fork(self, strictindex, new_value):
        
        forked_chunk = YAMLChunk(
            deepcopy(self._ruamelparsed),
            pointer=self.pointer,
            label=self.label,
            key_association=copy(self._key_association),
        )
        forked_chunk.contents[self.ruamelindex(strictindex)] = new_value.as_marked_up()
        forked_chunk.strictparsed()[strictindex] = deepcopy(new_value.as_marked_up())
        return forked_chunk
29037
def redis(self):
        """"""
        if self._redis is None:
            self._redis = redis.StrictRedis(host=self.args.redis_host, port=self.args.redis_port)
        return self._redis
928668
function forcelink(src, dest, options, callback) {
    if (!options || !options.cache) throw new Error('options.cache not defined!');
    if (!callback) throw new Error('callback not defined!');
    // uses relative path if linking to cache dir
    if (path.relative) {
        src = path.relative(options.cache, dest).slice(0, 2) !== '..' ? path.relative(path.dirname(dest), src) : src;
    }
    fs.lstat(dest, function(err, stat) {
        // Error.
        if (err && err.code !== 'ENOENT') {
            return callback(err);
        }

        // Path does not exist. Symlink.
        if (err && err.code === 'ENOENT') {
            if (env == 'development') console.error("[millstone] linking '" + dest + "' -> '"  + src + "'");
            return fs.symlink(src, dest, callback);
        }

        // Path exists and is not a symlink. Do nothing.
        if (!stat.isSymbolicLink()) {
            if (env == 'development') console.error("[millstone] skipping re-linking '" + src + "' because '"  + dest + " is already an existing file");
            return callback();
        }

        // Path exists and is a symlink. Check existing link path and update if necessary.
        // NOTE : broken symlinks will pass through this step
        fs.readlink(dest, function(err, old) {
            if (err) return callback(err);
            if (old === src) return callback();
            fs.unlink(dest, function(err) {
                if (err) return callback(err);
                if (env == 'development') console.error("[millstone] re-linking '" + dest + "' -> '"  + src + "'");
                fs.symlink(src, dest, callback);
            });
        });
    });
}
546048
function() {
      'use strict';
      var filesToCopy = {
         'control.json': 'control.json',
         'gitignore': '.gitignore',
         'default.theme/css/control.css': 'default.theme/css/' + this.placeholder.name + '.css'
      };
      var integrationTechnology = this.placeholder.laxarIntegrationTechnology;

      if( this.placeholder.infrastructure ) {
         filesToCopy[ 'README.md' ] = 'README.md';
         if( integrationTechnology === 'react' ) {
            filesToCopy[ 'bower.react.json' ] = 'bower.json';
         }
         else {
            filesToCopy[ 'bower.json' ] = 'bower.json';
         }
      }


      if( integrationTechnology === 'plain' ) {
         filesToCopy[ 'control.plain.js' ] = this.placeholder.name + '.js';
      }
      else if( integrationTechnology === 'angular' ) {
         filesToCopy[ 'control.angular.js' ] = this.placeholder.name + '.js';
      }
      else if( integrationTechnology === 'react' ) {
         filesToCopy[ 'control.react.jsx' ] = this.placeholder.name + '.jsx';
      }

      for( var file in filesToCopy ) {
         if( filesToCopy.hasOwnProperty( file ) ) {
            this.fs.copyTpl(
               this.templatePath( file ),
               this.destinationPath(
                  path.join( this.controlDirname, this.placeholder.name, filesToCopy[ file ] )
               ),
               this.placeholder
            );
         }
      }
   }
267063
def fix_code(code, directory):
    
    if not yapf_api:
        raise Fault('yapf not installed', code=400)
    style_config = file_resources.GetDefaultStyleForDir(directory or os.getcwd())
    try:
        reformatted_source, _ = yapf_api.FormatCode(code,
                                                    filename='<stdin>',
                                                    style_config=style_config,
                                                    verify=False)
        return reformatted_source
    except Exception as e:
            raise Fault("Error during formatting: {}".format(e),
                        code=400)
1242670
function parseError(e) {
  if(e.ns === 'STORE.REDIS') return true;
  if(e.code && e.code.indexOf('REDIS') === 0) {
    e.ns = 'STORE.REDIS';
    return true;
  }
}
309306
def validate(self, value, redis):
        '''
        
        '''
        # cleanup
        if type(value) == str:
            value = value.strip()

        value = self.value_or_default(value)

        # validation
        self.validate_required(value)

        if self.regex and not re.match(self.regex, value, flags=re.ASCII):
            raise InvalidFieldError(self.name)

        if self.forbidden and value in self.forbidden:
            raise ReservedFieldError(self.name)

        if self.allowed and value not in self.allowed:
            raise InvalidFieldError(self.name)

        if self.index:
            key = self.key()

            old = debyte_string(redis.hget(key, value))
            old_value = getattr(self.obj, self.name)

            if old is not None and old != self.obj.id:
                raise NotUniqueFieldError(self.name)
            elif old_value != value:
                self.obj._old[self.name] = old_value

        return value
951005
function(err) {
        var file = fs.realpathSync(this.file);
        if (!err) {
            this.console.info('Compiled code saved to', file);
        } else {
            this.console.info('Saving code failed to', file);
        }
    }