Create exports in bulk.
        :param exports: Exports to be submitted in bulk.
        :param copy_only: If true files are kept on SevenBridges bucket.
        :param api: Api instance.
        :return: list of ExportBulkRecord objects.
974490
def bulk_submit(cls, exports, copy_only=False, api=None):
        
        if not exports:
            raise SbgError('Exports are required')

        api = api or cls._API

        items = []
        for export in exports:
            file_ = Transform.to_file(export.get('file'))
            volume = Transform.to_volume(export.get('volume'))
            location = Transform.to_location(export.get('location'))
            properties = export.get('properties', {})
            overwrite = export.get('overwrite', False)

            item = {
                'source': {
                    'file': file_
                },
                'destination': {
                    'volume': volume,
                    'location': location
                },
                'properties': properties,
                'overwrite': overwrite
            }

            items.append(item)

        data = {'items': items}
        params = {'copy_only': copy_only}

        response = api.post(
            url=cls._URL['bulk_create'], params=params, data=data
        )
        return ExportBulkRecord.parse_records(response=response, api=api)
1071362
def _bulk_history_create(self, model, batch_size):
        

        instances = []
        history = utils.get_history_manager_for_model(model)
        if self.verbosity >= 1:
            self.stdout.write(
                "Starting bulk creating history models for {} instances {}-{}".format(
                    model, 0, batch_size
                )
            )

        iterator_kwargs = (
            {"chunk_size": batch_size} if django.VERSION >= (2, 0, 0) else {}
        )
        for index, instance in enumerate(
            model._default_manager.iterator(**iterator_kwargs)
        ):
            # Can't Just pass batch_size to bulk_create as this can lead to
            # Out of Memory Errors as we load too many models into memory after
            # creating them. So we only keep batch_size worth of models in
            # historical_instances and clear them after we hit batch_size
            if index % batch_size == 0:

                history.bulk_history_create(instances, batch_size=batch_size)

                instances = []

                if self.verbosity >= 1:
                    self.stdout.write(
                        "Finished bulk creating history models for {} "
                        "instances {}-{}, starting next {}".format(
                            model, index - batch_size, index, batch_size
                        )
                    )

            instances.append(instance)

        # create any we didn't get in the last loop
        if instances:
            history.bulk_history_create(instances, batch_size=batch_size)
1336957
def export_deleted_fields(self):
        
        result = self.__deleted_fields__.copy()

        for key, value in self.__original_data__.items():
            if key in result:
                continue
            try:
                partial = value.export_deleted_fields()
                result.extend(['.'.join([key, key2]) for key2 in partial])
            except AttributeError:
                pass

        return result
937230
def compute_exports(exports):
    """"""

    loc, glob = get_calling_namespaces()

    retval = {}
    try:
        for export in exports:
            if SCons.Util.is_Dict(export):
                retval.update(export)
            else:
                try:
                    retval[export] = loc[export]
                except KeyError:
                    retval[export] = glob[export]
    except KeyError as x:
        raise SCons.Errors.UserError("Export of non-existent variable '%s'"%x)

    return retval
471324
def make_export(self, exports):
        """"""
        sql = 'drop table if exists export'
        logging.debug(sql)
        self.cursor.execute(sql)
        sql = 'create table if not exists export ' \
              '(func text unique, module text)'
        logging.debug(sql)
        self.cursor.execute(sql)
        for module in exports:
            logging.debug(_('insering exports from %s'), module)
            sql = 'insert into export values (?, ?)'
            for func in exports[module]:
                if func:
                    try:
                        self.cursor.execute(sql, (func, module))
                    except sqlite3.IntegrityError:
                        pass
        self.con.commit()
1282061
def export(options = nil)
      self.class.attributes.reduce({}) do |result, name|
        value = attributes[name]
        if self.class.association?(name, :many)
          result[name] = export_values(value, options)
        elsif self.class.association?(name, :one)
          result[name] = export_value(value, options)
        else
          result[name] = value
        end
        result
      end
    end
791803
def copy(self, schema_only=False):
        
        o = type(self)()
        o.relation = self.relation
        o.attributes = list(self.attributes)
        o.attribute_types = self.attribute_types.copy()
        o.attribute_data = self.attribute_data.copy()
        if not schema_only:
            o.comment = list(self.comment)
            o.data = copy.deepcopy(self.data)
        return o
656972
def bulk_get(cls, imports, api=None):
        
        api = api or cls._API
        import_ids = [Transform.to_import(import_) for import_ in imports]
        data = {'import_ids': import_ids}

        response = api.post(url=cls._URL['bulk_get'], data=data)
        return ImportBulkRecord.parse_records(response=response, api=api)
756863
def bulk_create(self, objs, batch_size=None):
        
        self._insert(objs, batch_size=batch_size, return_id=False, force_insert=True)
        self.refresh()
480759
def export_json_object(dict_obj, filename=None):
    
    try:
        if filename:
            try:
                with open(filename, 'w') as handle:
                    handle.write(json.dumps(dict_obj, indent=4, sort_keys=True))
                    logger.info(
                        '%s: Wrote %s to local filesystem location' %
                        (inspect.stack()[0][3], filename))
                handle.close()
            except TypeError as e:
                logger.warning(
                    '%s: object in dict not serializable: %s' %
                    (inspect.stack()[0][3], str(e)))
        else:
            json_str = json.dumps(dict_obj, indent=4, sort_keys=True)
            print(highlight(json_str, lexers.JsonLexer(), formatters.TerminalFormatter()))
            logger.info('%s: successful export to stdout' % inspect.stack()[0][3])
            return True
    except IOError as e:
        logger.critical(
            '%s: export_file_object: error writing to %s to filesystem. Error: %s' %
            (inspect.stack()[0][3], filename, str(e)))
        return False
    else:
        logger.info('export_file_object: successful export to %s' % filename)
        return True
254570
def export(self):
        
        data = {}
        for key, value in self.items():
            data[key] = value

        return data
343133
def export(self, timestamp=None, info={}):
        
        tval = tuple(time.localtime()) if timestamp is None else timestamp
        tstamp = time.strftime(self.timestamp_format, tval)

        info = dict(info, timestamp=tstamp)
        export_name = self._format(self.export_name, info)
        files = [((self._format(base, info), ext), val)
                 for ((base, ext), val) in self._files.items()]
        root = os.path.abspath(self.root)
        # Make directory and populate if multiple files and not packed
        if len(self) > 1 and not self.pack:
            self._directory_archive(export_name, files, root)
        elif len(files) == 1:
            self._single_file_archive(export_name, files, root)
        elif self.archive_format == 'zip':
            self._zip_archive(export_name, files, root)
        elif self.archive_format == 'tar':
            self._tar_archive(export_name, files, root)
        if self.flush_archive:
            self._files = OrderedDict()
335704
def export_disks(
        self,
        standalone=True,
        dst_dir=None,
        compress=False,
        collect_only=False,
        with_threads=True,
        *args,
        **kwargs
    ):
        
        return self.provider.export_disks(
            standalone, dst_dir, compress, collect_only, with_threads, *args,
            **kwargs
        )
540870
def export_capacities(self):
        
        return [export for cls in getmro(type(self)) if hasattr(cls, "EXPORT_TO") for export in cls.EXPORT_TO]
1139692
def bulk_history_create(self, objs, batch_size=None):
        """"""

        historical_instances = [
            self.model(
                history_date=getattr(instance, "_history_date", now()),
                history_user=getattr(instance, "_history_user", None),
                history_change_reason=getattr(instance, "changeReason", ""),
                history_type="+",
                **{
                    field.attname: getattr(instance, field.attname)
                    for field in instance._meta.fields
                    if field.name not in self.model._history_excluded_fields
                }
            )
            for instance in objs
        ]

        return self.model.objects.bulk_create(
            historical_instances, batch_size=batch_size
        )
1222920
def bulkImport_json(self, filename, onDuplicate="error", formatType="auto", **params) :
        """"""

        url = "%s/import" % self.database.URL
        params["onDuplicate"] = onDuplicate
        params["collection"] = self.name
        params["type"] = formatType
        with open(filename) as f:
            data = f.read()
            r = self.connection.session.post(URL, params = params, data = data)

            try :
                errorMessage = "At least: %d errors. The first one is: '%s'\n\n more in <this_exception>.data" % (len(data), data[0]["errorMessage"])
            except KeyError:
                raise UpdateError(data['errorMessage'], data)
1000990
def get_exports(self, volume=None, state=None, offset=None, limit=None):
        
        return self._api.exports.query(project=self.id, volume=volume,
                                       state=state, offset=offset, limit=limit)