prompt_id int64 0 941 | project stringclasses 24
values | module stringlengths 7 49 | class stringlengths 0 32 | method stringlengths 2 37 | focal_method_txt stringlengths 43 41.5k | focal_method_lines listlengths 2 2 | in_stack bool 2
classes | globals listlengths 0 16 | type_context stringlengths 79 41.9k | has_branch bool 2
classes | total_branches int64 0 3 |
|---|---|---|---|---|---|---|---|---|---|---|---|
545 | string_utils | string_utils.manipulation | strip_margin | def strip_margin(input_string: str) -> str:
"""
Removes tab indentation from multi line strings (inspired by analogous Scala function).
*Example:*
>>> strip_margin('''
>>> line 1
>>> line 2
>>> line 3
>>> ''')
>>> # returns:
>>> '... | [
528,
557
] | false | [
"__all__"
] | import base64
import random
import unicodedata
import zlib
from typing import Union
from uuid import uuid4
from ._regex import *
from .errors import InvalidInputError
from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string
__all__ = [
'camel_case_to_snake',
'snake_case_to_ca... | true | 2 | |
546 | string_utils | string_utils.manipulation | compress | def compress(input_string: str, encoding: str = 'utf-8', compression_level: int = 9) -> str:
"""
Compress the given string by returning a shorter one that can be safely used in any context (like URL) and
restored back to its original state using `decompress()`.
**Bear in mind:**
Besides the provide... | [
560,
594
] | false | [
"__all__"
] | import base64
import random
import unicodedata
import zlib
from typing import Union
from uuid import uuid4
from ._regex import *
from .errors import InvalidInputError
from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string
__all__ = [
'camel_case_to_snake',
'snake_case_to_ca... | false | 0 | |
547 | string_utils | string_utils.manipulation | decompress | def decompress(input_string: str, encoding: str = 'utf-8') -> str:
"""
Restore a previously compressed string (obtained using `compress()`) back to its original state.
:param input_string: String to restore.
:type input_string: str
:param encoding: Original string encoding.
:type encoding: str
... | [
597,
607
] | false | [
"__all__"
] | import base64
import random
import unicodedata
import zlib
from typing import Union
from uuid import uuid4
from ._regex import *
from .errors import InvalidInputError
from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string
__all__ = [
'camel_case_to_snake',
'snake_case_to_ca... | false | 0 | |
548 | string_utils | string_utils.manipulation | roman_encode | def roman_encode(input_number: Union[str, int]) -> str:
"""
Convert the given number/string into a roman number.
The passed input must represents a positive integer in the range 1-3999 (inclusive).
Why this limit? You may be wondering:
1. zero is forbidden since there is no related representation... | [
610,
633
] | false | [
"__all__"
] | import base64
import random
import unicodedata
import zlib
from typing import Union
from uuid import uuid4
from ._regex import *
from .errors import InvalidInputError
from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string
__all__ = [
'camel_case_to_snake',
'snake_case_to_ca... | false | 0 | |
549 | string_utils | string_utils.manipulation | roman_decode | def roman_decode(input_string: str) -> int:
"""
Decode a roman number string into an integer if the provided string is valid.
*Example:*
>>> roman_decode('VII') # returns 7
:param input_string: (Assumed) Roman number
:type input_string: str
:return: Integer value
"""
return __Roma... | [
636,
648
] | false | [
"__all__"
] | import base64
import random
import unicodedata
import zlib
from typing import Union
from uuid import uuid4
from ._regex import *
from .errors import InvalidInputError
from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string
__all__ = [
'camel_case_to_snake',
'snake_case_to_ca... | false | 0 | |
550 | string_utils | string_utils.manipulation | __StringFormatter | __init__ | def __init__(self, input_string):
if not is_string(input_string):
raise InvalidInputError(input_string)
self.input_string = input_string | [
212,
216
] | false | [
"__all__"
] | import base64
import random
import unicodedata
import zlib
from typing import Union
from uuid import uuid4
from ._regex import *
from .errors import InvalidInputError
from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string
__all__ = [
'camel_case_to_snake',
'snake_case_to_ca... | true | 2 |
551 | string_utils | string_utils.manipulation | __StringFormatter | format | def format(self) -> str:
# map of temporary placeholders
placeholders = {}
out = self.input_string
# looks for url or email and updates placeholders map with found values
placeholders.update({self.__placeholder_key(): m[0] for m in URLS_RE.findall(out)})
placeholders... | [
249,
276
] | false | [
"__all__"
] | import base64
import random
import unicodedata
import zlib
from typing import Union
from uuid import uuid4
from ._regex import *
from .errors import InvalidInputError
from .validation import is_snake_case, is_full_string, is_camel_case, is_integer, is_string
__all__ = [
'camel_case_to_snake',
'snake_case_to_ca... | true | 2 |
552 | string_utils | string_utils.validation | is_integer | def is_integer(input_string: str) -> bool:
"""
Checks whether the given string represents an integer or not.
An integer may be signed or unsigned or use a "scientific notation".
*Examples:*
>>> is_integer('42') # returns true
>>> is_integer('42.0') # returns false
:param input_string: St... | [
140,
155
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | false | 0 | |
553 | string_utils | string_utils.validation | is_decimal | def is_decimal(input_string: str) -> bool:
"""
Checks whether the given string represents a decimal or not.
A decimal may be signed or unsigned or use a "scientific notation".
>>> is_decimal('42.0') # returns true
>>> is_decimal('42') # returns false
:param input_string: String to check
:... | [
158,
171
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | false | 0 | |
554 | string_utils | string_utils.validation | is_url | def is_url(input_string: Any, allowed_schemes: Optional[List[str]] = None) -> bool:
"""
Check if a string is a valid url.
*Examples:*
>>> is_url('http://www.mysite.com') # returns true
>>> is_url('https://mysite.com') # returns true
>>> is_url('.mysite.com') # returns false
:param input_s... | [
176,
200
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | true | 2 | |
555 | string_utils | string_utils.validation | is_email | def is_email(input_string: Any) -> bool:
"""
Check if a string is a valid email.
Reference: https://tools.ietf.org/html/rfc3696#section-3
*Examples:*
>>> is_email('my.email@the-provider.com') # returns true
>>> is_email('@gmail.com') # returns false
:param input_string: String to check.
... | [
203,
243
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | true | 2 | |
556 | string_utils | string_utils.validation | is_credit_card | def is_credit_card(input_string: Any, card_type: str = None) -> bool:
"""
Checks if a string is a valid credit card number.
If card type is provided then it checks against that specific type only,
otherwise any known credit card number will be accepted.
Supported card types are the following:
... | [
246,
282
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | true | 2 | |
557 | string_utils | string_utils.validation | is_json | def is_json(input_string: Any) -> bool:
"""
Check if a string is a valid json.
*Examples:*
>>> is_json('{"name": "Peter"}') # returns true
>>> is_json('[1, 2, 3]') # returns true
>>> is_json('{nope}') # returns false
:param input_string: String to check.
:type input_string: str
:r... | [
344,
364
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | true | 2 | |
558 | string_utils | string_utils.validation | is_ip_v4 | def is_ip_v4(input_string: Any) -> bool:
"""
Checks if a string is a valid ip v4.
*Examples:*
>>> is_ip_v4('255.200.100.75') # returns true
>>> is_ip_v4('nope') # returns false (not an ip)
>>> is_ip_v4('255.200.100.999') # returns false (999 is out of range)
:param input_string: String to... | [
392,
414
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | true | 2 | |
559 | string_utils | string_utils.validation | is_ip | def is_ip(input_string: Any) -> bool:
"""
Checks if a string is a valid ip (either v4 or v6).
*Examples:*
>>> is_ip('255.200.100.75') # returns true
>>> is_ip('2001:db8:85a3:0000:0000:8a2e:370:7334') # returns true
>>> is_ip('1.2.3') # returns false
:param input_string: String to check.
... | [
433,
447
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | false | 0 | |
560 | string_utils | string_utils.validation | is_palindrome | def is_palindrome(input_string: Any, ignore_spaces: bool = False, ignore_case: bool = False) -> bool:
"""
Checks if the string is a palindrome (https://en.wikipedia.org/wiki/Palindrome).
*Examples:*
>>> is_palindrome('LOL') # returns true
>>> is_palindrome('Lol') # returns false
>>> is_palindr... | [
450,
493
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | true | 2 | |
561 | string_utils | string_utils.validation | is_isbn | def is_isbn(input_string: str, normalize: bool = True) -> bool:
"""
Checks if the given string represents a valid ISBN (International Standard Book Number).
By default hyphens in the string are ignored, so digits can be separated in different ways, by calling this
function with `normalize=False` only di... | [
640,
656
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | false | 0 | |
562 | string_utils | string_utils.validation | __ISBNChecker | is_isbn_13 | def is_isbn_13(self) -> bool:
if len(self.input_string) == 13:
product = 0
try:
for index, digit in enumerate(self.input_string):
weight = 1 if (index % 2 == 0) else 3
product += int(digit) * weight
return prod... | [
48,
62
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | true | 2 |
563 | string_utils | string_utils.validation | __ISBNChecker | is_isbn_10 | def is_isbn_10(self) -> bool:
if len(self.input_string) == 10:
product = 0
try:
for index, digit in enumerate(self.input_string):
product += int(digit) * (index + 1)
return product % 11 == 0
except ValueError:
... | [
64,
77
] | false | [
"__all__"
] | import json
import string
from typing import Any, Optional, List
from ._regex import *
from .errors import InvalidInputError
__all__ = [
'is_string',
'is_full_string',
'is_number',
'is_integer',
'is_decimal',
'is_url',
'is_email',
'is_credit_card',
'is_camel_case',
'is_snake_cas... | true | 2 |
564 | sty | sty.lib | mute | def mute(*objects: Register) -> None:
"""
Use this function to mute multiple register-objects at once.
:param objects: Pass multiple register-objects to the function.
"""
err = ValueError(
"The mute() method can only be used with objects that inherit "
"from the 'Register class'."
... | [
3,
16
] | false | [] | from .primitive import Register
def mute(*objects: Register) -> None:
"""
Use this function to mute multiple register-objects at once.
:param objects: Pass multiple register-objects to the function.
"""
err = ValueError(
"The mute() method can only be used with objects that inherit "
... | true | 2 | |
565 | sty | sty.lib | unmute | def unmute(*objects: Register) -> None:
"""
Use this function to unmute multiple register-objects at once.
:param objects: Pass multiple register-objects to the function.
"""
err = ValueError(
"The unmute() method can only be used with objects that inherit "
"from the 'Register clas... | [
19,
32
] | false | [] | from .primitive import Register
def unmute(*objects: Register) -> None:
"""
Use this function to unmute multiple register-objects at once.
:param objects: Pass multiple register-objects to the function.
"""
err = ValueError(
"The unmute() method can only be used with objects that inherit... | true | 2 | |
566 | sty | sty.primitive | Style | __new__ | def __new__(cls, *rules: StylingRule, value: str = "") -> "Style":
new_cls = str.__new__(cls, value) # type: ignore
setattr(new_cls, "rules", rules)
return new_cls | [
33,
36
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Style(str):
rules: Iterable[StylingRule]
... | false | 0 |
567 | sty | sty.primitive | Register | __init__ | def __init__(self):
self.renderfuncs: Renderfuncs = {}
self.is_muted = False
self.eightbit_call = lambda x: x
self.rgb_call = lambda r, g, b: (r, g, b) | [
71,
75
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | false | 0 |
568 | sty | sty.primitive | Register | __setattr__ | def __setattr__(self, name: str, value: Style):
if isinstance(value, Style):
if self.is_muted:
rendered_style = Style(*value.rules, value="")
else:
rendered, rules = _render_rules(self.renderfuncs, value.rules)
rendered_style = Style(... | [
77,
90
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | true | 2 |
569 | sty | sty.primitive | Register | __call__ | def __call__(self, *args: Union[int, str], **kwargs) -> str:
"""
This function is to handle calls such as `fg(42)`, `bg(102, 49, 42)`, `fg('red')`.
"""
# Return empty str if object is muted.
if self.is_muted:
return ""
len_args = len(args)
if le... | [
92,
119
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | true | 2 |
570 | sty | sty.primitive | Register | set_eightbit_call | def set_eightbit_call(self, rendertype: Type[RenderType]) -> None:
"""
You can call a register-object directly. A call like this ``fg(144)``
is a Eightbit-call. With this method you can define the render-type for such calls.
:param rendertype: The new rendertype that is used for Eig... | [
121,
129
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | false | 0 |
571 | sty | sty.primitive | Register | set_rgb_call | def set_rgb_call(self, rendertype: Type[RenderType]) -> None:
"""
You can call a register-object directly. A call like this ``fg(10, 42, 255)``
is a RGB-call. With this method you can define the render-type for such calls.
:param rendertype: The new rendertype that is used for RGB-c... | [
131,
139
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | false | 0 |
572 | sty | sty.primitive | Register | set_renderfunc | def set_renderfunc(self, rendertype: Type[RenderType], func: Callable) -> None:
"""
With this method you can add or replace render-functions for a given register-object:
:param rendertype: The render type for which the new renderfunc is used.
:param func: The new render function.
... | [
141,
155
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | true | 2 |
573 | sty | sty.primitive | Register | mute | def mute(self) -> None:
"""
Sometimes it is useful to disable the formatting for a register-object. You can
do so by invoking this method.
"""
self.is_muted = True
for attr_name in dir(self):
val = getattr(self, attr_name)
if isinstance(val, S... | [
157,
167
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | true | 2 |
574 | sty | sty.primitive | Register | unmute | def unmute(self) -> None:
"""
Use this method to unmute a previously muted register object.
"""
self.is_muted = False
for attr_name in dir(self):
val = getattr(self, attr_name)
if isinstance(val, Style):
setattr(self, attr_name, val) | [
169,
178
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | true | 2 |
575 | sty | sty.primitive | Register | as_dict | def as_dict(self) -> Dict[str, str]:
"""
Export color register as dict.
"""
items: Dict[str, str] = {}
for name in dir(self):
if not name.startswith("_") and isinstance(getattr(self, name), str):
items.update({name: str(getattr(self, name))})
... | [
180,
192
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | true | 2 |
576 | sty | sty.primitive | Register | as_namedtuple | def as_namedtuple(self):
"""
Export color register as namedtuple.
"""
d = self.as_dict()
return namedtuple("StyleRegister", d.keys())(*d.values()) | [
194,
199
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | false | 0 |
577 | sty | sty.primitive | Register | copy | def copy(self) -> "Register":
"""
Make a deepcopy of a register-object.
"""
return deepcopy(self) | [
201,
205
] | false | [
"Renderfuncs",
"StylingRule"
] | from collections import namedtuple
from copy import deepcopy
from typing import Callable, Dict, Iterable, List, NamedTuple, Tuple, Type, Union
from .rendertype import RenderType
Renderfuncs = Dict[Type[RenderType], Callable]
StylingRule = Union["Style", RenderType]
class Register:
def __init__(self):
sel... | false | 0 |
578 | thefuck | thefuck.argument_parser | Parser | __init__ | def __init__(self):
self._parser = ArgumentParser(prog='thefuck', add_help=False)
self._add_arguments() | [
12,
14
] | false | [] | import sys
from argparse import ArgumentParser, SUPPRESS
from .const import ARGUMENT_PLACEHOLDER
from .utils import get_alias
class Parser(object):
def __init__(self):
self._parser = ArgumentParser(prog='thefuck', add_help=False)
self._add_arguments() | false | 0 |
579 | thefuck | thefuck.argument_parser | Parser | parse | def parse(self, argv):
arguments = self._prepare_arguments(argv[1:])
return self._parser.parse_args(arguments) | [
83,
85
] | false | [] | import sys
from argparse import ArgumentParser, SUPPRESS
from .const import ARGUMENT_PLACEHOLDER
from .utils import get_alias
class Parser(object):
def __init__(self):
self._parser = ArgumentParser(prog='thefuck', add_help=False)
self._add_arguments()
def parse(self, argv):
argument... | false | 0 |
580 | thefuck | thefuck.argument_parser | Parser | print_usage | def print_usage(self):
self._parser.print_usage(sys.stderr) | [
87,
88
] | false | [] | import sys
from argparse import ArgumentParser, SUPPRESS
from .const import ARGUMENT_PLACEHOLDER
from .utils import get_alias
class Parser(object):
def __init__(self):
self._parser = ArgumentParser(prog='thefuck', add_help=False)
self._add_arguments()
def print_usage(self):
self._pa... | false | 0 |
581 | thefuck | thefuck.argument_parser | Parser | print_help | def print_help(self):
self._parser.print_help(sys.stderr) | [
90,
91
] | false | [] | import sys
from argparse import ArgumentParser, SUPPRESS
from .const import ARGUMENT_PLACEHOLDER
from .utils import get_alias
class Parser(object):
def __init__(self):
self._parser = ArgumentParser(prog='thefuck', add_help=False)
self._add_arguments()
def print_help(self):
self._par... | false | 0 |
582 | thefuck | thefuck.conf | Settings | init | def init(self, args=None):
"""Fills `settings` with values from `settings.py` and env."""
from .logs import exception
self._setup_user_dir()
self._init_settings_file()
try:
self.update(self._settings_from_file())
except Exception:
exception("... | [
16,
33
] | false | [
"settings"
] | from imp import load_source
import os
import sys
from warnings import warn
from six import text_type
from . import const
from .system import Path
settings = Settings(const.DEFAULT_SETTINGS)
class Settings(dict):
def init(self, args=None):
"""Fills `settings` with values from `settings.py` and env."""
... | false | 0 |
583 | thefuck | thefuck.corrector | get_loaded_rules | def get_loaded_rules(rules_paths):
"""Yields all available rules.
:type rules_paths: [Path]
:rtype: Iterable[Rule]
"""
for path in rules_paths:
if path.name != '__init__.py':
rule = Rule.from_path(path)
if rule and rule.is_enabled:
yield rule | [
7,
18
] | false | [] | import sys
from .conf import settings
from .types import Rule
from .system import Path
from . import logs
def get_loaded_rules(rules_paths):
"""Yields all available rules.
:type rules_paths: [Path]
:rtype: Iterable[Rule]
"""
for path in rules_paths:
if path.name != '__init__.py':
... | true | 2 | |
584 | thefuck | thefuck.corrector | get_rules_import_paths | def get_rules_import_paths():
"""Yields all rules import paths.
:rtype: Iterable[Path]
"""
# Bundled rules:
yield Path(__file__).parent.joinpath('rules')
# Rules defined by user:
yield settings.user_dir.joinpath('rules')
# Packages with third-party rules:
for path in sys.path:
... | [
21,
36
] | false | [] | import sys
from .conf import settings
from .types import Rule
from .system import Path
from . import logs
def get_rules_import_paths():
"""Yields all rules import paths.
:rtype: Iterable[Path]
"""
# Bundled rules:
yield Path(__file__).parent.joinpath('rules')
# Rules defined by user:
yi... | true | 2 | |
585 | thefuck | thefuck.corrector | get_rules | def get_rules():
"""Returns all enabled rules.
:rtype: [Rule]
"""
paths = [rule_path for path in get_rules_import_paths()
for rule_path in sorted(path.glob('*.py'))]
return sorted(get_loaded_rules(paths),
key=lambda rule: rule.priority) | [
39,
47
] | false | [] | import sys
from .conf import settings
from .types import Rule
from .system import Path
from . import logs
def get_rules():
"""Returns all enabled rules.
:rtype: [Rule]
"""
paths = [rule_path for path in get_rules_import_paths()
for rule_path in sorted(path.glob('*.py'))]
return sor... | false | 0 | |
586 | thefuck | thefuck.corrector | organize_commands | def organize_commands(corrected_commands):
"""Yields sorted commands without duplicates.
:type corrected_commands: Iterable[thefuck.types.CorrectedCommand]
:rtype: Iterable[thefuck.types.CorrectedCommand]
"""
try:
first_command = next(corrected_commands)
yield first_command
exc... | [
51,
77
] | false | [] | import sys
from .conf import settings
from .types import Rule
from .system import Path
from . import logs
def organize_commands(corrected_commands):
"""Yields sorted commands without duplicates.
:type corrected_commands: Iterable[thefuck.types.CorrectedCommand]
:rtype: Iterable[thefuck.types.CorrectedCo... | true | 2 | |
587 | thefuck | thefuck.corrector | get_corrected_commands | def get_corrected_commands(command):
"""Returns generator with sorted and unique corrected commands.
:type command: thefuck.types.Command
:rtype: Iterable[thefuck.types.CorrectedCommand]
"""
corrected_commands = (
corrected for rule in get_rules()
if rule.is_match(command)
... | [
80,
91
] | false | [] | import sys
from .conf import settings
from .types import Rule
from .system import Path
from . import logs
def get_corrected_commands(command):
"""Returns generator with sorted and unique corrected commands.
:type command: thefuck.types.Command
:rtype: Iterable[thefuck.types.CorrectedCommand]
"""
... | false | 0 | |
588 | thefuck | thefuck.entrypoints.fix_command | fix_command | def fix_command(known_args):
"""Fixes previous command. Used when `thefuck` called without arguments."""
settings.init(known_args)
with logs.debug_time('Total'):
logs.debug(u'Run with settings: {}'.format(pformat(settings)))
raw_command = _get_raw_command(known_args)
try:
... | [
28,
47
] | false | [] | from pprint import pformat
import os
import sys
from difflib import SequenceMatcher
from .. import logs, types, const
from ..conf import settings
from ..corrector import get_corrected_commands
from ..exceptions import EmptyCommand
from ..ui import select_command
from ..utils import get_alias, get_all_executables
def... | true | 2 | |
589 | thefuck | thefuck.entrypoints.main | main | def main():
parser = Parser()
known_args = parser.parse(sys.argv)
if known_args.help:
parser.print_help()
elif known_args.version:
logs.version(get_installation_info().version,
sys.version.split()[0], shell.info())
# It's important to check if an alias is being ... | [
15,
39
] | false | [] | from ..system import init_output
import os
import sys
from .. import logs
from ..argument_parser import Parser
from ..utils import get_installation_info
from ..shells import shell
from .alias import print_alias
from .fix_command import fix_command
def main():
parser = Parser()
known_args = parser.parse(sys.a... | true | 2 | |
590 | thefuck | thefuck.entrypoints.shell_logger | shell_logger | def shell_logger(output):
"""Logs shell output to the `output`.
Works like unix script command with `-f` flag.
"""
if not os.environ.get('SHELL'):
logs.warn("Shell logger doesn't support your platform.")
sys.exit(1)
fd = os.open(output, os.O_CREAT | os.O_TRUNC | os.O_RDWR)
os.... | [
63,
78
] | false | [] | import array
import fcntl
from functools import partial
import mmap
import os
import pty
import signal
import sys
import termios
import tty
from .. import logs, const
def shell_logger(output):
"""Logs shell output to the `output`.
Works like unix script command with `-f` flag.
"""
if not os.environ... | true | 2 | |
591 | thefuck | thefuck.logs | color | def color(color_):
"""Utility for ability to disabling colored output."""
if settings.no_colors:
return ''
else:
return color_ | [
11,
16
] | false | [] | from contextlib import contextmanager
from datetime import datetime
import sys
from traceback import format_exception
import colorama
from .conf import settings
from . import const
def color(color_):
"""Utility for ability to disabling colored output."""
if settings.no_colors:
return ''
else:
... | true | 2 | |
592 | thefuck | thefuck.logs | show_corrected_command | def show_corrected_command(corrected_command):
sys.stderr.write(u'{prefix}{bold}{script}{reset}{side_effect}\n'.format(
prefix=const.USER_COMMAND_MARK,
script=corrected_command.script,
side_effect=u' (+side effect)' if corrected_command.side_effect else u'',
bold=color(colorama.Style... | [
49,
50
] | false | [] | from contextlib import contextmanager
from datetime import datetime
import sys
from traceback import format_exception
import colorama
from .conf import settings
from . import const
def show_corrected_command(corrected_command):
sys.stderr.write(u'{prefix}{bold}{script}{reset}{side_effect}\n'.format(
pref... | false | 0 | |
593 | thefuck | thefuck.logs | confirm_text | def confirm_text(corrected_command):
sys.stderr.write(
(u'{prefix}{clear}{bold}{script}{reset}{side_effect} '
u'[{green}enter{reset}/{blue}↑{reset}/{blue}↓{reset}'
u'/{red}ctrl+c{reset}]').format(
prefix=const.USER_COMMAND_MARK,
script=corrected_command.script,
... | [
58,
59
] | false | [] | from contextlib import contextmanager
from datetime import datetime
import sys
from traceback import format_exception
import colorama
from .conf import settings
from . import const
def confirm_text(corrected_command):
sys.stderr.write(
(u'{prefix}{clear}{bold}{script}{reset}{side_effect} '
u'[{g... | false | 0 | |
594 | thefuck | thefuck.logs | debug | def debug(msg):
if settings.debug:
sys.stderr.write(u'{blue}{bold}DEBUG:{reset} {msg}\n'.format(
msg=msg,
reset=color(colorama.Style.RESET_ALL),
blue=color(colorama.Fore.BLUE),
bold=color(colorama.Style.BRIGHT))) | [
74,
76
] | false | [] | from contextlib import contextmanager
from datetime import datetime
import sys
from traceback import format_exception
import colorama
from .conf import settings
from . import const
def debug(msg):
if settings.debug:
sys.stderr.write(u'{blue}{bold}DEBUG:{reset} {msg}\n'.format(
msg=msg,
... | true | 2 | |
595 | thefuck | thefuck.logs | how_to_configure_alias | def how_to_configure_alias(configuration_details):
print(u"Seems like {bold}fuck{reset} alias isn't configured!".format(
bold=color(colorama.Style.BRIGHT),
reset=color(colorama.Style.RESET_ALL)))
if configuration_details:
print(
u"Please put {bold}{content}{reset} in your "
... | [
92,
113
] | false | [] | from contextlib import contextmanager
from datetime import datetime
import sys
from traceback import format_exception
import colorama
from .conf import settings
from . import const
def how_to_configure_alias(configuration_details):
print(u"Seems like {bold}fuck{reset} alias isn't configured!".format(
bol... | true | 2 | |
596 | thefuck | thefuck.rules.aws_cli | get_new_command | def get_new_command(command):
mistake = re.search(INVALID_CHOICE, command.output).group(0)
options = re.findall(OPTIONS, command.output, flags=re.MULTILINE)
return [replace_argument(command.script, mistake, o) for o in options] | [
13,
16
] | false | [
"INVALID_CHOICE",
"OPTIONS"
] | import re
from thefuck.utils import for_app, replace_argument
INVALID_CHOICE = "(?<=Invalid choice: ')(.*)(?=', maybe you meant:)"
OPTIONS = "^\\s*\\*\\s(.*)"
def get_new_command(command):
mistake = re.search(INVALID_CHOICE, command.output).group(0)
options = re.findall(OPTIONS, command.output, flags=re.MULTI... | false | 0 | |
597 | thefuck | thefuck.rules.brew_install | match | def match(command):
is_proper_command = ('brew install' in command.script and
'No available formula' in command.output)
if is_proper_command:
formula = re.findall(r'Error: No available formula for ([a-z]+)',
command.output)[0]
return bool(_g... | [
25,
33
] | false | [
"enabled_by_default"
] | import os
import re
from thefuck.utils import get_closest, replace_argument
from thefuck.specific.brew import get_brew_path_prefix, brew_available
enabled_by_default = brew_available
def match(command):
is_proper_command = ('brew install' in command.script and
'No available formula' in co... | true | 2 | |
598 | thefuck | thefuck.rules.brew_install | get_new_command | def get_new_command(command):
not_exist_formula = re.findall(r'Error: No available formula for ([a-z]+)',
command.output)[0]
exist_formula = _get_similar_formula(not_exist_formula)
return replace_argument(command.script, not_exist_formula, exist_formula) | [
36,
41
] | false | [
"enabled_by_default"
] | import os
import re
from thefuck.utils import get_closest, replace_argument
from thefuck.specific.brew import get_brew_path_prefix, brew_available
enabled_by_default = brew_available
def get_new_command(command):
not_exist_formula = re.findall(r'Error: No available formula for ([a-z]+)',
... | false | 0 | |
599 | thefuck | thefuck.rules.choco_install | get_new_command | def get_new_command(command):
# Find the argument that is the package name
for script_part in command.script_parts:
if (
script_part not in ["choco", "cinst", "install"]
# Need exact match (bc chocolatey is a package)
and not script_part.startswith('-')
# ... | [
9,
21
] | false | [
"enabled_by_default"
] | from thefuck.utils import for_app, which
enabled_by_default = bool(which("choco")) or bool(which("cinst"))
def get_new_command(command):
# Find the argument that is the package name
for script_part in command.script_parts:
if (
script_part not in ["choco", "cinst", "install"]
#... | true | 2 | |
600 | thefuck | thefuck.rules.dirty_unzip | side_effect | def side_effect(old_cmd, command):
with zipfile.ZipFile(_zip_file(old_cmd), 'r') as archive:
for file in archive.namelist():
if not os.path.abspath(file).startswith(os.getcwd()):
# it's unsafe to overwrite files outside of the current directory
continue
... | [
44,
56
] | false | [
"requires_output"
] | import os
import zipfile
from thefuck.utils import for_app
from thefuck.shells import shell
requires_output = False
def side_effect(old_cmd, command):
with zipfile.ZipFile(_zip_file(old_cmd), 'r') as archive:
for file in archive.namelist():
if not os.path.abspath(file).startswith(os.getcwd()):... | true | 2 | |
601 | thefuck | thefuck.rules.django_south_merge | match | def match(command):
return 'manage.py' in command.script and \
'migrate' in command.script \
and '--merge: will just attempt the migration' in command.output | [
0,
1
] | false | [] |
def match(command):
return 'manage.py' in command.script and \
'migrate' in command.script \
and '--merge: will just attempt the migration' in command.output | false | 0 | |
602 | thefuck | thefuck.rules.no_such_file | match | def match(command):
for pattern in patterns:
if re.search(pattern, command.output):
return True
return False | [
12,
17
] | false | [
"patterns"
] | import re
from thefuck.shells import shell
patterns = (
r"mv: cannot move '[^']*' to '([^']*)': No such file or directory",
r"mv: cannot move '[^']*' to '([^']*)': Not a directory",
r"cp: cannot create regular file '([^']*)': No such file or directory",
r"cp: cannot create regular file '([^']*)': Not a... | true | 2 | |
603 | thefuck | thefuck.rules.no_such_file | get_new_command | def get_new_command(command):
for pattern in patterns:
file = re.findall(pattern, command.output)
if file:
file = file[0]
dir = file[0:file.rfind('/')]
formatme = shell.and_('mkdir -p {}', '{}')
return formatme.format(dir, command.script) | [
20,
29
] | false | [
"patterns"
] | import re
from thefuck.shells import shell
patterns = (
r"mv: cannot move '[^']*' to '([^']*)': No such file or directory",
r"mv: cannot move '[^']*' to '([^']*)': Not a directory",
r"cp: cannot create regular file '([^']*)': No such file or directory",
r"cp: cannot create regular file '([^']*)': Not a... | true | 2 | |
604 | thefuck | thefuck.rules.pacman_invalid_option | get_new_command | def get_new_command(command):
option = re.findall(r" -[dfqrstuv]", command.script)[0]
return re.sub(option, option.upper(), command.script) | [
14,
16
] | false | [
"enabled_by_default"
] | from thefuck.specific.archlinux import archlinux_env
from thefuck.specific.sudo import sudo_support
from thefuck.utils import for_app
import re
enabled_by_default = archlinux_env()
def get_new_command(command):
option = re.findall(r" -[dfqrstuv]", command.script)[0]
return re.sub(option, option.upper(), comma... | false | 0 | |
605 | thefuck | thefuck.rules.sudo_command_from_user_path | get_new_command | def get_new_command(command):
command_name = _get_command_name(command)
return replace_argument(command.script, command_name,
u'env "PATH=$PATH" {}'.format(command_name)) | [
17,
19
] | false | [] | import re
from thefuck.utils import for_app, which, replace_argument
def get_new_command(command):
command_name = _get_command_name(command)
return replace_argument(command.script, command_name,
u'env "PATH=$PATH" {}'.format(command_name)) | false | 0 | |
606 | thefuck | thefuck.rules.tsuru_not_command | get_new_command | def get_new_command(command):
broken_cmd = re.findall(r'tsuru: "([^"]*)" is not a tsuru command',
command.output)[0]
return replace_command(command, broken_cmd,
get_all_matched_commands(command.output)) | [
10,
13
] | false | [] | import re
from thefuck.utils import get_all_matched_commands, replace_command, for_app
def get_new_command(command):
broken_cmd = re.findall(r'tsuru: "([^"]*)" is not a tsuru command',
command.output)[0]
return replace_command(command, broken_cmd,
get_al... | false | 0 | |
607 | thefuck | thefuck.rules.vagrant_up | get_new_command | def get_new_command(command):
cmds = command.script_parts
machine = None
if len(cmds) >= 3:
machine = cmds[2]
start_all_instances = shell.and_(u"vagrant up", command.script)
if machine is None:
return start_all_instances
else:
return [shell.and_(u"vagrant up {}".format(m... | [
9,
19
] | false | [] | from thefuck.shells import shell
from thefuck.utils import for_app
def get_new_command(command):
cmds = command.script_parts
machine = None
if len(cmds) >= 3:
machine = cmds[2]
start_all_instances = shell.and_(u"vagrant up", command.script)
if machine is None:
return start_all_in... | true | 2 | |
608 | thefuck | thefuck.system.unix | getch | def getch():
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old) | [
11,
18
] | false | [
"init_output"
] | import os
import sys
import tty
import termios
import colorama
from distutils.spawn import find_executable
from .. import const
init_output = colorama.init
def getch():
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.read(1)
finally:
ter... | false | 0 | |
609 | thefuck | thefuck.system.unix | get_key | def get_key():
ch = getch()
if ch in const.KEY_MAPPING:
return const.KEY_MAPPING[ch]
elif ch == '\x1b':
next_ch = getch()
if next_ch == '[':
last_ch = getch()
if last_ch == 'A':
return const.KEY_UP
elif last_ch == 'B':
... | [
21,
36
] | false | [
"init_output"
] | import os
import sys
import tty
import termios
import colorama
from distutils.spawn import find_executable
from .. import const
init_output = colorama.init
def get_key():
ch = getch()
if ch in const.KEY_MAPPING:
return const.KEY_MAPPING[ch]
elif ch == '\x1b':
next_ch = getch()
if ... | true | 2 | |
610 | thefuck | thefuck.system.unix | open_command | def open_command(arg):
if find_executable('xdg-open'):
return 'xdg-open ' + arg
return 'open ' + arg | [
39,
42
] | false | [
"init_output"
] | import os
import sys
import tty
import termios
import colorama
from distutils.spawn import find_executable
from .. import const
init_output = colorama.init
def open_command(arg):
if find_executable('xdg-open'):
return 'xdg-open ' + arg
return 'open ' + arg | true | 2 | |
611 | thefuck | thefuck.types | Command | __eq__ | def __eq__(self, other):
if isinstance(other, Command):
return (self.script, self.output) == (other.script, other.output)
else:
return False | [
47,
51
] | false | [] | from imp import load_source
import os
import sys
from . import logs
from .shells import shell
from .conf import settings
from .const import DEFAULT_PRIORITY, ALL_ENABLED
from .exceptions import EmptyCommand
from .utils import get_alias, format_raw_script
from .output_readers import get_output
class Command(object):
... | true | 2 |
612 | thefuck | thefuck.types | Rule | __eq__ | def __eq__(self, other):
if isinstance(other, Rule):
return ((self.name, self.match, self.get_new_command,
self.enabled_by_default, self.side_effect,
self.priority, self.requires_output)
== (other.name, other.match, other.get_new_comm... | [
110,
119
] | false | [] | from imp import load_source
import os
import sys
from . import logs
from .shells import shell
from .conf import settings
from .const import DEFAULT_PRIORITY, ALL_ENABLED
from .exceptions import EmptyCommand
from .utils import get_alias, format_raw_script
from .output_readers import get_output
class Rule(object):
... | true | 2 |
613 | thefuck | thefuck.types | Rule | is_match | def is_match(self, command):
"""Returns `True` if rule matches the command.
:type command: Command
:rtype: bool
"""
if command.output is None and self.requires_output:
return False
try:
with logs.debug_time(u'Trying rule: {};'.format(self.na... | [
168,
183
] | false | [] | from imp import load_source
import os
import sys
from . import logs
from .shells import shell
from .conf import settings
from .const import DEFAULT_PRIORITY, ALL_ENABLED
from .exceptions import EmptyCommand
from .utils import get_alias, format_raw_script
from .output_readers import get_output
class Command(object):
... | true | 2 |
614 | thefuck | thefuck.types | Rule | get_corrected_commands | def get_corrected_commands(self, command):
"""Returns generator with corrected commands.
:type command: Command
:rtype: Iterable[CorrectedCommand]
"""
new_commands = self.get_new_command(command)
if not isinstance(new_commands, list):
new_commands = (new... | [
185,
196
] | false | [] | from imp import load_source
import os
import sys
from . import logs
from .shells import shell
from .conf import settings
from .const import DEFAULT_PRIORITY, ALL_ENABLED
from .exceptions import EmptyCommand
from .utils import get_alias, format_raw_script
from .output_readers import get_output
class Command(object):
... | true | 2 |
615 | thefuck | thefuck.types | CorrectedCommand | __eq__ | def __eq__(self, other):
"""Ignores `priority` field."""
if isinstance(other, CorrectedCommand):
return (other.script, other.side_effect) == \
(self.script, self.side_effect)
else:
return False | [
216,
222
] | false | [] | from imp import load_source
import os
import sys
from . import logs
from .shells import shell
from .conf import settings
from .const import DEFAULT_PRIORITY, ALL_ENABLED
from .exceptions import EmptyCommand
from .utils import get_alias, format_raw_script
from .output_readers import get_output
class Command(object):
... | true | 2 |
616 | thefuck | thefuck.types | CorrectedCommand | run | def run(self, old_cmd):
"""Runs command from rule for passed command.
:type old_cmd: Command
"""
if self.side_effect:
self.side_effect(old_cmd, self.script)
if settings.alter_history:
shell.put_to_history(self.script)
# This depends on correc... | [
247,
261
] | false | [] | from imp import load_source
import os
import sys
from . import logs
from .shells import shell
from .conf import settings
from .const import DEFAULT_PRIORITY, ALL_ENABLED
from .exceptions import EmptyCommand
from .utils import get_alias, format_raw_script
from .output_readers import get_output
class Command(object):
... | true | 2 |
617 | thonny | thonny.jedi_utils | get_script_completions | def get_script_completions(source: str, row: int, column: int, filename: str, sys_path=None):
import jedi
if _using_older_jedi(jedi):
try:
script = jedi.Script(source, row, column, filename, sys_path=sys_path)
except Exception as e:
logger.info("Could not get completions... | [
51,
66
] | true | [
"logger"
] | import logging
from typing import List, Dict
logger = logging.getLogger(__name__)
def get_script_completions(source: str, row: int, column: int, filename: str, sys_path=None):
import jedi
if _using_older_jedi(jedi):
try:
script = jedi.Script(source, row, column, filename, sys_path=sys_pat... | true | 2 | |
618 | thonny | thonny.jedi_utils | get_interpreter_completions | def get_interpreter_completions(source: str, namespaces: List[Dict], sys_path=None):
import jedi
if _using_older_jedi(jedi):
try:
interpreter = jedi.Interpreter(source, namespaces, sys_path=sys_path)
except Exception as e:
logger.info("Could not get completions with give... | [
69,
86
] | true | [
"logger"
] | import logging
from typing import List, Dict
logger = logging.getLogger(__name__)
def get_interpreter_completions(source: str, namespaces: List[Dict], sys_path=None):
import jedi
if _using_older_jedi(jedi):
try:
interpreter = jedi.Interpreter(source, namespaces, sys_path=sys_path)
... | true | 2 | |
619 | thonny | thonny.jedi_utils | get_definitions | def get_definitions(source: str, row: int, column: int, filename: str):
import jedi
if _using_older_jedi(jedi):
script = jedi.Script(source, row, column, filename)
return script.goto_definitions()
else:
script = jedi.Script(code=source, path=filename)
return script.infer(lin... | [
122,
130
] | true | [
"logger"
] | import logging
from typing import List, Dict
logger = logging.getLogger(__name__)
def get_definitions(source: str, row: int, column: int, filename: str):
import jedi
if _using_older_jedi(jedi):
script = jedi.Script(source, row, column, filename)
return script.goto_definitions()
else:
... | true | 2 | |
620 | thonny | thonny.plugins.pgzero_frontend | toggle_variable | def toggle_variable():
var = get_workbench().get_variable(_OPTION_NAME)
var.set(not var.get())
update_environment() | [
8,
11
] | true | [
"_OPTION_NAME"
] | import os
from thonny import get_workbench
from thonny.languages import tr
_OPTION_NAME = "run.pgzero_mode"
def toggle_variable():
var = get_workbench().get_variable(_OPTION_NAME)
var.set(not var.get())
update_environment() | false | 0 | |
621 | thonny | thonny.plugins.pgzero_frontend | update_environment | def update_environment():
if get_workbench().in_simple_mode():
os.environ["PGZERO_MODE"] = "auto"
else:
os.environ["PGZERO_MODE"] = str(get_workbench().get_option(_OPTION_NAME)) | [
14,
18
] | true | [
"_OPTION_NAME"
] | import os
from thonny import get_workbench
from thonny.languages import tr
_OPTION_NAME = "run.pgzero_mode"
def update_environment():
if get_workbench().in_simple_mode():
os.environ["PGZERO_MODE"] = "auto"
else:
os.environ["PGZERO_MODE"] = str(get_workbench().get_option(_OPTION_NAME)) | true | 2 | |
622 | thonny | thonny.plugins.pgzero_frontend | load_plugin | def load_plugin():
get_workbench().set_default(_OPTION_NAME, False)
get_workbench().add_command(
"toggle_pgzero_mode",
"run",
tr("Pygame Zero mode"),
toggle_variable,
flag_name=_OPTION_NAME,
group=40,
)
update_environment() | [
21,
31
] | true | [
"_OPTION_NAME"
] | import os
from thonny import get_workbench
from thonny.languages import tr
_OPTION_NAME = "run.pgzero_mode"
def load_plugin():
get_workbench().set_default(_OPTION_NAME, False)
get_workbench().add_command(
"toggle_pgzero_mode",
"run",
tr("Pygame Zero mode"),
toggle_variable,
... | false | 0 | |
623 | thonny | thonny.roughparse | StringTranslatePseudoMapping | __getitem__ | def __getitem__(self, item):
return self._get(item) | [
148,
149
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
624 | thonny | thonny.roughparse | StringTranslatePseudoMapping | __len__ | def __len__(self):
return len(self._non_defaults) | [
151,
152
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
625 | thonny | thonny.roughparse | StringTranslatePseudoMapping | __iter__ | def __iter__(self):
return iter(self._non_defaults) | [
154,
155
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
626 | thonny | thonny.roughparse | StringTranslatePseudoMapping | get | def get(self, key, default=None):
return self._get(key) | [
157,
158
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
627 | thonny | thonny.roughparse | RoughParser | set_str | def set_str(self, s):
assert len(s) == 0 or s[-1] == "\n"
self.str = s
self.study_level = 0 | [
166,
169
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
628 | thonny | thonny.roughparse | RoughParser | find_good_parse_start | def find_good_parse_start(self, is_char_in_string=None, _synchre=_synchre):
# pylint: disable=redefined-builtin
str, pos = self.str, None # @ReservedAssignment
if not is_char_in_string:
# no clue -- make the caller pass everything
return None
# Peek back f... | [
182,
230
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | true | 2 |
629 | thonny | thonny.roughparse | RoughParser | set_lo | def set_lo(self, lo):
assert lo == 0 or self.str[lo - 1] == "\n"
if lo > 0:
self.str = self.str[lo:] | [
235,
238
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | true | 2 |
630 | thonny | thonny.roughparse | RoughParser | get_continuation_type | def get_continuation_type(self):
self._study1()
return self.continuation | [
391,
393
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
631 | thonny | thonny.roughparse | RoughParser | compute_bracket_indent | def compute_bracket_indent(self):
# pylint: disable=redefined-builtin
self._study2()
assert self.continuation == C_BRACKET
j = self.lastopenbracketpos
str = self.str # @ReservedAssignment
n = len(str)
origi = i = str.rfind("\n", 0, j) + 1
j = j + 1 #... | [
523,
549
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | true | 2 |
632 | thonny | thonny.roughparse | RoughParser | get_num_lines_in_stmt | def get_num_lines_in_stmt(self):
self._study1()
goodlines = self.goodlines
return goodlines[-1] - goodlines[-2] | [
555,
558
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
633 | thonny | thonny.roughparse | RoughParser | compute_backslash_indent | def compute_backslash_indent(self):
# pylint: disable=redefined-builtin
self._study2()
assert self.continuation == C_BACKSLASH
str = self.str # @ReservedAssignment
i = self.stmt_start
while str[i] in " \t":
i = i + 1
startpos = i
# See wh... | [
564,
615
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | true | 2 |
634 | thonny | thonny.roughparse | RoughParser | get_base_indent_string | def get_base_indent_string(self):
self._study2()
i, n = self.stmt_start, self.stmt_end
j = i
str_ = self.str
while j < n and str_[j] in " \t":
j = j + 1
return str_[i:j] | [
620,
627
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | true | 2 |
635 | thonny | thonny.roughparse | RoughParser | is_block_opener | def is_block_opener(self):
self._study2()
return self.lastch == ":" | [
631,
633
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
636 | thonny | thonny.roughparse | RoughParser | is_block_closer | def is_block_closer(self):
self._study2()
return _closere(self.str, self.stmt_start) is not None | [
637,
639
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
637 | thonny | thonny.roughparse | RoughParser | get_last_open_bracket_pos | def get_last_open_bracket_pos(self):
self._study2()
return self.lastopenbracketpos | [
644,
646
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
638 | thonny | thonny.roughparse | RoughParser | get_last_stmt_bracketing | def get_last_stmt_bracketing(self):
self._study2()
return self.stmt_bracketing | [
653,
655
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
639 | thonny | thonny.roughparse | HyperParser | __init__ | def __init__(self, text, index):
"To initialize, analyze the surroundings of the given index."
self.text = text
parser = RoughParser(text.indent_width, text.tabwidth)
def index2line(index):
return int(float(index))
lno = index2line(text.index(index))
... | [
678,
718
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | true | 2 |
640 | thonny | thonny.roughparse | HyperParser | set_index | def set_index(self, index):
"""Set the index to which the functions relate.
The index must be in the same statement.
"""
indexinrawtext = len(self.rawtext) - len(self.text.get(index, self.stopatindex))
if indexinrawtext < 0:
raise ValueError("Index %s precedes th... | [
720,
741
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | true | 2 |
641 | thonny | thonny.roughparse | HyperParser | is_in_string | def is_in_string(self):
"""Is the index given to the HyperParser in a string?"""
# The bracket to which we belong should be an opener.
# If it's an opener, it has to have a character.
return self.isopener[self.indexbracket] and self.rawtext[
self.bracketing[self.indexbrac... | [
743,
747
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
642 | thonny | thonny.roughparse | HyperParser | is_in_code | def is_in_code(self):
"""Is the index given to the HyperParser in normal code?"""
return not self.isopener[self.indexbracket] or self.rawtext[
self.bracketing[self.indexbracket][0]
] not in ("#", '"', "'") | [
751,
753
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | false | 0 |
643 | thonny | thonny.roughparse | HyperParser | get_surrounding_brackets | def get_surrounding_brackets(self, openers="([{", mustclose=False):
"""Return bracket indexes or None.
If the index given to the HyperParser is surrounded by a
bracket defined in openers (or at least has one before it),
return the indices of the opening bracket and the closing
... | [
757,
798
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | true | 2 |
644 | thonny | thonny.roughparse | HyperParser | get_expression | def get_expression(self):
"""Return a string with the Python expression which ends at the
given index, which is empty if there is no real one.
"""
if not self.is_in_code():
raise ValueError("get_expression should only be called" "if index is inside a code.")
rawt... | [
858,
944
] | true | [
"NUM_CONTEXT_LINES",
"C_NONE",
"C_BACKSLASH",
"C_STRING_FIRST_LINE",
"C_STRING_NEXT_LINES",
"C_BRACKET",
"_synchre",
"_junkre",
"_match_stringre",
"_itemre",
"_closere",
"_chew_ordinaryre",
"_ASCII_ID_CHARS",
"_ASCII_ID_FIRST_CHARS",
"_IS_ASCII_ID_CHAR",
"_IS_ASCII_ID_FIRST_CHAR"
] | import re
import string
from collections.abc import Mapping
from keyword import iskeyword
from typing import Dict
NUM_CONTEXT_LINES = (50, 500, 5000000)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = range(5)
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE, C_STRING_NEXT_LINES, C_BRACKET) = ran... | true | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.