collective / sc.social.like

Social: Like Actions is a Plone package (add-on) providing simple Google+, Twitter and Facebook integration for Plone Content Types.
7 stars 23 forks source link

Add dependency on plone.formwidget.namedfile 1.0.15+ #173

Open tobiasherp opened 5 years ago

tobiasherp commented 5 years ago

... because of the b64decode_file function.

idgserpro commented 5 years ago

@hvelarde we really need this. See:

https://github.com/collective/sc.social.like/blob/c334d235687ceabefb02664819d3324512937718/sc/social/like/utils.py#L5

rafaelbco commented 5 years ago

I think adding the dependency just because of this function is not optimal. The function is pretty simple, and depends only on the base64 module from the stdlib:

def b64decode_file(value):
    if isinstance(value, six.text_type):
        value = value.encode('utf8')
    filename, data = value.split(b';')

    filename = filename.split(b':')[1]
    filename = base64.standard_b64decode(filename)
    filename = filename.decode('utf-8')

    data = data.split(b':')[1]
    data = base64.standard_b64decode(data)

    return filename, data

I'd rather duplicate the function.

Just my 2 cents.

idgserpro commented 5 years ago

@rafaelbco it's not just because of the function. The widget is also used:

https://github.com/collective/sc.social.like/blob/efc18c974eb14084db1af3229c27b8ddefbc915c/sc/social/like/interfaces.py#L3