コード例 #1
0
ファイル: interface.py プロジェクト: cuberskulk/shoop
    def _load_module(self):
        spec = self.default_module_spec
        module_identifier = self.module_identifier
        if module_identifier:
            impls = self.get_module_implementation_map()
            if module_identifier not in impls:
                raise ModuleNotFound(
                    "Invalid module identifier %r in %s" % (module_identifier, force_ascii(repr(self)))
                )
            spec = impls[module_identifier]

        cls = load(spec, context_explanation="Loading module for %s" % force_ascii(repr(self)))

        options = getattr(self, self.module_options_field, None) or {}
        return cls(self, options)
コード例 #2
0
 def __repr__(self):
     if hasattr(self, self.identifier_attr):
         identifier = getattr(self, self.identifier_attr) or ''
         identifier_suf = '-{}'.format(text.force_ascii(identifier))
     else:
         identifier_suf = ''
     return '<{}:{}{}>'.format(type(self).__name__, self.pk, identifier_suf)
コード例 #3
0
ファイル: _base.py プロジェクト: 00WhengWheng/shuup
 def __repr__(self):
     identifier = getattr(self, self.identifier_attr, None)
     if identifier:
         identifier_suf = '-{}'.format(text.force_ascii(identifier))
     else:
         identifier_suf = ''
     return '<{}:{}{}>'.format(type(self).__name__, self.pk, identifier_suf)
コード例 #4
0
    def _load_module(self):
        spec = self.default_module_spec
        module_identifier = self.module_identifier
        if module_identifier:
            impls = self.get_module_implementation_map()
            if module_identifier not in impls:
                raise ModuleNotFound(
                    "Invalid module identifier %r in %s" %
                    (module_identifier, force_ascii(repr(self))))
            spec = impls[module_identifier]

        cls = load(spec,
                   context_explanation="Loading module for %s" %
                   force_ascii(repr(self)))

        options = getattr(self, self.module_options_field, None) or {}
        return cls(self, options)
コード例 #5
0
ファイル: product.py プロジェクト: MIKNOTAURO/shoop
def _map_relation_type(relation_type):
    """
    Map relation type to enum value.

    :type relation_type: ProductCrossSellType|str
    :rtype: ProductCrossSellType
    :raises: `LookupError` if unknown string is given
    """
    if isinstance(relation_type, ProductCrossSellType):
        return relation_type
    attr_name = force_ascii(relation_type).upper()
    try:
        return getattr(ProductCrossSellType, attr_name)
    except AttributeError:
        raise LookupError('Unknown ProductCrossSellType %r' % (relation_type,))
コード例 #6
0
def map_relation_type(relation_type):
    """
    Map relation type to enum value.

    :type relation_type: ProductCrossSellType|str
    :rtype: ProductCrossSellType
    :raises: `LookupError` if unknown string is given
    """
    if isinstance(relation_type, ProductCrossSellType):
        return relation_type
    attr_name = force_ascii(relation_type).upper()
    try:
        return getattr(ProductCrossSellType, attr_name)
    except AttributeError:
        raise LookupError('Unknown ProductCrossSellType %r' % (relation_type,))
コード例 #7
0
ファイル: _methods.py プロジェクト: itsrashad/shoop
 def __repr__(self):
     identifier = force_ascii(getattr(self, 'identifier', ''))
     return '<%s: %s "%s">' % (type(self).__name__, self.pk, identifier)
コード例 #8
0
ファイル: methods.py プロジェクト: skada/shoop
 def __repr__(self):
     identifier = force_ascii(getattr(self, 'identifier', ''))
     return '<%s: %s "%s">' % (type(self).__name__, self.pk, identifier)