| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1e8c893 commit cd46e2a
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,7 @@ | |||
| 34 | 34 | from bpython import importcompletion | |
| 35 | 35 | from bpython import line as lineparts | |
| 36 | 36 | from bpython._py3compat import py3 | |
| 37 | + from bpython.lazyre import LazyReCompile | ||
| 37 | 38 | ||
| 38 | 39 | ||
| 39 | 40 | # Autocomplete modes | |
@@ -460,7 +461,7 @@ def safe_eval(expr, namespace): | |||
| 460 | 461 | raise EvaluationError | |
| 461 | 462 | ||
| 462 | 463 | ||
| 463 | - attr_matches_re = lineparts.LazyReCompile(r"(\w+(\.\w+)*)\.(\w*)") | ||
| 464 | + attr_matches_re = LazyReCompile(r"(\w+(\.\w+)*)\.(\w*)") | ||
| 464 | 465 | ||
| 465 | 466 | ||
| 466 | 467 | def attr_matches(text, namespace): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | ||
| 2 | - from bpython.line import LazyReCompile | ||
| 2 | + from bpython.lazyre import LazyReCompile | ||
| 3 | 3 | from bpython.formatter import BPythonFormatter | |
| 4 | 4 | from bpython._py3compat import PythonLexer | |
| 5 | 5 | from bpython.config import Struct, loadini, default_config_path | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,50 @@ | |||
| 1 | + # The MIT License | ||
| 2 | + # | ||
| 3 | + # Copyright (c) 2015 the bpython authors. | ||
| 4 | + # | ||
| 5 | + # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 6 | + # of this software and associated documentation files (the "Software"), to deal | ||
| 7 | + # in the Software without restriction, including without limitation the rights | ||
| 8 | + # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 9 | + # copies of the Software, and to permit persons to whom the Software is | ||
| 10 | + # furnished to do so, subject to the following conditions: | ||
| 11 | + # | ||
| 12 | + # The above copyright notice and this permission notice shall be included in | ||
| 13 | + # all copies or substantial portions of the Software. | ||
| 14 | + # | ||
| 15 | + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 16 | + # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 17 | + # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 18 | + # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 19 | + # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 20 | + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 21 | + # THE SOFTWARE. | ||
| 22 | + | ||
| 23 | + import re | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + class LazyReCompile(object): | ||
| 27 | + | ||
| 28 | + def __init__(self, regex, flags=0): | ||
| 29 | + self.regex = regex | ||
| 30 | + self.flags = flags | ||
| 31 | + self.compiled = None | ||
| 32 | + | ||
| 33 | + def compile_regex(method): | ||
| 34 | + def _impl(self, *args, **kwargs): | ||
| 35 | + if self.compiled is None: | ||
| 36 | + self.compiled = re.compile(self.regex, self.flags) | ||
| 37 | + return method(self, *args, **kwargs) | ||
| 38 | + return _impl | ||
| 39 | + | ||
| 40 | + @compile_regex | ||
| 41 | + def finditer(self, *args, **kwargs): | ||
| 42 | + return self.compiled.finditer(*args, **kwargs) | ||
| 43 | + | ||
| 44 | + @compile_regex | ||
| 45 | + def search(self, *args, **kwargs): | ||
| 46 | + return self.compiled.search(*args, **kwargs) | ||
| 47 | + | ||
| 48 | + @compile_regex | ||
| 49 | + def match(self, *args, **kwargs): | ||
| 50 | + return self.compiled.match(*args, **kwargs) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,35 +4,8 @@ | |||
| 4 | 4 | Python code, and return None, or a tuple of the start index, end index, and the | |
| 5 | 5 | word.""" | |
| 6 | 6 | ||
| 7 | - import re | ||
| 8 | 7 | from itertools import chain | |
| 9 | - | ||
| 10 | - | ||
| 11 | - class LazyReCompile(object): | ||
| 12 | - | ||
| 13 | - def __init__(self, regex, flags=0): | ||
| 14 | - self.regex = regex | ||
| 15 | - self.flags = flags | ||
| 16 | - self.compiled = None | ||
| 17 | - | ||
| 18 | - def compile_regex(method): | ||
| 19 | - def _impl(self, *args, **kwargs): | ||
| 20 | - if self.compiled is None: | ||
| 21 | - self.compiled = re.compile(self.regex, self.flags) | ||
| 22 | - return method(self, *args, **kwargs) | ||
| 23 | - return _impl | ||
| 24 | - | ||
| 25 | - @compile_regex | ||
| 26 | - def finditer(self, *args, **kwargs): | ||
| 27 | - return self.compiled.finditer(*args, **kwargs) | ||
| 28 | - | ||
| 29 | - @compile_regex | ||
| 30 | - def search(self, *args, **kwargs): | ||
| 31 | - return self.compiled.search(*args, **kwargs) | ||
| 32 | - | ||
| 33 | - @compile_regex | ||
| 34 | - def match(self, *args, **kwargs): | ||
| 35 | - return self.compiled.match(*args, **kwargs) | ||
| 8 | + from bpython.lazyre import LazyReCompile | ||
| 36 | 9 | ||
| 37 | 10 | ||
| 38 | 11 | current_word_re = LazyReCompile(r'[\w_][\w0-9._]*[(]?') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments