-
Notifications
You must be signed in to change notification settings - Fork 18
/
_repeat.txt
102 lines (83 loc) · 3.33 KB
/
_repeat.txt
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# -*- mode: python -*-
# (c) Copyright 2015 by James Stout
# Licensed under the LGPL, see <http://www.gnu.org/licenses/>
#---------------------------------------------------------------------------
# Here we define various functions for formatting text.
# Each of these functions must have a docstring which defines its
# spoken-form. This docstring must include the "<dictation>" extra.
# See below for various examples.
import re
import _text_utils as text
# Format: some_words
def format_score(dictation): # Function name must start with "format_".
""" score <dictation> """ # Docstring defining spoken-form.
return u"_".join(text.split_dictation(dictation)) # Put underscores between words.
# Format: some_words_
def format_trail_score(dictation):
""" trail score <dictation> """
return u"_".join(text.split_dictation(dictation)) + u"_"
# Format: _some_words
def format_pre_score(dictation):
""" pre score <dictation> """
return u"_" + u"_".join(text.split_dictation(dictation))
# Format: some_words()
def format_under_function(dictation):
""" func score <dictation> """
return u"_".join(text.split_dictation(dictation)) + u"()"
# Format: FLAGS_some_words
def format_flag(dictation):
""" flag score <dictation> """
return u"FLAGS_" + u"_".join(text.split_dictation(dictation))
# Format: some_words::
def format_namespace(dictation):
""" namespace <dictation> """
return u"_".join(text.split_dictation(dictation)) + u"::"
# Format: SomeWords
def format_studley(dictation):
""" studley <dictation> """
words = [word.capitalize() for words in text.split_dictation(dictation)
for word in re.findall(r"(\W+|\w+)", words)]
return u"".join(words)
# Format: kSomeWords
def format_k_studley(dictation):
""" K studley <dictation> """
words = [word.capitalize() for words in text.split_dictation(dictation)
for word in re.findall(r"(\W+|\w+)", words)]
return u"k" + u"".join(words)
# Format: QSomeWords
def format_q_studley(dictation):
""" Q studley <dictation> """
words = [word.capitalize() for words in text.split_dictation(dictation)
for word in re.findall(r"(\W+|\w+)", words)]
return u"Q" + u"".join(words)
# Format: somewords
def format_compound(dictation):
""" [all] compound <dictation> """
return u"".join(text.split_dictation(dictation))
# Format: SOMEWORDS
def format_upper_compound(dictation):
""" upper compound <dictation> """
words = [word.upper() for word in text.split_dictation(dictation)]
return u"".join(words)
# Format: SOME_WORDS
def format_upper_score(dictation):
""" upper score <dictation> """
words = [word.upper() for word in text.split_dictation(dictation)]
return u"_".join(words)
# Format: someWords
def format_camel(dictation):
""" camel <dictation> """
words = text.split_dictation(dictation)
return words[0] + u"".join(w.capitalize() for w in words[1:])
# Format: some-words
def format_dashes(dictation):
""" dashes <dictation> """
return u"-".join(text.split_dictation(dictation))
# Format: some words
def format_spaces(dictation):
""" spaces <dictation> """
return u" ".join(text.split_dictation(dictation))
# Format: some words
def format_padded(dictation):
""" padded <dictation> """
return u" " + " ".join(text.split_dictation(dictation)) + " "