from waterbutler.core import metadata


class BaseBoxMetadata(metadata.BaseMetadata):

    def __init__(self, raw, path_obj):
        super().__init__(raw)
        self._path_obj = path_obj

    @property
    def provider(self):
        return 'box'

    @property
    def full_path(self):
        return str(self._path_obj)


class BoxFolderMetadata(BaseBoxMetadata, metadata.BaseFolderMetadata):

    @property
    def name(self):
        return self.raw['name']

    @property
    def path(self):
        return '/{}/'.format(self.raw['id'])

    @property
    def full_path(self):
        path = super().full_path
        if path is None:
            return None
        return path + '/'


class BoxFileMetadata(BaseBoxMetadata, metadata.BaseFileMetadata):

    @property
    def name(self):
        return self.raw['name']

    @property
    def path(self):
        return '/{0}'.format(self.raw['id'])

    @property
    def size(self):
        return self.raw.get('size')

    @property
    def modified(self):
        return self.raw.get('modified_at')

    @property
    def content_type(self):
        return None

    @property
    def extra(self):
        return {
            'etag': self.raw.get('etag'),
            'fullPath': self.full_path
        }


class BoxRevision(metadata.BaseFileRevisionMetadata):

    @property
    def version(self):
        try:
            return self.raw['id']
        except KeyError:
            return self.raw['path'].split('/')[1]

    @property
    def version_identifier(self):
        return 'revision'

    @property
    def path(self):
        try:
            return '/{0}/{1}'.format(self.raw['id'], self.raw['name'])
        except KeyError:
            return self.raw.get('path')

    @property
    def modified(self):
        try:
            return self.raw['modified_at']
        except KeyError:
            return self.raw.get('modified')

@@ -258,36 +258,44 @@
 roperty%0A    def 
-full
+materialized
 _path(self):%0A   
@@ -551,157 +551,8 @@
 %5D)%0A%0A
-    @property%0A    def full_path(self):%0A        path = super().full_path%0A        if path is None:%0A            return None%0A        return path + '/'%0A%0A%0A
 clas
@@ -1076,47 +1076,8 @@
 '),%0A
-            'fullPath': self.full_path%0A
     

Update box metadata