repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.flags
def flags(self, text, scoped=False): """Analyze flags.""" global_retry = False if ('a' in text or 'L' in text) and self.unicode: self.unicode = False if not _SCOPED_FLAG_SUPPORT or not scoped: self.temp_global_flag_swap["unicode"] = True g...
python
def flags(self, text, scoped=False): """Analyze flags.""" global_retry = False if ('a' in text or 'L' in text) and self.unicode: self.unicode = False if not _SCOPED_FLAG_SUPPORT or not scoped: self.temp_global_flag_swap["unicode"] = True g...
[ "def", "flags", "(", "self", ",", "text", ",", "scoped", "=", "False", ")", ":", "global_retry", "=", "False", "if", "(", "'a'", "in", "text", "or", "'L'", "in", "text", ")", "and", "self", ".", "unicode", ":", "self", ".", "unicode", "=", "False",...
Analyze flags.
[ "Analyze", "flags", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L161-L183
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.get_unicode_property
def get_unicode_property(self, i): """Get Unicode property.""" index = i.index prop = [] value = [] try: c = next(i) if c.upper() in _ASCII_LETTERS: prop.append(c) elif c != '{': raise SyntaxError("Unicode prope...
python
def get_unicode_property(self, i): """Get Unicode property.""" index = i.index prop = [] value = [] try: c = next(i) if c.upper() in _ASCII_LETTERS: prop.append(c) elif c != '{': raise SyntaxError("Unicode prope...
[ "def", "get_unicode_property", "(", "self", ",", "i", ")", ":", "index", "=", "i", ".", "index", "prop", "=", "[", "]", "value", "=", "[", "]", "try", ":", "c", "=", "next", "(", "i", ")", "if", "c", ".", "upper", "(", ")", "in", "_ASCII_LETTER...
Get Unicode property.
[ "Get", "Unicode", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L185-L221
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.get_named_unicode
def get_named_unicode(self, i): """Get Unicode name.""" index = i.index value = [] try: if next(i) != '{': raise ValueError("Named Unicode missing '{' %d!" % (i.index - 1)) c = next(i) while c != '}': value.append(c) ...
python
def get_named_unicode(self, i): """Get Unicode name.""" index = i.index value = [] try: if next(i) != '{': raise ValueError("Named Unicode missing '{' %d!" % (i.index - 1)) c = next(i) while c != '}': value.append(c) ...
[ "def", "get_named_unicode", "(", "self", ",", "i", ")", ":", "index", "=", "i", ".", "index", "value", "=", "[", "]", "try", ":", "if", "next", "(", "i", ")", "!=", "'{'", ":", "raise", "ValueError", "(", "\"Named Unicode missing '{' %d!\"", "%", "(", ...
Get Unicode name.
[ "Get", "Unicode", "name", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L223-L238
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.reference
def reference(self, t, i, in_group=False): """Handle references.""" current = [] if not in_group and t == "m": current.append(self._re_start_wb) elif not in_group and t == "M": current.append(self._re_end_wb) elif not in_group and t == "R": c...
python
def reference(self, t, i, in_group=False): """Handle references.""" current = [] if not in_group and t == "m": current.append(self._re_start_wb) elif not in_group and t == "M": current.append(self._re_end_wb) elif not in_group and t == "R": c...
[ "def", "reference", "(", "self", ",", "t", ",", "i", ",", "in_group", "=", "False", ")", ":", "current", "=", "[", "]", "if", "not", "in_group", "and", "t", "==", "\"m\"", ":", "current", ".", "append", "(", "self", ".", "_re_start_wb", ")", "elif"...
Handle references.
[ "Handle", "references", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L240-L286
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.get_comments
def get_comments(self, i): """Get comments.""" index = i.index value = ['('] escaped = False try: c = next(i) if c != '?': i.rewind(1) return None value.append(c) c = next(i) if c != '#':...
python
def get_comments(self, i): """Get comments.""" index = i.index value = ['('] escaped = False try: c = next(i) if c != '?': i.rewind(1) return None value.append(c) c = next(i) if c != '#':...
[ "def", "get_comments", "(", "self", ",", "i", ")", ":", "index", "=", "i", ".", "index", "value", "=", "[", "'('", "]", "escaped", "=", "False", "try", ":", "c", "=", "next", "(", "i", ")", "if", "c", "!=", "'?'", ":", "i", ".", "rewind", "("...
Get comments.
[ "Get", "comments", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L288-L317
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.get_flags
def get_flags(self, i, scoped=False): """Get flags.""" if scoped and not _SCOPED_FLAG_SUPPORT: return None index = i.index value = ['('] toggle = False end = ':' if scoped else ')' try: c = next(i) if c != '?': ...
python
def get_flags(self, i, scoped=False): """Get flags.""" if scoped and not _SCOPED_FLAG_SUPPORT: return None index = i.index value = ['('] toggle = False end = ':' if scoped else ')' try: c = next(i) if c != '?': ...
[ "def", "get_flags", "(", "self", ",", "i", ",", "scoped", "=", "False", ")", ":", "if", "scoped", "and", "not", "_SCOPED_FLAG_SUPPORT", ":", "return", "None", "index", "=", "i", ".", "index", "value", "=", "[", "'('", "]", "toggle", "=", "False", "en...
Get flags.
[ "Get", "flags", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L319-L354
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.subgroup
def subgroup(self, t, i): """Handle parenthesis.""" current = [] # (?flags) flags = self.get_flags(i) if flags: self.flags(flags[2:-1]) return [flags] # (?#comment) comments = self.get_comments(i) if comments: return ...
python
def subgroup(self, t, i): """Handle parenthesis.""" current = [] # (?flags) flags = self.get_flags(i) if flags: self.flags(flags[2:-1]) return [flags] # (?#comment) comments = self.get_comments(i) if comments: return ...
[ "def", "subgroup", "(", "self", ",", "t", ",", "i", ")", ":", "current", "=", "[", "]", "# (?flags)", "flags", "=", "self", ".", "get_flags", "(", "i", ")", "if", "flags", ":", "self", ".", "flags", "(", "flags", "[", "2", ":", "-", "1", "]", ...
Handle parenthesis.
[ "Handle", "parenthesis", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L356-L399
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.char_groups
def char_groups(self, t, i): """Handle character groups.""" current = [] pos = i.index - 1 found = False escaped = False first = None found_property = False self.found_property = False self.found_named_unicode = False try: whi...
python
def char_groups(self, t, i): """Handle character groups.""" current = [] pos = i.index - 1 found = False escaped = False first = None found_property = False self.found_property = False self.found_named_unicode = False try: whi...
[ "def", "char_groups", "(", "self", ",", "t", ",", "i", ")", ":", "current", "=", "[", "]", "pos", "=", "i", ".", "index", "-", "1", "found", "=", "False", "escaped", "=", "False", "first", "=", "None", "found_property", "=", "False", "self", ".", ...
Handle character groups.
[ "Handle", "character", "groups", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L428-L510
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.normal
def normal(self, t, i): """Handle normal chars.""" current = [] if t == "\\": try: t = next(i) current.extend(self.reference(t, i)) except StopIteration: current.append(t) elif t == "(": current.extend(...
python
def normal(self, t, i): """Handle normal chars.""" current = [] if t == "\\": try: t = next(i) current.extend(self.reference(t, i)) except StopIteration: current.append(t) elif t == "(": current.extend(...
[ "def", "normal", "(", "self", ",", "t", ",", "i", ")", ":", "current", "=", "[", "]", "if", "t", "==", "\"\\\\\"", ":", "try", ":", "t", "=", "next", "(", "i", ")", "current", ".", "extend", "(", "self", ".", "reference", "(", "t", ",", "i", ...
Handle normal chars.
[ "Handle", "normal", "chars", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L512-L531
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.posix_props
def posix_props(self, prop, in_group=False): """ Insert POSIX properties. Posix style properties are not as forgiving as Unicode properties. Case does matter, and whitespace and '-' and '_' will not be tolerated. """ try: if self.is_bytes or not sel...
python
def posix_props(self, prop, in_group=False): """ Insert POSIX properties. Posix style properties are not as forgiving as Unicode properties. Case does matter, and whitespace and '-' and '_' will not be tolerated. """ try: if self.is_bytes or not sel...
[ "def", "posix_props", "(", "self", ",", "prop", ",", "in_group", "=", "False", ")", ":", "try", ":", "if", "self", ".", "is_bytes", "or", "not", "self", ".", "unicode", ":", "pattern", "=", "_uniprops", ".", "get_posix_property", "(", "prop", ",", "(",...
Insert POSIX properties. Posix style properties are not as forgiving as Unicode properties. Case does matter, and whitespace and '-' and '_' will not be tolerated.
[ "Insert", "POSIX", "properties", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L533-L554
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.unicode_name
def unicode_name(self, name, in_group=False): """Insert Unicode value by its name.""" value = ord(_unicodedata.lookup(name)) if (self.is_bytes and value > 0xFF): value = "" if not in_group and value == "": return '[^%s]' % ('\x00-\xff' if self.is_bytes else _unip...
python
def unicode_name(self, name, in_group=False): """Insert Unicode value by its name.""" value = ord(_unicodedata.lookup(name)) if (self.is_bytes and value > 0xFF): value = "" if not in_group and value == "": return '[^%s]' % ('\x00-\xff' if self.is_bytes else _unip...
[ "def", "unicode_name", "(", "self", ",", "name", ",", "in_group", "=", "False", ")", ":", "value", "=", "ord", "(", "_unicodedata", ".", "lookup", "(", "name", ")", ")", "if", "(", "self", ".", "is_bytes", "and", "value", ">", "0xFF", ")", ":", "va...
Insert Unicode value by its name.
[ "Insert", "Unicode", "value", "by", "its", "name", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L556-L567
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.unicode_props
def unicode_props(self, props, value, in_group=False, negate=False): """ Insert Unicode properties. Unicode properties are very forgiving. Case doesn't matter and `[ -_]` will be stripped out. """ # `'GC = Some_Unpredictable-Category Name' -> 'gc=someunpredictablecatego...
python
def unicode_props(self, props, value, in_group=False, negate=False): """ Insert Unicode properties. Unicode properties are very forgiving. Case doesn't matter and `[ -_]` will be stripped out. """ # `'GC = Some_Unpredictable-Category Name' -> 'gc=someunpredictablecatego...
[ "def", "unicode_props", "(", "self", ",", "props", ",", "value", ",", "in_group", "=", "False", ",", "negate", "=", "False", ")", ":", "# `'GC = Some_Unpredictable-Category Name' -> 'gc=someunpredictablecategoryname'`", "category", "=", "None", "# `\\p{^negated}` Strip of...
Insert Unicode properties. Unicode properties are very forgiving. Case doesn't matter and `[ -_]` will be stripped out.
[ "Insert", "Unicode", "properties", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L569-L609
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.letter_case_props
def letter_case_props(self, case, in_group, negate=False): """Insert letter (ASCII or Unicode) case properties.""" # Use traditional ASCII upper/lower case unless: # 1. The strings fed in are not bytes # 2. And the the Unicode flag was used if not in_group: v =...
python
def letter_case_props(self, case, in_group, negate=False): """Insert letter (ASCII or Unicode) case properties.""" # Use traditional ASCII upper/lower case unless: # 1. The strings fed in are not bytes # 2. And the the Unicode flag was used if not in_group: v =...
[ "def", "letter_case_props", "(", "self", ",", "case", ",", "in_group", ",", "negate", "=", "False", ")", ":", "# Use traditional ASCII upper/lower case unless:", "# 1. The strings fed in are not bytes", "# 2. And the the Unicode flag was used", "if", "not", "in_group", ...
Insert letter (ASCII or Unicode) case properties.
[ "Insert", "letter", "(", "ASCII", "or", "Unicode", ")", "case", "properties", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L611-L622
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.main_group
def main_group(self, i): """The main group: group 0.""" current = [] while True: try: t = next(i) current.extend(self.normal(t, i)) except StopIteration: break return current
python
def main_group(self, i): """The main group: group 0.""" current = [] while True: try: t = next(i) current.extend(self.normal(t, i)) except StopIteration: break return current
[ "def", "main_group", "(", "self", ",", "i", ")", ":", "current", "=", "[", "]", "while", "True", ":", "try", ":", "t", "=", "next", "(", "i", ")", "current", ".", "extend", "(", "self", ".", "normal", "(", "t", ",", "i", ")", ")", "except", "...
The main group: group 0.
[ "The", "main", "group", ":", "group", "0", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L624-L634
facelessuser/backrefs
backrefs/_bre_parse.py
_SearchParser.parse
def parse(self): """Apply search template.""" self.verbose = bool(self.re_verbose) self.unicode = bool(self.re_unicode) self.global_flag_swap = { "unicode": ((self.re_unicode is not None) if not _util.PY37 else False), "verbose": False } self.temp...
python
def parse(self): """Apply search template.""" self.verbose = bool(self.re_verbose) self.unicode = bool(self.re_unicode) self.global_flag_swap = { "unicode": ((self.re_unicode is not None) if not _util.PY37 else False), "verbose": False } self.temp...
[ "def", "parse", "(", "self", ")", ":", "self", ".", "verbose", "=", "bool", "(", "self", ".", "re_verbose", ")", "self", ".", "unicode", "=", "bool", "(", "self", ".", "re_unicode", ")", "self", ".", "global_flag_swap", "=", "{", "\"unicode\"", ":", ...
Apply search template.
[ "Apply", "search", "template", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L636-L684
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.parse_format_index
def parse_format_index(self, text): """Parse format index.""" base = 10 prefix = text[1:3] if text[0] == "-" else text[:2] if prefix[0:1] == "0": char = prefix[-1] if char == "b": base = 2 elif char == "o": base = 8 ...
python
def parse_format_index(self, text): """Parse format index.""" base = 10 prefix = text[1:3] if text[0] == "-" else text[:2] if prefix[0:1] == "0": char = prefix[-1] if char == "b": base = 2 elif char == "o": base = 8 ...
[ "def", "parse_format_index", "(", "self", ",", "text", ")", ":", "base", "=", "10", "prefix", "=", "text", "[", "1", ":", "3", "]", "if", "text", "[", "0", "]", "==", "\"-\"", "else", "text", "[", ":", "2", "]", "if", "prefix", "[", "0", ":", ...
Parse format index.
[ "Parse", "format", "index", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L704-L721
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.handle_format
def handle_format(self, t, i): """Handle format.""" if t == '{': t = self.format_next(i) if t == '{': self.get_single_stack() self.result.append(t) else: field, text = self.get_format(t, i) self.handle_f...
python
def handle_format(self, t, i): """Handle format.""" if t == '{': t = self.format_next(i) if t == '{': self.get_single_stack() self.result.append(t) else: field, text = self.get_format(t, i) self.handle_f...
[ "def", "handle_format", "(", "self", ",", "t", ",", "i", ")", ":", "if", "t", "==", "'{'", ":", "t", "=", "self", ".", "format_next", "(", "i", ")", "if", "t", "==", "'{'", ":", "self", ".", "get_single_stack", "(", ")", "self", ".", "result", ...
Handle format.
[ "Handle", "format", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L857-L874
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.get_octal
def get_octal(self, c, i): """Get octal.""" index = i.index value = [] zero_count = 0 try: if c == '0': for x in range(3): if c != '0': break value.append(c) c = next(...
python
def get_octal(self, c, i): """Get octal.""" index = i.index value = [] zero_count = 0 try: if c == '0': for x in range(3): if c != '0': break value.append(c) c = next(...
[ "def", "get_octal", "(", "self", ",", "c", ",", "i", ")", ":", "index", "=", "i", ".", "index", "value", "=", "[", "]", "zero_count", "=", "0", "try", ":", "if", "c", "==", "'0'", ":", "for", "x", "in", "range", "(", "3", ")", ":", "if", "c...
Get octal.
[ "Get", "octal", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L876-L905
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.parse_octal
def parse_octal(self, text, i): """Parse octal value.""" value = int(text, 8) if value > 0xFF and self.is_bytes: # Re fails on octal greater than `0o377` or `0xFF` raise ValueError("octal escape value outside of range 0-0o377!") else: single = self.ge...
python
def parse_octal(self, text, i): """Parse octal value.""" value = int(text, 8) if value > 0xFF and self.is_bytes: # Re fails on octal greater than `0o377` or `0xFF` raise ValueError("octal escape value outside of range 0-0o377!") else: single = self.ge...
[ "def", "parse_octal", "(", "self", ",", "text", ",", "i", ")", ":", "value", "=", "int", "(", "text", ",", "8", ")", "if", "value", ">", "0xFF", "and", "self", ".", "is_bytes", ":", "# Re fails on octal greater than `0o377` or `0xFF`", "raise", "ValueError",...
Parse octal value.
[ "Parse", "octal", "value", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L907-L926
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.get_named_unicode
def get_named_unicode(self, i): """Get named Unicode.""" index = i.index value = [] try: if next(i) != '{': raise SyntaxError("Named Unicode missing '{'' at %d!" % (i.index - 1)) c = next(i) while c != '}': value.append...
python
def get_named_unicode(self, i): """Get named Unicode.""" index = i.index value = [] try: if next(i) != '{': raise SyntaxError("Named Unicode missing '{'' at %d!" % (i.index - 1)) c = next(i) while c != '}': value.append...
[ "def", "get_named_unicode", "(", "self", ",", "i", ")", ":", "index", "=", "i", ".", "index", "value", "=", "[", "]", "try", ":", "if", "next", "(", "i", ")", "!=", "'{'", ":", "raise", "SyntaxError", "(", "\"Named Unicode missing '{'' at %d!\"", "%", ...
Get named Unicode.
[ "Get", "named", "Unicode", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L928-L943
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.parse_named_unicode
def parse_named_unicode(self, i): """Parse named Unicode.""" value = ord(_unicodedata.lookup(self.get_named_unicode(i))) single = self.get_single_stack() if self.span_stack: text = self.convert_case(chr(value), self.span_stack[-1]) value = ord(self.convert_case(t...
python
def parse_named_unicode(self, i): """Parse named Unicode.""" value = ord(_unicodedata.lookup(self.get_named_unicode(i))) single = self.get_single_stack() if self.span_stack: text = self.convert_case(chr(value), self.span_stack[-1]) value = ord(self.convert_case(t...
[ "def", "parse_named_unicode", "(", "self", ",", "i", ")", ":", "value", "=", "ord", "(", "_unicodedata", ".", "lookup", "(", "self", ".", "get_named_unicode", "(", "i", ")", ")", ")", "single", "=", "self", ".", "get_single_stack", "(", ")", "if", "sel...
Parse named Unicode.
[ "Parse", "named", "Unicode", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L945-L960
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.get_wide_unicode
def get_wide_unicode(self, i): """Get narrow Unicode.""" value = [] for x in range(3): c = next(i) if c == '0': value.append(c) else: # pragma: no cover raise SyntaxError('Invalid wide Unicode character at %d!' % (i.index - 1)...
python
def get_wide_unicode(self, i): """Get narrow Unicode.""" value = [] for x in range(3): c = next(i) if c == '0': value.append(c) else: # pragma: no cover raise SyntaxError('Invalid wide Unicode character at %d!' % (i.index - 1)...
[ "def", "get_wide_unicode", "(", "self", ",", "i", ")", ":", "value", "=", "[", "]", "for", "x", "in", "range", "(", "3", ")", ":", "c", "=", "next", "(", "i", ")", "if", "c", "==", "'0'", ":", "value", ".", "append", "(", "c", ")", "else", ...
Get narrow Unicode.
[ "Get", "narrow", "Unicode", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L962-L985
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.parse_unicode
def parse_unicode(self, i, wide=False): """Parse Unicode.""" text = self.get_wide_unicode(i) if wide else self.get_narrow_unicode(i) value = int(text, 16) single = self.get_single_stack() if self.span_stack: text = self.convert_case(chr(value), self.span_stack[-1]) ...
python
def parse_unicode(self, i, wide=False): """Parse Unicode.""" text = self.get_wide_unicode(i) if wide else self.get_narrow_unicode(i) value = int(text, 16) single = self.get_single_stack() if self.span_stack: text = self.convert_case(chr(value), self.span_stack[-1]) ...
[ "def", "parse_unicode", "(", "self", ",", "i", ",", "wide", "=", "False", ")", ":", "text", "=", "self", ".", "get_wide_unicode", "(", "i", ")", "if", "wide", "else", "self", ".", "get_narrow_unicode", "(", "i", ")", "value", "=", "int", "(", "text",...
Parse Unicode.
[ "Parse", "Unicode", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L999-L1015
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.get_byte
def get_byte(self, i): """Get byte.""" value = [] for x in range(2): c = next(i) if c.lower() in _HEX: value.append(c) else: # pragma: no cover raise SyntaxError('Invalid byte character at %d!' % (i.index - 1)) return ...
python
def get_byte(self, i): """Get byte.""" value = [] for x in range(2): c = next(i) if c.lower() in _HEX: value.append(c) else: # pragma: no cover raise SyntaxError('Invalid byte character at %d!' % (i.index - 1)) return ...
[ "def", "get_byte", "(", "self", ",", "i", ")", ":", "value", "=", "[", "]", "for", "x", "in", "range", "(", "2", ")", ":", "c", "=", "next", "(", "i", ")", "if", "c", ".", "lower", "(", ")", "in", "_HEX", ":", "value", ".", "append", "(", ...
Get byte.
[ "Get", "byte", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1017-L1027
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.parse_bytes
def parse_bytes(self, i): """Parse byte.""" value = int(self.get_byte(i), 16) single = self.get_single_stack() if self.span_stack: text = self.convert_case(chr(value), self.span_stack[-1]) value = ord(self.convert_case(text, single)) if single is not None else or...
python
def parse_bytes(self, i): """Parse byte.""" value = int(self.get_byte(i), 16) single = self.get_single_stack() if self.span_stack: text = self.convert_case(chr(value), self.span_stack[-1]) value = ord(self.convert_case(text, single)) if single is not None else or...
[ "def", "parse_bytes", "(", "self", ",", "i", ")", ":", "value", "=", "int", "(", "self", ".", "get_byte", "(", "i", ")", ",", "16", ")", "single", "=", "self", ".", "get_single_stack", "(", ")", "if", "self", ".", "span_stack", ":", "text", "=", ...
Parse byte.
[ "Parse", "byte", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1029-L1042
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.get_named_group
def get_named_group(self, t, i): """Get group number.""" index = i.index value = [t] try: c = next(i) if c != "<": raise SyntaxError("Group missing '<' at %d!" % (i.index - 1)) value.append(c) c = next(i) if c i...
python
def get_named_group(self, t, i): """Get group number.""" index = i.index value = [t] try: c = next(i) if c != "<": raise SyntaxError("Group missing '<' at %d!" % (i.index - 1)) value.append(c) c = next(i) if c i...
[ "def", "get_named_group", "(", "self", ",", "t", ",", "i", ")", ":", "index", "=", "i", ".", "index", "value", "=", "[", "t", "]", "try", ":", "c", "=", "next", "(", "i", ")", "if", "c", "!=", "\"<\"", ":", "raise", "SyntaxError", "(", "\"Group...
Get group number.
[ "Get", "group", "number", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1044-L1076
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.get_group
def get_group(self, t, i): """Get group number.""" try: value = [] if t in _DIGIT and t != '0': value.append(t) t = next(i) if t in _DIGIT: value.append(t) else: i.rewind(1) ...
python
def get_group(self, t, i): """Get group number.""" try: value = [] if t in _DIGIT and t != '0': value.append(t) t = next(i) if t in _DIGIT: value.append(t) else: i.rewind(1) ...
[ "def", "get_group", "(", "self", ",", "t", ",", "i", ")", ":", "try", ":", "value", "=", "[", "]", "if", "t", "in", "_DIGIT", "and", "t", "!=", "'0'", ":", "value", ".", "append", "(", "t", ")", "t", "=", "next", "(", "i", ")", "if", "t", ...
Get group number.
[ "Get", "group", "number", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1078-L1092
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.format_next
def format_next(self, i): """Get next format char.""" c = next(i) return self.format_references(next(i), i) if c == '\\' else c
python
def format_next(self, i): """Get next format char.""" c = next(i) return self.format_references(next(i), i) if c == '\\' else c
[ "def", "format_next", "(", "self", ",", "i", ")", ":", "c", "=", "next", "(", "i", ")", "return", "self", ".", "format_references", "(", "next", "(", "i", ")", ",", "i", ")", "if", "c", "==", "'\\\\'", "else", "c" ]
Get next format char.
[ "Get", "next", "format", "char", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1094-L1098
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.format_references
def format_references(self, t, i): """Handle format references.""" octal = self.get_octal(t, i) if octal: value = int(octal, 8) if value > 0xFF and self.is_bytes: # Re fails on octal greater than `0o377` or `0xFF` raise ValueError("octal e...
python
def format_references(self, t, i): """Handle format references.""" octal = self.get_octal(t, i) if octal: value = int(octal, 8) if value > 0xFF and self.is_bytes: # Re fails on octal greater than `0o377` or `0xFF` raise ValueError("octal e...
[ "def", "format_references", "(", "self", ",", "t", ",", "i", ")", ":", "octal", "=", "self", ".", "get_octal", "(", "t", ",", "i", ")", "if", "octal", ":", "value", "=", "int", "(", "octal", ",", "8", ")", "if", "value", ">", "0xFF", "and", "se...
Handle format references.
[ "Handle", "format", "references", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1100-L1123
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.reference
def reference(self, t, i): """Handle references.""" octal = self.get_octal(t, i) if t in _OCTAL and octal: self.parse_octal(octal, i) elif (t in _DIGIT or t == 'g') and not self.use_format: group = self.get_group(t, i) if not group: gro...
python
def reference(self, t, i): """Handle references.""" octal = self.get_octal(t, i) if t in _OCTAL and octal: self.parse_octal(octal, i) elif (t in _DIGIT or t == 'g') and not self.use_format: group = self.get_group(t, i) if not group: gro...
[ "def", "reference", "(", "self", ",", "t", ",", "i", ")", ":", "octal", "=", "self", ".", "get_octal", "(", "t", ",", "i", ")", "if", "t", "in", "_OCTAL", "and", "octal", ":", "self", ".", "parse_octal", "(", "octal", ",", "i", ")", "elif", "("...
Handle references.
[ "Handle", "references", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1125-L1167
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.span_case
def span_case(self, i, case): """Uppercase or lowercase the next range of characters until end marker is found.""" # A new \L, \C or \E should pop the last in the stack. if self.span_stack: self.span_stack.pop() if self.single_stack: self.single_stack.pop() ...
python
def span_case(self, i, case): """Uppercase or lowercase the next range of characters until end marker is found.""" # A new \L, \C or \E should pop the last in the stack. if self.span_stack: self.span_stack.pop() if self.single_stack: self.single_stack.pop() ...
[ "def", "span_case", "(", "self", ",", "i", ",", "case", ")", ":", "# A new \\L, \\C or \\E should pop the last in the stack.", "if", "self", ".", "span_stack", ":", "self", ".", "span_stack", ".", "pop", "(", ")", "if", "self", ".", "single_stack", ":", "self"...
Uppercase or lowercase the next range of characters until end marker is found.
[ "Uppercase", "or", "lowercase", "the", "next", "range", "of", "characters", "until", "end", "marker", "is", "found", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1206-L1237
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.convert_case
def convert_case(self, value, case): """Convert case.""" if self.is_bytes: cased = [] for c in value: if c in _ASCII_LETTERS: cased.append(c.lower() if case == _LOWER else c.upper()) else: cased.append(c) ...
python
def convert_case(self, value, case): """Convert case.""" if self.is_bytes: cased = [] for c in value: if c in _ASCII_LETTERS: cased.append(c.lower() if case == _LOWER else c.upper()) else: cased.append(c) ...
[ "def", "convert_case", "(", "self", ",", "value", ",", "case", ")", ":", "if", "self", ".", "is_bytes", ":", "cased", "=", "[", "]", "for", "c", "in", "value", ":", "if", "c", "in", "_ASCII_LETTERS", ":", "cased", ".", "append", "(", "c", ".", "l...
Convert case.
[ "Convert", "case", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1239-L1251
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.single_case
def single_case(self, i, case): """Uppercase or lowercase the next character.""" # Pop a previous case if we have consecutive ones. if self.single_stack: self.single_stack.pop() self.single_stack.append(case) try: t = next(i) if self.use_forma...
python
def single_case(self, i, case): """Uppercase or lowercase the next character.""" # Pop a previous case if we have consecutive ones. if self.single_stack: self.single_stack.pop() self.single_stack.append(case) try: t = next(i) if self.use_forma...
[ "def", "single_case", "(", "self", ",", "i", ",", "case", ")", ":", "# Pop a previous case if we have consecutive ones.", "if", "self", ".", "single_stack", ":", "self", ".", "single_stack", ".", "pop", "(", ")", "self", ".", "single_stack", ".", "append", "("...
Uppercase or lowercase the next character.
[ "Uppercase", "or", "lowercase", "the", "next", "character", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1253-L1274
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.get_single_stack
def get_single_stack(self): """Get the correct single stack item to use.""" single = None while self.single_stack: single = self.single_stack.pop() return single
python
def get_single_stack(self): """Get the correct single stack item to use.""" single = None while self.single_stack: single = self.single_stack.pop() return single
[ "def", "get_single_stack", "(", "self", ")", ":", "single", "=", "None", "while", "self", ".", "single_stack", ":", "single", "=", "self", ".", "single_stack", ".", "pop", "(", ")", "return", "single" ]
Get the correct single stack item to use.
[ "Get", "the", "correct", "single", "stack", "item", "to", "use", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1276-L1282
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.handle_format_group
def handle_format_group(self, field, text): """Handle format group.""" # Handle auto incrementing group indexes if field == '': if self.auto: field = str(self.auto_index) text[0] = (_util.FMT_FIELD, field) self.auto_index += 1 ...
python
def handle_format_group(self, field, text): """Handle format group.""" # Handle auto incrementing group indexes if field == '': if self.auto: field = str(self.auto_index) text[0] = (_util.FMT_FIELD, field) self.auto_index += 1 ...
[ "def", "handle_format_group", "(", "self", ",", "field", ",", "text", ")", ":", "# Handle auto incrementing group indexes", "if", "field", "==", "''", ":", "if", "self", ".", "auto", ":", "field", "=", "str", "(", "self", ".", "auto_index", ")", "text", "[...
Handle format group.
[ "Handle", "format", "group", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1284-L1305
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.handle_group
def handle_group(self, text, capture=None, is_format=False): """Handle groups.""" if capture is None: capture = tuple() if self.is_bytes else '' if len(self.result) > 1: self.literal_slots.append("".join(self.result)) if is_format: self.liter...
python
def handle_group(self, text, capture=None, is_format=False): """Handle groups.""" if capture is None: capture = tuple() if self.is_bytes else '' if len(self.result) > 1: self.literal_slots.append("".join(self.result)) if is_format: self.liter...
[ "def", "handle_group", "(", "self", ",", "text", ",", "capture", "=", "None", ",", "is_format", "=", "False", ")", ":", "if", "capture", "is", "None", ":", "capture", "=", "tuple", "(", ")", "if", "self", ".", "is_bytes", "else", "''", "if", "len", ...
Handle groups.
[ "Handle", "groups", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1307-L1337
facelessuser/backrefs
backrefs/_bre_parse.py
_ReplaceParser.parse
def parse(self, pattern, template, use_format=False): """Parse template.""" if isinstance(template, bytes): self.is_bytes = True else: self.is_bytes = False if isinstance(pattern.pattern, bytes) != self.is_bytes: raise TypeError('Pattern string type m...
python
def parse(self, pattern, template, use_format=False): """Parse template.""" if isinstance(template, bytes): self.is_bytes = True else: self.is_bytes = False if isinstance(pattern.pattern, bytes) != self.is_bytes: raise TypeError('Pattern string type m...
[ "def", "parse", "(", "self", ",", "pattern", ",", "template", ",", "use_format", "=", "False", ")", ":", "if", "isinstance", "(", "template", ",", "bytes", ")", ":", "self", ".", "is_bytes", "=", "True", "else", ":", "self", ".", "is_bytes", "=", "Fa...
Parse template.
[ "Parse", "template", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1344-L1364
facelessuser/backrefs
backrefs/_bre_parse.py
ReplaceTemplate._get_group_index
def _get_group_index(self, index): """Find and return the appropriate group index.""" g_index = None for group in self.groups: if group[0] == index: g_index = group[1] break return g_index
python
def _get_group_index(self, index): """Find and return the appropriate group index.""" g_index = None for group in self.groups: if group[0] == index: g_index = group[1] break return g_index
[ "def", "_get_group_index", "(", "self", ",", "index", ")", ":", "g_index", "=", "None", "for", "group", "in", "self", ".", "groups", ":", "if", "group", "[", "0", "]", "==", "index", ":", "g_index", "=", "group", "[", "1", "]", "break", "return", "...
Find and return the appropriate group index.
[ "Find", "and", "return", "the", "appropriate", "group", "index", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1436-L1444
facelessuser/backrefs
backrefs/_bre_parse.py
ReplaceTemplate._get_group_attributes
def _get_group_attributes(self, index): """Find and return the appropriate group case.""" g_case = (None, None, -1) for group in self.group_slots: if group[0] == index: g_case = group[1] break return g_case
python
def _get_group_attributes(self, index): """Find and return the appropriate group case.""" g_case = (None, None, -1) for group in self.group_slots: if group[0] == index: g_case = group[1] break return g_case
[ "def", "_get_group_attributes", "(", "self", ",", "index", ")", ":", "g_case", "=", "(", "None", ",", "None", ",", "-", "1", ")", "for", "group", "in", "self", ".", "group_slots", ":", "if", "group", "[", "0", "]", "==", "index", ":", "g_case", "="...
Find and return the appropriate group case.
[ "Find", "and", "return", "the", "appropriate", "group", "case", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1446-L1454
facelessuser/backrefs
backrefs/util.py
_to_bstr
def _to_bstr(l): """Convert to byte string.""" if isinstance(l, str): l = l.encode('ascii', 'backslashreplace') elif not isinstance(l, bytes): l = str(l).encode('ascii', 'backslashreplace') return l
python
def _to_bstr(l): """Convert to byte string.""" if isinstance(l, str): l = l.encode('ascii', 'backslashreplace') elif not isinstance(l, bytes): l = str(l).encode('ascii', 'backslashreplace') return l
[ "def", "_to_bstr", "(", "l", ")", ":", "if", "isinstance", "(", "l", ",", "str", ")", ":", "l", "=", "l", ".", "encode", "(", "'ascii'", ",", "'backslashreplace'", ")", "elif", "not", "isinstance", "(", "l", ",", "bytes", ")", ":", "l", "=", "str...
Convert to byte string.
[ "Convert", "to", "byte", "string", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/util.py#L65-L72
facelessuser/backrefs
backrefs/util.py
format_string
def format_string(m, l, capture, is_bytes): """Perform a string format.""" for fmt_type, value in capture[1:]: if fmt_type == FMT_ATTR: # Attribute l = getattr(l, value) elif fmt_type == FMT_INDEX: # Index l = l[value] elif fmt_type == FMT...
python
def format_string(m, l, capture, is_bytes): """Perform a string format.""" for fmt_type, value in capture[1:]: if fmt_type == FMT_ATTR: # Attribute l = getattr(l, value) elif fmt_type == FMT_INDEX: # Index l = l[value] elif fmt_type == FMT...
[ "def", "format_string", "(", "m", ",", "l", ",", "capture", ",", "is_bytes", ")", ":", "for", "fmt_type", ",", "value", "in", "capture", "[", "1", ":", "]", ":", "if", "fmt_type", "==", "FMT_ATTR", ":", "# Attribute", "l", "=", "getattr", "(", "l", ...
Perform a string format.
[ "Perform", "a", "string", "format", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/util.py#L75-L122
facelessuser/backrefs
backrefs/util.py
StringIter.rewind
def rewind(self, count): """Rewind index.""" if count > self._index: # pragma: no cover raise ValueError("Can't rewind past beginning!") self._index -= count
python
def rewind(self, count): """Rewind index.""" if count > self._index: # pragma: no cover raise ValueError("Can't rewind past beginning!") self._index -= count
[ "def", "rewind", "(", "self", ",", "count", ")", ":", "if", "count", ">", "self", ".", "_index", ":", "# pragma: no cover", "raise", "ValueError", "(", "\"Can't rewind past beginning!\"", ")", "self", ".", "_index", "-=", "count" ]
Rewind index.
[ "Rewind", "index", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/util.py#L45-L51
facelessuser/backrefs
setup.py
get_version
def get_version(): """Get version and version_info without importing the entire module.""" path = os.path.join(os.path.dirname(__file__), 'backrefs') fp, pathname, desc = imp.find_module('__meta__', [path]) try: vi = imp.load_module('__meta__', fp, pathname, desc).__version_info__ retur...
python
def get_version(): """Get version and version_info without importing the entire module.""" path = os.path.join(os.path.dirname(__file__), 'backrefs') fp, pathname, desc = imp.find_module('__meta__', [path]) try: vi = imp.load_module('__meta__', fp, pathname, desc).__version_info__ retur...
[ "def", "get_version", "(", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'backrefs'", ")", "fp", ",", "pathname", ",", "desc", "=", "imp", ".", "find_module", "(", "'__met...
Get version and version_info without importing the entire module.
[ "Get", "version", "and", "version_info", "without", "importing", "the", "entire", "module", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/setup.py#L13-L24
facelessuser/backrefs
setup.py
get_requirements
def get_requirements(): """Load list of dependencies.""" install_requires = [] with open("requirements/project.txt") as f: for line in f: if not line.startswith("#"): install_requires.append(line.strip()) return install_requires
python
def get_requirements(): """Load list of dependencies.""" install_requires = [] with open("requirements/project.txt") as f: for line in f: if not line.startswith("#"): install_requires.append(line.strip()) return install_requires
[ "def", "get_requirements", "(", ")", ":", "install_requires", "=", "[", "]", "with", "open", "(", "\"requirements/project.txt\"", ")", "as", "f", ":", "for", "line", "in", "f", ":", "if", "not", "line", ".", "startswith", "(", "\"#\"", ")", ":", "install...
Load list of dependencies.
[ "Load", "list", "of", "dependencies", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/setup.py#L27-L35
facelessuser/backrefs
setup.py
get_unicodedata
def get_unicodedata(): """Download the `unicodedata` version for the given Python version.""" import unicodedata fail = False uver = unicodedata.unidata_version path = os.path.join(os.path.dirname(__file__), 'tools') fp, pathname, desc = imp.find_module('unidatadownload', [path]) try: ...
python
def get_unicodedata(): """Download the `unicodedata` version for the given Python version.""" import unicodedata fail = False uver = unicodedata.unidata_version path = os.path.join(os.path.dirname(__file__), 'tools') fp, pathname, desc = imp.find_module('unidatadownload', [path]) try: ...
[ "def", "get_unicodedata", "(", ")", ":", "import", "unicodedata", "fail", "=", "False", "uver", "=", "unicodedata", ".", "unidata_version", "path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", ...
Download the `unicodedata` version for the given Python version.
[ "Download", "the", "unicodedata", "version", "for", "the", "given", "Python", "version", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/setup.py#L38-L57
facelessuser/backrefs
setup.py
generate_unicode_table
def generate_unicode_table(): """Generate the Unicode table for the given Python version.""" uver = get_unicodedata() fail = False path = os.path.join(os.path.dirname(__file__), 'tools') fp, pathname, desc = imp.find_module('unipropgen', [path]) try: unipropgen = imp.load_module('unipro...
python
def generate_unicode_table(): """Generate the Unicode table for the given Python version.""" uver = get_unicodedata() fail = False path = os.path.join(os.path.dirname(__file__), 'tools') fp, pathname, desc = imp.find_module('unipropgen', [path]) try: unipropgen = imp.load_module('unipro...
[ "def", "generate_unicode_table", "(", ")", ":", "uver", "=", "get_unicodedata", "(", ")", "fail", "=", "False", "path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'tools'", ")", "fp", ",",...
Generate the Unicode table for the given Python version.
[ "Generate", "the", "Unicode", "table", "for", "the", "given", "Python", "version", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/setup.py#L60-L82
facelessuser/backrefs
backrefs/bregex.py
_cached_search_compile
def _cached_search_compile(pattern, re_verbose, re_version, pattern_type): """Cached search compile.""" return _bregex_parse._SearchParser(pattern, re_verbose, re_version).parse()
python
def _cached_search_compile(pattern, re_verbose, re_version, pattern_type): """Cached search compile.""" return _bregex_parse._SearchParser(pattern, re_verbose, re_version).parse()
[ "def", "_cached_search_compile", "(", "pattern", ",", "re_verbose", ",", "re_version", ",", "pattern_type", ")", ":", "return", "_bregex_parse", ".", "_SearchParser", "(", "pattern", ",", "re_verbose", ",", "re_version", ")", ".", "parse", "(", ")" ]
Cached search compile.
[ "Cached", "search", "compile", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L85-L88
facelessuser/backrefs
backrefs/bregex.py
_cached_replace_compile
def _cached_replace_compile(pattern, repl, flags, pattern_type): """Cached replace compile.""" return _bregex_parse._ReplaceParser().parse(pattern, repl, bool(flags & FORMAT))
python
def _cached_replace_compile(pattern, repl, flags, pattern_type): """Cached replace compile.""" return _bregex_parse._ReplaceParser().parse(pattern, repl, bool(flags & FORMAT))
[ "def", "_cached_replace_compile", "(", "pattern", ",", "repl", ",", "flags", ",", "pattern_type", ")", ":", "return", "_bregex_parse", ".", "_ReplaceParser", "(", ")", ".", "parse", "(", "pattern", ",", "repl", ",", "bool", "(", "flags", "&", "FORMAT", ")"...
Cached replace compile.
[ "Cached", "replace", "compile", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L92-L95
facelessuser/backrefs
backrefs/bregex.py
_get_cache_size
def _get_cache_size(replace=False): """Get size of cache.""" if not replace: size = _cached_search_compile.cache_info().currsize else: size = _cached_replace_compile.cache_info().currsize return size
python
def _get_cache_size(replace=False): """Get size of cache.""" if not replace: size = _cached_search_compile.cache_info().currsize else: size = _cached_replace_compile.cache_info().currsize return size
[ "def", "_get_cache_size", "(", "replace", "=", "False", ")", ":", "if", "not", "replace", ":", "size", "=", "_cached_search_compile", ".", "cache_info", "(", ")", ".", "currsize", "else", ":", "size", "=", "_cached_replace_compile", ".", "cache_info", "(", "...
Get size of cache.
[ "Get", "size", "of", "cache", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L98-L105
facelessuser/backrefs
backrefs/bregex.py
_apply_replace_backrefs
def _apply_replace_backrefs(m, repl=None, flags=0): """Expand with either the `ReplaceTemplate` or compile on the fly, or return None.""" if m is None: raise ValueError("Match is None!") else: if isinstance(repl, ReplaceTemplate): return repl.expand(m) elif isinstance(re...
python
def _apply_replace_backrefs(m, repl=None, flags=0): """Expand with either the `ReplaceTemplate` or compile on the fly, or return None.""" if m is None: raise ValueError("Match is None!") else: if isinstance(repl, ReplaceTemplate): return repl.expand(m) elif isinstance(re...
[ "def", "_apply_replace_backrefs", "(", "m", ",", "repl", "=", "None", ",", "flags", "=", "0", ")", ":", "if", "m", "is", "None", ":", "raise", "ValueError", "(", "\"Match is None!\"", ")", "else", ":", "if", "isinstance", "(", "repl", ",", "ReplaceTempla...
Expand with either the `ReplaceTemplate` or compile on the fly, or return None.
[ "Expand", "with", "either", "the", "ReplaceTemplate", "or", "compile", "on", "the", "fly", "or", "return", "None", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L121-L130
facelessuser/backrefs
backrefs/bregex.py
_apply_search_backrefs
def _apply_search_backrefs(pattern, flags=0): """Apply the search backrefs to the search pattern.""" if isinstance(pattern, (str, bytes)): re_verbose = VERBOSE & flags if flags & V0: re_version = V0 elif flags & V1: re_version = V1 else: re_ve...
python
def _apply_search_backrefs(pattern, flags=0): """Apply the search backrefs to the search pattern.""" if isinstance(pattern, (str, bytes)): re_verbose = VERBOSE & flags if flags & V0: re_version = V0 elif flags & V1: re_version = V1 else: re_ve...
[ "def", "_apply_search_backrefs", "(", "pattern", ",", "flags", "=", "0", ")", ":", "if", "isinstance", "(", "pattern", ",", "(", "str", ",", "bytes", ")", ")", ":", "re_verbose", "=", "VERBOSE", "&", "flags", "if", "flags", "&", "V0", ":", "re_version"...
Apply the search backrefs to the search pattern.
[ "Apply", "the", "search", "backrefs", "to", "the", "search", "pattern", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L133-L157
facelessuser/backrefs
backrefs/bregex.py
_assert_expandable
def _assert_expandable(repl, use_format=False): """Check if replace template is expandable.""" if isinstance(repl, ReplaceTemplate): if repl.use_format != use_format: if use_format: raise ValueError("Replace not compiled as a format replace") else: ...
python
def _assert_expandable(repl, use_format=False): """Check if replace template is expandable.""" if isinstance(repl, ReplaceTemplate): if repl.use_format != use_format: if use_format: raise ValueError("Replace not compiled as a format replace") else: ...
[ "def", "_assert_expandable", "(", "repl", ",", "use_format", "=", "False", ")", ":", "if", "isinstance", "(", "repl", ",", "ReplaceTemplate", ")", ":", "if", "repl", ".", "use_format", "!=", "use_format", ":", "if", "use_format", ":", "raise", "ValueError", ...
Check if replace template is expandable.
[ "Check", "if", "replace", "template", "is", "expandable", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L160-L170
facelessuser/backrefs
backrefs/bregex.py
compile
def compile(pattern, flags=0, auto_compile=None, **kwargs): # noqa A001 """Compile both the search or search and replace into one object.""" if isinstance(pattern, Bregex): if auto_compile is not None: raise ValueError("Cannot compile Bregex with a different auto_compile!") elif fl...
python
def compile(pattern, flags=0, auto_compile=None, **kwargs): # noqa A001 """Compile both the search or search and replace into one object.""" if isinstance(pattern, Bregex): if auto_compile is not None: raise ValueError("Cannot compile Bregex with a different auto_compile!") elif fl...
[ "def", "compile", "(", "pattern", ",", "flags", "=", "0", ",", "auto_compile", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# noqa A001", "if", "isinstance", "(", "pattern", ",", "Bregex", ")", ":", "if", "auto_compile", "is", "not", "None", ":", ...
Compile both the search or search and replace into one object.
[ "Compile", "both", "the", "search", "or", "search", "and", "replace", "into", "one", "object", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L173-L186
facelessuser/backrefs
backrefs/bregex.py
compile_search
def compile_search(pattern, flags=0, **kwargs): """Compile with extended search references.""" return _regex.compile(_apply_search_backrefs(pattern, flags), flags, **kwargs)
python
def compile_search(pattern, flags=0, **kwargs): """Compile with extended search references.""" return _regex.compile(_apply_search_backrefs(pattern, flags), flags, **kwargs)
[ "def", "compile_search", "(", "pattern", ",", "flags", "=", "0", ",", "*", "*", "kwargs", ")", ":", "return", "_regex", ".", "compile", "(", "_apply_search_backrefs", "(", "pattern", ",", "flags", ")", ",", "flags", ",", "*", "*", "kwargs", ")" ]
Compile with extended search references.
[ "Compile", "with", "extended", "search", "references", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L189-L192
facelessuser/backrefs
backrefs/bregex.py
expandf
def expandf(m, format): # noqa A002 """Expand the string using the format replace pattern or function.""" _assert_expandable(format, True) return _apply_replace_backrefs(m, format, flags=FORMAT)
python
def expandf(m, format): # noqa A002 """Expand the string using the format replace pattern or function.""" _assert_expandable(format, True) return _apply_replace_backrefs(m, format, flags=FORMAT)
[ "def", "expandf", "(", "m", ",", "format", ")", ":", "# noqa A002", "_assert_expandable", "(", "format", ",", "True", ")", "return", "_apply_replace_backrefs", "(", "m", ",", "format", ",", "flags", "=", "FORMAT", ")" ]
Expand the string using the format replace pattern or function.
[ "Expand", "the", "string", "using", "the", "format", "replace", "pattern", "or", "function", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L387-L391
facelessuser/backrefs
backrefs/bregex.py
subfn
def subfn(pattern, format, string, *args, **kwargs): # noqa A002 """Wrapper for `subfn`.""" flags = args[4] if len(args) > 4 else kwargs.get('flags', 0) is_replace = _is_replace(format) is_string = isinstance(format, (str, bytes)) if is_replace and not format.use_format: raise ValueError("...
python
def subfn(pattern, format, string, *args, **kwargs): # noqa A002 """Wrapper for `subfn`.""" flags = args[4] if len(args) > 4 else kwargs.get('flags', 0) is_replace = _is_replace(format) is_string = isinstance(format, (str, bytes)) if is_replace and not format.use_format: raise ValueError("...
[ "def", "subfn", "(", "pattern", ",", "format", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa A002", "flags", "=", "args", "[", "4", "]", "if", "len", "(", "args", ")", ">", "4", "else", "kwargs", ".", "get", "(", "...
Wrapper for `subfn`.
[ "Wrapper", "for", "subfn", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L464-L478
facelessuser/backrefs
backrefs/bregex.py
Bregex._auto_compile
def _auto_compile(self, template, use_format=False): """Compile replacements.""" is_replace = _is_replace(template) is_string = isinstance(template, (str, bytes)) if is_replace and use_format != template.use_format: raise ValueError("Compiled replace cannot be a format objec...
python
def _auto_compile(self, template, use_format=False): """Compile replacements.""" is_replace = _is_replace(template) is_string = isinstance(template, (str, bytes)) if is_replace and use_format != template.use_format: raise ValueError("Compiled replace cannot be a format objec...
[ "def", "_auto_compile", "(", "self", ",", "template", ",", "use_format", "=", "False", ")", ":", "is_replace", "=", "_is_replace", "(", "template", ")", "is_string", "=", "isinstance", "(", "template", ",", "(", "str", ",", "bytes", ")", ")", "if", "is_r...
Compile replacements.
[ "Compile", "replacements", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L295-L310
facelessuser/backrefs
backrefs/bregex.py
Bregex.search
def search(self, string, *args, **kwargs): """Apply `search`.""" return self._pattern.search(string, *args, **kwargs)
python
def search(self, string, *args, **kwargs): """Apply `search`.""" return self._pattern.search(string, *args, **kwargs)
[ "def", "search", "(", "self", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_pattern", ".", "search", "(", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Apply `search`.
[ "Apply", "search", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L317-L320
facelessuser/backrefs
backrefs/bregex.py
Bregex.match
def match(self, string, *args, **kwargs): """Apply `match`.""" return self._pattern.match(string, *args, **kwargs)
python
def match(self, string, *args, **kwargs): """Apply `match`.""" return self._pattern.match(string, *args, **kwargs)
[ "def", "match", "(", "self", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_pattern", ".", "match", "(", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Apply `match`.
[ "Apply", "match", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L322-L325
facelessuser/backrefs
backrefs/bregex.py
Bregex.fullmatch
def fullmatch(self, string, *args, **kwargs): """Apply `fullmatch`.""" return self._pattern.fullmatch(string, *args, **kwargs)
python
def fullmatch(self, string, *args, **kwargs): """Apply `fullmatch`.""" return self._pattern.fullmatch(string, *args, **kwargs)
[ "def", "fullmatch", "(", "self", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_pattern", ".", "fullmatch", "(", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Apply `fullmatch`.
[ "Apply", "fullmatch", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L327-L330
facelessuser/backrefs
backrefs/bregex.py
Bregex.split
def split(self, string, *args, **kwargs): """Apply `split`.""" return self._pattern.split(string, *args, **kwargs)
python
def split(self, string, *args, **kwargs): """Apply `split`.""" return self._pattern.split(string, *args, **kwargs)
[ "def", "split", "(", "self", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_pattern", ".", "split", "(", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Apply `split`.
[ "Apply", "split", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L332-L335
facelessuser/backrefs
backrefs/bregex.py
Bregex.splititer
def splititer(self, string, *args, **kwargs): """Apply `splititer`.""" return self._pattern.splititer(string, *args, **kwargs)
python
def splititer(self, string, *args, **kwargs): """Apply `splititer`.""" return self._pattern.splititer(string, *args, **kwargs)
[ "def", "splititer", "(", "self", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_pattern", ".", "splititer", "(", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Apply `splititer`.
[ "Apply", "splititer", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L337-L340
facelessuser/backrefs
backrefs/bregex.py
Bregex.findall
def findall(self, string, *args, **kwargs): """Apply `findall`.""" return self._pattern.findall(string, *args, **kwargs)
python
def findall(self, string, *args, **kwargs): """Apply `findall`.""" return self._pattern.findall(string, *args, **kwargs)
[ "def", "findall", "(", "self", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_pattern", ".", "findall", "(", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Apply `findall`.
[ "Apply", "findall", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L342-L345
facelessuser/backrefs
backrefs/bregex.py
Bregex.finditer
def finditer(self, string, *args, **kwargs): """Apply `finditer`.""" return self._pattern.finditer(string, *args, **kwargs)
python
def finditer(self, string, *args, **kwargs): """Apply `finditer`.""" return self._pattern.finditer(string, *args, **kwargs)
[ "def", "finditer", "(", "self", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_pattern", ".", "finditer", "(", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Apply `finditer`.
[ "Apply", "finditer", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L347-L350
facelessuser/backrefs
backrefs/bregex.py
Bregex.sub
def sub(self, repl, string, *args, **kwargs): """Apply `sub`.""" return self._pattern.sub(self._auto_compile(repl), string, *args, **kwargs)
python
def sub(self, repl, string, *args, **kwargs): """Apply `sub`.""" return self._pattern.sub(self._auto_compile(repl), string, *args, **kwargs)
[ "def", "sub", "(", "self", ",", "repl", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_pattern", ".", "sub", "(", "self", ".", "_auto_compile", "(", "repl", ")", ",", "string", ",", "*", "args", ",", ...
Apply `sub`.
[ "Apply", "sub", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L352-L355
facelessuser/backrefs
backrefs/_bregex_parse.py
_SearchParser.flags
def flags(self, text, scoped=False): """Analyze flags.""" global_retry = False if (self.version == _regex.V1 or scoped) and '-x' in text and self.verbose: self.verbose = False elif 'x' in text and not self.verbose: self.verbose = True if not scoped an...
python
def flags(self, text, scoped=False): """Analyze flags.""" global_retry = False if (self.version == _regex.V1 or scoped) and '-x' in text and self.verbose: self.verbose = False elif 'x' in text and not self.verbose: self.verbose = True if not scoped an...
[ "def", "flags", "(", "self", ",", "text", ",", "scoped", "=", "False", ")", ":", "global_retry", "=", "False", "if", "(", "self", ".", "version", "==", "_regex", ".", "V1", "or", "scoped", ")", "and", "'-x'", "in", "text", "and", "self", ".", "verb...
Analyze flags.
[ "Analyze", "flags", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L165-L187
facelessuser/backrefs
backrefs/_bregex_parse.py
_SearchParser.reference
def reference(self, t, i, in_group=False): """Handle references.""" current = [] if not in_group and t == "R": current.append(self._re_line_break) elif t == 'e': current.extend(self._re_escape) else: current.extend(["\\", t]) return c...
python
def reference(self, t, i, in_group=False): """Handle references.""" current = [] if not in_group and t == "R": current.append(self._re_line_break) elif t == 'e': current.extend(self._re_escape) else: current.extend(["\\", t]) return c...
[ "def", "reference", "(", "self", ",", "t", ",", "i", ",", "in_group", "=", "False", ")", ":", "current", "=", "[", "]", "if", "not", "in_group", "and", "t", "==", "\"R\"", ":", "current", ".", "append", "(", "self", ".", "_re_line_break", ")", "eli...
Handle references.
[ "Handle", "references", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L189-L200
facelessuser/backrefs
backrefs/_bregex_parse.py
_SearchParser.get_posix
def get_posix(self, i): """Get POSIX.""" index = i.index value = ['['] try: c = next(i) if c != ':': raise ValueError('Not a valid property!') else: value.append(c) c = next(i) if c == '^...
python
def get_posix(self, i): """Get POSIX.""" index = i.index value = ['['] try: c = next(i) if c != ':': raise ValueError('Not a valid property!') else: value.append(c) c = next(i) if c == '^...
[ "def", "get_posix", "(", "self", ",", "i", ")", ":", "index", "=", "i", ".", "index", "value", "=", "[", "'['", "]", "try", ":", "c", "=", "next", "(", "i", ")", "if", "c", "!=", "':'", ":", "raise", "ValueError", "(", "'Not a valid property!'", ...
Get POSIX.
[ "Get", "POSIX", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L202-L231
facelessuser/backrefs
backrefs/_bregex_parse.py
_SearchParser.get_flags
def get_flags(self, i, version0, scoped=False): """Get flags.""" index = i.index value = ['('] version = False toggle = False end = ':' if scoped else ')' try: c = next(i) if c != '?': i.rewind(1) return Non...
python
def get_flags(self, i, version0, scoped=False): """Get flags.""" index = i.index value = ['('] version = False toggle = False end = ':' if scoped else ')' try: c = next(i) if c != '?': i.rewind(1) return Non...
[ "def", "get_flags", "(", "self", ",", "i", ",", "version0", ",", "scoped", "=", "False", ")", ":", "index", "=", "i", ".", "index", "value", "=", "[", "'('", "]", "version", "=", "False", "toggle", "=", "False", "end", "=", "':'", "if", "scoped", ...
Get flags.
[ "Get", "flags", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L265-L302
facelessuser/backrefs
backrefs/_bregex_parse.py
_SearchParser.subgroup
def subgroup(self, t, i): """Handle parenthesis.""" # (?flags) flags = self.get_flags(i, self.version == _regex.V0) if flags: self.flags(flags[2:-1]) return [flags] # (?#comment) comments = self.get_comments(i) if comments: re...
python
def subgroup(self, t, i): """Handle parenthesis.""" # (?flags) flags = self.get_flags(i, self.version == _regex.V0) if flags: self.flags(flags[2:-1]) return [flags] # (?#comment) comments = self.get_comments(i) if comments: re...
[ "def", "subgroup", "(", "self", ",", "t", ",", "i", ")", ":", "# (?flags)", "flags", "=", "self", ".", "get_flags", "(", "i", ",", "self", ".", "version", "==", "_regex", ".", "V0", ")", "if", "flags", ":", "self", ".", "flags", "(", "flags", "["...
Handle parenthesis.
[ "Handle", "parenthesis", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L304-L341
facelessuser/backrefs
backrefs/_bregex_parse.py
_SearchParser.char_groups
def char_groups(self, t, i): """Handle character groups.""" current = [] pos = i.index - 1 found = 0 sub_first = None escaped = False first = None try: while True: if not escaped and t == "\\": escaped = Tr...
python
def char_groups(self, t, i): """Handle character groups.""" current = [] pos = i.index - 1 found = 0 sub_first = None escaped = False first = None try: while True: if not escaped and t == "\\": escaped = Tr...
[ "def", "char_groups", "(", "self", ",", "t", ",", "i", ")", ":", "current", "=", "[", "]", "pos", "=", "i", ".", "index", "-", "1", "found", "=", "0", "sub_first", "=", "None", "escaped", "=", "False", "first", "=", "None", "try", ":", "while", ...
Handle character groups.
[ "Handle", "character", "groups", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L343-L407
facelessuser/backrefs
backrefs/_bregex_parse.py
_SearchParser.parse
def parse(self): """Apply search template.""" self.verbose = bool(self.re_verbose) self.version = self.re_version if self.re_version else _regex.DEFAULT_VERSION self.global_flag_swap = { "version": self.re_version != 0, "verbose": False } self.tem...
python
def parse(self): """Apply search template.""" self.verbose = bool(self.re_verbose) self.version = self.re_version if self.re_version else _regex.DEFAULT_VERSION self.global_flag_swap = { "version": self.re_version != 0, "verbose": False } self.tem...
[ "def", "parse", "(", "self", ")", ":", "self", ".", "verbose", "=", "bool", "(", "self", ".", "re_verbose", ")", "self", ".", "version", "=", "self", ".", "re_version", "if", "self", ".", "re_version", "else", "_regex", ".", "DEFAULT_VERSION", "self", ...
Apply search template.
[ "Apply", "search", "template", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L442-L487
facelessuser/backrefs
backrefs/_bregex_parse.py
_ReplaceParser.get_format
def get_format(self, c, i): """Get format group.""" index = i.index field = '' value = [] try: if c == '}': value.append((_util.FMT_FIELD, '')) value.append((_util.FMT_INDEX, -1)) else: # Field ...
python
def get_format(self, c, i): """Get format group.""" index = i.index field = '' value = [] try: if c == '}': value.append((_util.FMT_FIELD, '')) value.append((_util.FMT_INDEX, -1)) else: # Field ...
[ "def", "get_format", "(", "self", ",", "c", ",", "i", ")", ":", "index", "=", "i", ".", "index", "field", "=", "''", "value", "=", "[", "]", "try", ":", "if", "c", "==", "'}'", ":", "value", ".", "append", "(", "(", "_util", ".", "FMT_FIELD", ...
Get format group.
[ "Get", "format", "group", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L526-L666
facelessuser/backrefs
backrefs/_bregex_parse.py
_ReplaceParser.regex_parse_template
def regex_parse_template(self, template, pattern): """ Parse template for the regex module. Do NOT edit the literal list returned by _compile_replacement_helper as you will edit the original cached value. Copy the values instead. """ groups = [] ...
python
def regex_parse_template(self, template, pattern): """ Parse template for the regex module. Do NOT edit the literal list returned by _compile_replacement_helper as you will edit the original cached value. Copy the values instead. """ groups = [] ...
[ "def", "regex_parse_template", "(", "self", ",", "template", ",", "pattern", ")", ":", "groups", "=", "[", "]", "literals", "=", "[", "]", "replacements", "=", "_compile_replacement_helper", "(", "pattern", ",", "template", ")", "count", "=", "0", "for", "...
Parse template for the regex module. Do NOT edit the literal list returned by _compile_replacement_helper as you will edit the original cached value. Copy the values instead.
[ "Parse", "template", "for", "the", "regex", "module", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L980-L1001
facelessuser/backrefs
backrefs/_bregex_parse.py
_ReplaceParser.parse_template
def parse_template(self, pattern): """Parse template.""" i = _util.StringIter((self._original.decode('latin-1') if self.is_bytes else self._original)) iter(i) self.result = [""] while True: try: t = next(i) if self.use_format and t in...
python
def parse_template(self, pattern): """Parse template.""" i = _util.StringIter((self._original.decode('latin-1') if self.is_bytes else self._original)) iter(i) self.result = [""] while True: try: t = next(i) if self.use_format and t in...
[ "def", "parse_template", "(", "self", ",", "pattern", ")", ":", "i", "=", "_util", ".", "StringIter", "(", "(", "self", ".", "_original", ".", "decode", "(", "'latin-1'", ")", "if", "self", ".", "is_bytes", "else", "self", ".", "_original", ")", ")", ...
Parse template.
[ "Parse", "template", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L1003-L1038
facelessuser/backrefs
backrefs/_bregex_parse.py
ReplaceTemplate.expand
def expand(self, m): """Using the template, expand the string.""" if m is None: raise ValueError("Match is None!") sep = m.string[:0] if isinstance(sep, bytes) != self._bytes: raise TypeError('Match string type does not match expander string type!') text...
python
def expand(self, m): """Using the template, expand the string.""" if m is None: raise ValueError("Match is None!") sep = m.string[:0] if isinstance(sep, bytes) != self._bytes: raise TypeError('Match string type does not match expander string type!') text...
[ "def", "expand", "(", "self", ",", "m", ")", ":", "if", "m", "is", "None", ":", "raise", "ValueError", "(", "\"Match is None!\"", ")", "sep", "=", "m", ".", "string", "[", ":", "0", "]", "if", "isinstance", "(", "sep", ",", "bytes", ")", "!=", "s...
Using the template, expand the string.
[ "Using", "the", "template", "expand", "the", "string", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L1290-L1332
facelessuser/backrefs
tools/unipropgen.py
uniformat
def uniformat(value): """Convert a Unicode char.""" if value in GROUP_ESCAPES: # Escape characters that are (or will be in the future) problematic c = "\\x%02x\\x%02x" % (0x5c, value) elif value <= 0xFF: c = "\\x%02x" % value elif value <= 0xFFFF: c = "\\u%04x" % value ...
python
def uniformat(value): """Convert a Unicode char.""" if value in GROUP_ESCAPES: # Escape characters that are (or will be in the future) problematic c = "\\x%02x\\x%02x" % (0x5c, value) elif value <= 0xFF: c = "\\x%02x" % value elif value <= 0xFFFF: c = "\\u%04x" % value ...
[ "def", "uniformat", "(", "value", ")", ":", "if", "value", "in", "GROUP_ESCAPES", ":", "# Escape characters that are (or will be in the future) problematic", "c", "=", "\"\\\\x%02x\\\\x%02x\"", "%", "(", "0x5c", ",", "value", ")", "elif", "value", "<=", "0xFF", ":",...
Convert a Unicode char.
[ "Convert", "a", "Unicode", "char", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L35-L47
facelessuser/backrefs
tools/unipropgen.py
create_span
def create_span(unirange, is_bytes=False): """Clamp the Unicode range.""" if len(unirange) < 2: unirange.append(unirange[0]) if is_bytes: if unirange[0] > MAXASCII: return None if unirange[1] > MAXASCII: unirange[1] = MAXASCII return [x for x in range(uni...
python
def create_span(unirange, is_bytes=False): """Clamp the Unicode range.""" if len(unirange) < 2: unirange.append(unirange[0]) if is_bytes: if unirange[0] > MAXASCII: return None if unirange[1] > MAXASCII: unirange[1] = MAXASCII return [x for x in range(uni...
[ "def", "create_span", "(", "unirange", ",", "is_bytes", "=", "False", ")", ":", "if", "len", "(", "unirange", ")", "<", "2", ":", "unirange", ".", "append", "(", "unirange", "[", "0", "]", ")", "if", "is_bytes", ":", "if", "unirange", "[", "0", "]"...
Clamp the Unicode range.
[ "Clamp", "the", "Unicode", "range", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L66-L76
facelessuser/backrefs
tools/unipropgen.py
not_explicitly_defined
def not_explicitly_defined(table, name, is_bytes=False): """Compose a table with the specified entry name of values not explicitly defined.""" all_chars = ALL_ASCII if is_bytes else ALL_CHARS s = set() for k, v in table.items(): s.update(v) if name in table: table[name] = list(set(t...
python
def not_explicitly_defined(table, name, is_bytes=False): """Compose a table with the specified entry name of values not explicitly defined.""" all_chars = ALL_ASCII if is_bytes else ALL_CHARS s = set() for k, v in table.items(): s.update(v) if name in table: table[name] = list(set(t...
[ "def", "not_explicitly_defined", "(", "table", ",", "name", ",", "is_bytes", "=", "False", ")", ":", "all_chars", "=", "ALL_ASCII", "if", "is_bytes", "else", "ALL_CHARS", "s", "=", "set", "(", ")", "for", "k", ",", "v", "in", "table", ".", "items", "("...
Compose a table with the specified entry name of values not explicitly defined.
[ "Compose", "a", "table", "with", "the", "specified", "entry", "name", "of", "values", "not", "explicitly", "defined", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L79-L89
facelessuser/backrefs
tools/unipropgen.py
char2range
def char2range(d, is_bytes=False, invert=True): """Convert the characters in the dict to a range in string form.""" fmt = bytesformat if is_bytes else uniformat maxrange = MAXASCII if is_bytes else MAXUNICODE for k1 in sorted(d.keys()): v1 = d[k1] if not isinstance(v1, list): ...
python
def char2range(d, is_bytes=False, invert=True): """Convert the characters in the dict to a range in string form.""" fmt = bytesformat if is_bytes else uniformat maxrange = MAXASCII if is_bytes else MAXUNICODE for k1 in sorted(d.keys()): v1 = d[k1] if not isinstance(v1, list): ...
[ "def", "char2range", "(", "d", ",", "is_bytes", "=", "False", ",", "invert", "=", "True", ")", ":", "fmt", "=", "bytesformat", "if", "is_bytes", "else", "uniformat", "maxrange", "=", "MAXASCII", "if", "is_bytes", "else", "MAXUNICODE", "for", "k1", "in", ...
Convert the characters in the dict to a range in string form.
[ "Convert", "the", "characters", "in", "the", "dict", "to", "a", "range", "in", "string", "form", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L92-L156
facelessuser/backrefs
tools/unipropgen.py
gen_blocks
def gen_blocks(output, ascii_props=False, append=False, prefix=""): """Generate Unicode blocks.""" with codecs.open(output, 'a' if append else 'w', 'utf-8') as f: if not append: f.write(HEADER) f.write('%s_blocks = {' % prefix) no_block = [] last = -1 max_ra...
python
def gen_blocks(output, ascii_props=False, append=False, prefix=""): """Generate Unicode blocks.""" with codecs.open(output, 'a' if append else 'w', 'utf-8') as f: if not append: f.write(HEADER) f.write('%s_blocks = {' % prefix) no_block = [] last = -1 max_ra...
[ "def", "gen_blocks", "(", "output", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ",", "prefix", "=", "\"\"", ")", ":", "with", "codecs", ".", "open", "(", "output", ",", "'a'", "if", "append", "else", "'w'", ",", "'utf-8'", ")", "as...
Generate Unicode blocks.
[ "Generate", "Unicode", "blocks", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L159-L217
facelessuser/backrefs
tools/unipropgen.py
gen_ccc
def gen_ccc(output, ascii_props=False, append=False, prefix=""): """Generate `canonical combining class` property.""" obj = {} with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedCombiningClass.txt'), 'r', 'utf-8') as uf: for line in uf: if not line.startswith('#'): ...
python
def gen_ccc(output, ascii_props=False, append=False, prefix=""): """Generate `canonical combining class` property.""" obj = {} with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedCombiningClass.txt'), 'r', 'utf-8') as uf: for line in uf: if not line.startswith('#'): ...
[ "def", "gen_ccc", "(", "output", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ",", "prefix", "=", "\"\"", ")", ":", "obj", "=", "{", "}", "with", "codecs", ".", "open", "(", "os", ".", "path", ".", "join", "(", "HOME", ",", "'un...
Generate `canonical combining class` property.
[ "Generate", "canonical", "combining", "class", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L220-L266
facelessuser/backrefs
tools/unipropgen.py
gen_scripts
def gen_scripts( file_name, file_name_ext, obj_name, obj_ext_name, output, output_ext, field=1, notexplicit=None, ascii_props=False, append=False, prefix="" ): """Generate `script` property.""" obj = {} obj2 = {} aliases = {} with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'P...
python
def gen_scripts( file_name, file_name_ext, obj_name, obj_ext_name, output, output_ext, field=1, notexplicit=None, ascii_props=False, append=False, prefix="" ): """Generate `script` property.""" obj = {} obj2 = {} aliases = {} with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'P...
[ "def", "gen_scripts", "(", "file_name", ",", "file_name_ext", ",", "obj_name", ",", "obj_ext_name", ",", "output", ",", "output_ext", ",", "field", "=", "1", ",", "notexplicit", "=", "None", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ",...
Generate `script` property.
[ "Generate", "script", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L269-L363
facelessuser/backrefs
tools/unipropgen.py
gen_age
def gen_age(output, ascii_props=False, append=False, prefix=""): """Generate `age` property.""" obj = {} all_chars = ALL_ASCII if ascii_props else ALL_CHARS with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedAge.txt'), 'r', 'utf-8') as uf: for line in uf: if not ...
python
def gen_age(output, ascii_props=False, append=False, prefix=""): """Generate `age` property.""" obj = {} all_chars = ALL_ASCII if ascii_props else ALL_CHARS with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedAge.txt'), 'r', 'utf-8') as uf: for line in uf: if not ...
[ "def", "gen_age", "(", "output", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ",", "prefix", "=", "\"\"", ")", ":", "obj", "=", "{", "}", "all_chars", "=", "ALL_ASCII", "if", "ascii_props", "else", "ALL_CHARS", "with", "codecs", ".", ...
Generate `age` property.
[ "Generate", "age", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L412-L459
facelessuser/backrefs
tools/unipropgen.py
gen_nf_quick_check
def gen_nf_quick_check(output, ascii_props=False, append=False, prefix=""): """Generate quick check properties.""" categories = [] nf = {} all_chars = ALL_ASCII if ascii_props else ALL_CHARS file_name = os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedNormalizationProps.txt') with codecs.o...
python
def gen_nf_quick_check(output, ascii_props=False, append=False, prefix=""): """Generate quick check properties.""" categories = [] nf = {} all_chars = ALL_ASCII if ascii_props else ALL_CHARS file_name = os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedNormalizationProps.txt') with codecs.o...
[ "def", "gen_nf_quick_check", "(", "output", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ",", "prefix", "=", "\"\"", ")", ":", "categories", "=", "[", "]", "nf", "=", "{", "}", "all_chars", "=", "ALL_ASCII", "if", "ascii_props", "else",...
Generate quick check properties.
[ "Generate", "quick", "check", "properties", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L462-L520
facelessuser/backrefs
tools/unipropgen.py
gen_binary
def gen_binary(table, output, ascii_props=False, append=False, prefix=""): """Generate binary properties.""" categories = [] binary_props = ( ('DerivedCoreProperties.txt', None), ('PropList.txt', None), ('DerivedNormalizationProps.txt', ('Changes_When_NFKC_Casefolded', 'Full_Composi...
python
def gen_binary(table, output, ascii_props=False, append=False, prefix=""): """Generate binary properties.""" categories = [] binary_props = ( ('DerivedCoreProperties.txt', None), ('PropList.txt', None), ('DerivedNormalizationProps.txt', ('Changes_When_NFKC_Casefolded', 'Full_Composi...
[ "def", "gen_binary", "(", "table", ",", "output", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ",", "prefix", "=", "\"\"", ")", ":", "categories", "=", "[", "]", "binary_props", "=", "(", "(", "'DerivedCoreProperties.txt'", ",", "None", ...
Generate binary properties.
[ "Generate", "binary", "properties", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L523-L609
facelessuser/backrefs
tools/unipropgen.py
gen_bidi
def gen_bidi(output, ascii_props=False, append=False, prefix=""): """Generate `bidi class` property.""" bidi_class = {} max_range = MAXASCII if ascii_props else MAXUNICODE with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'UnicodeData.txt'), 'r', 'utf-8') as uf: for line in uf: ...
python
def gen_bidi(output, ascii_props=False, append=False, prefix=""): """Generate `bidi class` property.""" bidi_class = {} max_range = MAXASCII if ascii_props else MAXUNICODE with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'UnicodeData.txt'), 'r', 'utf-8') as uf: for line in uf: ...
[ "def", "gen_bidi", "(", "output", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ",", "prefix", "=", "\"\"", ")", ":", "bidi_class", "=", "{", "}", "max_range", "=", "MAXASCII", "if", "ascii_props", "else", "MAXUNICODE", "with", "codecs", ...
Generate `bidi class` property.
[ "Generate", "bidi", "class", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L612-L653
facelessuser/backrefs
tools/unipropgen.py
gen_posix
def gen_posix(output, is_bytes=False, append=False, prefix=""): """Generate the bytes posix table and write out to file.""" posix_table = {} # `Alnum: [a-zA-Z0-9]` s = set([x for x in range(0x30, 0x39 + 1)]) s |= set([x for x in range(0x41, 0x5a + 1)]) s |= set([x for x in range(0x61, 0x7a + 1...
python
def gen_posix(output, is_bytes=False, append=False, prefix=""): """Generate the bytes posix table and write out to file.""" posix_table = {} # `Alnum: [a-zA-Z0-9]` s = set([x for x in range(0x30, 0x39 + 1)]) s |= set([x for x in range(0x41, 0x5a + 1)]) s |= set([x for x in range(0x61, 0x7a + 1...
[ "def", "gen_posix", "(", "output", ",", "is_bytes", "=", "False", ",", "append", "=", "False", ",", "prefix", "=", "\"\"", ")", ":", "posix_table", "=", "{", "}", "# `Alnum: [a-zA-Z0-9]`", "s", "=", "set", "(", "[", "x", "for", "x", "in", "range", "(...
Generate the bytes posix table and write out to file.
[ "Generate", "the", "bytes", "posix", "table", "and", "write", "out", "to", "file", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L656-L737
facelessuser/backrefs
tools/unipropgen.py
gen_uposix
def gen_uposix(table, posix_table): """Generate the posix table and write out to file.""" # `Alnum: [\p{L&}\p{Nd}]` s = set(table['l']['c'] + table['n']['d']) posix_table["posixalnum"] = list(s) # `Alpha: [\p{L&}]` s = set(table['l']['c']) posix_table["posixalpha"] = list(s) # `ASCII:...
python
def gen_uposix(table, posix_table): """Generate the posix table and write out to file.""" # `Alnum: [\p{L&}\p{Nd}]` s = set(table['l']['c'] + table['n']['d']) posix_table["posixalnum"] = list(s) # `Alpha: [\p{L&}]` s = set(table['l']['c']) posix_table["posixalpha"] = list(s) # `ASCII:...
[ "def", "gen_uposix", "(", "table", ",", "posix_table", ")", ":", "# `Alnum: [\\p{L&}\\p{Nd}]`", "s", "=", "set", "(", "table", "[", "'l'", "]", "[", "'c'", "]", "+", "table", "[", "'n'", "]", "[", "'d'", "]", ")", "posix_table", "[", "\"posixalnum\"", ...
Generate the posix table and write out to file.
[ "Generate", "the", "posix", "table", "and", "write", "out", "to", "file", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L740-L812
facelessuser/backrefs
tools/unipropgen.py
gen_alias
def gen_alias(enum, binary, output, ascii_props=False, append=False, prefix=""): """Generate alias.""" alias_re = re.compile(r'^#\s+(\w+)\s+\((\w+)\)\s*$') categories = enum + binary alias = {} gather = False current_category = None line_re = None alias_header_re = re.compile(r'^#\s+(\...
python
def gen_alias(enum, binary, output, ascii_props=False, append=False, prefix=""): """Generate alias.""" alias_re = re.compile(r'^#\s+(\w+)\s+\((\w+)\)\s*$') categories = enum + binary alias = {} gather = False current_category = None line_re = None alias_header_re = re.compile(r'^#\s+(\...
[ "def", "gen_alias", "(", "enum", ",", "binary", ",", "output", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ",", "prefix", "=", "\"\"", ")", ":", "alias_re", "=", "re", ".", "compile", "(", "r'^#\\s+(\\w+)\\s+\\((\\w+)\\)\\s*$'", ")", "ca...
Generate alias.
[ "Generate", "alias", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L815-L945
facelessuser/backrefs
tools/unipropgen.py
gen_properties
def gen_properties(output, ascii_props=False, append=False): """Generate the property table and dump it to the provided file.""" files = { 'gc': os.path.join(output, 'generalcategory.py'), 'blk': os.path.join(output, 'block.py'), 'sc': os.path.join(output, 'script.py'), 'bc': os...
python
def gen_properties(output, ascii_props=False, append=False): """Generate the property table and dump it to the provided file.""" files = { 'gc': os.path.join(output, 'generalcategory.py'), 'blk': os.path.join(output, 'block.py'), 'sc': os.path.join(output, 'script.py'), 'bc': os...
[ "def", "gen_properties", "(", "output", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ")", ":", "files", "=", "{", "'gc'", ":", "os", ".", "path", ".", "join", "(", "output", ",", "'generalcategory.py'", ")", ",", "'blk'", ":", "os", ...
Generate the property table and dump it to the provided file.
[ "Generate", "the", "property", "table", "and", "dump", "it", "to", "the", "provided", "file", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L948-L1212
facelessuser/backrefs
tools/unipropgen.py
build_unicode_property_table
def build_unicode_property_table(output): """Build and write out Unicode property table.""" if not os.path.exists(output): os.mkdir(output) gen_properties(output)
python
def build_unicode_property_table(output): """Build and write out Unicode property table.""" if not os.path.exists(output): os.mkdir(output) gen_properties(output)
[ "def", "build_unicode_property_table", "(", "output", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "output", ")", ":", "os", ".", "mkdir", "(", "output", ")", "gen_properties", "(", "output", ")" ]
Build and write out Unicode property table.
[ "Build", "and", "write", "out", "Unicode", "property", "table", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L1215-L1220
facelessuser/backrefs
tools/unipropgen.py
build_ascii_property_table
def build_ascii_property_table(output): """Build and write out Unicode property table.""" if not os.path.exists(output): os.mkdir(output) gen_properties(output, ascii_props=True, append=True)
python
def build_ascii_property_table(output): """Build and write out Unicode property table.""" if not os.path.exists(output): os.mkdir(output) gen_properties(output, ascii_props=True, append=True)
[ "def", "build_ascii_property_table", "(", "output", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "output", ")", ":", "os", ".", "mkdir", "(", "output", ")", "gen_properties", "(", "output", ",", "ascii_props", "=", "True", ",", "append",...
Build and write out Unicode property table.
[ "Build", "and", "write", "out", "Unicode", "property", "table", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L1223-L1228
facelessuser/backrefs
tools/unipropgen.py
set_version
def set_version(version): """Set version.""" global UNIVERSION global UNIVERSION_INFO if version is None: version = unicodedata.unidata_version UNIVERSION = version UNIVERSION_INFO = tuple([int(x) for x in UNIVERSION.split('.')])
python
def set_version(version): """Set version.""" global UNIVERSION global UNIVERSION_INFO if version is None: version = unicodedata.unidata_version UNIVERSION = version UNIVERSION_INFO = tuple([int(x) for x in UNIVERSION.split('.')])
[ "def", "set_version", "(", "version", ")", ":", "global", "UNIVERSION", "global", "UNIVERSION_INFO", "if", "version", "is", "None", ":", "version", "=", "unicodedata", ".", "unidata_version", "UNIVERSION", "=", "version", "UNIVERSION_INFO", "=", "tuple", "(", "[...
Set version.
[ "Set", "version", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L1239-L1249
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_posix_property
def get_posix_property(value, mode=POSIX): """Retrieve the posix category.""" if mode == POSIX_BYTES: return unidata.ascii_posix_properties[value] elif mode == POSIX_UNICODE: return unidata.unicode_binary[ ('^posix' + value[1:]) if value.startswith('^') else ('posix' + value) ...
python
def get_posix_property(value, mode=POSIX): """Retrieve the posix category.""" if mode == POSIX_BYTES: return unidata.ascii_posix_properties[value] elif mode == POSIX_UNICODE: return unidata.unicode_binary[ ('^posix' + value[1:]) if value.startswith('^') else ('posix' + value) ...
[ "def", "get_posix_property", "(", "value", ",", "mode", "=", "POSIX", ")", ":", "if", "mode", "==", "POSIX_BYTES", ":", "return", "unidata", ".", "ascii_posix_properties", "[", "value", "]", "elif", "mode", "==", "POSIX_UNICODE", ":", "return", "unidata", "....
Retrieve the posix category.
[ "Retrieve", "the", "posix", "category", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L16-L26
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_gc_property
def get_gc_property(value, is_bytes=False): """Get `GC` property.""" obj = unidata.ascii_properties if is_bytes else unidata.unicode_properties if value.startswith('^'): negate = True value = value[1:] else: negate = False value = unidata.unicode_alias['generalcategory'].g...
python
def get_gc_property(value, is_bytes=False): """Get `GC` property.""" obj = unidata.ascii_properties if is_bytes else unidata.unicode_properties if value.startswith('^'): negate = True value = value[1:] else: negate = False value = unidata.unicode_alias['generalcategory'].g...
[ "def", "get_gc_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_properties", "if", "is_bytes", "else", "unidata", ".", "unicode_properties", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "negate",...
Get `GC` property.
[ "Get", "GC", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L29-L53
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_binary_property
def get_binary_property(value, is_bytes=False): """Get `BINARY` property.""" obj = unidata.ascii_binary if is_bytes else unidata.unicode_binary if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['binary'].get(negated, negated) else: value = unidat...
python
def get_binary_property(value, is_bytes=False): """Get `BINARY` property.""" obj = unidata.ascii_binary if is_bytes else unidata.unicode_binary if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['binary'].get(negated, negated) else: value = unidat...
[ "def", "get_binary_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_binary", "if", "is_bytes", "else", "unidata", ".", "unicode_binary", "if", "value", ".", "startswith", "(", "'^'", ")", ":", "negated", ...
Get `BINARY` property.
[ "Get", "BINARY", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L56-L67
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_canonical_combining_class_property
def get_canonical_combining_class_property(value, is_bytes=False): """Get `CANONICAL COMBINING CLASS` property.""" obj = unidata.ascii_canonical_combining_class if is_bytes else unidata.unicode_canonical_combining_class if value.startswith('^'): negated = value[1:] value = '^' + unidata.un...
python
def get_canonical_combining_class_property(value, is_bytes=False): """Get `CANONICAL COMBINING CLASS` property.""" obj = unidata.ascii_canonical_combining_class if is_bytes else unidata.unicode_canonical_combining_class if value.startswith('^'): negated = value[1:] value = '^' + unidata.un...
[ "def", "get_canonical_combining_class_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_canonical_combining_class", "if", "is_bytes", "else", "unidata", ".", "unicode_canonical_combining_class", "if", "value", ".", "s...
Get `CANONICAL COMBINING CLASS` property.
[ "Get", "CANONICAL", "COMBINING", "CLASS", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L70-L81
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_east_asian_width_property
def get_east_asian_width_property(value, is_bytes=False): """Get `EAST ASIAN WIDTH` property.""" obj = unidata.ascii_east_asian_width if is_bytes else unidata.unicode_east_asian_width if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['eastasianwidth'].get(ne...
python
def get_east_asian_width_property(value, is_bytes=False): """Get `EAST ASIAN WIDTH` property.""" obj = unidata.ascii_east_asian_width if is_bytes else unidata.unicode_east_asian_width if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias['eastasianwidth'].get(ne...
[ "def", "get_east_asian_width_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_east_asian_width", "if", "is_bytes", "else", "unidata", ".", "unicode_east_asian_width", "if", "value", ".", "startswith", "(", "'^'",...
Get `EAST ASIAN WIDTH` property.
[ "Get", "EAST", "ASIAN", "WIDTH", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L84-L95
facelessuser/backrefs
backrefs/uniprops/__init__.py
get_grapheme_cluster_break_property
def get_grapheme_cluster_break_property(value, is_bytes=False): """Get `GRAPHEME CLUSTER BREAK` property.""" obj = unidata.ascii_grapheme_cluster_break if is_bytes else unidata.unicode_grapheme_cluster_break if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias[...
python
def get_grapheme_cluster_break_property(value, is_bytes=False): """Get `GRAPHEME CLUSTER BREAK` property.""" obj = unidata.ascii_grapheme_cluster_break if is_bytes else unidata.unicode_grapheme_cluster_break if value.startswith('^'): negated = value[1:] value = '^' + unidata.unicode_alias[...
[ "def", "get_grapheme_cluster_break_property", "(", "value", ",", "is_bytes", "=", "False", ")", ":", "obj", "=", "unidata", ".", "ascii_grapheme_cluster_break", "if", "is_bytes", "else", "unidata", ".", "unicode_grapheme_cluster_break", "if", "value", ".", "startswith...
Get `GRAPHEME CLUSTER BREAK` property.
[ "Get", "GRAPHEME", "CLUSTER", "BREAK", "property", "." ]
train
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L98-L109