示例#1
0
def test_casers():
    text = u"What is Love? Baby Don't Hurt Me"
    assert snake_case(text) == "what_is_love?_baby_don't_hurt_me"
    assert kebab_case(text) == "what-is-love?-baby-don't-hurt-me"
    assert camel_case(text) == "WhatIsLove?BabyDon'THurtMe"
    assert identifierify(snake_case(text)) == "what_is_love_baby_dont_hurt_me"
    assert identifierify(kebab_case(text), "-") == "what-is-love-baby-dont-hurt-me"
    assert identifierify(camel_case(text)) == "WhatIsLoveBabyDonTHurtMe"
    assert space_case("some_identifier") == "some identifier"
示例#2
0
文件: test_text.py 项目: sidaga/shoop
def test_casers():
    text = u"What is Love? Baby Don't Hurt Me"
    assert snake_case(text) == "what_is_love?_baby_don't_hurt_me"
    assert kebab_case(text) == "what-is-love?-baby-don't-hurt-me"
    assert camel_case(text) == "WhatIsLove?BabyDon'THurtMe"
    assert identifierify(snake_case(text)) == "what_is_love_baby_dont_hurt_me"
    assert identifierify(kebab_case(text), "-") == "what-is-love-baby-dont-hurt-me"
    assert identifierify(camel_case(text)) == "WhatIsLoveBabyDonTHurtMe"
    assert space_case("some_identifier") == "some identifier"
示例#3
0
    def __new__(cls, name, bases, namespace):
        variables = []
        bindings = []
        for key in list(namespace.keys()):
            value = namespace[key]
            if isinstance(value, Binding):
                dest_list = bindings
            elif isinstance(value, Variable):
                dest_list = variables
            else:
                dest_list = None

            if dest_list is not None:
                dest_list.append((key, value))
                del namespace[key]

        namespace.setdefault("variables", {}).update(variables)
        namespace.setdefault("bindings", {}).update(bindings)

        # Figure out some sane defaults
        if "identifier" not in namespace:
            namespace["identifier"] = snake_case(camel_case_to_spaces(name))
        if namespace.get("identifier") and not namespace.get("name"):
            namespace["name"] = space_case(namespace["identifier"]).title()

        return type.__new__(cls, name, bases, namespace)
示例#4
0
文件: editor.py 项目: sebad78/shoop
 def dispatch(self):
     data = json.loads(self.request.body.decode("UTF-8"))
     command = data.pop("command")
     func_name = "handle_%s" % snake_case(camel_case_to_spaces(command))
     func = getattr(self, func_name, None)
     if not callable(func):
         return JsonResponse({"error": "No handler: %s" % func_name})
     return func(data)
示例#5
0
文件: editor.py 项目: sidaga/shoop
 def dispatch(self):
     data = json.loads(self.request.body.decode("UTF-8"))
     command = data.pop("command")
     func_name = "handle_%s" % snake_case(camel_case_to_spaces(command))
     func = getattr(self, func_name, None)
     if not callable(func):
         return JsonResponse({"error": "No handler: %s" % func_name})
     return func(data)