Recreate the class based in your args, multiple uses
330080
def recreate(cls, *args, **kwargs):
        """"""
        cls.check_arguments(kwargs)
        first_is_callable = True if any(args) and callable(args[0]) else False
        signature = cls.default_arguments()
        allowed_arguments = {k: v for k, v in kwargs.items() if k in signature}
        if (any(allowed_arguments) or any(args)) and not first_is_callable:
            if any(args) and not first_is_callable:
                return cls(args[0], **allowed_arguments)
            elif any(allowed_arguments):
                return cls(**allowed_arguments)

        return cls.instances[-1] if any(cls.instances) else cls()
1364196
def generate_classes(self, items):
        ""
        classes = set()
        for c in items: classes = classes.union(set(c))
        classes = list(classes)
        classes.sort()
        return classes
767096
def init_args(cls):
    
    # This looks insanely goofy, but seems to literally be the
    # only thing that actually works.  Your obvious ways to
    # accomplish this task do not apply here.
    try:
        # Assume it's a factory function, static method, or other callable
        argspec = getargspec(cls)
    except TypeError:
        # assume it's a class
        argspec = getargspec(cls.__init__)
    args = argspec.args

    # Note:  There is a special place in hell for people who don't
    #        call the first method argument 'self'.
    if args[0] == 'self':
        args.remove('self')

    return args
928521
def factory(cls, class_name):
        
        class_name = str(class_name.lstrip('_'))
        types = ParseResource.__subclasses__()
        while types:
            t = types.pop()
            if t.__name__ == class_name:
                return t
            types.extend(t.__subclasses__())
        else:
            return type(class_name, (Object,), {})
1191712
def arg(*args, **kwargs):
    
    def decorate(func):
        """
        Decorate
        """
        # we'll set the command name with the passed cmd_name argument, if
        # exist, else the command name will be the function name
        func.__cmd_name__ = kwargs.pop(
            'cmd_name', getattr(func, '__cmd_name__', func.__name__))
        # retrieve the class (SillyClass)
        func.__cls__ = utils.check_class()
        if not hasattr(func, '__arguments__'):
            # if the funcion hasn't the __arguments__ yet, we'll setup them
            # using get_functarguments.
            func.__arguments__ = utils.get_functarguments(func)
        if len(args) or len(kwargs):
            # if we have some argument or keyword argument
            # we'll try to get the destination name from the kwargs ('dest')
            # else we'll use the last arg name as destination
            arg_name = kwargs.get(
                'dest', args[-1].lstrip('-').replace('-', '_'))
            try:
                # we try to get the command index.
                idx = func.__named__.index(arg_name)
                # and delete it from the named list
                del func.__named__[idx]
                # and delete it from the arguments list
                del func.__arguments__[idx]
            except ValueError:
                pass
            # append the args and kwargs to the function arguments list
            func.__arguments__.append((args, kwargs,))
        if func.__cls__ is None and isinstance(func, types.FunctionType):
            # if the function don't have a class and is a FunctionType
            # we'll add it directly to he commands list.
            ap_ = ArgParseInator(skip_init=True)
            if func.__cmd_name__ not in ap_.commands:
                # we'll add it if not exists
                ap_.commands[func.__cmd_name__] = func
        return func
    return decorate
967837
def remap_args(input_args, remap):
    
    out_args = input_args
    for dest_key, src_keys in remap.items():
        remap_value = None
        if isinstance(src_keys, str):
            src_keys = [src_keys]

        for key in src_keys:
            if key in input_args:
                remap_value = input_args[key]
                break

        if remap_value is not None:
            if out_args is input_args:
                out_args = {**input_args}
            out_args[dest_key] = remap_value

    return out_args
1131093
public static function create()
	{
		switch (func_num_args()) {
			case 0:
				return new ClassWithFixed64Property();
			case 1:
				return new ClassWithFixed64Property(func_get_arg(0));
			case 2:
				return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1));
			case 3:
				return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2));
			case 4:
				return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
			case 5:
				return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
			case 6:
				return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
			case 7:
				return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
			case 8:
				return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
			default:
				throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
		}
	}
1187586
def _create_class_proxy(cls, theclass):
        """"""

        def make_method(name):
            def method(self, *args, **kw):
                return getattr(object.__getattribute__(self, "_obj"), name)(*args, **kw)
            return method

        namespace = {}
        for name in cls._special_names:
            if hasattr(theclass, name):
                namespace[name] = make_method(name)
        return type("%s(%s)" % (cls.__name__, theclass.__name__), (cls,), namespace)
846934
def _arg(__decorated__, **Config):
  
  """
  if isinstance(__decorated__, tuple):  # this decorator is followed by another arg decorator
    __decorated__[1].insert(0, Config)
    return __decorated__

  else:
    return __decorated__, [Config]
752969
def instantiate(self, cls=None):
        
        if cls is None:
            cls = self.cls
        if cls is None:
            raise TypeError("cls must a class")
        return cls.create(*self.args, **self.kwargs)
1198260
public static function create()
	{
		switch (func_num_args()) {
			case 0:
				return new ClassWithStringProperty();
			case 1:
				return new ClassWithStringProperty(func_get_arg(0));
			case 2:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1));
			case 3:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2));
			case 4:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
			case 5:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
			case 6:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
			case 7:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
			case 8:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
			default:
				throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
		}
	}
1003513
def swap_args(self, new_args, new_length=None):
        

        if len(self.args) == len(new_args) and all(a is b for a,b in zip(self.args, new_args)):
            return self

        #symbolic = any(a.symbolic for a in new_args if isinstance(a, Base))
        #variables = frozenset.union(frozenset(), *(a.variables for a in new_args if isinstance(a, Base)))
        length = self.length if new_length is None else new_length
        a = self.__class__(self.op, new_args, length=length)
        #if a.op != self.op or a.symbolic != self.symbolic or a.variables != self.variables:
        #   raise ClaripyOperationError("major bug in swap_args()")
        return a
1164189
def generate_from_args(self, *args):
        
        if len(args) != len(self.variable_args):
            raise ValueError("variable argument length mismatch")
        return self.generate(**dict(zip(self.variable_args, args)))
176149
private function generateWrapperClass(): void
  {
    $this->io->title('Wrapper');

    /** @var NameMangler $mangler */
    $mangler  = new $this->nameMangler();
    $routines = $this->readRoutineMetadata();

    if (!empty($routines))
    {
      // Sort routines by their wrapper method name.
      $sorted_routines = [];
      foreach ($routines as $routine)
      {
        $method_name                   = $mangler->getMethodName($routine['routine_name']);
        $sorted_routines[$method_name] = $routine;
      }
      ksort($sorted_routines);

      // Write methods for each stored routine.
      foreach ($sorted_routines as $method_name => $routine)
      {
        // If routine type is hidden don't create routine wrapper.
        if ($routine['designation']!='hidden')
        {
          $this->writeRoutineFunction($routine, $mangler);
        }
      }
    }
    else
    {
      echo "No files with stored routines found.\n";
    }

    $wrappers        = $this->codeStore->getRawCode();
    $this->codeStore = new PhpCodeStore();

    // Write the header of the wrapper class.
    $this->writeClassHeader();

    // Write methods of the wrapper calls.
    $this->codeStore->append($wrappers, false);

    // Write the trailer of the wrapper class.
    $this->writeClassTrailer();

    // Write the wrapper class to the filesystem.
    $this->storeWrapperClass();
  }
335769
def create(clazz, *args)
      raise ArgumentError, "#{clazz} is not a class" unless clazz.is_a?(Class)
      inject(clazz.new(*args))
    end
848502
public static ApplicationContext run(Class cls, String... args) {
        return run(new Class[]{cls}, args);
    }
288233
def parametrized_class(decorator):
    ''''''

    def decorator_builder(*args, **kwargs):

        def meta_decorator(cls):
            return decorator(cls, *args, **kwargs)

        return meta_decorator

    return decorator_builder