from ..base import ShopifyResource
import base64
import re


class Image(ShopifyResource):
    _prefix_source = "/admin/products/$product_id/"

    def __getattr__(self, name):
        if name in ["pico", "icon", "thumb", "small", "compact", "medium", "large", "grande", "original"]:
            return re.sub(r"/(.*)\.(\w{2,4})", r"/\1_%s.\2" % (name), self.src)
        else:
            return super(Image, self).__getattr__(name)

    def attach_image(self, data, filename=None):
        self.attributes["attachment"] = base64.b64encode(data)
        if filename:
            self.attributes["filename"] = filename

b12c35a02ec6bcca18612abb1789ae45a9dda7ab
<mask token>

<mask token>


class Image(ShopifyResource):
    <mask token>

    def __getattr__(self, name):
        if name in ['pico', 'icon', 'thumb', 'small', 'compact', 'medium',
            'large', 'grande', 'original']:
            return re.sub('/(.*)\\.(\\w{2,4})', '/\\1_%s.\\2' % name, self.src)
        else:
            return super(Image, self).__getattr__(name)

    def attach_image(self, data, filename=None):
        self.attributes['attachment'] = base64.b64encode(data)
        if filename:
            self.attributes['filename'] = filename

<mask token>


class Image(ShopifyResource):
    _prefix_source = '/admin/products/$product_id/'

    def __getattr__(self, name):
        if name in ['pico', 'icon', 'thumb', 'small', 'compact', 'medium',
            'large', 'grande', 'original']:
            return re.sub('/(.*)\\.(\\w{2,4})', '/\\1_%s.\\2' % name, self.src)
        else:
            return super(Image, self).__getattr__(name)

    def attach_image(self, data, filename=None):
        self.attributes['attachment'] = base64.b64encode(data)
        if filename:
            self.attributes['filename'] = filename

from ..base import ShopifyResource
import base64
import re


class Image(ShopifyResource):
    _prefix_source = '/admin/products/$product_id/'

    def __getattr__(self, name):
        if name in ['pico', 'icon', 'thumb', 'small', 'compact', 'medium',
            'large', 'grande', 'original']:
            return re.sub('/(.*)\\.(\\w{2,4})', '/\\1_%s.\\2' % name, self.src)
        else:
            return super(Image, self).__getattr__(name)

    def attach_image(self, data, filename=None):
        self.attributes['attachment'] = base64.b64encode(data)
        if filename:
            self.attributes['filename'] = filename

from ..base import ShopifyResource
import base64
import re


class Image(ShopifyResource):
    _prefix_source = "/admin/products/$product_id/"

    def __getattr__(self, name):
        if name in ["pico", "icon", "thumb", "small", "compact", "medium", "large", "grande", "original"]:
            return re.sub(r"/(.*)\.(\w{2,4})", r"/\1_%s.\2" % (name), self.src)
        else:
            return super(Image, self).__getattr__(name)

    def attach_image(self, data, filename=None):
        self.attributes["attachment"] = base64.b64encode(data)
        if filename:
            self.attributes["filename"] = filename
