Convenience function for returning the right FBA problem instance
550078
def _get_fba_problem(model, tfba, solver):
    """"""
    p = FluxBalanceProblem(model, solver)
    if tfba:
        p.add_thermodynamic()
    return p
373551
def fval(self, instance):
        """"""
        try:
            val = instance.__dict__[self.instance_field_name]
        except KeyError as e:
            #raise AttributeError(str(e))
            val = None

        return val
50588
def fn_getma(fn, bnum=1, return_ds=False):
    
    #Add check for filename existence
    ds = fn_getds(fn)
    out = ds_getma(ds, bnum=bnum)
    if return_ds:
        out = (out, ds)
    return out
1199718
function(accountsError, accountsResult) {
        const fixedAccountsResult = accountsResult.slice(0);

        // if no error, fixed result
        if (!accountsError) {
          fixedAccountsResult.map(function(item) {
            return String(item.toLowerCase());
          });
        }

        // fire oldd callback with new fix
        oldCallback(accountsError, fixedAccountsResult);
      }
1327559
function (type, fn) {
  var result;
  try {
    result = fn();
  }
  catch (e) {
    result = {error: e};
  }

  if (result && !result.type && type)
    result.type = type;

  return result;
}
585819
function fc() {
        for (var _len = arguments.length, params = Array(_len), _key = 0; _key < _len; _key++) {
            params[_key] = arguments[_key];
        }

        return createFrontendConnector(parametrize(c, params), debug);
    }
964722
def checkForSpiceError(f):
    
    if failed():
        errorparts = {
            "tkvsn": tkvrsn("TOOLKIT").replace("CSPICE_", ""),
            "short": getmsg("SHORT", 26),
            "explain": getmsg("EXPLAIN", 100).strip(),
            "long": getmsg("LONG", 321).strip(),
            "traceback": qcktrc(200)}
        msg = stypes.errorformat.format(**errorparts)
        reset()
        raise stypes.SpiceyError(msg)
98949
function (/*util*/) {

      function compare(actual, expected) {
        return {
          pass: actual instanceof Error && ('' + actual).indexOf(expected) >= 0
        }
      }

      return {compare: compare}
    }
2643
function customError(name, error) {
  return {
    error: error,
    message: error.message,
    name: name
  };
}
319351
function getError (type, expected, actual) {
        return {
            attribute: type,
            expected: expected,
            actual: actual,
            message: getMsg(type, expected)
        };
    }
926576
def _only_if_file_not_exist(func_, *args, **kwargs):
    
    obj_dict = args[1]
    conn = args[-1]
    try:
        RBF.get(obj_dict[PRIMARY_FIELD]).pluck(PRIMARY_FIELD).run(conn)
        err_str = "Duplicate primary key `Name`: {}".format(obj_dict[PRIMARY_FIELD])
        err_dict = {'errors': 1,
                    'first_error':  err_str}
        return err_dict
    except r.errors.ReqlNonExistenceError:
        return func_(*args, **kwargs)
1038071
def dont_crash(fn):
    

    def safe_exec(self, *args, **kwargs):
        try:
            return fn(self, *args, **kwargs)
        except Exception as e:
            logging.exception(e)
            QMessageBox.information(
                self, type(e).__name__, " ".join(str(x) for x in e.args)
            )

    return safe_exec
232438
def getApplicationsErrorNameFromEnum(self, error):
        """"""

        fn = self.function_table.getApplicationsErrorNameFromEnum
        result = fn(error)
        return result
804091
def check(*args, **kwds):
  
  def wrapper(checkfunc):
    return wraps(checkfunc)(FontBakeryCheck(checkfunc, *args, **kwds))
  return wrapper
1236209
def handle_g_error(error, return_value):
    
    error = error[0]
    assert bool(return_value) == (error == ffi.NULL)
    if error != ffi.NULL:
        if error.message != ffi.NULL:
            message = ('Pixbuf error: ' +
                       ffi.string(error.message).decode('utf8', 'replace'))
        else:  # pragma: no cover
            message = 'Pixbuf error'
        glib.g_error_free(error)
        raise ImageLoadingError(message)
292061
def friendly_fqcn(cls_name):
    
    if isinstance(cls_name, type):
        cls_name = fqcn(cls_name)

    return cls_name.rsplit(".", 1)[-1]
127349
def fn_available_argcount(callable):
    
    fn = get_fn_or_method(callable)
    if _inspect.isfunction(fn):
        return fn.__code__.co_argcount
    else: # method
        if fn.__self__ is None:
            return fn.__func__.__code__.co_argcount
        else:
            return fn.__func__.__code__.co_argcount - 1