Factory function that lazily creates the guarded TFile class, and creates and returns an
    instance with all passed *args* and *kwargs*. This is required as we do not want to import ROOT
    in the global scope.
511092
def GuardedTFile(*args, **kwargs):
    
    global guarded_tfile_cls

    if not guarded_tfile_cls:
        import ROOT

        class GuardedTFile(ROOT.TFile):

            def __enter__(self):
                return self

            def __exit__(self, exc_type, exc_value, traceback):
                if self.IsOpen():
                    self.Close()

        guarded_tfile_cls = GuardedTFile

    return guarded_tfile_cls(*args, **kwargs)
930761
def make(self, src_templ, evaldict=None, addsource=False, **attrs):
        ""
        src = src_templ % vars(self) # expand name and signature
        evaldict = evaldict or {}
        mo = DEF.match(src)
        if mo is None:
            raise SyntaxError('not a valid function template\n%s' % src)
        name = mo.group(1) # extract the function name
        names = set([name] + [arg.strip(' *') for arg in
                             self.shortsignature.split(',')])
        for n in names:
            if n in ('_func_', '_call_'):
                raise NameError('%s is overridden in\n%s' % (n, src))
        if not src.endswith('\n'): # add a newline just for safety
            src += '\n' # this is needed in old versions of Python
        try:
            code = compile(src, '<string>', 'single')
            # print >> sys.stderr, 'Compiling %s' % src
            exec(code, evaldict)
        except:
            print('Error in generated code:', file=sys.stderr)
            print(src, file=sys.stderr)
            raise
        func = evaldict[name]
        if addsource:
            attrs['__source__'] = src
        self.update(func, **attrs)
        return func
1369430
def create(self):
        
        fdint = os.open(self.path, (os.O_EXCL |
                                    os.O_CREAT |
                                    os.O_RDWR))

        # XXX TODO: 'name' attribute of returned files is not mutable or
        # settable via fdopen, so this file is slighly less functional than the
        # one returned from 'open' by default.  send a patch to Python...

        return os.fdopen(fdint, 'w+b')
1252854
def create(obj: PersistedObject, obj_type: Type[Any], arg_name: str):
        

        return MissingMandatoryAttributeFiles('Multifile object ' + str(obj) + ' cannot be built from constructor of '
                                              'type ' + get_pretty_type_str(obj_type) +
                                              ', mandatory constructor argument \'' + arg_name + '\'was not found on '
                                              'filesystem')
964996
def create(self, **kwargs):
        
        obj = self.resource(**kwargs)
        obj.save(force_insert=True)
        return obj
738255
@Override
    public <T> T createSpyComponent(final T instance) {
        checkArgument(instance != null, "instance must not be null!");
        if (isFinalOrPrimitive(instance.getClass())) {
            LOG.warn("Skipping creation of a spy : {} as it is final or primitive type.", instance.getClass()
                    .getSimpleName());
            return null;
        }
        return Mockito.spy(instance);
    }
53141
public static function create()
	{
		switch (func_num_args()) {
			case 0:
				return new FileOptions();
			case 1:
				return new FileOptions(func_get_arg(0));
			case 2:
				return new FileOptions(func_get_arg(0), func_get_arg(1));
			case 3:
				return new FileOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2));
			case 4:
				return new FileOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
			case 5:
				return new FileOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
			case 6:
				return new FileOptions(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 FileOptions(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 FileOptions(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.');
		}
	}
997441
def _getOrCreate(cls):
        
        if not isinstance(cls._taskContext, BarrierTaskContext):
            cls._taskContext = object.__new__(cls)
        return cls._taskContext
497793
def instantiate(self, scope, args, interp):
        
        param_instances = []

        BYREF = "byref"

        # TODO are default values for function parameters allowed in 010?
        for param_name, param_cls in self._params:
            # we don't instantiate a copy of byref params
            if getattr(param_cls, "byref", False):
                param_instances.append(BYREF)
            else:
                field = param_cls()
                field._pfp__name = param_name
                param_instances.append(field)

        if len(args) != len(param_instances):
            raise errors.InvalidArguments(
                self._coords,
                [x.__class__.__name__ for x in args],
                [x.__class__.__name__ for x in param_instances]
            )

        # TODO type checking on provided types

        for x in six.moves.range(len(args)):
            param = param_instances[x]
             
            # arrays are simply passed through into the function. We shouldn't
            # have to worry about frozenness/unfrozenness at this point
            if param is BYREF or isinstance(param, pfp.fields.Array):
                param = args[x]
                param_instances[x] = param
                scope.add_local(self._params[x][0], param)
            else:
                param._pfp__set_value(args[x])
                scope.add_local(param._pfp__name, param)
            param._pfp__interp = interp

        return ParamList(param_instances)
859149
def func_factory(p, method: str) -> callable:
    

    def callback(pretty: bool = False):
        res = getattr(p, method)
        dump = partial(json.dumps, indent=4) if pretty else partial(json.dumps)
        click.echo(dump(res))

    return callback
1246936
def class_sealer(fields, defaults,
                 base=__base__, make_init_func=make_init_func,
                 initializer=True, comparable=True, printable=True, convertible=False, pass_kwargs=False):
    
    baseclass_name = 'FieldsBase_for__{0}'.format('__'.join(fields))
    if pass_kwargs:
        options = dict(
            header_end=', **__fields_kwargs__):\n',
            super_call_end=', **__fields_kwargs__)\n',
            super_call_pass_allargs=False,
        )
    else:
        options = {}

    if initializer:
        global_namespace, local_namespace = make_init_func(fields, defaults, baseclass_name, **options)

    class FieldsBase(base):
        if initializer:
            __init__ = local_namespace['__init__']

        if comparable:
            def __eq__(self, other):
                if isinstance(other, self.__class__):
                    return tuple(getattr(self, a) for a in fields) == tuple(getattr(other, a) for a in fields)
                else:
                    return NotImplemented

            def __ne__(self, other):
                result = self.__eq__(other)
                if result is NotImplemented:
                    return NotImplemented
                else:
                    return not result

            def __lt__(self, other):
                if isinstance(other, self.__class__):
                    return tuple(getattr(self, a) for a in fields) < tuple(getattr(other, a) for a in fields)
                else:
                    return NotImplemented

            def __le__(self, other):
                if isinstance(other, self.__class__):
                    return tuple(getattr(self, a) for a in fields) <= tuple(getattr(other, a) for a in fields)
                else:
                    return NotImplemented

            def __gt__(self, other):
                if isinstance(other, self.__class__):
                    return tuple(getattr(self, a) for a in fields) > tuple(getattr(other, a) for a in fields)
                else:
                    return NotImplemented

            def __ge__(self, other):
                if isinstance(other, self.__class__):
                    return tuple(getattr(self, a) for a in fields) >= tuple(getattr(other, a) for a in fields)
                else:
                    return NotImplemented

            def __hash__(self):
                return hash(tuple(getattr(self, a) for a in fields))

        if printable:
            def __repr__(self):
                return "{0}({1})".format(
                    self.__class__.__name__,
                    ", ".join("{0}={1}".format(attr, repr(getattr(self, attr))) for attr in fields)
                )
        if convertible:
            @property
            def as_dict(self):
                return dict((attr, getattr(self, attr)) for attr in fields)

            @property
            def as_tuple(self):
                return tuple(getattr(self, attr) for attr in fields)

    if initializer:
        global_namespace[baseclass_name] = FieldsBase
    return FieldsBase
746579
def _create(self, **kwargs):
        '''
        '''

        try:
            return super(Service, self)._create(**kwargs)
        except HTTPError as ex:
            if "The configuration was updated successfully but could not be " \
                    "retrieved" not in ex.response.text:
                raise

            # BIG-IP® will create in Common partition if none is given.
            # In order to create the uri properly in this class's load,
            # drop in Common as the partition in kwargs.
            if 'partition' not in kwargs:
                kwargs['partition'] = 'Common'
            # Pop all but the necessary load kwargs from the kwargs given to
            # create. Otherwise, load may fail.
            kwargs_copy = kwargs.copy()
            for key in kwargs_copy:
                if key not in self._meta_data['required_load_parameters']:
                    kwargs.pop(key)
            # If response was created successfully, do a local_update.
            # If not, call to overridden _load method via load
            return self.load(**kwargs)
627117
def _instance(self, cls, *args, **kwargs):
        
        logger.debug(f'args: {args}, kwargs: {kwargs}')
        return cls(*args, **kwargs)
746684
def singleton(wrapped, _, args, kwargs):
    
    if wrapped not in _INSTANCES:
        _INSTANCES[wrapped] = wrapped(*args, **kwargs)
    return _INSTANCES[wrapped]
1287831
def new(cls, arg):
        
        content = None

        if arg.kind == 'file':
            if os.path.exists(arg.value):
                with open(arg.value, 'r') as f:
                    content = f.read()
            else:
                raise Exception('File does not exist: {}'.format(arg.value))
        elif arg.kind == 'cli':
            content = arg.value

        for source_cls in cls.sources:
            if source_cls.supports_source(arg):
                return source_cls(content)

        msg = 'Unsupported Parameter Source "{}"'
        raise Execption(msg.format(arg.value))
113787
def create(self, type_, **kwargs):
        
        obj = self.factory.create("ns0:%s" % type_)
        for key, value in kwargs.items():
            setattr(obj, key, value)
        return obj
296469
def factory(fileobject, jfs, parentpath): # fileobject from lxml.objectify
        ''
        if hasattr(fileobject, 'currentRevision'): # a normal file
            return JFSFile(fileobject, jfs, parentpath)
        elif str(fileobject.latestRevision.state) == ProtoFile.STATE_INCOMPLETE:
            return JFSIncompleteFile(fileobject, jfs, parentpath)
        elif str(fileobject.latestRevision.state) == ProtoFile.STATE_CORRUPT:
            return JFSCorruptFile(fileobject, jfs, parentpath)
        else:
            raise NotImplementedError('No JFS*File support for state %r. Please file a bug!' % fileobject.latestRevision.state)