versatileimagefield/registry.py
def register_sizer(self, attr_name, sizedimage_cls):
        """
        Register a new SizedImage subclass (`sizedimage_cls`).

        To be used via the attribute (`attr_name`).
        """
        if attr_name.startswith(
            '_'
        ) or attr_name in self.unallowed_sizer_names:
            raise UnallowedSizerName(
                "`%s` is an unallowed Sizer name. Sizer names cannot begin "
                "with an underscore or be named any of the "
                "following: %s." % (
                    attr_name,
                    ', '.join([
                        name
                        for name in self.unallowed_sizer_names
                    ])
                )
            )
        if not issubclass(sizedimage_cls, SizedImage):
            raise InvalidSizedImageSubclass(
                'Only subclasses of versatileimagefield.datastructures.'
                'SizedImage may be registered with register_sizer'
            )

        if attr_name in self._sizedimage_registry:
            raise AlreadyRegistered(
                'A SizedImage class is already registered to the `%s` '
                'attribute. If you would like to override this attribute, '
                'use the unregister method' % attr_name
            )
        else:
            self._sizedimage_registry[attr_name] = sizedimage_cls
def register_sizer(self, attr_name, sizedimage_cls):
        """
        Register a new SizedImage subclass (`sizedimage_cls`).

        To be used via the attribute (`attr_name`).
        """
        if attr_name.startswith(
            '_'
        ) or attr_name in self.unallowed_sizer_names:
            raise UnallowedSizerName(
                "`%s` is an unallowed Sizer name. Sizer names cannot begin "
                "with an underscore or be named any of the "
                "following: %s." % (
                    attr_name,
                    ', '.join([
                        name
                        for name in self.unallowed_sizer_names
                    ])
                )
            )
        if not issubclass(sizedimage_cls, SizedImage):
            raise InvalidSizedImageSubclass(
                'Only subclasses of versatileimagefield.datastructures.'
                'SizedImage may be registered with register_sizer'
            )

        if attr_name in self._sizedimage_registry:
            raise AlreadyRegistered(
                'A SizedImage class is already registered to the `%s` '
                'attribute. If you would like to override this attribute, '
                'use the unregister method' % attr_name
            )
        else:
            self._sizedimage_registry[attr_name] = sizedimage_cls
def register_sizer ( self , attr_name , sizedimage_cls ) : if attr_name . startswith ( '_' ) or attr_name in self . unallowed_sizer_names : raise UnallowedSizerName ( "`%s` is an unallowed Sizer name. Sizer names cannot begin " "with an underscore or be named any of the " "following: %s." % ( attr_name , ', ' . join ( [ name for name in self . unallowed_sizer_names ] ) ) ) if not issubclass ( sizedimage_cls , SizedImage ) : raise InvalidSizedImageSubclass ( 'Only subclasses of versatileimagefield.datastructures.' 'SizedImage may be registered with register_sizer' ) if attr_name in self . _sizedimage_registry : raise AlreadyRegistered ( 'A SizedImage class is already registered to the `%s` ' 'attribute. If you would like to override this attribute, ' 'use the unregister method' % attr_name ) else : self . _sizedimage_registry [ attr_name ] = sizedimage_cls
Register a new SizedImage subclass (`sizedimage_cls`).

        To be used via the attribute (`attr_name`).
Register a new SizedImage subclass ( sizedimage_cls ) .