invenio_migrator/records.py
def create_files(cls, record, files, existing_files):
        """Create files.

        This method is currently limited to a single bucket per record.
        """
        default_bucket = None
        # Look for bucket id in existing files.
        for f in existing_files:
            if 'bucket' in f:
                default_bucket = f['bucket']
                break

        # Create a bucket in default location if none is found.
        if default_bucket is None:
            b = Bucket.create()
            BucketTag.create(b, 'record', str(record.id))
            default_bucket = str(b.id)
            db.session.commit()
        else:
            b = Bucket.get(default_bucket)

        record['_files'] = []
        for key, meta in files.items():
            obj = cls.create_file(b, key, meta)
            ext = splitext(obj.key)[1].lower()
            if ext.startswith('.'):
                ext = ext[1:]
            record['_files'].append(dict(
                bucket=str(obj.bucket.id),
                key=obj.key,
                version_id=str(obj.version_id),
                size=obj.file.size,
                checksum=obj.file.checksum,
                type=ext,
            ))
        db.session.add(
            RecordsBuckets(record_id=record.id, bucket_id=b.id)
        )
        record.commit()
        db.session.commit()

        return [b]
def create_files(cls, record, files, existing_files):
        default_bucket = None
        # Look for bucket id in existing files.
        for f in existing_files:
            if 'bucket' in f:
                default_bucket = f['bucket']
                break

        # Create a bucket in default location if none is found.
        if default_bucket is None:
            b = Bucket.create()
            BucketTag.create(b, 'record', str(record.id))
            default_bucket = str(b.id)
            db.session.commit()
        else:
            b = Bucket.get(default_bucket)

        record['_files'] = []
        for key, meta in files.items():
            obj = cls.create_file(b, key, meta)
            ext = splitext(obj.key)[1].lower()
            if ext.startswith('.'):
                ext = ext[1:]
            record['_files'].append(dict(
                bucket=str(obj.bucket.id),
                key=obj.key,
                version_id=str(obj.version_id),
                size=obj.file.size,
                checksum=obj.file.checksum,
                type=ext,
            ))
        db.session.add(
            RecordsBuckets(record_id=record.id, bucket_id=b.id)
        )
        record.commit()
        db.session.commit()

        return [b]
def create_files ( cls , record , files , existing_files ) : default_bucket = None # Look for bucket id in existing files. for f in existing_files : if 'bucket' in f : default_bucket = f [ 'bucket' ] break # Create a bucket in default location if none is found. if default_bucket is None : b = Bucket . create ( ) BucketTag . create ( b , 'record' , str ( record . id ) ) default_bucket = str ( b . id ) db . session . commit ( ) else : b = Bucket . get ( default_bucket ) record [ '_files' ] = [ ] for key , meta in files . items ( ) : obj = cls . create_file ( b , key , meta ) ext = splitext ( obj . key ) [ 1 ] . lower ( ) if ext . startswith ( '.' ) : ext = ext [ 1 : ] record [ '_files' ] . append ( dict ( bucket = str ( obj . bucket . id ) , key = obj . key , version_id = str ( obj . version_id ) , size = obj . file . size , checksum = obj . file . checksum , type = ext , ) ) db . session . add ( RecordsBuckets ( record_id = record . id , bucket_id = b . id ) ) record . commit ( ) db . session . commit ( ) return [ b ]
Create files.

        This method is currently limited to a single bucket per record.
Create files .