repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
praw-dev/prawcore
prawcore/auth.py
Authorizer.refresh
def refresh(self): """Obtain a new access token from the refresh_token.""" if self.refresh_token is None: raise InvalidInvocation("refresh token not provided") self._request_token( grant_type="refresh_token", refresh_token=self.refresh_token )
python
def refresh(self): """Obtain a new access token from the refresh_token.""" if self.refresh_token is None: raise InvalidInvocation("refresh token not provided") self._request_token( grant_type="refresh_token", refresh_token=self.refresh_token )
[ "def", "refresh", "(", "self", ")", ":", "if", "self", ".", "refresh_token", "is", "None", ":", "raise", "InvalidInvocation", "(", "\"refresh token not provided\"", ")", "self", ".", "_request_token", "(", "grant_type", "=", "\"refresh_token\"", ",", "refresh_toke...
Obtain a new access token from the refresh_token.
[ "Obtain", "a", "new", "access", "token", "from", "the", "refresh_token", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L225-L231
praw-dev/prawcore
prawcore/auth.py
Authorizer.revoke
def revoke(self, only_access=False): """Revoke the current Authorization. :param only_access: (Optional) When explicitly set to True, do not evict the refresh token if one is set. Revoking a refresh token will in-turn revoke all access tokens associated with that authorizat...
python
def revoke(self, only_access=False): """Revoke the current Authorization. :param only_access: (Optional) When explicitly set to True, do not evict the refresh token if one is set. Revoking a refresh token will in-turn revoke all access tokens associated with that authorizat...
[ "def", "revoke", "(", "self", ",", "only_access", "=", "False", ")", ":", "if", "only_access", "or", "self", ".", "refresh_token", "is", "None", ":", "super", "(", "Authorizer", ",", "self", ")", ".", "revoke", "(", ")", "else", ":", "self", ".", "_a...
Revoke the current Authorization. :param only_access: (Optional) When explicitly set to True, do not evict the refresh token if one is set. Revoking a refresh token will in-turn revoke all access tokens associated with that authorization.
[ "Revoke", "the", "current", "Authorization", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L233-L250
praw-dev/prawcore
prawcore/auth.py
DeviceIDAuthorizer.refresh
def refresh(self): """Obtain a new access token.""" grant_type = "https://oauth.reddit.com/grants/installed_client" self._request_token(grant_type=grant_type, device_id=self._device_id)
python
def refresh(self): """Obtain a new access token.""" grant_type = "https://oauth.reddit.com/grants/installed_client" self._request_token(grant_type=grant_type, device_id=self._device_id)
[ "def", "refresh", "(", "self", ")", ":", "grant_type", "=", "\"https://oauth.reddit.com/grants/installed_client\"", "self", ".", "_request_token", "(", "grant_type", "=", "grant_type", ",", "device_id", "=", "self", ".", "_device_id", ")" ]
Obtain a new access token.
[ "Obtain", "a", "new", "access", "token", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L275-L278
praw-dev/prawcore
prawcore/auth.py
ScriptAuthorizer.refresh
def refresh(self): """Obtain a new personal-use script type access token.""" self._request_token( grant_type="password", username=self._username, password=self._password, )
python
def refresh(self): """Obtain a new personal-use script type access token.""" self._request_token( grant_type="password", username=self._username, password=self._password, )
[ "def", "refresh", "(", "self", ")", ":", "self", ".", "_request_token", "(", "grant_type", "=", "\"password\"", ",", "username", "=", "self", ".", "_username", ",", "password", "=", "self", ".", "_password", ",", ")" ]
Obtain a new personal-use script type access token.
[ "Obtain", "a", "new", "personal", "-", "use", "script", "type", "access", "token", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L347-L353
praw-dev/prawcore
prawcore/requestor.py
Requestor.request
def request(self, *args, **kwargs): """Issue the HTTP request capturing any errors that may occur.""" try: return self._http.request(*args, timeout=TIMEOUT, **kwargs) except Exception as exc: raise RequestException(exc, args, kwargs)
python
def request(self, *args, **kwargs): """Issue the HTTP request capturing any errors that may occur.""" try: return self._http.request(*args, timeout=TIMEOUT, **kwargs) except Exception as exc: raise RequestException(exc, args, kwargs)
[ "def", "request", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "_http", ".", "request", "(", "*", "args", ",", "timeout", "=", "TIMEOUT", ",", "*", "*", "kwargs", ")", "except", "Exception", ...
Issue the HTTP request capturing any errors that may occur.
[ "Issue", "the", "HTTP", "request", "capturing", "any", "errors", "that", "may", "occur", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/requestor.py#L50-L55
JDongian/python-jamo
jamo/jamo.py
_hangul_char_to_jamo
def _hangul_char_to_jamo(syllable): """Return a 3-tuple of lead, vowel, and tail jamo characters. Note: Non-Hangul characters are echoed back. """ if is_hangul_char(syllable): rem = ord(syllable) - _JAMO_OFFSET tail = rem % 28 vowel = 1 + ((rem - tail) % 588) // 28 lead =...
python
def _hangul_char_to_jamo(syllable): """Return a 3-tuple of lead, vowel, and tail jamo characters. Note: Non-Hangul characters are echoed back. """ if is_hangul_char(syllable): rem = ord(syllable) - _JAMO_OFFSET tail = rem % 28 vowel = 1 + ((rem - tail) % 588) // 28 lead =...
[ "def", "_hangul_char_to_jamo", "(", "syllable", ")", ":", "if", "is_hangul_char", "(", "syllable", ")", ":", "rem", "=", "ord", "(", "syllable", ")", "-", "_JAMO_OFFSET", "tail", "=", "rem", "%", "28", "vowel", "=", "1", "+", "(", "(", "rem", "-", "t...
Return a 3-tuple of lead, vowel, and tail jamo characters. Note: Non-Hangul characters are echoed back.
[ "Return", "a", "3", "-", "tuple", "of", "lead", "vowel", "and", "tail", "jamo", "characters", ".", "Note", ":", "Non", "-", "Hangul", "characters", "are", "echoed", "back", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L54-L71
JDongian/python-jamo
jamo/jamo.py
_jamo_to_hangul_char
def _jamo_to_hangul_char(lead, vowel, tail=0): """Return the Hangul character for the given jamo characters. """ lead = ord(lead) - _JAMO_LEAD_OFFSET vowel = ord(vowel) - _JAMO_VOWEL_OFFSET tail = ord(tail) - _JAMO_TAIL_OFFSET if tail else 0 return chr(tail + (vowel - 1) * 28 + (lead - 1) * 588 ...
python
def _jamo_to_hangul_char(lead, vowel, tail=0): """Return the Hangul character for the given jamo characters. """ lead = ord(lead) - _JAMO_LEAD_OFFSET vowel = ord(vowel) - _JAMO_VOWEL_OFFSET tail = ord(tail) - _JAMO_TAIL_OFFSET if tail else 0 return chr(tail + (vowel - 1) * 28 + (lead - 1) * 588 ...
[ "def", "_jamo_to_hangul_char", "(", "lead", ",", "vowel", ",", "tail", "=", "0", ")", ":", "lead", "=", "ord", "(", "lead", ")", "-", "_JAMO_LEAD_OFFSET", "vowel", "=", "ord", "(", "vowel", ")", "-", "_JAMO_VOWEL_OFFSET", "tail", "=", "ord", "(", "tail...
Return the Hangul character for the given jamo characters.
[ "Return", "the", "Hangul", "character", "for", "the", "given", "jamo", "characters", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L74-L80
JDongian/python-jamo
jamo/jamo.py
_get_unicode_name
def _get_unicode_name(char): """Fetch the unicode name for jamo characters. """ if char not in _JAMO_TO_NAME.keys() and char not in _HCJ_TO_NAME.keys(): raise InvalidJamoError("Not jamo or nameless jamo character", char) else: if is_hcj(char): return _HCJ_TO_NAME[char] ...
python
def _get_unicode_name(char): """Fetch the unicode name for jamo characters. """ if char not in _JAMO_TO_NAME.keys() and char not in _HCJ_TO_NAME.keys(): raise InvalidJamoError("Not jamo or nameless jamo character", char) else: if is_hcj(char): return _HCJ_TO_NAME[char] ...
[ "def", "_get_unicode_name", "(", "char", ")", ":", "if", "char", "not", "in", "_JAMO_TO_NAME", ".", "keys", "(", ")", "and", "char", "not", "in", "_HCJ_TO_NAME", ".", "keys", "(", ")", ":", "raise", "InvalidJamoError", "(", "\"Not jamo or nameless jamo charact...
Fetch the unicode name for jamo characters.
[ "Fetch", "the", "unicode", "name", "for", "jamo", "characters", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L93-L101
JDongian/python-jamo
jamo/jamo.py
is_jamo
def is_jamo(character): """Test if a single character is a jamo character. Valid jamo includes all modern and archaic jamo, as well as all HCJ. Non-assigned code points are invalid. """ code = ord(character) return 0x1100 <= code <= 0x11FF or\ 0xA960 <= code <= 0xA97C or\ 0xD7B0 ...
python
def is_jamo(character): """Test if a single character is a jamo character. Valid jamo includes all modern and archaic jamo, as well as all HCJ. Non-assigned code points are invalid. """ code = ord(character) return 0x1100 <= code <= 0x11FF or\ 0xA960 <= code <= 0xA97C or\ 0xD7B0 ...
[ "def", "is_jamo", "(", "character", ")", ":", "code", "=", "ord", "(", "character", ")", "return", "0x1100", "<=", "code", "<=", "0x11FF", "or", "0xA960", "<=", "code", "<=", "0xA97C", "or", "0xD7B0", "<=", "code", "<=", "0xD7C6", "or", "0xD7CB", "<=",...
Test if a single character is a jamo character. Valid jamo includes all modern and archaic jamo, as well as all HCJ. Non-assigned code points are invalid.
[ "Test", "if", "a", "single", "character", "is", "a", "jamo", "character", ".", "Valid", "jamo", "includes", "all", "modern", "and", "archaic", "jamo", "as", "well", "as", "all", "HCJ", ".", "Non", "-", "assigned", "code", "points", "are", "invalid", "." ...
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L104-L113
JDongian/python-jamo
jamo/jamo.py
is_jamo_modern
def is_jamo_modern(character): """Test if a single character is a modern jamo character. Modern jamo includes all U+11xx jamo in addition to HCJ in modern usage, as defined in Unicode 7.0. WARNING: U+1160 is NOT considered a modern jamo character, but it is listed under 'Medial Vowels' in the Unicod...
python
def is_jamo_modern(character): """Test if a single character is a modern jamo character. Modern jamo includes all U+11xx jamo in addition to HCJ in modern usage, as defined in Unicode 7.0. WARNING: U+1160 is NOT considered a modern jamo character, but it is listed under 'Medial Vowels' in the Unicod...
[ "def", "is_jamo_modern", "(", "character", ")", ":", "code", "=", "ord", "(", "character", ")", "return", "0x1100", "<=", "code", "<=", "0x1112", "or", "0x1161", "<=", "code", "<=", "0x1175", "or", "0x11A8", "<=", "code", "<=", "0x11C2", "or", "is_hcj_mo...
Test if a single character is a modern jamo character. Modern jamo includes all U+11xx jamo in addition to HCJ in modern usage, as defined in Unicode 7.0. WARNING: U+1160 is NOT considered a modern jamo character, but it is listed under 'Medial Vowels' in the Unicode 7.0 spec.
[ "Test", "if", "a", "single", "character", "is", "a", "modern", "jamo", "character", ".", "Modern", "jamo", "includes", "all", "U", "+", "11xx", "jamo", "in", "addition", "to", "HCJ", "in", "modern", "usage", "as", "defined", "in", "Unicode", "7", ".", ...
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L116-L127
JDongian/python-jamo
jamo/jamo.py
is_jamo_compound
def is_jamo_compound(character): """Test if a single character is a compound, i.e., a consonant cluster, double consonant, or dipthong. """ if len(character) != 1: return False # Consider instead: # raise TypeError('is_jamo_compound() expected a single character') if is_jamo(...
python
def is_jamo_compound(character): """Test if a single character is a compound, i.e., a consonant cluster, double consonant, or dipthong. """ if len(character) != 1: return False # Consider instead: # raise TypeError('is_jamo_compound() expected a single character') if is_jamo(...
[ "def", "is_jamo_compound", "(", "character", ")", ":", "if", "len", "(", "character", ")", "!=", "1", ":", "return", "False", "# Consider instead:", "# raise TypeError('is_jamo_compound() expected a single character')", "if", "is_jamo", "(", "character", ")", ":", "re...
Test if a single character is a compound, i.e., a consonant cluster, double consonant, or dipthong.
[ "Test", "if", "a", "single", "character", "is", "a", "compound", "i", ".", "e", ".", "a", "consonant", "cluster", "double", "consonant", "or", "dipthong", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L155-L165
JDongian/python-jamo
jamo/jamo.py
get_jamo_class
def get_jamo_class(jamo): """Determine if a jamo character is a lead, vowel, or tail. Integers and U+11xx characters are valid arguments. HCJ consonants are not valid here. get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a given character or integer. Note: jamo class dire...
python
def get_jamo_class(jamo): """Determine if a jamo character is a lead, vowel, or tail. Integers and U+11xx characters are valid arguments. HCJ consonants are not valid here. get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a given character or integer. Note: jamo class dire...
[ "def", "get_jamo_class", "(", "jamo", ")", ":", "# TODO: Perhaps raise a separate error for U+3xxx jamo.", "if", "jamo", "in", "JAMO_LEADS", "or", "jamo", "==", "chr", "(", "0x115F", ")", ":", "return", "\"lead\"", "if", "jamo", "in", "JAMO_VOWELS", "or", "jamo", ...
Determine if a jamo character is a lead, vowel, or tail. Integers and U+11xx characters are valid arguments. HCJ consonants are not valid here. get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a given character or integer. Note: jamo class directly corresponds to the Unicode 7...
[ "Determine", "if", "a", "jamo", "character", "is", "a", "lead", "vowel", "or", "tail", ".", "Integers", "and", "U", "+", "11xx", "characters", "are", "valid", "arguments", ".", "HCJ", "consonants", "are", "not", "valid", "here", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L168-L188
JDongian/python-jamo
jamo/jamo.py
hcj_to_jamo
def hcj_to_jamo(hcj_char, position="vowel"): """Convert a HCJ character to a jamo character. Arguments may be single characters along with the desired jamo class (lead, vowel, tail). Non-mappable input will raise an InvalidJamoError. """ if position == "lead": jamo_class = "CHOSEONG" eli...
python
def hcj_to_jamo(hcj_char, position="vowel"): """Convert a HCJ character to a jamo character. Arguments may be single characters along with the desired jamo class (lead, vowel, tail). Non-mappable input will raise an InvalidJamoError. """ if position == "lead": jamo_class = "CHOSEONG" eli...
[ "def", "hcj_to_jamo", "(", "hcj_char", ",", "position", "=", "\"vowel\"", ")", ":", "if", "position", "==", "\"lead\"", ":", "jamo_class", "=", "\"CHOSEONG\"", "elif", "position", "==", "\"vowel\"", ":", "jamo_class", "=", "\"JUNGSEONG\"", "elif", "position", ...
Convert a HCJ character to a jamo character. Arguments may be single characters along with the desired jamo class (lead, vowel, tail). Non-mappable input will raise an InvalidJamoError.
[ "Convert", "a", "HCJ", "character", "to", "a", "jamo", "character", ".", "Arguments", "may", "be", "single", "characters", "along", "with", "the", "desired", "jamo", "class", "(", "lead", "vowel", "tail", ")", ".", "Non", "-", "mappable", "input", "will", ...
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L216-L235
JDongian/python-jamo
jamo/jamo.py
hangul_to_jamo
def hangul_to_jamo(hangul_string): """Convert a string of Hangul to jamo. Arguments may be iterables of characters. hangul_to_jamo should split every Hangul character into U+11xx jamo characters for any given string. Non-hangul characters are not changed. hangul_to_jamo is the generator version of...
python
def hangul_to_jamo(hangul_string): """Convert a string of Hangul to jamo. Arguments may be iterables of characters. hangul_to_jamo should split every Hangul character into U+11xx jamo characters for any given string. Non-hangul characters are not changed. hangul_to_jamo is the generator version of...
[ "def", "hangul_to_jamo", "(", "hangul_string", ")", ":", "return", "(", "_", "for", "_", "in", "chain", ".", "from_iterable", "(", "_hangul_char_to_jamo", "(", "_", ")", "for", "_", "in", "hangul_string", ")", ")" ]
Convert a string of Hangul to jamo. Arguments may be iterables of characters. hangul_to_jamo should split every Hangul character into U+11xx jamo characters for any given string. Non-hangul characters are not changed. hangul_to_jamo is the generator version of h2j, the string version.
[ "Convert", "a", "string", "of", "Hangul", "to", "jamo", ".", "Arguments", "may", "be", "iterables", "of", "characters", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L245-L256
JDongian/python-jamo
jamo/jamo.py
jamo_to_hangul
def jamo_to_hangul(lead, vowel, tail=''): """Return the Hangul character for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character Hangul string. This function is identical to j2h. """ # Internally, ...
python
def jamo_to_hangul(lead, vowel, tail=''): """Return the Hangul character for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character Hangul string. This function is identical to j2h. """ # Internally, ...
[ "def", "jamo_to_hangul", "(", "lead", ",", "vowel", ",", "tail", "=", "''", ")", ":", "# Internally, we convert everything to a jamo char,", "# then pass it to _jamo_to_hangul_char", "lead", "=", "hcj_to_jamo", "(", "lead", ",", "\"lead\"", ")", "vowel", "=", "hcj_to_...
Return the Hangul character for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character Hangul string. This function is identical to j2h.
[ "Return", "the", "Hangul", "character", "for", "the", "given", "jamo", "input", ".", "Integers", "corresponding", "to", "U", "+", "11xx", "jamo", "codepoints", "U", "+", "11xx", "jamo", "characters", "or", "HCJ", "are", "valid", "inputs", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L271-L295
JDongian/python-jamo
jamo/jamo.py
decompose_jamo
def decompose_jamo(compound): """Return a tuple of jamo character constituents of a compound. Note: Non-compound characters are echoed back. WARNING: Archaic jamo compounds will raise NotImplementedError. """ if len(compound) != 1: raise TypeError("decompose_jamo() expects a single characte...
python
def decompose_jamo(compound): """Return a tuple of jamo character constituents of a compound. Note: Non-compound characters are echoed back. WARNING: Archaic jamo compounds will raise NotImplementedError. """ if len(compound) != 1: raise TypeError("decompose_jamo() expects a single characte...
[ "def", "decompose_jamo", "(", "compound", ")", ":", "if", "len", "(", "compound", ")", "!=", "1", ":", "raise", "TypeError", "(", "\"decompose_jamo() expects a single character,\"", ",", "\"but received\"", ",", "type", "(", "compound", ")", ",", "\"length\"", "...
Return a tuple of jamo character constituents of a compound. Note: Non-compound characters are echoed back. WARNING: Archaic jamo compounds will raise NotImplementedError.
[ "Return", "a", "tuple", "of", "jamo", "character", "constituents", "of", "a", "compound", ".", "Note", ":", "Non", "-", "compound", "characters", "are", "echoed", "back", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L310-L325
JDongian/python-jamo
jamo/jamo.py
compose_jamo
def compose_jamo(*parts): """Return the compound jamo for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character jamo string. """ # Internally, we convert everything to a jamo char, # then pass it to _...
python
def compose_jamo(*parts): """Return the compound jamo for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character jamo string. """ # Internally, we convert everything to a jamo char, # then pass it to _...
[ "def", "compose_jamo", "(", "*", "parts", ")", ":", "# Internally, we convert everything to a jamo char,", "# then pass it to _jamo_to_hangul_char", "# NOTE: Relies on hcj_to_jamo not strictly requiring \"position\" arg.", "for", "p", "in", "parts", ":", "if", "not", "(", "type",...
Return the compound jamo for the given jamo input. Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters, or HCJ are valid inputs. Outputs a one-character jamo string.
[ "Return", "the", "compound", "jamo", "for", "the", "given", "jamo", "input", ".", "Integers", "corresponding", "to", "U", "+", "11xx", "jamo", "codepoints", "U", "+", "11xx", "jamo", "characters", "or", "HCJ", "are", "valid", "inputs", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L328-L350
JDongian/python-jamo
jamo/jamo.py
synth_hangul
def synth_hangul(string): """Convert jamo characters in a string into hcj as much as possible.""" raise NotImplementedError return ''.join([''.join(''.join(jamo_to_hcj(_)) for _ in string)])
python
def synth_hangul(string): """Convert jamo characters in a string into hcj as much as possible.""" raise NotImplementedError return ''.join([''.join(''.join(jamo_to_hcj(_)) for _ in string)])
[ "def", "synth_hangul", "(", "string", ")", ":", "raise", "NotImplementedError", "return", "''", ".", "join", "(", "[", "''", ".", "join", "(", "''", ".", "join", "(", "jamo_to_hcj", "(", "_", ")", ")", "for", "_", "in", "string", ")", "]", ")" ]
Convert jamo characters in a string into hcj as much as possible.
[ "Convert", "jamo", "characters", "in", "a", "string", "into", "hcj", "as", "much", "as", "possible", "." ]
train
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L353-L356
praw-dev/prawcore
prawcore/util.py
authorization_error_class
def authorization_error_class(response): """Return an exception instance that maps to the OAuth Error. :param response: The HTTP response containing a www-authenticate error. """ message = response.headers.get("www-authenticate") if message: error = message.replace('"', "").rsplit("=", 1)[...
python
def authorization_error_class(response): """Return an exception instance that maps to the OAuth Error. :param response: The HTTP response containing a www-authenticate error. """ message = response.headers.get("www-authenticate") if message: error = message.replace('"', "").rsplit("=", 1)[...
[ "def", "authorization_error_class", "(", "response", ")", ":", "message", "=", "response", ".", "headers", ".", "get", "(", "\"www-authenticate\"", ")", "if", "message", ":", "error", "=", "message", ".", "replace", "(", "'\"'", ",", "\"\"", ")", ".", "rsp...
Return an exception instance that maps to the OAuth Error. :param response: The HTTP response containing a www-authenticate error.
[ "Return", "an", "exception", "instance", "that", "maps", "to", "the", "OAuth", "Error", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/util.py#L12-L23
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
_last_bookmark
def _last_bookmark(b0, b1): """ Return the latest of two bookmarks by looking for the maximum integer value following the last colon in the bookmark string. """ n = [None, None] _, _, n[0] = b0.rpartition(":") _, _, n[1] = b1.rpartition(":") for i in range(2): try: n[i] =...
python
def _last_bookmark(b0, b1): """ Return the latest of two bookmarks by looking for the maximum integer value following the last colon in the bookmark string. """ n = [None, None] _, _, n[0] = b0.rpartition(":") _, _, n[1] = b1.rpartition(":") for i in range(2): try: n[i] =...
[ "def", "_last_bookmark", "(", "b0", ",", "b1", ")", ":", "n", "=", "[", "None", ",", "None", "]", "_", ",", "_", ",", "n", "[", "0", "]", "=", "b0", ".", "rpartition", "(", "\":\"", ")", "_", ",", "_", ",", "n", "[", "1", "]", "=", "b1", ...
Return the latest of two bookmarks by looking for the maximum integer value following the last colon in the bookmark string.
[ "Return", "the", "latest", "of", "two", "bookmarks", "by", "looking", "for", "the", "maximum", "integer", "value", "following", "the", "last", "colon", "in", "the", "bookmark", "string", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L705-L717
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
last_bookmark
def last_bookmark(bookmarks): """ The bookmark returned by the last :class:`.Transaction`. """ last = None for bookmark in bookmarks: if last is None: last = bookmark else: last = _last_bookmark(last, bookmark) return last
python
def last_bookmark(bookmarks): """ The bookmark returned by the last :class:`.Transaction`. """ last = None for bookmark in bookmarks: if last is None: last = bookmark else: last = _last_bookmark(last, bookmark) return last
[ "def", "last_bookmark", "(", "bookmarks", ")", ":", "last", "=", "None", "for", "bookmark", "in", "bookmarks", ":", "if", "last", "is", "None", ":", "last", "=", "bookmark", "else", ":", "last", "=", "_last_bookmark", "(", "last", ",", "bookmark", ")", ...
The bookmark returned by the last :class:`.Transaction`.
[ "The", "bookmark", "returned", "by", "the", "last", ":", "class", ":", ".", "Transaction", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L721-L730
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
connect
def connect(address, **config): """ Connect and perform a handshake and return a valid Connection object, assuming a protocol version can be agreed. """ ssl_context = make_ssl_context(**config) last_error = None # Establish a connection to the host and port specified # Catches refused connec...
python
def connect(address, **config): """ Connect and perform a handshake and return a valid Connection object, assuming a protocol version can be agreed. """ ssl_context = make_ssl_context(**config) last_error = None # Establish a connection to the host and port specified # Catches refused connec...
[ "def", "connect", "(", "address", ",", "*", "*", "config", ")", ":", "ssl_context", "=", "make_ssl_context", "(", "*", "*", "config", ")", "last_error", "=", "None", "# Establish a connection to the host and port specified", "# Catches refused connections see:", "# http...
Connect and perform a handshake and return a valid Connection object, assuming a protocol version can be agreed.
[ "Connect", "and", "perform", "a", "handshake", "and", "return", "a", "valid", "Connection", "object", "assuming", "a", "protocol", "version", "can", "be", "agreed", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L858-L884
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Connection._append
def _append(self, signature, fields=(), response=None): """ Add a message to the outgoing queue. :arg signature: the signature of the message :arg fields: the fields of the message as a tuple :arg response: a response object to handle callbacks """ self.packer.pack_struc...
python
def _append(self, signature, fields=(), response=None): """ Add a message to the outgoing queue. :arg signature: the signature of the message :arg fields: the fields of the message as a tuple :arg response: a response object to handle callbacks """ self.packer.pack_struc...
[ "def", "_append", "(", "self", ",", "signature", ",", "fields", "=", "(", ")", ",", "response", "=", "None", ")", ":", "self", ".", "packer", ".", "pack_struct", "(", "signature", ",", "fields", ")", "self", ".", "output_buffer", ".", "chunk", "(", "...
Add a message to the outgoing queue. :arg signature: the signature of the message :arg fields: the fields of the message as a tuple :arg response: a response object to handle callbacks
[ "Add", "a", "message", "to", "the", "outgoing", "queue", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L288-L298
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Connection.reset
def reset(self): """ Add a RESET message to the outgoing queue, send it and consume all remaining messages. """ def fail(metadata): raise ProtocolError("RESET failed %r" % metadata) log_debug("[#%04X] C: RESET", self.local_port) self._append(b"\x0F", respon...
python
def reset(self): """ Add a RESET message to the outgoing queue, send it and consume all remaining messages. """ def fail(metadata): raise ProtocolError("RESET failed %r" % metadata) log_debug("[#%04X] C: RESET", self.local_port) self._append(b"\x0F", respon...
[ "def", "reset", "(", "self", ")", ":", "def", "fail", "(", "metadata", ")", ":", "raise", "ProtocolError", "(", "\"RESET failed %r\"", "%", "metadata", ")", "log_debug", "(", "\"[#%04X] C: RESET\"", ",", "self", ".", "local_port", ")", "self", ".", "_append...
Add a RESET message to the outgoing queue, send it and consume all remaining messages.
[ "Add", "a", "RESET", "message", "to", "the", "outgoing", "queue", "send", "it", "and", "consume", "all", "remaining", "messages", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L300-L310
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Connection._send
def _send(self): """ Send all queued messages to the server. """ data = self.output_buffer.view() if not data: return if self.closed(): raise self.Error("Failed to write to closed connection {!r}".format(self.server.address)) if self.defunct(): ...
python
def _send(self): """ Send all queued messages to the server. """ data = self.output_buffer.view() if not data: return if self.closed(): raise self.Error("Failed to write to closed connection {!r}".format(self.server.address)) if self.defunct(): ...
[ "def", "_send", "(", "self", ")", ":", "data", "=", "self", ".", "output_buffer", ".", "view", "(", ")", "if", "not", "data", ":", "return", "if", "self", ".", "closed", "(", ")", ":", "raise", "self", ".", "Error", "(", "\"Failed to write to closed co...
Send all queued messages to the server.
[ "Send", "all", "queued", "messages", "to", "the", "server", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L320-L331
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Connection._fetch
def _fetch(self): """ Receive at least one message from the server, if available. :return: 2-tuple of number of detail messages and number of summary messages fetched """ if self.closed(): raise self.Error("Failed to read from closed connection {!r}".format(self.server.addre...
python
def _fetch(self): """ Receive at least one message from the server, if available. :return: 2-tuple of number of detail messages and number of summary messages fetched """ if self.closed(): raise self.Error("Failed to read from closed connection {!r}".format(self.server.addre...
[ "def", "_fetch", "(", "self", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "self", ".", "Error", "(", "\"Failed to read from closed connection {!r}\"", ".", "format", "(", "self", ".", "server", ".", "address", ")", ")", "if", "self", "...
Receive at least one message from the server, if available. :return: 2-tuple of number of detail messages and number of summary messages fetched
[ "Receive", "at", "least", "one", "message", "from", "the", "server", "if", "available", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L341-L381
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Connection.sync
def sync(self): """ Send and fetch all outstanding messages. :return: 2-tuple of number of detail messages and number of summary messages fetched """ self.send() detail_count = summary_count = 0 while self.responses: response = self.responses[0] w...
python
def sync(self): """ Send and fetch all outstanding messages. :return: 2-tuple of number of detail messages and number of summary messages fetched """ self.send() detail_count = summary_count = 0 while self.responses: response = self.responses[0] w...
[ "def", "sync", "(", "self", ")", ":", "self", ".", "send", "(", ")", "detail_count", "=", "summary_count", "=", "0", "while", "self", ".", "responses", ":", "response", "=", "self", ".", "responses", "[", "0", "]", "while", "not", "response", ".", "c...
Send and fetch all outstanding messages. :return: 2-tuple of number of detail messages and number of summary messages fetched
[ "Send", "and", "fetch", "all", "outstanding", "messages", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L431-L444
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Connection.close
def close(self): """ Close the connection. """ if not self._closed: if self.protocol_version >= 3: log_debug("[#%04X] C: GOODBYE", self.local_port) self._append(b"\x02", ()) try: self.send() except S...
python
def close(self): """ Close the connection. """ if not self._closed: if self.protocol_version >= 3: log_debug("[#%04X] C: GOODBYE", self.local_port) self._append(b"\x02", ()) try: self.send() except S...
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "_closed", ":", "if", "self", ".", "protocol_version", ">=", "3", ":", "log_debug", "(", "\"[#%04X] C: GOODBYE\"", ",", "self", ".", "local_port", ")", "self", ".", "_append", "(", "b\"\\x...
Close the connection.
[ "Close", "the", "connection", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L446-L463
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
AbstractConnectionPool.acquire_direct
def acquire_direct(self, address): """ Acquire a connection to a given address from the pool. The address supplied should always be an IP address, not a host name. This method is thread safe. """ if self.closed(): raise ServiceUnavailable("Connection pool clo...
python
def acquire_direct(self, address): """ Acquire a connection to a given address from the pool. The address supplied should always be an IP address, not a host name. This method is thread safe. """ if self.closed(): raise ServiceUnavailable("Connection pool clo...
[ "def", "acquire_direct", "(", "self", ",", "address", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ServiceUnavailable", "(", "\"Connection pool closed\"", ")", "with", "self", ".", "lock", ":", "try", ":", "connections", "=", "self", "."...
Acquire a connection to a given address from the pool. The address supplied should always be an IP address, not a host name. This method is thread safe.
[ "Acquire", "a", "connection", "to", "a", "given", "address", "from", "the", "pool", ".", "The", "address", "supplied", "should", "always", "be", "an", "IP", "address", "not", "a", "host", "name", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L492-L543
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
AbstractConnectionPool.release
def release(self, connection): """ Release a connection back into the pool. This method is thread safe. """ with self.lock: connection.in_use = False self.cond.notify_all()
python
def release(self, connection): """ Release a connection back into the pool. This method is thread safe. """ with self.lock: connection.in_use = False self.cond.notify_all()
[ "def", "release", "(", "self", ",", "connection", ")", ":", "with", "self", ".", "lock", ":", "connection", ".", "in_use", "=", "False", "self", ".", "cond", ".", "notify_all", "(", ")" ]
Release a connection back into the pool. This method is thread safe.
[ "Release", "a", "connection", "back", "into", "the", "pool", ".", "This", "method", "is", "thread", "safe", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L551-L557
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
AbstractConnectionPool.in_use_connection_count
def in_use_connection_count(self, address): """ Count the number of connections currently in use to a given address. """ try: connections = self.connections[address] except KeyError: return 0 else: return sum(1 if connection.in_use else...
python
def in_use_connection_count(self, address): """ Count the number of connections currently in use to a given address. """ try: connections = self.connections[address] except KeyError: return 0 else: return sum(1 if connection.in_use else...
[ "def", "in_use_connection_count", "(", "self", ",", "address", ")", ":", "try", ":", "connections", "=", "self", ".", "connections", "[", "address", "]", "except", "KeyError", ":", "return", "0", "else", ":", "return", "sum", "(", "1", "if", "connection", ...
Count the number of connections currently in use to a given address.
[ "Count", "the", "number", "of", "connections", "currently", "in", "use", "to", "a", "given", "address", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L559-L568
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
AbstractConnectionPool.deactivate
def deactivate(self, address): """ Deactivate an address from the connection pool, if present, closing all idle connection to that address """ with self.lock: try: connections = self.connections[address] except KeyError: # already removed from the ...
python
def deactivate(self, address): """ Deactivate an address from the connection pool, if present, closing all idle connection to that address """ with self.lock: try: connections = self.connections[address] except KeyError: # already removed from the ...
[ "def", "deactivate", "(", "self", ",", "address", ")", ":", "with", "self", ".", "lock", ":", "try", ":", "connections", "=", "self", ".", "connections", "[", "address", "]", "except", "KeyError", ":", "# already removed from the connection pool", "return", "f...
Deactivate an address from the connection pool, if present, closing all idle connection to that address
[ "Deactivate", "an", "address", "from", "the", "connection", "pool", "if", "present", "closing", "all", "idle", "connection", "to", "that", "address" ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L570-L587
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
AbstractConnectionPool.remove
def remove(self, address): """ Remove an address from the connection pool, if present, closing all connections to that address. """ with self.lock: for connection in self.connections.pop(address, ()): try: connection.close() ...
python
def remove(self, address): """ Remove an address from the connection pool, if present, closing all connections to that address. """ with self.lock: for connection in self.connections.pop(address, ()): try: connection.close() ...
[ "def", "remove", "(", "self", ",", "address", ")", ":", "with", "self", ".", "lock", ":", "for", "connection", "in", "self", ".", "connections", ".", "pop", "(", "address", ",", "(", ")", ")", ":", "try", ":", "connection", ".", "close", "(", ")", ...
Remove an address from the connection pool, if present, closing all connections to that address.
[ "Remove", "an", "address", "from", "the", "connection", "pool", "if", "present", "closing", "all", "connections", "to", "that", "address", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L589-L598
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
AbstractConnectionPool.close
def close(self): """ Close all connections and empty the pool. This method is thread safe. """ if self._closed: return try: with self.lock: if not self._closed: self._closed = True for address in list...
python
def close(self): """ Close all connections and empty the pool. This method is thread safe. """ if self._closed: return try: with self.lock: if not self._closed: self._closed = True for address in list...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "try", ":", "with", "self", ".", "lock", ":", "if", "not", "self", ".", "_closed", ":", "self", ".", "_closed", "=", "True", "for", "address", "in", "list", "(", ...
Close all connections and empty the pool. This method is thread safe.
[ "Close", "all", "connections", "and", "empty", "the", "pool", ".", "This", "method", "is", "thread", "safe", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L600-L613
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Response.on_records
def on_records(self, records): """ Called when one or more RECORD messages have been received. """ handler = self.handlers.get("on_records") if callable(handler): handler(records)
python
def on_records(self, records): """ Called when one or more RECORD messages have been received. """ handler = self.handlers.get("on_records") if callable(handler): handler(records)
[ "def", "on_records", "(", "self", ",", "records", ")", ":", "handler", "=", "self", ".", "handlers", ".", "get", "(", "\"on_records\"", ")", "if", "callable", "(", "handler", ")", ":", "handler", "(", "records", ")" ]
Called when one or more RECORD messages have been received.
[ "Called", "when", "one", "or", "more", "RECORD", "messages", "have", "been", "received", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L648-L653
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Response.on_success
def on_success(self, metadata): """ Called when a SUCCESS message has been received. """ handler = self.handlers.get("on_success") if callable(handler): handler(metadata) handler = self.handlers.get("on_summary") if callable(handler): handler()
python
def on_success(self, metadata): """ Called when a SUCCESS message has been received. """ handler = self.handlers.get("on_success") if callable(handler): handler(metadata) handler = self.handlers.get("on_summary") if callable(handler): handler()
[ "def", "on_success", "(", "self", ",", "metadata", ")", ":", "handler", "=", "self", ".", "handlers", ".", "get", "(", "\"on_success\"", ")", "if", "callable", "(", "handler", ")", ":", "handler", "(", "metadata", ")", "handler", "=", "self", ".", "han...
Called when a SUCCESS message has been received.
[ "Called", "when", "a", "SUCCESS", "message", "has", "been", "received", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L655-L663
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Response.on_failure
def on_failure(self, metadata): """ Called when a FAILURE message has been received. """ self.connection.reset() handler = self.handlers.get("on_failure") if callable(handler): handler(metadata) handler = self.handlers.get("on_summary") if callable(han...
python
def on_failure(self, metadata): """ Called when a FAILURE message has been received. """ self.connection.reset() handler = self.handlers.get("on_failure") if callable(handler): handler(metadata) handler = self.handlers.get("on_summary") if callable(han...
[ "def", "on_failure", "(", "self", ",", "metadata", ")", ":", "self", ".", "connection", ".", "reset", "(", ")", "handler", "=", "self", ".", "handlers", ".", "get", "(", "\"on_failure\"", ")", "if", "callable", "(", "handler", ")", ":", "handler", "(",...
Called when a FAILURE message has been received.
[ "Called", "when", "a", "FAILURE", "message", "has", "been", "received", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L665-L675
neo4j-drivers/neobolt
neobolt/impl/python/direct.py
Response.on_ignored
def on_ignored(self, metadata=None): """ Called when an IGNORED message has been received. """ handler = self.handlers.get("on_ignored") if callable(handler): handler(metadata) handler = self.handlers.get("on_summary") if callable(handler): handler...
python
def on_ignored(self, metadata=None): """ Called when an IGNORED message has been received. """ handler = self.handlers.get("on_ignored") if callable(handler): handler(metadata) handler = self.handlers.get("on_summary") if callable(handler): handler...
[ "def", "on_ignored", "(", "self", ",", "metadata", "=", "None", ")", ":", "handler", "=", "self", ".", "handlers", ".", "get", "(", "\"on_ignored\"", ")", "if", "callable", "(", "handler", ")", ":", "handler", "(", "metadata", ")", "handler", "=", "sel...
Called when an IGNORED message has been received.
[ "Called", "when", "an", "IGNORED", "message", "has", "been", "received", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L677-L685
trehn/hnmp
hnmp.py
cached_property
def cached_property(prop): """ A replacement for the property decorator that will only compute the attribute's value on the first call and serve a cached copy from then on. """ def cache_wrapper(self): if not hasattr(self, "_cache"): self._cache = {} if prop.__name__ ...
python
def cached_property(prop): """ A replacement for the property decorator that will only compute the attribute's value on the first call and serve a cached copy from then on. """ def cache_wrapper(self): if not hasattr(self, "_cache"): self._cache = {} if prop.__name__ ...
[ "def", "cached_property", "(", "prop", ")", ":", "def", "cache_wrapper", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_cache\"", ")", ":", "self", ".", "_cache", "=", "{", "}", "if", "prop", ".", "__name__", "not", "in", "self"...
A replacement for the property decorator that will only compute the attribute's value on the first call and serve a cached copy from then on.
[ "A", "replacement", "for", "the", "property", "decorator", "that", "will", "only", "compute", "the", "attribute", "s", "value", "on", "the", "first", "call", "and", "serve", "a", "cached", "copy", "from", "then", "on", "." ]
train
https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L47-L62
trehn/hnmp
hnmp.py
_convert_value_to_native
def _convert_value_to_native(value): """ Converts pysnmp objects into native Python objects. """ if isinstance(value, Counter32): return int(value.prettyPrint()) if isinstance(value, Counter64): return int(value.prettyPrint()) if isinstance(value, Gauge32): return int(val...
python
def _convert_value_to_native(value): """ Converts pysnmp objects into native Python objects. """ if isinstance(value, Counter32): return int(value.prettyPrint()) if isinstance(value, Counter64): return int(value.prettyPrint()) if isinstance(value, Gauge32): return int(val...
[ "def", "_convert_value_to_native", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Counter32", ")", ":", "return", "int", "(", "value", ".", "prettyPrint", "(", ")", ")", "if", "isinstance", "(", "value", ",", "Counter64", ")", ":", "retu...
Converts pysnmp objects into native Python objects.
[ "Converts", "pysnmp", "objects", "into", "native", "Python", "objects", "." ]
train
https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L65-L90
trehn/hnmp
hnmp.py
SNMP.get
def get(self, oid): """ Get a single OID value. """ snmpsecurity = self._get_snmp_security() try: engine_error, pdu_error, pdu_error_index, objects = self._cmdgen.getCmd( snmpsecurity, cmdgen.UdpTransportTarget((self.host, self.port), ...
python
def get(self, oid): """ Get a single OID value. """ snmpsecurity = self._get_snmp_security() try: engine_error, pdu_error, pdu_error_index, objects = self._cmdgen.getCmd( snmpsecurity, cmdgen.UdpTransportTarget((self.host, self.port), ...
[ "def", "get", "(", "self", ",", "oid", ")", ":", "snmpsecurity", "=", "self", ".", "_get_snmp_security", "(", ")", "try", ":", "engine_error", ",", "pdu_error", ",", "pdu_error_index", ",", "objects", "=", "self", ".", "_cmdgen", ".", "getCmd", "(", "snm...
Get a single OID value.
[ "Get", "a", "single", "OID", "value", "." ]
train
https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L178-L201
trehn/hnmp
hnmp.py
SNMP.set
def set(self, oid, value, value_type=None): """ Sets a single OID value. If you do not pass value_type hnmp will try to guess the correct type. Autodetection is supported for: * int and float (as Integer, fractional part will be discarded) * IPv4 address (as IpAddress) *...
python
def set(self, oid, value, value_type=None): """ Sets a single OID value. If you do not pass value_type hnmp will try to guess the correct type. Autodetection is supported for: * int and float (as Integer, fractional part will be discarded) * IPv4 address (as IpAddress) *...
[ "def", "set", "(", "self", ",", "oid", ",", "value", ",", "value_type", "=", "None", ")", ":", "snmpsecurity", "=", "self", ".", "_get_snmp_security", "(", ")", "if", "value_type", "is", "None", ":", "if", "isinstance", "(", "value", ",", "int", ")", ...
Sets a single OID value. If you do not pass value_type hnmp will try to guess the correct type. Autodetection is supported for: * int and float (as Integer, fractional part will be discarded) * IPv4 address (as IpAddress) * str (as OctetString) Unfortunately, pysnmp does not su...
[ "Sets", "a", "single", "OID", "value", ".", "If", "you", "do", "not", "pass", "value_type", "hnmp", "will", "try", "to", "guess", "the", "correct", "type", ".", "Autodetection", "is", "supported", "for", ":" ]
train
https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L203-L257
trehn/hnmp
hnmp.py
SNMP.table
def table(self, oid, columns=None, column_value_mapping=None, non_repeaters=0, max_repetitions=20, fetch_all_columns=True): """ Get a table of values with the given OID prefix. """ snmpsecurity = self._get_snmp_security() base_oid = oid.strip(".") if not fe...
python
def table(self, oid, columns=None, column_value_mapping=None, non_repeaters=0, max_repetitions=20, fetch_all_columns=True): """ Get a table of values with the given OID prefix. """ snmpsecurity = self._get_snmp_security() base_oid = oid.strip(".") if not fe...
[ "def", "table", "(", "self", ",", "oid", ",", "columns", "=", "None", ",", "column_value_mapping", "=", "None", ",", "non_repeaters", "=", "0", ",", "max_repetitions", "=", "20", ",", "fetch_all_columns", "=", "True", ")", ":", "snmpsecurity", "=", "self",...
Get a table of values with the given OID prefix.
[ "Get", "a", "table", "of", "values", "with", "the", "given", "OID", "prefix", "." ]
train
https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L259-L317
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
get_parser
def get_parser(): """Load parser for command line arguments. It parses argv/input into args variable. """ desc = Colors.LIGHTBLUE + textwrap.dedent( '''\ Welcome to _ _ _ __ _ _ _| |_ ___ _ __ ...
python
def get_parser(): """Load parser for command line arguments. It parses argv/input into args variable. """ desc = Colors.LIGHTBLUE + textwrap.dedent( '''\ Welcome to _ _ _ __ _ _ _| |_ ___ _ __ ...
[ "def", "get_parser", "(", ")", ":", "desc", "=", "Colors", ".", "LIGHTBLUE", "+", "textwrap", ".", "dedent", "(", "'''\\\n Welcome to\n _ _ _\n __ _ _ _| |_ ___ _ __ _ _ | |_ ___ _ _...
Load parser for command line arguments. It parses argv/input into args variable.
[ "Load", "parser", "for", "command", "line", "arguments", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L98-L174
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
insert
def insert(args): """Insert args values into instance variables.""" string_search = args.str_search mode_search = MODES[args.mode] page = list(TORRENTS[args.torr_page].keys())[0] key_search = TORRENTS[args.torr_page][page]['key_search'] torrent_page = TORRENTS[args.torr_page][page]['page'] d...
python
def insert(args): """Insert args values into instance variables.""" string_search = args.str_search mode_search = MODES[args.mode] page = list(TORRENTS[args.torr_page].keys())[0] key_search = TORRENTS[args.torr_page][page]['key_search'] torrent_page = TORRENTS[args.torr_page][page]['page'] d...
[ "def", "insert", "(", "args", ")", ":", "string_search", "=", "args", ".", "str_search", "mode_search", "=", "MODES", "[", "args", ".", "mode", "]", "page", "=", "list", "(", "TORRENTS", "[", "args", ".", "torr_page", "]", ".", "keys", "(", ")", ")",...
Insert args values into instance variables.
[ "Insert", "args", "values", "into", "instance", "variables", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L579-L588
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
run_it
def run_it(): """Search and download torrents until the user says it so.""" initialize() parser = get_parser() args = None first_parse = True while(True): if first_parse is True: first_parse = False args = parser.parse_args() else: print(textwr...
python
def run_it(): """Search and download torrents until the user says it so.""" initialize() parser = get_parser() args = None first_parse = True while(True): if first_parse is True: first_parse = False args = parser.parse_args() else: print(textwr...
[ "def", "run_it", "(", ")", ":", "initialize", "(", ")", "parser", "=", "get_parser", "(", ")", "args", "=", "None", "first_parse", "=", "True", "while", "(", "True", ")", ":", "if", "first_parse", "is", "True", ":", "first_parse", "=", "False", "args",...
Search and download torrents until the user says it so.
[ "Search", "and", "download", "torrents", "until", "the", "user", "says", "it", "so", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L596-L636
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
AutoPy.open_magnet
def open_magnet(self): """Open magnet according to os.""" if sys.platform.startswith('linux'): subprocess.Popen(['xdg-open', self.magnet], stdout=subprocess.PIPE, stderr=subprocess.PIPE) elif sys.platform.startswith('win32'): os.startfile(self...
python
def open_magnet(self): """Open magnet according to os.""" if sys.platform.startswith('linux'): subprocess.Popen(['xdg-open', self.magnet], stdout=subprocess.PIPE, stderr=subprocess.PIPE) elif sys.platform.startswith('win32'): os.startfile(self...
[ "def", "open_magnet", "(", "self", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'linux'", ")", ":", "subprocess", ".", "Popen", "(", "[", "'xdg-open'", ",", "self", ".", "magnet", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ...
Open magnet according to os.
[ "Open", "magnet", "according", "to", "os", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L211-L225
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
AutoPy.get_magnet
def get_magnet(self, url): """Get magnet from torrent page. Url already got domain.""" content_most_rated = requests.get(url) rated_soup = BeautifulSoup(content_most_rated.content, 'lxml') if self.page == 'torrent_project': self.magnet = rated_soup.find( 'a',...
python
def get_magnet(self, url): """Get magnet from torrent page. Url already got domain.""" content_most_rated = requests.get(url) rated_soup = BeautifulSoup(content_most_rated.content, 'lxml') if self.page == 'torrent_project': self.magnet = rated_soup.find( 'a',...
[ "def", "get_magnet", "(", "self", ",", "url", ")", ":", "content_most_rated", "=", "requests", ".", "get", "(", "url", ")", "rated_soup", "=", "BeautifulSoup", "(", "content_most_rated", ".", "content", ",", "'lxml'", ")", "if", "self", ".", "page", "==", ...
Get magnet from torrent page. Url already got domain.
[ "Get", "magnet", "from", "torrent", "page", ".", "Url", "already", "got", "domain", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L227-L251
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
AutoPy.download_torrent
def download_torrent(self): """Download torrent. Rated implies download the unique best rated torrent found. Otherwise: get the magnet and download it. """ try: if self.back_to_menu is True: return if self.found_torrents is False: ...
python
def download_torrent(self): """Download torrent. Rated implies download the unique best rated torrent found. Otherwise: get the magnet and download it. """ try: if self.back_to_menu is True: return if self.found_torrents is False: ...
[ "def", "download_torrent", "(", "self", ")", ":", "try", ":", "if", "self", ".", "back_to_menu", "is", "True", ":", "return", "if", "self", ".", "found_torrents", "is", "False", ":", "print", "(", "'Nothing found.'", ")", "return", "if", "self", ".", "mo...
Download torrent. Rated implies download the unique best rated torrent found. Otherwise: get the magnet and download it.
[ "Download", "torrent", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L253-L290
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
AutoPy.build_table
def build_table(self): """Build table.""" headers = ['Title', 'Seeders', 'Leechers', 'Age', 'Size'] titles = [] seeders = [] leechers = [] ages = [] sizes = [] if self.page == 'torrent_project': titles = [list(span.find('a').stripped_strings)[...
python
def build_table(self): """Build table.""" headers = ['Title', 'Seeders', 'Leechers', 'Age', 'Size'] titles = [] seeders = [] leechers = [] ages = [] sizes = [] if self.page == 'torrent_project': titles = [list(span.find('a').stripped_strings)[...
[ "def", "build_table", "(", "self", ")", ":", "headers", "=", "[", "'Title'", ",", "'Seeders'", ",", "'Leechers'", ",", "'Age'", ",", "'Size'", "]", "titles", "=", "[", "]", "seeders", "=", "[", "]", "leechers", "=", "[", "]", "ages", "=", "[", "]",...
Build table.
[ "Build", "table", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L292-L408
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
AutoPy.soupify
def soupify(self): """Get proper torrent/magnet information. If search_mode is rated then get torrent/magnet. If not, get all the elements to build the table. There are different ways for each page. """ soup = BeautifulSoup(self.content_page.content, 'lxml') if s...
python
def soupify(self): """Get proper torrent/magnet information. If search_mode is rated then get torrent/magnet. If not, get all the elements to build the table. There are different ways for each page. """ soup = BeautifulSoup(self.content_page.content, 'lxml') if s...
[ "def", "soupify", "(", "self", ")", ":", "soup", "=", "BeautifulSoup", "(", "self", ".", "content_page", ".", "content", ",", "'lxml'", ")", "if", "self", ".", "page", "==", "'torrent_project'", ":", "main", "=", "soup", ".", "find", "(", "'div'", ",",...
Get proper torrent/magnet information. If search_mode is rated then get torrent/magnet. If not, get all the elements to build the table. There are different ways for each page.
[ "Get", "proper", "torrent", "/", "magnet", "information", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L410-L488
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
AutoPy.handle_select
def handle_select(self): """Handle user's input in list mode.""" self.selected = input('>> ') if self.selected in ['Q', 'q']: sys.exit(1) elif self.selected in ['B', 'b']: self.back_to_menu = True return True elif is_num(self.selected): ...
python
def handle_select(self): """Handle user's input in list mode.""" self.selected = input('>> ') if self.selected in ['Q', 'q']: sys.exit(1) elif self.selected in ['B', 'b']: self.back_to_menu = True return True elif is_num(self.selected): ...
[ "def", "handle_select", "(", "self", ")", ":", "self", ".", "selected", "=", "input", "(", "'>> '", ")", "if", "self", ".", "selected", "in", "[", "'Q'", ",", "'q'", "]", ":", "sys", ".", "exit", "(", "1", ")", "elif", "self", ".", "selected", "i...
Handle user's input in list mode.
[ "Handle", "user", "s", "input", "in", "list", "mode", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L490-L513
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
AutoPy.select_torrent
def select_torrent(self): """Select torrent. First check if specific element/info is obtained in content_page. Specify to user if it wants best rated torrent or select one from list. If the user wants best rated: Directly obtain magnet/torrent. Else: build table with all data an...
python
def select_torrent(self): """Select torrent. First check if specific element/info is obtained in content_page. Specify to user if it wants best rated torrent or select one from list. If the user wants best rated: Directly obtain magnet/torrent. Else: build table with all data an...
[ "def", "select_torrent", "(", "self", ")", ":", "try", ":", "self", ".", "found_torrents", "=", "not", "bool", "(", "self", ".", "key_search", "in", "self", ".", "content_page", ".", "text", ")", "if", "not", "self", ".", "found_torrents", ":", "print", ...
Select torrent. First check if specific element/info is obtained in content_page. Specify to user if it wants best rated torrent or select one from list. If the user wants best rated: Directly obtain magnet/torrent. Else: build table with all data and enable the user select the torrent.
[ "Select", "torrent", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L515-L550
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
AutoPy.build_url
def build_url(self): """Build appropiate encoded URL. This implies the same way of searching a torrent as in the page itself. """ url = requests.utils.requote_uri( self.torrent_page + self.string_search) if self.page == '1337x': return(url + '/1/') ...
python
def build_url(self): """Build appropiate encoded URL. This implies the same way of searching a torrent as in the page itself. """ url = requests.utils.requote_uri( self.torrent_page + self.string_search) if self.page == '1337x': return(url + '/1/') ...
[ "def", "build_url", "(", "self", ")", ":", "url", "=", "requests", ".", "utils", ".", "requote_uri", "(", "self", ".", "torrent_page", "+", "self", ".", "string_search", ")", "if", "self", ".", "page", "==", "'1337x'", ":", "return", "(", "url", "+", ...
Build appropiate encoded URL. This implies the same way of searching a torrent as in the page itself.
[ "Build", "appropiate", "encoded", "URL", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L552-L564
ocslegna/auto_py_torrent
auto_py_torrent/auto_py_torrent.py
AutoPy.get_content
def get_content(self): """Get content of the page through url.""" url = self.build_url() try: self.content_page = requests.get(url) if not(self.content_page.status_code == requests.codes.ok): self.content_page.raise_for_status() except requests.exc...
python
def get_content(self): """Get content of the page through url.""" url = self.build_url() try: self.content_page = requests.get(url) if not(self.content_page.status_code == requests.codes.ok): self.content_page.raise_for_status() except requests.exc...
[ "def", "get_content", "(", "self", ")", ":", "url", "=", "self", ".", "build_url", "(", ")", "try", ":", "self", ".", "content_page", "=", "requests", ".", "get", "(", "url", ")", "if", "not", "(", "self", ".", "content_page", ".", "status_code", "==...
Get content of the page through url.
[ "Get", "content", "of", "the", "page", "through", "url", "." ]
train
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L566-L576
neo4j-drivers/neobolt
neobolt/impl/python/bolt/io.py
ChunkedInputBuffer._recycle
def _recycle(self): """ Reclaim buffer space before the origin. Note: modifies buffer size """ origin = self._origin if origin == 0: return False available = self._extent - origin self._data[:available] = self._data[origin:self._extent] self._...
python
def _recycle(self): """ Reclaim buffer space before the origin. Note: modifies buffer size """ origin = self._origin if origin == 0: return False available = self._extent - origin self._data[:available] = self._data[origin:self._extent] self._...
[ "def", "_recycle", "(", "self", ")", ":", "origin", "=", "self", ".", "_origin", "if", "origin", "==", "0", ":", "return", "False", "available", "=", "self", ".", "_extent", "-", "origin", "self", ".", "_data", "[", ":", "available", "]", "=", "self"...
Reclaim buffer space before the origin. Note: modifies buffer size
[ "Reclaim", "buffer", "space", "before", "the", "origin", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/bolt/io.py#L180-L193
neo4j-drivers/neobolt
neobolt/impl/python/bolt/io.py
ChunkedInputBuffer.frame_message
def frame_message(self): """ Construct a frame around the first complete message in the buffer. """ if self._frame is not None: self.discard_message() panes = [] p = origin = self._origin extent = self._extent while p < extent: available = ...
python
def frame_message(self): """ Construct a frame around the first complete message in the buffer. """ if self._frame is not None: self.discard_message() panes = [] p = origin = self._origin extent = self._extent while p < extent: available = ...
[ "def", "frame_message", "(", "self", ")", ":", "if", "self", ".", "_frame", "is", "not", "None", ":", "self", ".", "discard_message", "(", ")", "panes", "=", "[", "]", "p", "=", "origin", "=", "self", ".", "_origin", "extent", "=", "self", ".", "_e...
Construct a frame around the first complete message in the buffer.
[ "Construct", "a", "frame", "around", "the", "first", "complete", "message", "in", "the", "buffer", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/bolt/io.py#L198-L219
praw-dev/prawcore
prawcore/rate_limit.py
RateLimiter.call
def call(self, request_function, set_header_callback, *args, **kwargs): """Rate limit the call to request_function. :param request_function: A function call that returns an HTTP response object. :param set_header_callback: A callback function used to set the request head...
python
def call(self, request_function, set_header_callback, *args, **kwargs): """Rate limit the call to request_function. :param request_function: A function call that returns an HTTP response object. :param set_header_callback: A callback function used to set the request head...
[ "def", "call", "(", "self", ",", "request_function", ",", "set_header_callback", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "delay", "(", ")", "kwargs", "[", "\"headers\"", "]", "=", "set_header_callback", "(", ")", "response", "="...
Rate limit the call to request_function. :param request_function: A function call that returns an HTTP response object. :param set_header_callback: A callback function used to set the request headers. This callback is called after any necessary sleep time occurs. ...
[ "Rate", "limit", "the", "call", "to", "request_function", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/rate_limit.py#L22-L38
praw-dev/prawcore
prawcore/rate_limit.py
RateLimiter.delay
def delay(self): """Sleep for an amount of time to remain under the rate limit.""" if self.next_request_timestamp is None: return sleep_seconds = self.next_request_timestamp - time.time() if sleep_seconds <= 0: return message = "Sleeping: {:0.2f} seconds p...
python
def delay(self): """Sleep for an amount of time to remain under the rate limit.""" if self.next_request_timestamp is None: return sleep_seconds = self.next_request_timestamp - time.time() if sleep_seconds <= 0: return message = "Sleeping: {:0.2f} seconds p...
[ "def", "delay", "(", "self", ")", ":", "if", "self", ".", "next_request_timestamp", "is", "None", ":", "return", "sleep_seconds", "=", "self", ".", "next_request_timestamp", "-", "time", ".", "time", "(", ")", "if", "sleep_seconds", "<=", "0", ":", "return...
Sleep for an amount of time to remain under the rate limit.
[ "Sleep", "for", "an", "amount", "of", "time", "to", "remain", "under", "the", "rate", "limit", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/rate_limit.py#L40-L51
praw-dev/prawcore
prawcore/rate_limit.py
RateLimiter.update
def update(self, response_headers): """Update the state of the rate limiter based on the response headers. This method should only be called following a HTTP request to reddit. Response headers that do not contain x-ratelimit fields will be treated as a single request. This behavior is...
python
def update(self, response_headers): """Update the state of the rate limiter based on the response headers. This method should only be called following a HTTP request to reddit. Response headers that do not contain x-ratelimit fields will be treated as a single request. This behavior is...
[ "def", "update", "(", "self", ",", "response_headers", ")", ":", "if", "\"x-ratelimit-remaining\"", "not", "in", "response_headers", ":", "if", "self", ".", "remaining", "is", "not", "None", ":", "self", ".", "remaining", "-=", "1", "self", ".", "used", "+...
Update the state of the rate limiter based on the response headers. This method should only be called following a HTTP request to reddit. Response headers that do not contain x-ratelimit fields will be treated as a single request. This behavior is to error on the safe-side as such resp...
[ "Update", "the", "state", "of", "the", "rate", "limiter", "based", "on", "the", "response", "headers", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/rate_limit.py#L53-L89
neo4j-drivers/neobolt
neobolt/impl/python/addressing.py
Resolver.custom_resolve
def custom_resolve(self): """ If a custom resolver is defined, perform custom resolution on the contained addresses. :return: """ if not callable(self.custom_resolver): return new_addresses = [] for address in self.addresses: for new_addre...
python
def custom_resolve(self): """ If a custom resolver is defined, perform custom resolution on the contained addresses. :return: """ if not callable(self.custom_resolver): return new_addresses = [] for address in self.addresses: for new_addre...
[ "def", "custom_resolve", "(", "self", ")", ":", "if", "not", "callable", "(", "self", ".", "custom_resolver", ")", ":", "return", "new_addresses", "=", "[", "]", "for", "address", "in", "self", ".", "addresses", ":", "for", "new_address", "in", "self", "...
If a custom resolver is defined, perform custom resolution on the contained addresses. :return:
[ "If", "a", "custom", "resolver", "is", "defined", "perform", "custom", "resolution", "on", "the", "contained", "addresses", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/addressing.py#L109-L121
neo4j-drivers/neobolt
neobolt/impl/python/addressing.py
Resolver.dns_resolve
def dns_resolve(self): """ Perform DNS resolution on the contained addresses. :return: """ new_addresses = [] for address in self.addresses: try: info = getaddrinfo(address[0], address[1], 0, SOCK_STREAM, IPPROTO_TCP) except gaierror: ...
python
def dns_resolve(self): """ Perform DNS resolution on the contained addresses. :return: """ new_addresses = [] for address in self.addresses: try: info = getaddrinfo(address[0], address[1], 0, SOCK_STREAM, IPPROTO_TCP) except gaierror: ...
[ "def", "dns_resolve", "(", "self", ")", ":", "new_addresses", "=", "[", "]", "for", "address", "in", "self", ".", "addresses", ":", "try", ":", "info", "=", "getaddrinfo", "(", "address", "[", "0", "]", ",", "address", "[", "1", "]", ",", "0", ",",...
Perform DNS resolution on the contained addresses. :return:
[ "Perform", "DNS", "resolution", "on", "the", "contained", "addresses", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/addressing.py#L123-L141
cuzzo/iw_parse
iw_parse.py
get_quality
def get_quality(cell): """ Gets the quality of a network / cell. @param string cell A network / cell from iwlist scan. @return string The quality of the network. """ quality = matching_line(cell, "Quality=") if quality is None: return "" quality = quality.split()[0]...
python
def get_quality(cell): """ Gets the quality of a network / cell. @param string cell A network / cell from iwlist scan. @return string The quality of the network. """ quality = matching_line(cell, "Quality=") if quality is None: return "" quality = quality.split()[0]...
[ "def", "get_quality", "(", "cell", ")", ":", "quality", "=", "matching_line", "(", "cell", ",", "\"Quality=\"", ")", "if", "quality", "is", "None", ":", "return", "\"\"", "quality", "=", "quality", ".", "split", "(", ")", "[", "0", "]", ".", "split", ...
Gets the quality of a network / cell. @param string cell A network / cell from iwlist scan. @return string The quality of the network.
[ "Gets", "the", "quality", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
train
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L29-L43
cuzzo/iw_parse
iw_parse.py
get_signal_level
def get_signal_level(cell): """ Gets the signal level of a network / cell. @param string cell A network / cell from iwlist scan. @return string The signal level of the network. """ signal = matching_line(cell, "Signal level=") if signal is None: return "" signal = sig...
python
def get_signal_level(cell): """ Gets the signal level of a network / cell. @param string cell A network / cell from iwlist scan. @return string The signal level of the network. """ signal = matching_line(cell, "Signal level=") if signal is None: return "" signal = sig...
[ "def", "get_signal_level", "(", "cell", ")", ":", "signal", "=", "matching_line", "(", "cell", ",", "\"Signal level=\"", ")", "if", "signal", "is", "None", ":", "return", "\"\"", "signal", "=", "signal", ".", "split", "(", "\"=\"", ")", "[", "1", "]", ...
Gets the signal level of a network / cell. @param string cell A network / cell from iwlist scan. @return string The signal level of the network.
[ "Gets", "the", "signal", "level", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
train
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L45-L63
cuzzo/iw_parse
iw_parse.py
get_noise_level
def get_noise_level(cell): """ Gets the noise level of a network / cell. @param string cell A network / cell from iwlist scan. @return string The noise level of the network. """ noise = matching_line(cell, "Noise level=") if noise is None: return "" noise = noise.sp...
python
def get_noise_level(cell): """ Gets the noise level of a network / cell. @param string cell A network / cell from iwlist scan. @return string The noise level of the network. """ noise = matching_line(cell, "Noise level=") if noise is None: return "" noise = noise.sp...
[ "def", "get_noise_level", "(", "cell", ")", ":", "noise", "=", "matching_line", "(", "cell", ",", "\"Noise level=\"", ")", "if", "noise", "is", "None", ":", "return", "\"\"", "noise", "=", "noise", ".", "split", "(", "\"=\"", ")", "[", "1", "]", "retur...
Gets the noise level of a network / cell. @param string cell A network / cell from iwlist scan. @return string The noise level of the network.
[ "Gets", "the", "noise", "level", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
train
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L65-L78
cuzzo/iw_parse
iw_parse.py
get_channel
def get_channel(cell): """ Gets the channel of a network / cell. @param string cell A network / cell from iwlist scan. @return string The channel of the network. """ channel = matching_line(cell, "Channel:") if channel: return channel frequency = matching_line(cell,...
python
def get_channel(cell): """ Gets the channel of a network / cell. @param string cell A network / cell from iwlist scan. @return string The channel of the network. """ channel = matching_line(cell, "Channel:") if channel: return channel frequency = matching_line(cell,...
[ "def", "get_channel", "(", "cell", ")", ":", "channel", "=", "matching_line", "(", "cell", ",", "\"Channel:\"", ")", "if", "channel", ":", "return", "channel", "frequency", "=", "matching_line", "(", "cell", ",", "\"Frequency:\"", ")", "channel", "=", "re", ...
Gets the channel of a network / cell. @param string cell A network / cell from iwlist scan. @return string The channel of the network.
[ "Gets", "the", "channel", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
train
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L80-L94
cuzzo/iw_parse
iw_parse.py
get_encryption
def get_encryption(cell, emit_version=False): """ Gets the encryption type of a network / cell. @param string cell A network / cell from iwlist scan. @return string The encryption type of the network. """ enc = "" if matching_line(cell, "Encryption key:") == "off": enc ...
python
def get_encryption(cell, emit_version=False): """ Gets the encryption type of a network / cell. @param string cell A network / cell from iwlist scan. @return string The encryption type of the network. """ enc = "" if matching_line(cell, "Encryption key:") == "off": enc ...
[ "def", "get_encryption", "(", "cell", ",", "emit_version", "=", "False", ")", ":", "enc", "=", "\"\"", "if", "matching_line", "(", "cell", ",", "\"Encryption key:\"", ")", "==", "\"off\"", ":", "enc", "=", "\"Open\"", "else", ":", "for", "line", "in", "c...
Gets the encryption type of a network / cell. @param string cell A network / cell from iwlist scan. @return string The encryption type of the network.
[ "Gets", "the", "encryption", "type", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
train
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L110-L152
cuzzo/iw_parse
iw_parse.py
matching_line
def matching_line(lines, keyword): """ Returns the first matching line in a list of lines. @see match() """ for line in lines: matching = match(line,keyword) if matching != None: return matching return None
python
def matching_line(lines, keyword): """ Returns the first matching line in a list of lines. @see match() """ for line in lines: matching = match(line,keyword) if matching != None: return matching return None
[ "def", "matching_line", "(", "lines", ",", "keyword", ")", ":", "for", "line", "in", "lines", ":", "matching", "=", "match", "(", "line", ",", "keyword", ")", "if", "matching", "!=", "None", ":", "return", "matching", "return", "None" ]
Returns the first matching line in a list of lines. @see match()
[ "Returns", "the", "first", "matching", "line", "in", "a", "list", "of", "lines", "." ]
train
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L202-L210
cuzzo/iw_parse
iw_parse.py
match
def match(line, keyword): """ If the first part of line (modulo blanks) matches keyword, returns the end of that line. Otherwise checks if keyword is anywhere in the line and returns that section, else returns None""" line = line.lstrip() length = len(keyword) if line[:length] == keyword: ...
python
def match(line, keyword): """ If the first part of line (modulo blanks) matches keyword, returns the end of that line. Otherwise checks if keyword is anywhere in the line and returns that section, else returns None""" line = line.lstrip() length = len(keyword) if line[:length] == keyword: ...
[ "def", "match", "(", "line", ",", "keyword", ")", ":", "line", "=", "line", ".", "lstrip", "(", ")", "length", "=", "len", "(", "keyword", ")", "if", "line", "[", ":", "length", "]", "==", "keyword", ":", "return", "line", "[", "length", ":", "]"...
If the first part of line (modulo blanks) matches keyword, returns the end of that line. Otherwise checks if keyword is anywhere in the line and returns that section, else returns None
[ "If", "the", "first", "part", "of", "line", "(", "modulo", "blanks", ")", "matches", "keyword", "returns", "the", "end", "of", "that", "line", ".", "Otherwise", "checks", "if", "keyword", "is", "anywhere", "in", "the", "line", "and", "returns", "that", "...
train
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L212-L225
cuzzo/iw_parse
iw_parse.py
parse_cell
def parse_cell(cell, rules): """ Applies the rules to the bunch of text describing a cell. @param string cell A network / cell from iwlist scan. @param dictionary rules A dictionary of parse rules. @return dictionary parsed networks. """ parsed_cell = {} for key in rule...
python
def parse_cell(cell, rules): """ Applies the rules to the bunch of text describing a cell. @param string cell A network / cell from iwlist scan. @param dictionary rules A dictionary of parse rules. @return dictionary parsed networks. """ parsed_cell = {} for key in rule...
[ "def", "parse_cell", "(", "cell", ",", "rules", ")", ":", "parsed_cell", "=", "{", "}", "for", "key", "in", "rules", ":", "rule", "=", "rules", "[", "key", "]", "parsed_cell", ".", "update", "(", "{", "key", ":", "rule", "(", "cell", ")", "}", ")...
Applies the rules to the bunch of text describing a cell. @param string cell A network / cell from iwlist scan. @param dictionary rules A dictionary of parse rules. @return dictionary parsed networks.
[ "Applies", "the", "rules", "to", "the", "bunch", "of", "text", "describing", "a", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", ".", "@param", "dictionary", "rules", "A", "dictionary", "of", "parse", "rules...
train
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L227-L241
cuzzo/iw_parse
iw_parse.py
get_parsed_cells
def get_parsed_cells(iw_data, rules=None): """ Parses iwlist output into a list of networks. @param list iw_data Output from iwlist scan. A list of strings. @return list properties: Name, Address, Quality, Channel, Frequency, Encryption, Signal Level, Noise Level...
python
def get_parsed_cells(iw_data, rules=None): """ Parses iwlist output into a list of networks. @param list iw_data Output from iwlist scan. A list of strings. @return list properties: Name, Address, Quality, Channel, Frequency, Encryption, Signal Level, Noise Level...
[ "def", "get_parsed_cells", "(", "iw_data", ",", "rules", "=", "None", ")", ":", "# Here's a dictionary of rules that will be applied to the description", "# of each cell. The key will be the name of the column in the table.", "# The value is a function defined above.", "rules", "=", "r...
Parses iwlist output into a list of networks. @param list iw_data Output from iwlist scan. A list of strings. @return list properties: Name, Address, Quality, Channel, Frequency, Encryption, Signal Level, Noise Level, Bit Rates, Mode.
[ "Parses", "iwlist", "output", "into", "a", "list", "of", "networks", ".", "@param", "list", "iw_data", "Output", "from", "iwlist", "scan", ".", "A", "list", "of", "strings", "." ]
train
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L269-L311
praw-dev/prawcore
prawcore/sessions.py
Session.request
def request( self, method, path, data=None, files=None, json=None, params=None ): """Return the json content from the resource at ``path``. :param method: The request verb. E.g., get, post, put. :param path: The path of the request. This path will be combined with the ``...
python
def request( self, method, path, data=None, files=None, json=None, params=None ): """Return the json content from the resource at ``path``. :param method: The request verb. E.g., get, post, put. :param path: The path of the request. This path will be combined with the ``...
[ "def", "request", "(", "self", ",", "method", ",", "path", ",", "data", "=", "None", ",", "files", "=", "None", ",", "json", "=", "None", ",", "params", "=", "None", ")", ":", "params", "=", "deepcopy", "(", "params", ")", "or", "{", "}", "params...
Return the json content from the resource at ``path``. :param method: The request verb. E.g., get, post, put. :param path: The path of the request. This path will be combined with the ``oauth_url`` of the Requestor. :param data: Dictionary, bytes, or file-like object to send in the ...
[ "Return", "the", "json", "content", "from", "the", "resource", "at", "path", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/sessions.py#L226-L260
praw-dev/prawcore
examples/script_auth_friend_list.py
main
def main(): """Provide the program's entry point when directly executed.""" authenticator = prawcore.TrustedAuthenticator( prawcore.Requestor("prawcore_script_auth_example"), os.environ["PRAWCORE_CLIENT_ID"], os.environ["PRAWCORE_CLIENT_SECRET"], ) authorizer = prawcore.ScriptAut...
python
def main(): """Provide the program's entry point when directly executed.""" authenticator = prawcore.TrustedAuthenticator( prawcore.Requestor("prawcore_script_auth_example"), os.environ["PRAWCORE_CLIENT_ID"], os.environ["PRAWCORE_CLIENT_SECRET"], ) authorizer = prawcore.ScriptAut...
[ "def", "main", "(", ")", ":", "authenticator", "=", "prawcore", ".", "TrustedAuthenticator", "(", "prawcore", ".", "Requestor", "(", "\"prawcore_script_auth_example\"", ")", ",", "os", ".", "environ", "[", "\"PRAWCORE_CLIENT_ID\"", "]", ",", "os", ".", "environ"...
Provide the program's entry point when directly executed.
[ "Provide", "the", "program", "s", "entry", "point", "when", "directly", "executed", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/script_auth_friend_list.py#L15-L35
praw-dev/prawcore
examples/caching_requestor.py
main
def main(): """Provide the program's entry point when directly executed.""" if len(sys.argv) != 2: print("Usage: {} USERNAME".format(sys.argv[0])) return 1 caching_requestor = prawcore.Requestor( "prawcore_device_id_auth_example", session=CachingSession() ) authenticator = p...
python
def main(): """Provide the program's entry point when directly executed.""" if len(sys.argv) != 2: print("Usage: {} USERNAME".format(sys.argv[0])) return 1 caching_requestor = prawcore.Requestor( "prawcore_device_id_auth_example", session=CachingSession() ) authenticator = p...
[ "def", "main", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", "!=", "2", ":", "print", "(", "\"Usage: {} USERNAME\"", ".", "format", "(", "sys", ".", "argv", "[", "0", "]", ")", ")", "return", "1", "caching_requestor", "=", "prawcore", "...
Provide the program's entry point when directly executed.
[ "Provide", "the", "program", "s", "entry", "point", "when", "directly", "executed", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/caching_requestor.py#L39-L83
praw-dev/prawcore
examples/caching_requestor.py
CachingSession.request
def request(self, method, url, params=None, **kwargs): """Perform a request, or return a cached response if available.""" params_key = tuple(params.items()) if params else () if method.upper() == "GET": if (url, params_key) in self.get_cache: print("Returning cached r...
python
def request(self, method, url, params=None, **kwargs): """Perform a request, or return a cached response if available.""" params_key = tuple(params.items()) if params else () if method.upper() == "GET": if (url, params_key) in self.get_cache: print("Returning cached r...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "params", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params_key", "=", "tuple", "(", "params", ".", "items", "(", ")", ")", "if", "params", "else", "(", ")", "if", "method", "."...
Perform a request, or return a cached response if available.
[ "Perform", "a", "request", "or", "return", "a", "cached", "response", "if", "available", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/caching_requestor.py#L25-L36
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingTable.parse_routing_info
def parse_routing_info(cls, records): """ Parse the records returned from a getServers call and return a new RoutingTable instance. """ if len(records) != 1: raise RoutingProtocolError("Expected exactly one record") record = records[0] routers = [] rea...
python
def parse_routing_info(cls, records): """ Parse the records returned from a getServers call and return a new RoutingTable instance. """ if len(records) != 1: raise RoutingProtocolError("Expected exactly one record") record = records[0] routers = [] rea...
[ "def", "parse_routing_info", "(", "cls", ",", "records", ")", ":", "if", "len", "(", "records", ")", "!=", "1", ":", "raise", "RoutingProtocolError", "(", "\"Expected exactly one record\"", ")", "record", "=", "records", "[", "0", "]", "routers", "=", "[", ...
Parse the records returned from a getServers call and return a new RoutingTable instance.
[ "Parse", "the", "records", "returned", "from", "a", "getServers", "call", "and", "return", "a", "new", "RoutingTable", "instance", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L97-L124
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingTable.is_fresh
def is_fresh(self, access_mode): """ Indicator for whether routing information is still usable. """ log_debug("[#0000] C: <ROUTING> Checking table freshness for %r", access_mode) expired = self.last_updated_time + self.ttl <= self.timer() has_server_for_mode = bool(access_mode =...
python
def is_fresh(self, access_mode): """ Indicator for whether routing information is still usable. """ log_debug("[#0000] C: <ROUTING> Checking table freshness for %r", access_mode) expired = self.last_updated_time + self.ttl <= self.timer() has_server_for_mode = bool(access_mode =...
[ "def", "is_fresh", "(", "self", ",", "access_mode", ")", ":", "log_debug", "(", "\"[#0000] C: <ROUTING> Checking table freshness for %r\"", ",", "access_mode", ")", "expired", "=", "self", ".", "last_updated_time", "+", "self", ".", "ttl", "<=", "self", ".", "tim...
Indicator for whether routing information is still usable.
[ "Indicator", "for", "whether", "routing", "information", "is", "still", "usable", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L142-L151
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingTable.update
def update(self, new_routing_table): """ Update the current routing table with new routing information from a replacement table. """ self.routers.replace(new_routing_table.routers) self.readers.replace(new_routing_table.readers) self.writers.replace(new_routing_table.writ...
python
def update(self, new_routing_table): """ Update the current routing table with new routing information from a replacement table. """ self.routers.replace(new_routing_table.routers) self.readers.replace(new_routing_table.readers) self.writers.replace(new_routing_table.writ...
[ "def", "update", "(", "self", ",", "new_routing_table", ")", ":", "self", ".", "routers", ".", "replace", "(", "new_routing_table", ".", "routers", ")", "self", ".", "readers", ".", "replace", "(", "new_routing_table", ".", "readers", ")", "self", ".", "wr...
Update the current routing table with new routing information from a replacement table.
[ "Update", "the", "current", "routing", "table", "with", "new", "routing", "information", "from", "a", "replacement", "table", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L153-L162
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingConnectionPool.fetch_routing_info
def fetch_routing_info(self, address): """ Fetch raw routing info from a given router address. :param address: router address :return: list of routing records or None if no connection could be established :raise ServiceUnavailable: if the server does not support routing...
python
def fetch_routing_info(self, address): """ Fetch raw routing info from a given router address. :param address: router address :return: list of routing records or None if no connection could be established :raise ServiceUnavailable: if the server does not support routing...
[ "def", "fetch_routing_info", "(", "self", ",", "address", ")", ":", "metadata", "=", "{", "}", "records", "=", "[", "]", "def", "fail", "(", "md", ")", ":", "if", "md", ".", "get", "(", "\"code\"", ")", "==", "\"Neo.ClientError.Procedure.ProcedureNotFound\...
Fetch raw routing info from a given router address. :param address: router address :return: list of routing records or None if no connection could be established :raise ServiceUnavailable: if the server does not support routing or if routing s...
[ "Fetch", "raw", "routing", "info", "from", "a", "given", "router", "address", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L222-L260
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingConnectionPool.fetch_routing_table
def fetch_routing_table(self, address): """ Fetch a routing table from a given router address. :param address: router address :return: a new RoutingTable instance or None if the given router is currently unable to provide routing information :raise ServiceUnavailable: i...
python
def fetch_routing_table(self, address): """ Fetch a routing table from a given router address. :param address: router address :return: a new RoutingTable instance or None if the given router is currently unable to provide routing information :raise ServiceUnavailable: i...
[ "def", "fetch_routing_table", "(", "self", ",", "address", ")", ":", "new_routing_info", "=", "self", ".", "fetch_routing_info", "(", "address", ")", "if", "new_routing_info", "is", "None", ":", "return", "None", "# Parse routing info and count the number of each type o...
Fetch a routing table from a given router address. :param address: router address :return: a new RoutingTable instance or None if the given router is currently unable to provide routing information :raise ServiceUnavailable: if no writers are available :raise ProtocolEr...
[ "Fetch", "a", "routing", "table", "from", "a", "given", "router", "address", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L262-L295
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingConnectionPool.update_routing_table_from
def update_routing_table_from(self, *routers): """ Try to update routing tables with the given routers. :return: True if the routing table is successfully updated, otherwise False """ for router in routers: new_routing_table = self.fetch_routing_table(router) if ...
python
def update_routing_table_from(self, *routers): """ Try to update routing tables with the given routers. :return: True if the routing table is successfully updated, otherwise False """ for router in routers: new_routing_table = self.fetch_routing_table(router) if ...
[ "def", "update_routing_table_from", "(", "self", ",", "*", "routers", ")", ":", "for", "router", "in", "routers", ":", "new_routing_table", "=", "self", ".", "fetch_routing_table", "(", "router", ")", "if", "new_routing_table", "is", "not", "None", ":", "self"...
Try to update routing tables with the given routers. :return: True if the routing table is successfully updated, otherwise False
[ "Try", "to", "update", "routing", "tables", "with", "the", "given", "routers", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L297-L307
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingConnectionPool.update_routing_table
def update_routing_table(self): """ Update the routing table from the first router able to provide valid routing information. """ # copied because it can be modified existing_routers = list(self.routing_table.routers) has_tried_initial_routers = False if self.mis...
python
def update_routing_table(self): """ Update the routing table from the first router able to provide valid routing information. """ # copied because it can be modified existing_routers = list(self.routing_table.routers) has_tried_initial_routers = False if self.mis...
[ "def", "update_routing_table", "(", "self", ")", ":", "# copied because it can be modified", "existing_routers", "=", "list", "(", "self", ".", "routing_table", ".", "routers", ")", "has_tried_initial_routers", "=", "False", "if", "self", ".", "missing_writer", ":", ...
Update the routing table from the first router able to provide valid routing information.
[ "Update", "the", "routing", "table", "from", "the", "first", "router", "able", "to", "provide", "valid", "routing", "information", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L309-L330
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingConnectionPool.ensure_routing_table_is_fresh
def ensure_routing_table_is_fresh(self, access_mode): """ Update the routing table if stale. This method performs two freshness checks, before and after acquiring the refresh lock. If the routing table is already fresh on entry, the method exits immediately; otherwise, the refresh lock ...
python
def ensure_routing_table_is_fresh(self, access_mode): """ Update the routing table if stale. This method performs two freshness checks, before and after acquiring the refresh lock. If the routing table is already fresh on entry, the method exits immediately; otherwise, the refresh lock ...
[ "def", "ensure_routing_table_is_fresh", "(", "self", ",", "access_mode", ")", ":", "if", "self", ".", "routing_table", ".", "is_fresh", "(", "access_mode", ")", ":", "return", "False", "with", "self", ".", "refresh_lock", ":", "if", "self", ".", "routing_table...
Update the routing table if stale. This method performs two freshness checks, before and after acquiring the refresh lock. If the routing table is already fresh on entry, the method exits immediately; otherwise, the refresh lock is acquired and the second freshness check that follows de...
[ "Update", "the", "routing", "table", "if", "stale", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L338-L361
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingConnectionPool.deactivate
def deactivate(self, address): """ Deactivate an address from the connection pool, if present, remove from the routing table and also closing all idle connections to that address. """ log_debug("[#0000] C: <ROUTING> Deactivating address %r", address) # We use `discard` i...
python
def deactivate(self, address): """ Deactivate an address from the connection pool, if present, remove from the routing table and also closing all idle connections to that address. """ log_debug("[#0000] C: <ROUTING> Deactivating address %r", address) # We use `discard` i...
[ "def", "deactivate", "(", "self", ",", "address", ")", ":", "log_debug", "(", "\"[#0000] C: <ROUTING> Deactivating address %r\"", ",", "address", ")", "# We use `discard` instead of `remove` here since the former", "# will not fail if the address has already been removed.", "self", ...
Deactivate an address from the connection pool, if present, remove from the routing table and also closing all idle connections to that address.
[ "Deactivate", "an", "address", "from", "the", "connection", "pool", "if", "present", "remove", "from", "the", "routing", "table", "and", "also", "closing", "all", "idle", "connections", "to", "that", "address", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L389-L401
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingConnectionPool.remove_writer
def remove_writer(self, address): """ Remove a writer address from the routing table, if present. """ log_debug("[#0000] C: <ROUTING> Removing writer %r", address) self.routing_table.writers.discard(address) log_debug("[#0000] C: <ROUTING> table=%r", self.routing_table)
python
def remove_writer(self, address): """ Remove a writer address from the routing table, if present. """ log_debug("[#0000] C: <ROUTING> Removing writer %r", address) self.routing_table.writers.discard(address) log_debug("[#0000] C: <ROUTING> table=%r", self.routing_table)
[ "def", "remove_writer", "(", "self", ",", "address", ")", ":", "log_debug", "(", "\"[#0000] C: <ROUTING> Removing writer %r\"", ",", "address", ")", "self", ".", "routing_table", ".", "writers", ".", "discard", "(", "address", ")", "log_debug", "(", "\"[#0000] C...
Remove a writer address from the routing table, if present.
[ "Remove", "a", "writer", "address", "from", "the", "routing", "table", "if", "present", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L403-L408
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
RoutingConnectionPool.handle
def handle(self, error, connection): """ Handle any cleanup or similar activity related to an error occurring on a pooled connection. """ error_class = error.__class__ if error_class in (ConnectionExpired, ServiceUnavailable, DatabaseUnavailableError): self.deactivate...
python
def handle(self, error, connection): """ Handle any cleanup or similar activity related to an error occurring on a pooled connection. """ error_class = error.__class__ if error_class in (ConnectionExpired, ServiceUnavailable, DatabaseUnavailableError): self.deactivate...
[ "def", "handle", "(", "self", ",", "error", ",", "connection", ")", ":", "error_class", "=", "error", ".", "__class__", "if", "error_class", "in", "(", "ConnectionExpired", ",", "ServiceUnavailable", ",", "DatabaseUnavailableError", ")", ":", "self", ".", "dea...
Handle any cleanup or similar activity related to an error occurring on a pooled connection.
[ "Handle", "any", "cleanup", "or", "similar", "activity", "related", "to", "an", "error", "occurring", "on", "a", "pooled", "connection", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L410-L418
neo4j-drivers/neobolt
neobolt/types/spatial.py
point_type
def point_type(name, fields, srid_map): """ Dynamically create a Point subclass. """ def srid(self): try: return srid_map[len(self)] except KeyError: return None attributes = {"srid": property(srid)} for index, subclass_field in enumerate(fields): ...
python
def point_type(name, fields, srid_map): """ Dynamically create a Point subclass. """ def srid(self): try: return srid_map[len(self)] except KeyError: return None attributes = {"srid": property(srid)} for index, subclass_field in enumerate(fields): ...
[ "def", "point_type", "(", "name", ",", "fields", ",", "srid_map", ")", ":", "def", "srid", "(", "self", ")", ":", "try", ":", "return", "srid_map", "[", "len", "(", "self", ")", "]", "except", "KeyError", ":", "return", "None", "attributes", "=", "{"...
Dynamically create a Point subclass.
[ "Dynamically", "create", "a", "Point", "subclass", "." ]
train
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/types/spatial.py#L72-L101
praw-dev/prawcore
examples/read_only_auth_trophies.py
main
def main(): """Provide the program's entry point when directly executed.""" if len(sys.argv) != 2: print("Usage: {} USERNAME".format(sys.argv[0])) return 1 authenticator = prawcore.TrustedAuthenticator( prawcore.Requestor("prawcore_read_only_example"), os.environ["PRAWCORE_C...
python
def main(): """Provide the program's entry point when directly executed.""" if len(sys.argv) != 2: print("Usage: {} USERNAME".format(sys.argv[0])) return 1 authenticator = prawcore.TrustedAuthenticator( prawcore.Requestor("prawcore_read_only_example"), os.environ["PRAWCORE_C...
[ "def", "main", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", "!=", "2", ":", "print", "(", "\"Usage: {} USERNAME\"", ".", "format", "(", "sys", ".", "argv", "[", "0", "]", ")", ")", "return", "1", "authenticator", "=", "prawcore", ".", ...
Provide the program's entry point when directly executed.
[ "Provide", "the", "program", "s", "entry", "point", "when", "directly", "executed", "." ]
train
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/read_only_auth_trophies.py#L14-L39
chaoss/grimoirelab-sigils
src/migration/to_kibana5.py
main
def main(): """Read a directory containing json files for Kibana panels, beautify them and replace size value in aggregations as specified through corresponding params params. """ args = parse_args() configure_logging(args.debug) src_path = args.src_path dest_path = args.dest_path o...
python
def main(): """Read a directory containing json files for Kibana panels, beautify them and replace size value in aggregations as specified through corresponding params params. """ args = parse_args() configure_logging(args.debug) src_path = args.src_path dest_path = args.dest_path o...
[ "def", "main", "(", ")", ":", "args", "=", "parse_args", "(", ")", "configure_logging", "(", "args", ".", "debug", ")", "src_path", "=", "args", ".", "src_path", "dest_path", "=", "args", ".", "dest_path", "old_str1", "=", "'\\\\\"size\\\\\":'", "+", "args...
Read a directory containing json files for Kibana panels, beautify them and replace size value in aggregations as specified through corresponding params params.
[ "Read", "a", "directory", "containing", "json", "files", "for", "Kibana", "panels", "beautify", "them", "and", "replace", "size", "value", "in", "aggregations", "as", "specified", "through", "corresponding", "params", "params", "." ]
train
https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/to_kibana5.py#L40-L84
chaoss/grimoirelab-sigils
src/migration/to_kibana5.py
parse_args
def parse_args(): """Parse arguments from the command line""" parser = argparse.ArgumentParser(description=TO_KIBANA5_DESC_MSG) parser.add_argument('-s', '--source', dest='src_path', \ required=True, help='source directory') parser.add_argument('-d', '--dest', dest='dest_path', \ requi...
python
def parse_args(): """Parse arguments from the command line""" parser = argparse.ArgumentParser(description=TO_KIBANA5_DESC_MSG) parser.add_argument('-s', '--source', dest='src_path', \ required=True, help='source directory') parser.add_argument('-d', '--dest', dest='dest_path', \ requi...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "TO_KIBANA5_DESC_MSG", ")", "parser", ".", "add_argument", "(", "'-s'", ",", "'--source'", ",", "dest", "=", "'src_path'", ",", "required", "=", "T...
Parse arguments from the command line
[ "Parse", "arguments", "from", "the", "command", "line" ]
train
https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/to_kibana5.py#L86-L104
chaoss/grimoirelab-sigils
src/migration/to_kibana5.py
configure_logging
def configure_logging(debug=False): """Configure logging The function configures log messages. By default, log messages are sent to stderr. Set the parameter `debug` to activate the debug mode. :param debug: set the debug mode """ if not debug: logging.basicConfig(level=logging.INFO,...
python
def configure_logging(debug=False): """Configure logging The function configures log messages. By default, log messages are sent to stderr. Set the parameter `debug` to activate the debug mode. :param debug: set the debug mode """ if not debug: logging.basicConfig(level=logging.INFO,...
[ "def", "configure_logging", "(", "debug", "=", "False", ")", ":", "if", "not", "debug", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ",", "format", "=", "LOG_FORMAT", ")", "else", ":", "logging", ".", "basicConfig", "(",...
Configure logging The function configures log messages. By default, log messages are sent to stderr. Set the parameter `debug` to activate the debug mode. :param debug: set the debug mode
[ "Configure", "logging", "The", "function", "configures", "log", "messages", ".", "By", "default", "log", "messages", "are", "sent", "to", "stderr", ".", "Set", "the", "parameter", "debug", "to", "activate", "the", "debug", "mode", ".", ":", "param", "debug",...
train
https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/to_kibana5.py#L107-L119
MartinThoma/memtop
memtop/__init__.py
signal_handler
def signal_handler(signal_name, frame): """Quit signal handler.""" sys.stdout.flush() print("\nSIGINT in frame signal received. Quitting...") sys.stdout.flush() sys.exit(0)
python
def signal_handler(signal_name, frame): """Quit signal handler.""" sys.stdout.flush() print("\nSIGINT in frame signal received. Quitting...") sys.stdout.flush() sys.exit(0)
[ "def", "signal_handler", "(", "signal_name", ",", "frame", ")", ":", "sys", ".", "stdout", ".", "flush", "(", ")", "print", "(", "\"\\nSIGINT in frame signal received. Quitting...\"", ")", "sys", ".", "stdout", ".", "flush", "(", ")", "sys", ".", "exit", "("...
Quit signal handler.
[ "Quit", "signal", "handler", "." ]
train
https://github.com/MartinThoma/memtop/blob/504d251f1951922db84883c2e660ba7e754d1546/memtop/__init__.py#L68-L73
MartinThoma/memtop
memtop/__init__.py
graph_format
def graph_format(new_mem, old_mem, is_firstiteration=True): """Show changes graphically in memory consumption""" if is_firstiteration: output = " n/a " elif new_mem - old_mem > 50000000: output = " +++++" elif new_mem - old_mem > 20000000: output = " ++++ " elif new_me...
python
def graph_format(new_mem, old_mem, is_firstiteration=True): """Show changes graphically in memory consumption""" if is_firstiteration: output = " n/a " elif new_mem - old_mem > 50000000: output = " +++++" elif new_mem - old_mem > 20000000: output = " ++++ " elif new_me...
[ "def", "graph_format", "(", "new_mem", ",", "old_mem", ",", "is_firstiteration", "=", "True", ")", ":", "if", "is_firstiteration", ":", "output", "=", "\" n/a \"", "elif", "new_mem", "-", "old_mem", ">", "50000000", ":", "output", "=", "\" +++++\"", "elif...
Show changes graphically in memory consumption
[ "Show", "changes", "graphically", "in", "memory", "consumption" ]
train
https://github.com/MartinThoma/memtop/blob/504d251f1951922db84883c2e660ba7e754d1546/memtop/__init__.py#L93-L115
MartinThoma/memtop
memtop/__init__.py
get_cur_mem_use
def get_cur_mem_use(): """return utilization of memory""" # http://lwn.net/Articles/28345/ lines = open("/proc/meminfo", 'r').readlines() emptySpace = re.compile('[ ]+') for line in lines: if "MemTotal" in line: memtotal = float(emptySpace.split(line)[1]) if "SwapFree" i...
python
def get_cur_mem_use(): """return utilization of memory""" # http://lwn.net/Articles/28345/ lines = open("/proc/meminfo", 'r').readlines() emptySpace = re.compile('[ ]+') for line in lines: if "MemTotal" in line: memtotal = float(emptySpace.split(line)[1]) if "SwapFree" i...
[ "def", "get_cur_mem_use", "(", ")", ":", "# http://lwn.net/Articles/28345/", "lines", "=", "open", "(", "\"/proc/meminfo\"", ",", "'r'", ")", ".", "readlines", "(", ")", "emptySpace", "=", "re", ".", "compile", "(", "'[ ]+'", ")", "for", "line", "in", "lines...
return utilization of memory
[ "return", "utilization", "of", "memory" ]
train
https://github.com/MartinThoma/memtop/blob/504d251f1951922db84883c2e660ba7e754d1546/memtop/__init__.py#L118-L144
MartinThoma/memtop
memtop/__init__.py
check_py_version
def check_py_version(): """Check if a propper Python version is used.""" try: if sys.version_info >= (2, 7): return except: pass print(" ") print(" ERROR - memtop needs python version at least 2.7") print(("Chances are that you can install newer version from your " ...
python
def check_py_version(): """Check if a propper Python version is used.""" try: if sys.version_info >= (2, 7): return except: pass print(" ") print(" ERROR - memtop needs python version at least 2.7") print(("Chances are that you can install newer version from your " ...
[ "def", "check_py_version", "(", ")", ":", "try", ":", "if", "sys", ".", "version_info", ">=", "(", "2", ",", "7", ")", ":", "return", "except", ":", "pass", "print", "(", "\" \"", ")", "print", "(", "\" ERROR - memtop needs python version at least 2.7\"", ")...
Check if a propper Python version is used.
[ "Check", "if", "a", "propper", "Python", "version", "is", "used", "." ]
train
https://github.com/MartinThoma/memtop/blob/504d251f1951922db84883c2e660ba7e754d1546/memtop/__init__.py#L229-L244
sfischer13/python-prompt
prompt/__init__.py
character
def character(prompt=None, empty=False): """Prompt a single character. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- str or None A str if the user entered a single-characte...
python
def character(prompt=None, empty=False): """Prompt a single character. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- str or None A str if the user entered a single-characte...
[ "def", "character", "(", "prompt", "=", "None", ",", "empty", "=", "False", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "elif", "len", "(", "s", ")", "==", "1", ":", "return", ...
Prompt a single character. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- str or None A str if the user entered a single-character, non-empty string. None if the user pr...
[ "Prompt", "a", "single", "character", "." ]
train
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L46-L69
sfischer13/python-prompt
prompt/__init__.py
email
def email(prompt=None, empty=False, mode="simple"): """Prompt an email address. This check is based on a simple regular expression and does not verify whether an email actually exists. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional ...
python
def email(prompt=None, empty=False, mode="simple"): """Prompt an email address. This check is based on a simple regular expression and does not verify whether an email actually exists. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional ...
[ "def", "email", "(", "prompt", "=", "None", ",", "empty", "=", "False", ",", "mode", "=", "\"simple\"", ")", ":", "if", "mode", "==", "\"simple\"", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", ...
Prompt an email address. This check is based on a simple regular expression and does not verify whether an email actually exists. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. mode : {'simple'}, optio...
[ "Prompt", "an", "email", "address", "." ]
train
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L72-L105
sfischer13/python-prompt
prompt/__init__.py
integer
def integer(prompt=None, empty=False): """Prompt an integer. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- int or None An int if the user entered a valid integer. N...
python
def integer(prompt=None, empty=False): """Prompt an integer. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- int or None An int if the user entered a valid integer. N...
[ "def", "integer", "(", "prompt", "=", "None", ",", "empty", "=", "False", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "else", ":", "try", ":", "return", "int", "(", "s", ")", "...
Prompt an integer. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- int or None An int if the user entered a valid integer. None if the user pressed only Enter and ``empty...
[ "Prompt", "an", "integer", "." ]
train
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L108-L132
sfischer13/python-prompt
prompt/__init__.py
real
def real(prompt=None, empty=False): """Prompt a real number. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- float or None A float if the user entered a valid real number. ...
python
def real(prompt=None, empty=False): """Prompt a real number. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- float or None A float if the user entered a valid real number. ...
[ "def", "real", "(", "prompt", "=", "None", ",", "empty", "=", "False", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "else", ":", "try", ":", "return", "float", "(", "s", ")", "e...
Prompt a real number. Parameters ---------- prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. Returns ------- float or None A float if the user entered a valid real number. None if the user pressed only Enter a...
[ "Prompt", "a", "real", "number", "." ]
train
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L135-L159
sfischer13/python-prompt
prompt/__init__.py
regex
def regex(pattern, prompt=None, empty=False, flags=0): """Prompt a string that matches a regular expression. Parameters ---------- pattern : str A regular expression that must be matched. prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an e...
python
def regex(pattern, prompt=None, empty=False, flags=0): """Prompt a string that matches a regular expression. Parameters ---------- pattern : str A regular expression that must be matched. prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an e...
[ "def", "regex", "(", "pattern", ",", "prompt", "=", "None", ",", "empty", "=", "False", ",", "flags", "=", "0", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "else", ":", "m", "=...
Prompt a string that matches a regular expression. Parameters ---------- pattern : str A regular expression that must be matched. prompt : str, optional Use an alternative prompt. empty : bool, optional Allow an empty response. flags : int, optional Flags that wi...
[ "Prompt", "a", "string", "that", "matches", "a", "regular", "expression", "." ]
train
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L162-L195