Introspect the kwargs and dump objects to disk
976393
def dump_artifacts(kwargs):
    '''
    
    '''
    private_data_dir = kwargs.get('private_data_dir')
    if not private_data_dir:
        private_data_dir = tempfile.mkdtemp()
        kwargs['private_data_dir'] = private_data_dir

    if not os.path.exists(private_data_dir):
        raise ValueError('private_data_dir path is either invalid or does not exist')

    if 'role' in kwargs:
        role = {'name': kwargs.pop('role')}
        if 'role_vars' in kwargs:
            role['vars'] = kwargs.pop('role_vars')

        play = [{'hosts': kwargs.pop('hosts', 'all'), 'roles': [role]}]

        if kwargs.pop('role_skip_facts', False):
            play[0]['gather_facts'] = False

        kwargs['playbook'] = play

        if 'envvars' not in kwargs:
            kwargs['envvars'] = {}

        roles_path = kwargs.pop('roles_path', None)
        if not roles_path:
            roles_path = os.path.join(private_data_dir, 'roles')
        else:
            roles_path += ':{}'.format(os.path.join(private_data_dir, 'roles'))

        kwargs['envvars']['ANSIBLE_ROLES_PATH'] = roles_path

    obj = kwargs.get('playbook')
    if obj and isplaybook(obj):
        path = os.path.join(private_data_dir, 'project')
        kwargs['playbook'] = dump_artifact(json.dumps(obj), path, 'main.json')

    obj = kwargs.get('inventory')
    if obj and isinventory(obj):
        path = os.path.join(private_data_dir, 'inventory')
        if isinstance(obj, Mapping):
            kwargs['inventory'] = dump_artifact(json.dumps(obj), path, 'hosts.json')
        elif isinstance(obj, string_types):
            if not os.path.exists(obj):
                kwargs['inventory'] = dump_artifact(obj, path, 'hosts')

    for key in ('envvars', 'extravars', 'passwords', 'settings'):
        obj = kwargs.get(key)
        if obj and not os.path.exists(os.path.join(private_data_dir, 'env', key)):
            path = os.path.join(private_data_dir, 'env')
            dump_artifact(json.dumps(obj), path, key)
            kwargs.pop(key)

    for key in ('ssh_key', 'cmdline'):
        obj = kwargs.get(key)
        if obj and not os.path.exists(os.path.join(private_data_dir, 'env', key)):
            path = os.path.join(private_data_dir, 'env')
            dump_artifact(str(kwargs[key]), path, key)
            kwargs.pop(key)
89991
def dumps(self, cnf, **kwargs):
        
        kwargs = anyconfig.utils.filter_options(self._dump_opts, kwargs)
        return self.dump_to_string(cnf, **kwargs)
336266
def dump_objects(self):
        
        path = os.path.join(tempfile.gettempdir(),
                            'dump-obj-scheduler-%s-%d.json' % (self.name, int(time.time())))

        logger.info('Dumping scheduler objects to: %s', path)
        try:
            fd = open(path, 'wb')
            output = 'type:uuid:status:t_to_go:poller_tag:worker:command\n'
            fd.write(output.encode('utf-8'))
            for check in list(self.checks.values()):
                output = 'check:%s:%s:%s:%s:%s:%s\n' \
                         % (check.uuid, check.status, check.t_to_go, check.poller_tag,
                            check.command, check.my_worker)
                fd.write(output.encode('utf-8'))
            logger.info('- dumped checks')
            for action in list(self.actions.values()):
                output = '%s: %s:%s:%s:%s:%s:%s\n'\
                         % (action.__class__.my_type, action.uuid, action.status,
                            action.t_to_go, action.reactionner_tag, action.command,
                            action.my_worker)
                fd.write(output.encode('utf-8'))
            logger.info('- dumped actions')
            broks = []
            for broker in list(self.my_daemon.brokers.values()):
                for brok in broker.broks:
                    broks.append(brok)
            for brok in broks:
                output = 'BROK: %s:%s\n' % (brok.uuid, brok.type)
                fd.write(output.encode('utf-8'))
            logger.info('- dumped broks')
            fd.close()
            logger.info('Dumped')
        except OSError as exp:  # pragma: no cover, should never happen...
            logger.critical("Error when writing the objects dump file %s : %s", path, str(exp))
684713
def dump(*args, **kwargs):
    
    kwargs.update(dict(cls=NumpyEncoder,
                       sort_keys=True,
                       indent=4,
                       separators=(',', ': ')))
    return _json.dump(*args, **kwargs)
1073322
def _merge_args_with_kwargs(args_dict, kwargs_dict):
    """"""
    ret = args_dict.copy()
    ret.update(kwargs_dict)
    return ret
462021
def rm(ctx, dataset, kwargs):
    ""

    kwargs = parse_kwargs(kwargs)
    data(dataset, **ctx.obj).rm(**kwargs)
1093556
def dump_database_object(obj: T, fieldlist: Iterable[str]) -> None:
    """"""
    log.info(_LINE_EQUALS)
    log.info("DUMP OF: {}", obj)
    for f in fieldlist:
        log.info(u"{f}: {v}", f=f, v=getattr(obj, f))
    log.info(_LINE_EQUALS)
1303532
def takes_kwargs(obj) -> bool:
    
    if inspect.isclass(obj):
        signature = inspect.signature(obj.__init__)
    elif inspect.ismethod(obj) or inspect.isfunction(obj):
        signature = inspect.signature(obj)
    else:
        raise ConfigurationError(f"object {obj} is not callable")
    return bool(any([p.kind == inspect.Parameter.VAR_KEYWORD  # type: ignore
                     for p in signature.parameters.values()]))
507431
def from_args(cls, **kwargs):
        
        # Create a VSGSuite for each filename on the command line.
        if kwargs.get('suite_commands', None) == 'generate':
            filenames = kwargs.pop('configuration_filenames', [])
            return [cls.from_file(f) for f in filenames]

        # Create a VSGSuit from the target directory and override commands
        if kwargs.get('suite_commands', None) == 'auto':
            type = kwargs.get('suite_type', None)
            return [cls.from_directory('', type, **kwargs)]

        # Create nothing.
        return []
695326
def dump(self, obj):
        ''''''
        pickle.dump(obj, self._file, protocol=self._protocol)
70436
def dump_to_path(self, cnf, filepath, **kwargs):
        
        _not_implemented(self, cnf, filepath, **kwargs)
681679
def save_inst(self, obj):
        """"""
        cls = obj.__class__

        # Try the dispatch table (pickle module doesn't do it)
        f = self.dispatch.get(cls)
        if f:
            f(self, obj)  # Call unbound method with explicit self
            return

        memo = self.memo
        write = self.write
        save = self.save

        if hasattr(obj, '__getinitargs__'):
            args = obj.__getinitargs__()
            len(args)  # XXX Assert it's a sequence
            pickle._keep_alive(args, memo)
        else:
            args = ()

        write(pickle.MARK)

        if self.bin:
            save(cls)
            for arg in args:
                save(arg)
            write(pickle.OBJ)
        else:
            for arg in args:
                save(arg)
            write(pickle.INST + cls.__module__ + '\n' + cls.__name__ + '\n')

        self.memoize(obj)

        try:
            getstate = obj.__getstate__
        except AttributeError:
            stuff = obj.__dict__
        else:
            stuff = getstate()
            pickle._keep_alive(stuff, memo)
        save(stuff)
        write(pickle.BUILD)
1077079
def dump(cls, filename, objects, properties, bools, encoding):
        """"""
        if encoding is None:
            encoding = cls.encoding

        source = cls.dumps(objects, properties, bools)
        if PY2:
            source = unicode(source)

        with io.open(filename, 'w', encoding=encoding) as fd:
            fd.write(source)
90956
def dump_to_template_obj(self, stack, t):
        
        if len(self.Parameters) > 0:
            t['Parameters'] = dict([e.contents(stack) for e in self.Parameters])
        if len(self.Mappings) > 0:
            t['Mappings'] = dict([e.contents(stack) for e in self.Mappings])
        if len(self.Resources) > 0:
            t['Resources'] = dict([e.contents(stack) for e in self.Resources])
        if len(self.Outputs) > 0:
            t['Outputs'] = dict([e.contents(stack) for e in self.Outputs])
831390
def load_kwargs(*args, **kwargs):
    
    def handle_scene():
        """
        Load a scene from our kwargs:

        class:      Scene
        geometry:   dict, name: Trimesh kwargs
        graph:      list of dict, kwargs for scene.graph.update
        base_frame: str, base frame of graph
        """
        scene = Scene()
        scene.geometry.update({k: load_kwargs(v) for
                               k, v in kwargs['geometry'].items()})
        for k in kwargs['graph']:
            if isinstance(k, dict):
                scene.graph.update(**k)
            elif util.is_sequence(k) and len(k) == 3:
                scene.graph.update(k[1], k[0], **k[2])
        if 'base_frame' in kwargs:
            scene.graph.base_frame = kwargs['base_frame']
        if 'metadata' in kwargs:
            scene.metadata.update(kwargs['metadata'])

        return scene

    def handle_trimesh_kwargs():
        """
        Load information with vertices and faces into a mesh
        or PointCloud object.
        """
        if (isinstance(kwargs['vertices'], dict) or
                isinstance(kwargs['faces'], dict)):
            return Trimesh(**misc.load_dict(kwargs))
        elif kwargs['faces'] is None:
            # vertices without faces returns a PointCloud
            return PointCloud(**kwargs)
        else:
            return Trimesh(**kwargs)

    def handle_trimesh_export():
        data, file_type = kwargs['data'], kwargs['file_type']
        if not isinstance(data, dict):
            data = util.wrap_as_stream(data)
        k = mesh_loaders[file_type](data,
                                    file_type=file_type)
        return Trimesh(**k)

    # if we've been passed a single dict instead of kwargs
    # substitute the dict for kwargs
    if (len(kwargs) == 0 and
        len(args) == 1 and
            isinstance(args[0], dict)):
        kwargs = args[0]

    # function : list of expected keys
    handlers = {handle_scene: ('graph', 'geometry'),
                handle_trimesh_kwargs: ('vertices', 'faces'),
                handle_trimesh_export: ('file_type', 'data')}

    # loop through handler functions and expected key
    handler = None
    for func, expected in handlers.items():
        if all(i in kwargs for i in expected):
            # all expected kwargs exist
            handler = func
            # exit the loop as we found one
            break

    if handler is None:
        raise ValueError('unable to determine type!')

    return handler()
704512
def dump(obj, path, **kw):
    
    open_kw = {'mode': 'w'}
    if PY3:  # pragma: no cover
        open_kw['encoding'] = 'utf-8'

    # avoid indented lines ending with ", " on PY2
    if kw.get('indent') and kw.get('separators') is None:
        kw['separators'] = (',', ': ')

    with open(str(path), **open_kw) as fp:
        return json.dump(obj, fp, **kw)
495072
def rm_raw(ctx, dataset, kwargs):
    ""

    kwargs = parse_kwargs(kwargs)
    data(dataset, **ctx.obj).rm_raw(**kwargs)