示例#1
0
 def serializers(self):
     available_serializers = serializers.gather(
         self.store.translation_project.project.__class__)
     found_serializers = []
     for serializer in self.project_serializers:
         found_serializers.append(available_serializers[serializer])
     return found_serializers
示例#2
0
 def serializers(self):
     available_serializers = serializers.gather(
         self.store.translation_project.project.__class__)
     found_serializers = []
     for serializer in self.project_serializers:
         found_serializers.append(available_serializers[serializer])
     return found_serializers
示例#3
0
def test_moz_ios():
    ios_serializers = serializers.gather(Store)
    assert "ios" in ios_serializers
    assert ios_serializers["ios"] is IOSSerializer

    ios_deserializers = deserializers.gather(Store)
    assert "ios" in ios_deserializers
    assert ios_deserializers["ios"] is IOSDeserializer
示例#4
0
 def handle(self, **kwargs):
     model = self.model_from_content_type(kwargs["model"])
     if kwargs["deserializers"]:
         return self.print_serializers_list(
             deserializers.gather(model),
             serializer_type="deserializers")
     return self.print_serializers_list(
         serializers.gather(model))
示例#5
0
def serializer_should_not_be_saved(**kwargs):

    if kwargs["key"] == "pootle.core.serializers":
        if not isinstance(kwargs["value"], list):
            return ValidationError("pootle.core.serializers must be a list")
        available_serializers = serializers.gather(kwargs["sender"]).keys()
        for k in kwargs["value"]:
            if k not in available_serializers:
                return ValidationError("Unrecognised pootle.core.serializers: '%s'" % k)
    elif kwargs["key"] == "pootle.core.deserializers":
        if not isinstance(kwargs["value"], list):
            return ValidationError("pootle.core.deserializers must be a list")
        available_deserializers = deserializers.gather(kwargs["sender"]).keys()
        for k in kwargs["value"]:
            if k not in available_deserializers:
                return ValidationError("Unrecognised pootle.core.deserializers: '%s'" % k)
示例#6
0
def _test_serializer_list(out, err, model=None):
    NO_SERIALS = "There are no serializers set up on your system"

    serials = serializers.gather(model)

    expected = []

    if not serials.keys():
        expected.append(NO_SERIALS)

    if serials.keys():
        heading = "Serializers"
        expected.append("\n%s" % heading)
        expected.append("-" * len(heading))
        for name, klass in serials.items():
            expected.append("{!s: <30} {!s: <50} ".format(name, klass))
    assert out == "%s\n" % ("\n".join(expected))
示例#7
0
def _test_serializer_list(out, err, model=None):
    NO_SERIALS = "There are no serializers set up on your system"

    serials = serializers.gather(model)

    expected = []

    if not serials.keys():
        expected.append(NO_SERIALS)

    if serials.keys():
        heading = "Serializers"
        expected.append("\n%s" % heading)
        expected.append("-" * len(heading))
        for name, klass in serials.items():
            expected.append("{!s: <30} {!s: <50} ".format(name, klass))
    assert out == "%s\n" % ("\n".join(expected))
示例#8
0
文件: getters.py 项目: sjhale/pootle
def serializer_should_not_be_saved(**kwargs):

    if kwargs["key"] == "pootle.core.serializers":
        if not isinstance(kwargs["value"], list):
            return ValidationError("pootle.core.serializers must be a list")
        available_serializers = serializers.gather(kwargs["sender"]).keys()
        for k in kwargs["value"]:
            if k not in available_serializers:
                return ValidationError(
                    "Unrecognised pootle.core.serializers: '%s'" % k)
    elif kwargs["key"] == "pootle.core.deserializers":
        if not isinstance(kwargs["value"], list):
            return ValidationError("pootle.core.deserializers must be a list")
        available_deserializers = deserializers.gather(kwargs["sender"]).keys()
        for k in kwargs["value"]:
            if k not in available_deserializers:
                return ValidationError(
                    "Unrecognised pootle.core.deserializers: '%s'" % k)