def dashcase(text, acronyms=None): """Return text in dash-case style (aka kebab-case, spinal-case). Args: text: input string to convert case detect_acronyms: should attempt to detect acronyms acronyms: a list of acronyms to detect >>> dashcase("hello world") 'hello-world' >>> dashcase("HelloHTMLWorld", True, ["HTML"]) 'hello-html-world' """ words, _case, _sep = case_parse.parse_case(text, acronyms) return '-'.join([w.lower() for w in words])
def constcase(text, acronyms=None): """Return text in CONST_CASE style (aka SCREAMING_SNAKE_CASE). Args: text: input string to convert case detect_acronyms: should attempt to detect acronyms acronyms: a list of acronyms to detect >>> constcase("hello world") 'HELLO_WORLD' >>> constcase("helloHTMLWorld", True, ["HTML"]) 'HELLO_HTML_WORLD' """ words, _case, _sep = case_parse.parse_case(text, acronyms) return '_'.join([w.upper() for w in words])
def snakecase(text, acronyms=None): """Return text in snake_case style. Args: text: input string to convert case detect_acronyms: should attempt to detect acronyms acronyms: a list of acronyms to detect >>> snakecase("hello world") 'hello_world' >>> snakecase("HelloHTMLWorld", True, ["HTML"]) 'hello_html_world' """ words, _case, _sep = case_parse.parse_case(text, acronyms) return '_'.join([w.lower() for w in words])
def pascalcase(text, acronyms=None): """Return text in PascalCase style (aka MixedCase). Args: text: input string to convert case detect_acronyms: should attempt to detect acronyms acronyms: a list of acronyms to detect >>> pascalcase("hello world") 'HelloWorld' >>> pascalcase("HELLO_HTML_WORLD", True, ["HTML"]) 'HelloHTMLWorld' """ words, _case, _sep = case_parse.parse_case(text, acronyms) return ''.join(words)
def backslashcase(text, acronyms=None): """Return text in backslash\case style. Args: text: input string to convert case detect_acronyms: should attempt to detect acronyms acronyms: a list of acronyms to detect >>> backslashcase("HELLO_WORLD") == r'HELLO\WORLD' True >>> backslashcase("helloHTMLWorld", True, ["HTML"]) == r'hello\HTML\World' True """ words, _case, _sep = case_parse.parse_case(text, acronyms, preserve_case=True) return '\\'.join(words)
def slashcase(text, acronyms=None): """Return text in slash/case style. Args: text: input string to convert case detect_acronyms: should attempt to detect acronyms acronyms: a list of acronyms to detect >>> slashcase("HELLO_WORLD") 'HELLO/WORLD' >>> slashcase("helloHTMLWorld", True, ["HTML"]) 'hello/HTML/World' """ words, _case, _sep = case_parse.parse_case(text, acronyms, preserve_case=True) return '/'.join(words)
def camelcase(text, acronyms=None): """Return text in camelCase style. Args: text: input string to convert case detect_acronyms: should attempt to detect acronyms acronyms: a list of acronyms to detect >>> camelcase("hello world") 'helloWorld' >>> camelcase("HELLO_HTML_WORLD", True, ["HTML"]) 'helloHTMLWorld' """ words, _case, _sep = case_parse.parse_case(text, acronyms) if words: words[0] = words[0].lower() return ''.join(words)
def separate_words(text, detect_acronyms=False, acronyms=[]): words, case, sep = case_parse.parse_case(text, detect_acronyms, acronyms, preserve_case=True) return ' '.join(words)
def dotcase(text, detect_acronyms=False, acronyms=[]): words, case, sep = case_parse.parse_case(text, detect_acronyms, acronyms) return '.'.join([w.lower() for w in words])
def constcase(text, detect_acronyms=False, acronyms=[]): words, case, sep = case_parse.parse_case(text, detect_acronyms, acronyms) return '_'.join([w.upper() for w in words])
def camelcase(text, detect_acronyms=False, acronyms=[]): words, case, sep = case_parse.parse_case(text, detect_acronyms, acronyms) if words: words[0] = words[0].lower() return ''.join(words)
def backslashcase(text, detect_acronyms=False, acronyms=[]): words, case, sep = case_parse.parse_case( text, detect_acronyms, acronyms, preserve_case=True) return '\\'.join(words)
def separate_words(text, detect_acronyms=False, acronyms=[]): words, case, sep = case_parse.parse_case( text, detect_acronyms, acronyms, preserve_case=True) return ' '.join(words)
def pascalcase(text, detect_acronyms=False, acronyms=[]): words, case, sep = case_parse.parse_case(text, detect_acronyms, acronyms) return ''.join(words)
def backslashcase(text, detect_acronyms=False, acronyms=[]): words, case, sep = case_parse.parse_case(text, detect_acronyms, acronyms, preserve_case=True) return '\\'.join(words)