Args: (Model) $obj
505701
public static function getId($obj) {
		// Valid Eloquent Model Inheritance?
		if (method_exists($obj, 'getKey') && $key = $obj->getKey()) {
			if (!empty($key)) return $obj->getKey();
		}
		// Catch Generic
		if (isset($obj['id'])) return $obj['id'];
		if (isset($obj['_id'])) return $obj['_id'];
		if (isset($obj['$id'])) return $obj['$id'];
		// Else
		throw new \UnexpectedValueException('Invalid model object received: no primary ID (id, _id, $id)');
 	}
967048
def getargs(obj):
    """"""
    if inspect.isfunction(obj) or inspect.isbuiltin(obj):
        func_obj = obj
    elif inspect.ismethod(obj):
        func_obj = get_meth_func(obj)
    elif inspect.isclass(obj) and hasattr(obj, '__init__'):
        func_obj = getattr(obj, '__init__')
    else:
        return []
    if not hasattr(func_obj, 'func_code'):
        # Builtin: try to extract info from doc
        args = getargsfromdoc(func_obj)
        if args is not None:
            return args
        else:
            # Example: PyQt5
            return getargsfromdoc(obj)
    args, _, _ = inspect.getargs(func_obj.func_code)
    if not args:
        return getargsfromdoc(obj)
    
    # Supporting tuple arguments in def statement:
    for i_arg, arg in enumerate(args):
        if isinstance(arg, list):
            args[i_arg] = "(%s)" % ", ".join(arg)
            
    defaults = get_func_defaults(func_obj)
    if defaults is not None:
        for index, default in enumerate(defaults):
            args[index+len(args)-len(defaults)] += '='+repr(default)
    if inspect.isclass(obj) or inspect.ismethod(obj):
        if len(args) == 1:
            return None
        if 'self' in args:
            args.remove('self')
    return args
823877
def as_ppmodel(cls, obj):
        
        if isinstance(obj, cls):
            return obj

        # obj is a string
        if ":" not in obj:
            mode, plasmon_freq = obj, None
        else:
            # Extract mode and plasmon_freq
            mode, plasmon_freq = obj.split(":")
            try:
                plasmon_freq = float(plasmon_freq)
            except ValueError:
                plasmon_freq, unit = plasmon_freq.split()
                plasmon_freq = units.Energy(float(plasmon_freq), unit).to("Ha")

        return cls(mode=mode, plasmon_freq=plasmon_freq)
1269091
function cast($obj=NULL) {
		if (!$obj)
			$obj=$this;
		return $obj->document+['_id'=>$this->id];
	}
986648
function(obj) {
      if (obj == null) return void 0;
      var id = this.modelId(this._isModel(obj) ? obj.attributes : obj);
      return this._byId[obj] || this._byId[id] || this._byId[obj.cid];
    }
423856
function ( obj, arg ) {
		if ( arg === undefined ) {
			return obj.innerHTML;
		}
		else {
			 obj.innerHTML = arg;
			 return obj;
		}
	}
1314415
public function getAttr($obj, $attr, $args = [])
    {
        if (is_array($obj)) {
            if (isset($obj[$attr])) {
                if ($obj[$attr] instanceof \Closure) {
                    if (is_array($args)) {
                        array_unshift($args, $obj);
                    } else {
                        $args = [$obj];
                    }

                    return call_user_func_array($obj[$attr], $args);
                }

                return $obj[$attr];
            }

            return null;
        } elseif (is_object($obj)) {
            if (is_array($args)) {
                $callable = [$obj, $attr];

                return is_callable($callable) ?
                    call_user_func_array($callable, $args) : null;
            }
            $members = array_keys(get_object_vars($obj));
            $methods = get_class_methods(get_class($obj));
            if (in_array($attr, $members)) {
                return @$obj->$attr;
            } elseif (in_array('__get', $methods)) {
                return $obj->__get($attr);
            }
            $callable = [$obj, $attr];

            return is_callable($callable) ?
                call_user_func($callable) : null;
        }

        return null;
    }
144902
public function before_update(Model $obj)
	{
		// determine the slug
		$properties = (array) $this->_source;
		$source = '';
		foreach ($properties as $property)
		{
			$source .= $this->_separator.$obj->{$property};
		}
		$slug = \Inflector::friendly_title(substr($source, 1), $this->_separator, true);

		// update it if it's different from the current one
		// and is not manually assigned
		if ($obj->{$this->_property} !== $slug)
		{
			$overwrite = $this->_overwrite;

			if ($overwrite === false and ! $obj->is_changed($this->_property))
			{
				$this->_overwrite = true;
			}

			$this->before_insert($obj);

			$this->_overwrite = $overwrite;
		}
	}
355251
function ( obj, arg ) {
		array.each( arg.replace( /\]$/, "" ).replace( /\]/g, "." ).replace( /\.\./g, "." ).split( /\.|\[/ ), function ( i ) {
			obj = obj[i];
		});

		return obj;
	}
84624
def dump(obj, fp, **kwargs):
    """"""

    s = dumps(obj, **kwargs)
    fp.write(str(s))
247816
def render(self, obj, opt=None):
        
        opt = self.default() if opt == None else opt
        if not isinstance(opt, dict):
            raise ValueError('Not a dict: {0}'.format(opt))

        if isinstance(obj, Parameter):
            if getattr(obj, 'in', None) == 'body':
                return self._generate(obj.schema, opt)
            return self._generate(obj, opt=opt)
        elif isinstance(obj, Schema):
            return self._generate(obj, opt)
        else:
            raise ValueError('Not a Schema/Parameter: {0}'.format(obj))
974732
public function assign($obj, ...$args)
    {
        if(is_object($obj)){
            foreach($args as &$source){
                if (!isset($source)) continue;

                if ( !is_object($source) ) {
                    throw new \Exception($source . 'must be object');
                }
                foreach($source as $key=>&$val){
                    $obj->{$key} = $source->{$key};
                }
            }
        }else{
            throw new \Exception("Utlis::assign() parameter 1 by not object");
        }

        return $obj;
    }
461800
function ( obj, arg ) {
		if ( !array.contains( obj, arg ) ) {
			obj.push( arg );
		}

		return obj;
	}
1146920
static function object2array($obj)
    {
        $arr = [];
        foreach ($obj as $key => $value) {
            $arr[$key] = is_object($value) ? static::object2array($value) : $value;
        }
        return $arr;
    }
1274813
def cli(obj):
    """"""
    for k, v in obj.items():
        if isinstance(v, list):
            v = ', '.join(v)
        click.echo('{:20}: {}'.format(k, v))
906740
def or_(cls, obj, **kwargs):
        
        return cls.__eval_seqexp(obj, operator.or_, **kwargs)
91403
def parse_args():
  """"""
  parser = ArgumentParser(description="ModelBase builder")
  subparsers = parser.add_subparsers()

  sql_parser = subparsers.add_parser(
    "get-query",
    description="Usage: e.g. psql -c \"copy ($(python3 lib/generate_models.py get-query)) to " +
                "stdout with csv header\" DB_NAME postgres")
  sql_parser.set_defaults(func=print_sql_query)

  gen_parser = subparsers.add_parser("generate")
  gen_parser.add_argument("filename", nargs="?", help="Read this file for input, or STDIN if not " \
                                                      "given")
  gen_parser.add_argument("-i", "--indent", default="  ")
  gen_parser.add_argument("-c", "--created-at-col-name", default="created_at")
  gen_parser.add_argument("-u", "--updated-at-col-name", default="updated_at")
  gen_parser.set_defaults(func=generate_models)

  args = parser.parse_args()

  if hasattr(args, "func"):
    return args
  else:
    arg_parser.print_help()
    sys.exit(1)