| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d4ce21e commit 1ef1776
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,21 +34,3 @@ | |||
| 34 | 34 | import sys | |
| 35 | 35 | ||
| 36 | 36 | py3 = sys.version_info[0] == 3 | |
| 37 | - | ||
| 38 | - | ||
| 39 | - if py3: | ||
| 40 | - | ||
| 41 | - def try_decode(s, encoding): | ||
| 42 | - return s | ||
| 43 | - | ||
| 44 | - | ||
| 45 | - else: | ||
| 46 | - | ||
| 47 | - def try_decode(s, encoding): | ||
| 48 | - """Try to decode s which is str names. Return None if not decodable""" | ||
| 49 | - if not isinstance(s, unicode): | ||
| 50 | - try: | ||
| 51 | - return s.decode(encoding) | ||
| 52 | - except UnicodeDecodeError: | ||
| 53 | - return None | ||
| 54 | - return s | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,7 +37,7 @@ | |||
| 37 | 37 | from . import importcompletion | |
| 38 | 38 | from . import line as lineparts | |
| 39 | 39 | from .line import LinePart | |
| 40 | - from ._py3compat import py3, try_decode | ||
| 40 | + from ._py3compat import py3 | ||
| 41 | 41 | from .lazyre import LazyReCompile | |
| 42 | 42 | from .simpleeval import safe_eval, evaluate_current_expression, EvaluationError | |
| 43 | 43 | ||
@@ -470,7 +470,6 @@ def matches(self, cursor_offset, line, **kwargs): | |||
| 470 | 470 | matches.add(word) | |
| 471 | 471 | for nspace in (builtins.__dict__, locals_): | |
| 472 | 472 | for word, val in iteritems(nspace): | |
| 473 | - word = try_decode(word, "ascii") | ||
| 474 | 473 | # if identifier isn't ascii, don't complete (syntax error) | |
| 475 | 474 | if word is None: | |
| 476 | 475 | continue | |
@@ -580,7 +579,7 @@ def matches(self, cursor_offset, line, **kwargs): | |||
| 580 | 579 | ||
| 581 | 580 | first_letter = line[self._orig_start : self._orig_start + 1] | |
| 582 | 581 | ||
| 583 | - matches = [try_decode(c.name, "ascii") for c in completions] | ||
| 582 | + matches = [c.name for c in completions] | ||
| 584 | 583 | if any( | |
| 585 | 584 | not m.lower().startswith(matches[0][0].lower()) for m in matches | |
| 586 | 585 | ): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,7 @@ | |||
| 21 | 21 | # THE SOFTWARE. | |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | - from ._py3compat import py3, try_decode | ||
| 24 | + from ._py3compat import py3 | ||
| 25 | 25 | from .line import ( | |
| 26 | 26 | current_word, | |
| 27 | 27 | current_import, | |
@@ -76,22 +76,21 @@ def attr_matches(cw, prefix="", only_modules=False): | |||
| 76 | 76 | return set() | |
| 77 | 77 | module = sys.modules[module_name] | |
| 78 | 78 | if only_modules: | |
| 79 | - matches = ( | ||
| 79 | + matches = { | ||
| 80 | 80 | name | |
| 81 | 81 | for name in dir(module) | |
| 82 | 82 | if name.startswith(name_after_dot) | |
| 83 | 83 | and "%s.%s" % (module_name, name) in sys.modules | |
| 84 | - ) | ||
| 84 | + } | ||
| 85 | 85 | else: | |
| 86 | - matches = ( | ||
| 86 | + matches = { | ||
| 87 | 87 | name for name in dir(module) if name.startswith(name_after_dot) | |
| 88 | - ) | ||
| 88 | + } | ||
| 89 | 89 | module_part, _, _ = cw.rpartition(".") | |
| 90 | 90 | if module_part: | |
| 91 | - matches = ("%s.%s" % (module_part, m) for m in matches) | ||
| 91 | + matches = {"%s.%s" % (module_part, m) for m in matches} | ||
| 92 | 92 | ||
| 93 | - generator = (try_decode(match, "ascii") for match in matches) | ||
| 94 | - return set(filter(lambda x: x is not None, generator)) | ||
| 93 | + return matches | ||
| 95 | 94 | ||
| 96 | 95 | ||
| 97 | 96 | def module_attr_matches(name): | |
@@ -210,16 +209,13 @@ def find_all_modules(path=None): | |||
| 210 | 209 | """Return a list with all modules in `path`, which should be a list of | |
| 211 | 210 | directory names. If path is not given, sys.path will be used.""" | |
| 212 | 211 | if path is None: | |
| 213 | - modules.update(try_decode(m, "ascii") for m in sys.builtin_module_names) | ||
| 212 | + modules.update(sys.builtin_module_names) | ||
| 214 | 213 | path = sys.path | |
| 215 | 214 | ||
| 216 | 215 | for p in path: | |
| 217 | 216 | if not p: | |
| 218 | 217 | p = os.curdir | |
| 219 | 218 | for module in find_modules(p): | |
| 220 | - module = try_decode(module, "ascii") | ||
| 221 | - if module is None: | ||
| 222 | - continue | ||
| 223 | 219 | modules.add(module) | |
| 224 | 220 | yield | |
| 225 | 221 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments