def deserialize(cls, data):
        # type: (dict) -> FontFileMetadata
        if data['mediaType'] != MediaType.font:
            raise ValueError('not font metadata')

        file_descriptor = FileDescriptor.deserialize(data['fileDescriptor'])
        basic = FontBasic.deserialize(
            data.get('basic')) if data.get('basic') else None

        return FontFileMetadata(file_descriptor, basic)
Exemple #2
0
    def deserialize(cls, data):
        # type: (dict) -> VideoFileMetadata
        if data['mediaType'] != MediaType.video:
            raise ValueError('not video metadata')

        file_descriptor = FileDescriptor.deserialize(data['fileDescriptor'])
        basic = VideoBasic.deserialize(
            data.get('basic')) if data.get('basic') else None

        return VideoFileMetadata(file_descriptor, basic)
    def deserialize(cls, data):
        # type: (dict) -> AudioFileMetadata
        if data['mediaType'] != MediaType.audio:
            raise ValueError('not audio metadata')

        file_descriptor = FileDescriptor.deserialize(data['fileDescriptor'])
        basic = AudioBasic.deserialize(
            data.get('basic')) if data.get('basic') else None
        extra = AudioExtra.deserialize(
            data.get('extra')) if data.get('extra') else None

        return AudioFileMetadata(file_descriptor, basic, extra)
Exemple #4
0
    def deserialize(cls, data):
        # type: (dict) -> ImageFileMetadata
        if data['mediaType'] != MediaType.image:
            raise ValueError('not image metadata')

        file_descriptor = FileDescriptor.deserialize(data['fileDescriptor'])
        basic = ImageBasic.deserialize(
            data.get('basic')) if data.get('basic') else None
        features = ImageFeatures.deserialize(
            data.get('features')) if data.get('features') else None

        return ImageFileMetadata(file_descriptor, basic, features)
    def test_deserialize(self):
        file_data = {
            'id': 'moshe',
            'path': '/client/images/animals/cat.jpg',
            'type': FileType.file,
            'mimeType': 'image/jpg',
            'size': 15431,
            'acl': ACL.private,
            'hash': 'bulldog'
        }

        file_descriptor = FileDescriptor.deserialize(file_data)

        assert_that(file_descriptor.id, is_(file_data['id']))
        assert_that(file_descriptor.path, is_(file_data['path']))
    def deserialize(cls, data):
        # type: (dict) -> Operation
        o = Component.deserialize(data)
        o.__class__ = cls

        o.status = data['status']
        o.results = [
            FileDescriptor.deserialize(r) for r in data.get('results', [])
        ]
        o.jobs = data.get('jobs', [])
        o.extra_results = data.get('extraResults', {})
        o.error_message = data.get('errorMessage')
        o.error_code = data.get('errorCode')
        o.state_id = data.get('stateId')
        o.component_key = data.get('componentKey')
        return o
    def test_serialize(self):
        file_data = {
            'path': '/client/images/animals/cat.jpg',
            'type': FileType.file,
            'mimeType': 'image/jpg',
            'size': 15431,
            'acl': ACL.private,
            'hash': '324234234',
            'id': '123456789',
            'lifecycle': {
                'age': 500,
                'action': 'delete'
            },
            'dateUpdated': '2017-01-01T00:00:00Z',
            'dateCreated': '2017-01-01T00:00:00Z'
        }

        file_descriptor = FileDescriptor.deserialize(file_data)

        assert_that(file_descriptor.serialize(), is_(file_data))
Exemple #8
0
 def deserialize(cls, data):
     # type: (dict) -> _CreateFilesResponse
     return cls([FileDescriptor.deserialize(f) for f in data['files']])
Exemple #9
0
 def deserialize(cls, data):
     return _UploadFileResponse(
         [FileDescriptor.deserialize(item) for item in data])
Exemple #10
0
    def deserialize(cls, data):
        # type: (dict) -> FileMetadata
        file_descriptor = FileDescriptor.deserialize(data['fileDescriptor'])

        return FileMetadata(MediaType.undefined, file_descriptor)
Exemple #11
0
    def deserialize(cls, data):
        # type: (dict) -> FileList

        files = [FileDescriptor.deserialize(f) for f in data['files']]

        return FileList(data['nextPageToken'], files)