Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc21753b

Browse files
committed
Mark regexes as "private"
1 parent22ebf12 commitc21753b

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

‎bpython/line.py‎

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
from .lazyreimportLazyReCompile
1212

1313
LinePart=namedtuple("LinePart", ["start","stop","word"])
14-
current_word_re=LazyReCompile(r"(?<![)\]\w_.])"r"([\w_][\w0-9._]*[(]?)")
14+
_current_word_re=LazyReCompile(r"(?<![)\]\w_.])"r"([\w_][\w0-9._]*[(]?)")
1515

1616

1717
defcurrent_word(cursor_offset:int,line:str)->Optional[LinePart]:
1818
"""the object.attribute.attribute just before or under the cursor"""
1919
start=cursor_offset
2020
end=cursor_offset
2121
word=None
22-
formincurrent_word_re.finditer(line):
22+
formin_current_word_re.finditer(line):
2323
ifm.start(1)<cursor_offset<=m.end(1):
2424
start=m.start(1)
2525
end=m.end(1)
@@ -29,29 +29,29 @@ def current_word(cursor_offset: int, line: str) -> Optional[LinePart]:
2929
returnLinePart(start,end,word)
3030

3131

32-
current_dict_key_re=LazyReCompile(r"""[\w_][\w0-9._]*\[([\w0-9._(), '"]*)""")
32+
_current_dict_key_re=LazyReCompile(r"""[\w_][\w0-9._]*\[([\w0-9._(), '"]*)""")
3333

3434

3535
defcurrent_dict_key(cursor_offset:int,line:str)->Optional[LinePart]:
3636
"""If in dictionary completion, return the current key"""
37-
formincurrent_dict_key_re.finditer(line):
37+
formin_current_dict_key_re.finditer(line):
3838
ifm.start(1)<=cursor_offset<=m.end(1):
3939
returnLinePart(m.start(1),m.end(1),m.group(1))
4040
returnNone
4141

4242

43-
current_dict_re=LazyReCompile(r"""([\w_][\w0-9._]*)\[([\w0-9._(), '"]*)""")
43+
_current_dict_re=LazyReCompile(r"""([\w_][\w0-9._]*)\[([\w0-9._(), '"]*)""")
4444

4545

4646
defcurrent_dict(cursor_offset:int,line:str)->Optional[LinePart]:
4747
"""If in dictionary completion, return the dict that should be used"""
48-
formincurrent_dict_re.finditer(line):
48+
formin_current_dict_re.finditer(line):
4949
ifm.start(2)<=cursor_offset<=m.end(2):
5050
returnLinePart(m.start(1),m.end(1),m.group(1))
5151
returnNone
5252

5353

54-
current_string_re=LazyReCompile(
54+
_current_string_re=LazyReCompile(
5555
'''(?P<open>(?:""")|"|(?:''\')|')(?:((?P<closed>.+?)(?P=open))|'''
5656
"""(?P<unclosed>.+))"""
5757
)
@@ -63,14 +63,14 @@ def current_string(cursor_offset: int, line: str) -> Optional[LinePart]:
6363
6464
Weaker than bpython.Repl's current_string, because that checks that a
6565
string is a string based on previous lines in the buffer."""
66-
formincurrent_string_re.finditer(line):
66+
formin_current_string_re.finditer(line):
6767
i=3ifm.group(3)else4
6868
ifm.start(i)<=cursor_offset<=m.end(i):
6969
returnLinePart(m.start(i),m.end(i),m.group(i))
7070
returnNone
7171

7272

73-
current_object_re=LazyReCompile(r"([\w_][\w0-9_]*)[.]")
73+
_current_object_re=LazyReCompile(r"([\w_][\w0-9_]*)[.]")
7474

7575

7676
defcurrent_object(cursor_offset:int,line:str)->Optional[LinePart]:
@@ -82,15 +82,15 @@ def current_object(cursor_offset: int, line: str) -> Optional[LinePart]:
8282
start,end,word=match
8383
s=".".join(
8484
m.group(1)
85-
formincurrent_object_re.finditer(word)
85+
formin_current_object_re.finditer(word)
8686
ifm.end(1)+start<cursor_offset
8787
)
8888
ifnots:
8989
returnNone
9090
returnLinePart(start,start+len(s),s)
9191

9292

93-
current_object_attribute_re=LazyReCompile(r"([\w_][\w0-9_]*)[.]?")
93+
_current_object_attribute_re=LazyReCompile(r"([\w_][\w0-9_]*)[.]?")
9494

9595

9696
defcurrent_object_attribute(
@@ -102,15 +102,15 @@ def current_object_attribute(
102102
ifmatchisNone:
103103
returnNone
104104
start,end,word=match
105-
matches=current_object_attribute_re.finditer(word)
105+
matches=_current_object_attribute_re.finditer(word)
106106
next(matches)
107107
forminmatches:
108108
ifm.start(1)+start<=cursor_offset<=m.end(1)+start:
109109
returnLinePart(m.start(1)+start,m.end(1)+start,m.group(1))
110110
returnNone
111111

112112

113-
current_from_import_from_re=LazyReCompile(
113+
_current_from_import_from_re=LazyReCompile(
114114
r"from +([\w0-9_.]*)(?:\s+import\s+([\w0-9_]+[,]?\s*)+)*"
115115
)
116116

@@ -124,17 +124,19 @@ def current_from_import_from(
124124
parts of an import: from (module) import (name1, name2)
125125
"""
126126
# TODO allow for as's
127-
formincurrent_from_import_from_re.finditer(line):
127+
formin_current_from_import_from_re.finditer(line):
128128
if (m.start(1)<cursor_offset<=m.end(1))or (
129129
m.start(2)<cursor_offset<=m.end(2)
130130
):
131131
returnLinePart(m.start(1),m.end(1),m.group(1))
132132
returnNone
133133

134134

135-
current_from_import_import_re_1=LazyReCompile(r"from\s+([\w0-9_.]*)\s+import")
136-
current_from_import_import_re_2=LazyReCompile(r"([\w0-9_]+)")
137-
current_from_import_import_re_3=LazyReCompile(r", *([\w0-9_]*)")
135+
_current_from_import_import_re_1=LazyReCompile(
136+
r"from\s+([\w0-9_.]*)\s+import"
137+
)
138+
_current_from_import_import_re_2=LazyReCompile(r"([\w0-9_]+)")
139+
_current_from_import_import_re_3=LazyReCompile(r", *([\w0-9_]*)")
138140

139141

140142
defcurrent_from_import_import(
@@ -144,15 +146,15 @@ def current_from_import_import(
144146
145147
returns None if cursor not in or just after one of these words
146148
"""
147-
baseline=current_from_import_import_re_1.search(line)
149+
baseline=_current_from_import_import_re_1.search(line)
148150
ifbaselineisNone:
149151
returnNone
150-
match1=current_from_import_import_re_2.search(line[baseline.end() :])
152+
match1=_current_from_import_import_re_2.search(line[baseline.end() :])
151153
ifmatch1isNone:
152154
returnNone
153155
forminchain(
154156
(match1,),
155-
current_from_import_import_re_3.finditer(line[baseline.end() :]),
157+
_current_from_import_import_re_3.finditer(line[baseline.end() :]),
156158
):
157159
start=baseline.end()+m.start(1)
158160
end=baseline.end()+m.end(1)
@@ -161,21 +163,21 @@ def current_from_import_import(
161163
returnNone
162164

163165

164-
current_import_re_1=LazyReCompile(r"import")
165-
current_import_re_2=LazyReCompile(r"([\w0-9_.]+)")
166-
current_import_re_3=LazyReCompile(r"[,][ ]*([\w0-9_.]*)")
166+
_current_import_re_1=LazyReCompile(r"import")
167+
_current_import_re_2=LazyReCompile(r"([\w0-9_.]+)")
168+
_current_import_re_3=LazyReCompile(r"[,][ ]*([\w0-9_.]*)")
167169

168170

169171
defcurrent_import(cursor_offset:int,line:str)->Optional[LinePart]:
170172
# TODO allow for multiple as's
171-
baseline=current_import_re_1.search(line)
173+
baseline=_current_import_re_1.search(line)
172174
ifbaselineisNone:
173175
returnNone
174-
match1=current_import_re_2.search(line[baseline.end() :])
176+
match1=_current_import_re_2.search(line[baseline.end() :])
175177
ifmatch1isNone:
176178
returnNone
177179
forminchain(
178-
(match1,),current_import_re_3.finditer(line[baseline.end() :])
180+
(match1,),_current_import_re_3.finditer(line[baseline.end() :])
179181
):
180182
start=baseline.end()+m.start(1)
181183
end=baseline.end()+m.end(1)
@@ -184,25 +186,25 @@ def current_import(cursor_offset: int, line: str) -> Optional[LinePart]:
184186
returnNone
185187

186188

187-
current_method_definition_name_re=LazyReCompile(r"def\s+([a-zA-Z_][\w]*)")
189+
_current_method_definition_name_re=LazyReCompile(r"def\s+([a-zA-Z_][\w]*)")
188190

189191

190192
defcurrent_method_definition_name(
191193
cursor_offset:int,line:str
192194
)->Optional[LinePart]:
193195
"""The name of a method being defined"""
194-
formincurrent_method_definition_name_re.finditer(line):
196+
formin_current_method_definition_name_re.finditer(line):
195197
ifm.start(1)<=cursor_offset<=m.end(1):
196198
returnLinePart(m.start(1),m.end(1),m.group(1))
197199
returnNone
198200

199201

200-
current_single_word_re=LazyReCompile(r"(?<![.])\b([a-zA-Z_][\w]*)")
202+
_current_single_word_re=LazyReCompile(r"(?<![.])\b([a-zA-Z_][\w]*)")
201203

202204

203205
defcurrent_single_word(cursor_offset:int,line:str)->Optional[LinePart]:
204206
"""the un-dotted word just before or under the cursor"""
205-
formincurrent_single_word_re.finditer(line):
207+
formin_current_single_word_re.finditer(line):
206208
ifm.start(1)<=cursor_offset<=m.end(1):
207209
returnLinePart(m.start(1),m.end(1),m.group(1))
208210
returnNone
@@ -221,7 +223,7 @@ def current_dotted_attribute(
221223
returnNone
222224

223225

224-
current_expression_attribute_re=LazyReCompile(
226+
_current_expression_attribute_re=LazyReCompile(
225227
r"[.]\s*((?:[\w_][\w0-9_]*)|(?:))"
226228
)
227229

@@ -231,7 +233,7 @@ def current_expression_attribute(
231233
)->Optional[LinePart]:
232234
"""If after a dot, the attribute being completed"""
233235
# TODO replace with more general current_expression_attribute
234-
formincurrent_expression_attribute_re.finditer(line):
236+
formin_current_expression_attribute_re.finditer(line):
235237
ifm.start(1)<=cursor_offset<=m.end(1):
236238
returnLinePart(m.start(1),m.end(1),m.group(1))
237239
returnNone

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp