-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodifiers.py
More file actions
27 lines (20 loc) · 785 Bytes
/
Copy pathmodifiers.py
File metadata and controls
27 lines (20 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import re
import sublime
SETTINGS = sublime.load_settings("caser.sublime-settings")
SNAKE_CASE_PATTERN = re.compile(r'(?<!^)(?=[A-Z])')
def camel_case(string): # this is a test
separator = SETTINGS.get('snake_separator', '_')
return ''.join(word.title() for word in string.split(separator))
def snake_case(string):
separator = SETTINGS.get('snake_separator', '_')
return SNAKE_CASE_PATTERN.sub(separator, string).lower()
def snake_to_words(string):
word_separator = SETTINGS.get('word_separator', ' ')
snake_separator = SETTINGS.get('snake_separator', '_')
return word_separator.join(string.split(snake_separator))
def title(string):
return string.title()
def upper(string):
return string.upper()
def lower(string):
return string.lower()