partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
AutoPy.open_magnet
Open magnet according to os.
auto_py_torrent/auto_py_torrent.py
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): """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...
[ "Open", "magnet", "according", "to", "os", "." ]
ocslegna/auto_py_torrent
python
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L211-L225
[ "def", "open_magnet", "(", "self", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'linux'", ")", ":", "subprocess", ".", "Popen", "(", "[", "'xdg-open'", ",", "self", ".", "magnet", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ...
32761fe18b3112e6e3754da863488b50929fcc41
train
AutoPy.get_magnet
Get magnet from torrent page. Url already got domain.
auto_py_torrent/auto_py_torrent.py
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): """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',...
[ "Get", "magnet", "from", "torrent", "page", ".", "Url", "already", "got", "domain", "." ]
ocslegna/auto_py_torrent
python
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L227-L251
[ "def", "get_magnet", "(", "self", ",", "url", ")", ":", "content_most_rated", "=", "requests", ".", "get", "(", "url", ")", "rated_soup", "=", "BeautifulSoup", "(", "content_most_rated", ".", "content", ",", "'lxml'", ")", "if", "self", ".", "page", "==", ...
32761fe18b3112e6e3754da863488b50929fcc41
train
AutoPy.download_torrent
Download torrent. Rated implies download the unique best rated torrent found. Otherwise: get the magnet and download it.
auto_py_torrent/auto_py_torrent.py
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): """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: ...
[ "Download", "torrent", "." ]
ocslegna/auto_py_torrent
python
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L253-L290
[ "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...
32761fe18b3112e6e3754da863488b50929fcc41
train
AutoPy.build_table
Build table.
auto_py_torrent/auto_py_torrent.py
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): """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)[...
[ "Build", "table", "." ]
ocslegna/auto_py_torrent
python
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L292-L408
[ "def", "build_table", "(", "self", ")", ":", "headers", "=", "[", "'Title'", ",", "'Seeders'", ",", "'Leechers'", ",", "'Age'", ",", "'Size'", "]", "titles", "=", "[", "]", "seeders", "=", "[", "]", "leechers", "=", "[", "]", "ages", "=", "[", "]",...
32761fe18b3112e6e3754da863488b50929fcc41
train
AutoPy.soupify
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.
auto_py_torrent/auto_py_torrent.py
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): """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...
[ "Get", "proper", "torrent", "/", "magnet", "information", "." ]
ocslegna/auto_py_torrent
python
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L410-L488
[ "def", "soupify", "(", "self", ")", ":", "soup", "=", "BeautifulSoup", "(", "self", ".", "content_page", ".", "content", ",", "'lxml'", ")", "if", "self", ".", "page", "==", "'torrent_project'", ":", "main", "=", "soup", ".", "find", "(", "'div'", ",",...
32761fe18b3112e6e3754da863488b50929fcc41
train
AutoPy.handle_select
Handle user's input in list mode.
auto_py_torrent/auto_py_torrent.py
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): """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): ...
[ "Handle", "user", "s", "input", "in", "list", "mode", "." ]
ocslegna/auto_py_torrent
python
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L490-L513
[ "def", "handle_select", "(", "self", ")", ":", "self", ".", "selected", "=", "input", "(", "'>> '", ")", "if", "self", ".", "selected", "in", "[", "'Q'", ",", "'q'", "]", ":", "sys", ".", "exit", "(", "1", ")", "elif", "self", ".", "selected", "i...
32761fe18b3112e6e3754da863488b50929fcc41
train
AutoPy.select_torrent
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.
auto_py_torrent/auto_py_torrent.py
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): """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...
[ "Select", "torrent", "." ]
ocslegna/auto_py_torrent
python
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L515-L550
[ "def", "select_torrent", "(", "self", ")", ":", "try", ":", "self", ".", "found_torrents", "=", "not", "bool", "(", "self", ".", "key_search", "in", "self", ".", "content_page", ".", "text", ")", "if", "not", "self", ".", "found_torrents", ":", "print", ...
32761fe18b3112e6e3754da863488b50929fcc41
train
AutoPy.build_url
Build appropiate encoded URL. This implies the same way of searching a torrent as in the page itself.
auto_py_torrent/auto_py_torrent.py
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): """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/') ...
[ "Build", "appropiate", "encoded", "URL", "." ]
ocslegna/auto_py_torrent
python
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L552-L564
[ "def", "build_url", "(", "self", ")", ":", "url", "=", "requests", ".", "utils", ".", "requote_uri", "(", "self", ".", "torrent_page", "+", "self", ".", "string_search", ")", "if", "self", ".", "page", "==", "'1337x'", ":", "return", "(", "url", "+", ...
32761fe18b3112e6e3754da863488b50929fcc41
train
AutoPy.get_content
Get content of the page through url.
auto_py_torrent/auto_py_torrent.py
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): """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...
[ "Get", "content", "of", "the", "page", "through", "url", "." ]
ocslegna/auto_py_torrent
python
https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L566-L576
[ "def", "get_content", "(", "self", ")", ":", "url", "=", "self", ".", "build_url", "(", ")", "try", ":", "self", ".", "content_page", "=", "requests", ".", "get", "(", "url", ")", "if", "not", "(", "self", ".", "content_page", ".", "status_code", "==...
32761fe18b3112e6e3754da863488b50929fcc41
train
ChunkedInputBuffer._recycle
Reclaim buffer space before the origin. Note: modifies buffer size
neobolt/impl/python/bolt/io.py
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): """ 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._...
[ "Reclaim", "buffer", "space", "before", "the", "origin", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/bolt/io.py#L180-L193
[ "def", "_recycle", "(", "self", ")", ":", "origin", "=", "self", ".", "_origin", "if", "origin", "==", "0", ":", "return", "False", "available", "=", "self", ".", "_extent", "-", "origin", "self", ".", "_data", "[", ":", "available", "]", "=", "self"...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
ChunkedInputBuffer.frame_message
Construct a frame around the first complete message in the buffer.
neobolt/impl/python/bolt/io.py
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): """ 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 = ...
[ "Construct", "a", "frame", "around", "the", "first", "complete", "message", "in", "the", "buffer", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/bolt/io.py#L198-L219
[ "def", "frame_message", "(", "self", ")", ":", "if", "self", ".", "_frame", "is", "not", "None", ":", "self", ".", "discard_message", "(", ")", "panes", "=", "[", "]", "p", "=", "origin", "=", "self", ".", "_origin", "extent", "=", "self", ".", "_e...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RateLimiter.call
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. ...
prawcore/rate_limit.py
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): """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...
[ "Rate", "limit", "the", "call", "to", "request_function", "." ]
praw-dev/prawcore
python
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/rate_limit.py#L22-L38
[ "def", "call", "(", "self", ",", "request_function", ",", "set_header_callback", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "delay", "(", ")", "kwargs", "[", "\"headers\"", "]", "=", "set_header_callback", "(", ")", "response", "="...
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
train
RateLimiter.delay
Sleep for an amount of time to remain under the rate limit.
prawcore/rate_limit.py
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): """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...
[ "Sleep", "for", "an", "amount", "of", "time", "to", "remain", "under", "the", "rate", "limit", "." ]
praw-dev/prawcore
python
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/rate_limit.py#L40-L51
[ "def", "delay", "(", "self", ")", ":", "if", "self", ".", "next_request_timestamp", "is", "None", ":", "return", "sleep_seconds", "=", "self", ".", "next_request_timestamp", "-", "time", ".", "time", "(", ")", "if", "sleep_seconds", "<=", "0", ":", "return...
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
train
RateLimiter.update
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...
prawcore/rate_limit.py
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): """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...
[ "Update", "the", "state", "of", "the", "rate", "limiter", "based", "on", "the", "response", "headers", "." ]
praw-dev/prawcore
python
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/rate_limit.py#L53-L89
[ "def", "update", "(", "self", ",", "response_headers", ")", ":", "if", "\"x-ratelimit-remaining\"", "not", "in", "response_headers", ":", "if", "self", ".", "remaining", "is", "not", "None", ":", "self", ".", "remaining", "-=", "1", "self", ".", "used", "+...
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
train
Resolver.custom_resolve
If a custom resolver is defined, perform custom resolution on the contained addresses. :return:
neobolt/impl/python/addressing.py
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 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...
[ "If", "a", "custom", "resolver", "is", "defined", "perform", "custom", "resolution", "on", "the", "contained", "addresses", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/addressing.py#L109-L121
[ "def", "custom_resolve", "(", "self", ")", ":", "if", "not", "callable", "(", "self", ".", "custom_resolver", ")", ":", "return", "new_addresses", "=", "[", "]", "for", "address", "in", "self", ".", "addresses", ":", "for", "new_address", "in", "self", "...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
Resolver.dns_resolve
Perform DNS resolution on the contained addresses. :return:
neobolt/impl/python/addressing.py
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): """ 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: ...
[ "Perform", "DNS", "resolution", "on", "the", "contained", "addresses", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/addressing.py#L123-L141
[ "def", "dns_resolve", "(", "self", ")", ":", "new_addresses", "=", "[", "]", "for", "address", "in", "self", ".", "addresses", ":", "try", ":", "info", "=", "getaddrinfo", "(", "address", "[", "0", "]", ",", "address", "[", "1", "]", ",", "0", ",",...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
get_quality
Gets the quality of a network / cell. @param string cell A network / cell from iwlist scan. @return string The quality of the network.
iw_parse.py
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): """ 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]...
[ "Gets", "the", "quality", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
cuzzo/iw_parse
python
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L29-L43
[ "def", "get_quality", "(", "cell", ")", ":", "quality", "=", "matching_line", "(", "cell", ",", "\"Quality=\"", ")", "if", "quality", "is", "None", ":", "return", "\"\"", "quality", "=", "quality", ".", "split", "(", ")", "[", "0", "]", ".", "split", ...
84c287dc6cfceb04ccbc0a8995f8a87323356ee5
train
get_signal_level
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.
iw_parse.py
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): """ 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...
[ "Gets", "the", "signal", "level", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
cuzzo/iw_parse
python
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L45-L63
[ "def", "get_signal_level", "(", "cell", ")", ":", "signal", "=", "matching_line", "(", "cell", ",", "\"Signal level=\"", ")", "if", "signal", "is", "None", ":", "return", "\"\"", "signal", "=", "signal", ".", "split", "(", "\"=\"", ")", "[", "1", "]", ...
84c287dc6cfceb04ccbc0a8995f8a87323356ee5
train
get_noise_level
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.
iw_parse.py
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): """ 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...
[ "Gets", "the", "noise", "level", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
cuzzo/iw_parse
python
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L65-L78
[ "def", "get_noise_level", "(", "cell", ")", ":", "noise", "=", "matching_line", "(", "cell", ",", "\"Noise level=\"", ")", "if", "noise", "is", "None", ":", "return", "\"\"", "noise", "=", "noise", ".", "split", "(", "\"=\"", ")", "[", "1", "]", "retur...
84c287dc6cfceb04ccbc0a8995f8a87323356ee5
train
get_channel
Gets the channel of a network / cell. @param string cell A network / cell from iwlist scan. @return string The channel of the network.
iw_parse.py
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): """ 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,...
[ "Gets", "the", "channel", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
cuzzo/iw_parse
python
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L80-L94
[ "def", "get_channel", "(", "cell", ")", ":", "channel", "=", "matching_line", "(", "cell", ",", "\"Channel:\"", ")", "if", "channel", ":", "return", "channel", "frequency", "=", "matching_line", "(", "cell", ",", "\"Frequency:\"", ")", "channel", "=", "re", ...
84c287dc6cfceb04ccbc0a8995f8a87323356ee5
train
get_encryption
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.
iw_parse.py
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): """ 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 ...
[ "Gets", "the", "encryption", "type", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
cuzzo/iw_parse
python
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L110-L152
[ "def", "get_encryption", "(", "cell", ",", "emit_version", "=", "False", ")", ":", "enc", "=", "\"\"", "if", "matching_line", "(", "cell", ",", "\"Encryption key:\"", ")", "==", "\"off\"", ":", "enc", "=", "\"Open\"", "else", ":", "for", "line", "in", "c...
84c287dc6cfceb04ccbc0a8995f8a87323356ee5
train
matching_line
Returns the first matching line in a list of lines. @see match()
iw_parse.py
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): """ 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
[ "Returns", "the", "first", "matching", "line", "in", "a", "list", "of", "lines", "." ]
cuzzo/iw_parse
python
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L202-L210
[ "def", "matching_line", "(", "lines", ",", "keyword", ")", ":", "for", "line", "in", "lines", ":", "matching", "=", "match", "(", "line", ",", "keyword", ")", "if", "matching", "!=", "None", ":", "return", "matching", "return", "None" ]
84c287dc6cfceb04ccbc0a8995f8a87323356ee5
train
match
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
iw_parse.py
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): """ 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: ...
[ "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", "...
cuzzo/iw_parse
python
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L212-L225
[ "def", "match", "(", "line", ",", "keyword", ")", ":", "line", "=", "line", ".", "lstrip", "(", ")", "length", "=", "len", "(", "keyword", ")", "if", "line", "[", ":", "length", "]", "==", "keyword", ":", "return", "line", "[", "length", ":", "]"...
84c287dc6cfceb04ccbc0a8995f8a87323356ee5
train
parse_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.
iw_parse.py
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): """ 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...
[ "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...
cuzzo/iw_parse
python
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L227-L241
[ "def", "parse_cell", "(", "cell", ",", "rules", ")", ":", "parsed_cell", "=", "{", "}", "for", "key", "in", "rules", ":", "rule", "=", "rules", "[", "key", "]", "parsed_cell", ".", "update", "(", "{", "key", ":", "rule", "(", "cell", ")", "}", ")...
84c287dc6cfceb04ccbc0a8995f8a87323356ee5
train
get_parsed_cells
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.
iw_parse.py
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): """ 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...
[ "Parses", "iwlist", "output", "into", "a", "list", "of", "networks", ".", "@param", "list", "iw_data", "Output", "from", "iwlist", "scan", ".", "A", "list", "of", "strings", "." ]
cuzzo/iw_parse
python
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L269-L311
[ "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...
84c287dc6cfceb04ccbc0a8995f8a87323356ee5
train
Session.request
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 ...
prawcore/sessions.py
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 ): """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 ``...
[ "Return", "the", "json", "content", "from", "the", "resource", "at", "path", "." ]
praw-dev/prawcore
python
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/sessions.py#L226-L260
[ "def", "request", "(", "self", ",", "method", ",", "path", ",", "data", "=", "None", ",", "files", "=", "None", ",", "json", "=", "None", ",", "params", "=", "None", ")", ":", "params", "=", "deepcopy", "(", "params", ")", "or", "{", "}", "params...
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
train
main
Provide the program's entry point when directly executed.
examples/script_auth_friend_list.py
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(): """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...
[ "Provide", "the", "program", "s", "entry", "point", "when", "directly", "executed", "." ]
praw-dev/prawcore
python
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/script_auth_friend_list.py#L15-L35
[ "def", "main", "(", ")", ":", "authenticator", "=", "prawcore", ".", "TrustedAuthenticator", "(", "prawcore", ".", "Requestor", "(", "\"prawcore_script_auth_example\"", ")", ",", "os", ".", "environ", "[", "\"PRAWCORE_CLIENT_ID\"", "]", ",", "os", ".", "environ"...
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
train
main
Provide the program's entry point when directly executed.
examples/caching_requestor.py
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(): """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...
[ "Provide", "the", "program", "s", "entry", "point", "when", "directly", "executed", "." ]
praw-dev/prawcore
python
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/caching_requestor.py#L39-L83
[ "def", "main", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", "!=", "2", ":", "print", "(", "\"Usage: {} USERNAME\"", ".", "format", "(", "sys", ".", "argv", "[", "0", "]", ")", ")", "return", "1", "caching_requestor", "=", "prawcore", "...
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
train
CachingSession.request
Perform a request, or return a cached response if available.
examples/caching_requestor.py
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): """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...
[ "Perform", "a", "request", "or", "return", "a", "cached", "response", "if", "available", "." ]
praw-dev/prawcore
python
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/caching_requestor.py#L25-L36
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "params", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params_key", "=", "tuple", "(", "params", ".", "items", "(", ")", ")", "if", "params", "else", "(", ")", "if", "method", "."...
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
train
RoutingTable.parse_routing_info
Parse the records returned from a getServers call and return a new RoutingTable instance.
neobolt/impl/python/routing.py
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): """ 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...
[ "Parse", "the", "records", "returned", "from", "a", "getServers", "call", "and", "return", "a", "new", "RoutingTable", "instance", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L97-L124
[ "def", "parse_routing_info", "(", "cls", ",", "records", ")", ":", "if", "len", "(", "records", ")", "!=", "1", ":", "raise", "RoutingProtocolError", "(", "\"Expected exactly one record\"", ")", "record", "=", "records", "[", "0", "]", "routers", "=", "[", ...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingTable.is_fresh
Indicator for whether routing information is still usable.
neobolt/impl/python/routing.py
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): """ 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 =...
[ "Indicator", "for", "whether", "routing", "information", "is", "still", "usable", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L142-L151
[ "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...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingTable.update
Update the current routing table with new routing information from a replacement table.
neobolt/impl/python/routing.py
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): """ 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...
[ "Update", "the", "current", "routing", "table", "with", "new", "routing", "information", "from", "a", "replacement", "table", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L153-L162
[ "def", "update", "(", "self", ",", "new_routing_table", ")", ":", "self", ".", "routers", ".", "replace", "(", "new_routing_table", ".", "routers", ")", "self", ".", "readers", ".", "replace", "(", "new_routing_table", ".", "readers", ")", "self", ".", "wr...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingConnectionPool.fetch_routing_info
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...
neobolt/impl/python/routing.py
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): """ 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...
[ "Fetch", "raw", "routing", "info", "from", "a", "given", "router", "address", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L222-L260
[ "def", "fetch_routing_info", "(", "self", ",", "address", ")", ":", "metadata", "=", "{", "}", "records", "=", "[", "]", "def", "fail", "(", "md", ")", ":", "if", "md", ".", "get", "(", "\"code\"", ")", "==", "\"Neo.ClientError.Procedure.ProcedureNotFound\...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingConnectionPool.fetch_routing_table
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...
neobolt/impl/python/routing.py
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): """ 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...
[ "Fetch", "a", "routing", "table", "from", "a", "given", "router", "address", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L262-L295
[ "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...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingConnectionPool.update_routing_table_from
Try to update routing tables with the given routers. :return: True if the routing table is successfully updated, otherwise False
neobolt/impl/python/routing.py
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): """ 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 ...
[ "Try", "to", "update", "routing", "tables", "with", "the", "given", "routers", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L297-L307
[ "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"...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingConnectionPool.update_routing_table
Update the routing table from the first router able to provide valid routing information.
neobolt/impl/python/routing.py
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): """ 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...
[ "Update", "the", "routing", "table", "from", "the", "first", "router", "able", "to", "provide", "valid", "routing", "information", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L309-L330
[ "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", ":", ...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingConnectionPool.ensure_routing_table_is_fresh
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...
neobolt/impl/python/routing.py
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): """ 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 ...
[ "Update", "the", "routing", "table", "if", "stale", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L338-L361
[ "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...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingConnectionPool.deactivate
Deactivate an address from the connection pool, if present, remove from the routing table and also closing all idle connections to that address.
neobolt/impl/python/routing.py
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): """ 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...
[ "Deactivate", "an", "address", "from", "the", "connection", "pool", "if", "present", "remove", "from", "the", "routing", "table", "and", "also", "closing", "all", "idle", "connections", "to", "that", "address", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L389-L401
[ "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", ...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingConnectionPool.remove_writer
Remove a writer address from the routing table, if present.
neobolt/impl/python/routing.py
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): """ 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)
[ "Remove", "a", "writer", "address", "from", "the", "routing", "table", "if", "present", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L403-L408
[ "def", "remove_writer", "(", "self", ",", "address", ")", ":", "log_debug", "(", "\"[#0000] C: <ROUTING> Removing writer %r\"", ",", "address", ")", "self", ".", "routing_table", ".", "writers", ".", "discard", "(", "address", ")", "log_debug", "(", "\"[#0000] C...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
RoutingConnectionPool.handle
Handle any cleanup or similar activity related to an error occurring on a pooled connection.
neobolt/impl/python/routing.py
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): """ 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...
[ "Handle", "any", "cleanup", "or", "similar", "activity", "related", "to", "an", "error", "occurring", "on", "a", "pooled", "connection", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L410-L418
[ "def", "handle", "(", "self", ",", "error", ",", "connection", ")", ":", "error_class", "=", "error", ".", "__class__", "if", "error_class", "in", "(", "ConnectionExpired", ",", "ServiceUnavailable", ",", "DatabaseUnavailableError", ")", ":", "self", ".", "dea...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
point_type
Dynamically create a Point subclass.
neobolt/types/spatial.py
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): """ 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): ...
[ "Dynamically", "create", "a", "Point", "subclass", "." ]
neo4j-drivers/neobolt
python
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/types/spatial.py#L72-L101
[ "def", "point_type", "(", "name", ",", "fields", ",", "srid_map", ")", ":", "def", "srid", "(", "self", ")", ":", "try", ":", "return", "srid_map", "[", "len", "(", "self", ")", "]", "except", "KeyError", ":", "return", "None", "attributes", "=", "{"...
724569d76e85777c4f5e30e8d0a18116bda4d8cd
train
main
Provide the program's entry point when directly executed.
examples/read_only_auth_trophies.py
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(): """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...
[ "Provide", "the", "program", "s", "entry", "point", "when", "directly", "executed", "." ]
praw-dev/prawcore
python
https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/read_only_auth_trophies.py#L14-L39
[ "def", "main", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", "!=", "2", ":", "print", "(", "\"Usage: {} USERNAME\"", ".", "format", "(", "sys", ".", "argv", "[", "0", "]", ")", ")", "return", "1", "authenticator", "=", "prawcore", ".", ...
b16ae88a1f2bf98095ed6fe64851cb7add7ed752
train
main
Read a directory containing json files for Kibana panels, beautify them and replace size value in aggregations as specified through corresponding params params.
src/migration/to_kibana5.py
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(): """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...
[ "Read", "a", "directory", "containing", "json", "files", "for", "Kibana", "panels", "beautify", "them", "and", "replace", "size", "value", "in", "aggregations", "as", "specified", "through", "corresponding", "params", "params", "." ]
chaoss/grimoirelab-sigils
python
https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/to_kibana5.py#L40-L84
[ "def", "main", "(", ")", ":", "args", "=", "parse_args", "(", ")", "configure_logging", "(", "args", ".", "debug", ")", "src_path", "=", "args", ".", "src_path", "dest_path", "=", "args", ".", "dest_path", "old_str1", "=", "'\\\\\"size\\\\\":'", "+", "args...
33d395195acb316287143a535a2c6e4009bf0528
train
parse_args
Parse arguments from the command line
src/migration/to_kibana5.py
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(): """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...
[ "Parse", "arguments", "from", "the", "command", "line" ]
chaoss/grimoirelab-sigils
python
https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/to_kibana5.py#L86-L104
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "TO_KIBANA5_DESC_MSG", ")", "parser", ".", "add_argument", "(", "'-s'", ",", "'--source'", ",", "dest", "=", "'src_path'", ",", "required", "=", "T...
33d395195acb316287143a535a2c6e4009bf0528
train
configure_logging
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
src/migration/to_kibana5.py
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): """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,...
[ "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",...
chaoss/grimoirelab-sigils
python
https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/to_kibana5.py#L107-L119
[ "def", "configure_logging", "(", "debug", "=", "False", ")", ":", "if", "not", "debug", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ",", "format", "=", "LOG_FORMAT", ")", "else", ":", "logging", ".", "basicConfig", "(",...
33d395195acb316287143a535a2c6e4009bf0528
train
signal_handler
Quit signal handler.
memtop/__init__.py
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): """Quit signal handler.""" sys.stdout.flush() print("\nSIGINT in frame signal received. Quitting...") sys.stdout.flush() sys.exit(0)
[ "Quit", "signal", "handler", "." ]
MartinThoma/memtop
python
https://github.com/MartinThoma/memtop/blob/504d251f1951922db84883c2e660ba7e754d1546/memtop/__init__.py#L68-L73
[ "def", "signal_handler", "(", "signal_name", ",", "frame", ")", ":", "sys", ".", "stdout", ".", "flush", "(", ")", "print", "(", "\"\\nSIGINT in frame signal received. Quitting...\"", ")", "sys", ".", "stdout", ".", "flush", "(", ")", "sys", ".", "exit", "("...
504d251f1951922db84883c2e660ba7e754d1546
train
graph_format
Show changes graphically in memory consumption
memtop/__init__.py
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): """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...
[ "Show", "changes", "graphically", "in", "memory", "consumption" ]
MartinThoma/memtop
python
https://github.com/MartinThoma/memtop/blob/504d251f1951922db84883c2e660ba7e754d1546/memtop/__init__.py#L93-L115
[ "def", "graph_format", "(", "new_mem", ",", "old_mem", ",", "is_firstiteration", "=", "True", ")", ":", "if", "is_firstiteration", ":", "output", "=", "\" n/a \"", "elif", "new_mem", "-", "old_mem", ">", "50000000", ":", "output", "=", "\" +++++\"", "elif...
504d251f1951922db84883c2e660ba7e754d1546
train
get_cur_mem_use
return utilization of memory
memtop/__init__.py
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(): """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...
[ "return", "utilization", "of", "memory" ]
MartinThoma/memtop
python
https://github.com/MartinThoma/memtop/blob/504d251f1951922db84883c2e660ba7e754d1546/memtop/__init__.py#L118-L144
[ "def", "get_cur_mem_use", "(", ")", ":", "# http://lwn.net/Articles/28345/", "lines", "=", "open", "(", "\"/proc/meminfo\"", ",", "'r'", ")", ".", "readlines", "(", ")", "emptySpace", "=", "re", ".", "compile", "(", "'[ ]+'", ")", "for", "line", "in", "lines...
504d251f1951922db84883c2e660ba7e754d1546
train
check_py_version
Check if a propper Python version is used.
memtop/__init__.py
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(): """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 " ...
[ "Check", "if", "a", "propper", "Python", "version", "is", "used", "." ]
MartinThoma/memtop
python
https://github.com/MartinThoma/memtop/blob/504d251f1951922db84883c2e660ba7e754d1546/memtop/__init__.py#L229-L244
[ "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\"", ")...
504d251f1951922db84883c2e660ba7e754d1546
train
character
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/__init__.py
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): """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...
[ "Prompt", "a", "single", "character", "." ]
sfischer13/python-prompt
python
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L46-L69
[ "def", "character", "(", "prompt", "=", "None", ",", "empty", "=", "False", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "elif", "len", "(", "s", ")", "==", "1", ":", "return", ...
d2acf5db64a9e45247c7abf1d67c2eb7db87bb48
train
email
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/__init__.py
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"): """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 ...
[ "Prompt", "an", "email", "address", "." ]
sfischer13/python-prompt
python
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L72-L105
[ "def", "email", "(", "prompt", "=", "None", ",", "empty", "=", "False", ",", "mode", "=", "\"simple\"", ")", ":", "if", "mode", "==", "\"simple\"", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", ...
d2acf5db64a9e45247c7abf1d67c2eb7db87bb48
train
integer
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/__init__.py
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): """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...
[ "Prompt", "an", "integer", "." ]
sfischer13/python-prompt
python
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L108-L132
[ "def", "integer", "(", "prompt", "=", "None", ",", "empty", "=", "False", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "else", ":", "try", ":", "return", "int", "(", "s", ")", "...
d2acf5db64a9e45247c7abf1d67c2eb7db87bb48
train
real
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/__init__.py
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): """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. ...
[ "Prompt", "a", "real", "number", "." ]
sfischer13/python-prompt
python
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L135-L159
[ "def", "real", "(", "prompt", "=", "None", ",", "empty", "=", "False", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "else", ":", "try", ":", "return", "float", "(", "s", ")", "e...
d2acf5db64a9e45247c7abf1d67c2eb7db87bb48
train
regex
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/__init__.py
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): """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...
[ "Prompt", "a", "string", "that", "matches", "a", "regular", "expression", "." ]
sfischer13/python-prompt
python
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L162-L195
[ "def", "regex", "(", "pattern", ",", "prompt", "=", "None", ",", "empty", "=", "False", ",", "flags", "=", "0", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "else", ":", "m", "=...
d2acf5db64a9e45247c7abf1d67c2eb7db87bb48
train
secret
Prompt a string without echoing. 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 non-empty string. None if the user pressed only E...
prompt/__init__.py
def secret(prompt=None, empty=False): """Prompt a string without echoing. 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 non-empty st...
def secret(prompt=None, empty=False): """Prompt a string without echoing. 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 non-empty st...
[ "Prompt", "a", "string", "without", "echoing", "." ]
sfischer13/python-prompt
python
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L198-L233
[ "def", "secret", "(", "prompt", "=", "None", ",", "empty", "=", "False", ")", ":", "if", "prompt", "is", "None", ":", "prompt", "=", "PROMPT", "s", "=", "getpass", ".", "getpass", "(", "prompt", "=", "prompt", ")", "if", "empty", "and", "not", "s",...
d2acf5db64a9e45247c7abf1d67c2eb7db87bb48
train
string
Prompt a string. 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 non-empty string. None if the user pressed only Enter and ``empty...
prompt/__init__.py
def string(prompt=None, empty=False): """Prompt a string. 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 non-empty string. No...
def string(prompt=None, empty=False): """Prompt a string. 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 non-empty string. No...
[ "Prompt", "a", "string", "." ]
sfischer13/python-prompt
python
https://github.com/sfischer13/python-prompt/blob/d2acf5db64a9e45247c7abf1d67c2eb7db87bb48/prompt/__init__.py#L236-L260
[ "def", "string", "(", "prompt", "=", "None", ",", "empty", "=", "False", ")", ":", "s", "=", "_prompt_input", "(", "prompt", ")", "if", "empty", "and", "not", "s", ":", "return", "None", "else", ":", "if", "s", ":", "return", "s", "else", ":", "r...
d2acf5db64a9e45247c7abf1d67c2eb7db87bb48
train
CachingQuery._get_cache_plus_key
Return a cache region plus key.
flask_sqlalchemy_cache/core.py
def _get_cache_plus_key(self): """Return a cache region plus key.""" key = getattr(self, '_cache_key', self.key_from_query()) return self._cache.cache, key
def _get_cache_plus_key(self): """Return a cache region plus key.""" key = getattr(self, '_cache_key', self.key_from_query()) return self._cache.cache, key
[ "Return", "a", "cache", "region", "plus", "key", "." ]
iurisilvio/Flask-SQLAlchemy-Cache
python
https://github.com/iurisilvio/Flask-SQLAlchemy-Cache/blob/d29023c8fc09fd5a6a0ae24d18eee2de88215ab0/flask_sqlalchemy_cache/core.py#L52-L55
[ "def", "_get_cache_plus_key", "(", "self", ")", ":", "key", "=", "getattr", "(", "self", ",", "'_cache_key'", ",", "self", ".", "key_from_query", "(", ")", ")", "return", "self", ".", "_cache", ".", "cache", ",", "key" ]
d29023c8fc09fd5a6a0ae24d18eee2de88215ab0
train
CachingQuery.get_value
Return the value from the cache for this query.
flask_sqlalchemy_cache/core.py
def get_value(self, merge=True, createfunc=None, expiration_time=None, ignore_expiration=False): """ Return the value from the cache for this query. """ cache, cache_key = self._get_cache_plus_key() # ignore_expiration means, if the value is in the cache ...
def get_value(self, merge=True, createfunc=None, expiration_time=None, ignore_expiration=False): """ Return the value from the cache for this query. """ cache, cache_key = self._get_cache_plus_key() # ignore_expiration means, if the value is in the cache ...
[ "Return", "the", "value", "from", "the", "cache", "for", "this", "query", "." ]
iurisilvio/Flask-SQLAlchemy-Cache
python
https://github.com/iurisilvio/Flask-SQLAlchemy-Cache/blob/d29023c8fc09fd5a6a0ae24d18eee2de88215ab0/flask_sqlalchemy_cache/core.py#L62-L89
[ "def", "get_value", "(", "self", ",", "merge", "=", "True", ",", "createfunc", "=", "None", ",", "expiration_time", "=", "None", ",", "ignore_expiration", "=", "False", ")", ":", "cache", ",", "cache_key", "=", "self", ".", "_get_cache_plus_key", "(", ")",...
d29023c8fc09fd5a6a0ae24d18eee2de88215ab0
train
CachingQuery.set_value
Set the value in the cache for this query.
flask_sqlalchemy_cache/core.py
def set_value(self, value): """Set the value in the cache for this query.""" cache, cache_key = self._get_cache_plus_key() cache.set(cache_key, value)
def set_value(self, value): """Set the value in the cache for this query.""" cache, cache_key = self._get_cache_plus_key() cache.set(cache_key, value)
[ "Set", "the", "value", "in", "the", "cache", "for", "this", "query", "." ]
iurisilvio/Flask-SQLAlchemy-Cache
python
https://github.com/iurisilvio/Flask-SQLAlchemy-Cache/blob/d29023c8fc09fd5a6a0ae24d18eee2de88215ab0/flask_sqlalchemy_cache/core.py#L91-L94
[ "def", "set_value", "(", "self", ",", "value", ")", ":", "cache", ",", "cache_key", "=", "self", ".", "_get_cache_plus_key", "(", ")", "cache", ".", "set", "(", "cache_key", ",", "value", ")" ]
d29023c8fc09fd5a6a0ae24d18eee2de88215ab0
train
CachingQuery.key_from_query
Given a Query, create a cache key. There are many approaches to this; here we use the simplest, which is to create an md5 hash of the text of the SQL statement, combined with stringified versions of all the bound parameters within it. There's a bit of a performance hit with compiling o...
flask_sqlalchemy_cache/core.py
def key_from_query(self, qualifier=None): """ Given a Query, create a cache key. There are many approaches to this; here we use the simplest, which is to create an md5 hash of the text of the SQL statement, combined with stringified versions of all the bound parameters within it...
def key_from_query(self, qualifier=None): """ Given a Query, create a cache key. There are many approaches to this; here we use the simplest, which is to create an md5 hash of the text of the SQL statement, combined with stringified versions of all the bound parameters within it...
[ "Given", "a", "Query", "create", "a", "cache", "key", "." ]
iurisilvio/Flask-SQLAlchemy-Cache
python
https://github.com/iurisilvio/Flask-SQLAlchemy-Cache/blob/d29023c8fc09fd5a6a0ae24d18eee2de88215ab0/flask_sqlalchemy_cache/core.py#L96-L116
[ "def", "key_from_query", "(", "self", ",", "qualifier", "=", "None", ")", ":", "stmt", "=", "self", ".", "with_labels", "(", ")", ".", "statement", "compiled", "=", "stmt", ".", "compile", "(", ")", "params", "=", "compiled", ".", "params", "values", "...
d29023c8fc09fd5a6a0ae24d18eee2de88215ab0
train
RelationshipCache.process_query_conditionally
Process a Query that is used within a lazy loader. (the process_query_conditionally() method is a SQLAlchemy hook invoked only within lazyload.)
flask_sqlalchemy_cache/core.py
def process_query_conditionally(self, query): """ Process a Query that is used within a lazy loader. (the process_query_conditionally() method is a SQLAlchemy hook invoked only within lazyload.) """ if query._current_path: mapper, prop = query._current_path[-...
def process_query_conditionally(self, query): """ Process a Query that is used within a lazy loader. (the process_query_conditionally() method is a SQLAlchemy hook invoked only within lazyload.) """ if query._current_path: mapper, prop = query._current_path[-...
[ "Process", "a", "Query", "that", "is", "used", "within", "a", "lazy", "loader", "." ]
iurisilvio/Flask-SQLAlchemy-Cache
python
https://github.com/iurisilvio/Flask-SQLAlchemy-Cache/blob/d29023c8fc09fd5a6a0ae24d18eee2de88215ab0/flask_sqlalchemy_cache/core.py#L179-L193
[ "def", "process_query_conditionally", "(", "self", ",", "query", ")", ":", "if", "query", ".", "_current_path", ":", "mapper", ",", "prop", "=", "query", ".", "_current_path", "[", "-", "2", ":", "]", "for", "cls", "in", "mapper", ".", "class_", ".", "...
d29023c8fc09fd5a6a0ae24d18eee2de88215ab0
train
Smoother.fit
Fit the smoother Parameters ---------- t : array_like time locations of the points to smooth y : array_like y locations of the points to smooth dy : array_like or float (default = 1) Errors in the y values presorted : bool (default = F...
supersmoother/smoother.py
def fit(self, t, y, dy=1, presorted=False): """Fit the smoother Parameters ---------- t : array_like time locations of the points to smooth y : array_like y locations of the points to smooth dy : array_like or float (default = 1) Error...
def fit(self, t, y, dy=1, presorted=False): """Fit the smoother Parameters ---------- t : array_like time locations of the points to smooth y : array_like y locations of the points to smooth dy : array_like or float (default = 1) Error...
[ "Fit", "the", "smoother" ]
jakevdp/supersmoother
python
https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/smoother.py#L13-L33
[ "def", "fit", "(", "self", ",", "t", ",", "y", ",", "dy", "=", "1", ",", "presorted", "=", "False", ")", ":", "self", ".", "t", ",", "self", ".", "y", ",", "self", ".", "dy", "=", "self", ".", "_validate_inputs", "(", "t", ",", "y", ",", "d...
0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f
train
Smoother.predict
Predict the smoothed function value at time t Parameters ---------- t : array_like Times at which to predict the result Returns ------- y : ndarray Smoothed values at time t
supersmoother/smoother.py
def predict(self, t): """Predict the smoothed function value at time t Parameters ---------- t : array_like Times at which to predict the result Returns ------- y : ndarray Smoothed values at time t """ t = np.asarray(t) ...
def predict(self, t): """Predict the smoothed function value at time t Parameters ---------- t : array_like Times at which to predict the result Returns ------- y : ndarray Smoothed values at time t """ t = np.asarray(t) ...
[ "Predict", "the", "smoothed", "function", "value", "at", "time", "t" ]
jakevdp/supersmoother
python
https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/smoother.py#L35-L49
[ "def", "predict", "(", "self", ",", "t", ")", ":", "t", "=", "np", ".", "asarray", "(", "t", ")", "return", "self", ".", "_predict", "(", "np", ".", "ravel", "(", "t", ")", ")", ".", "reshape", "(", "t", ".", "shape", ")" ]
0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f
train
Smoother.cv_residuals
Return the residuals of the cross-validation for the fit data
supersmoother/smoother.py
def cv_residuals(self, cv=True): """Return the residuals of the cross-validation for the fit data""" vals = self.cv_values(cv) return (self.y - vals) / self.dy
def cv_residuals(self, cv=True): """Return the residuals of the cross-validation for the fit data""" vals = self.cv_values(cv) return (self.y - vals) / self.dy
[ "Return", "the", "residuals", "of", "the", "cross", "-", "validation", "for", "the", "fit", "data" ]
jakevdp/supersmoother
python
https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/smoother.py#L55-L58
[ "def", "cv_residuals", "(", "self", ",", "cv", "=", "True", ")", ":", "vals", "=", "self", ".", "cv_values", "(", "cv", ")", "return", "(", "self", ".", "y", "-", "vals", ")", "/", "self", ".", "dy" ]
0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f
train
Smoother.cv_error
Return the sum of cross-validation residuals for the input data
supersmoother/smoother.py
def cv_error(self, cv=True, skip_endpoints=True): """Return the sum of cross-validation residuals for the input data""" resids = self.cv_residuals(cv) if skip_endpoints: resids = resids[1:-1] return np.mean(abs(resids))
def cv_error(self, cv=True, skip_endpoints=True): """Return the sum of cross-validation residuals for the input data""" resids = self.cv_residuals(cv) if skip_endpoints: resids = resids[1:-1] return np.mean(abs(resids))
[ "Return", "the", "sum", "of", "cross", "-", "validation", "residuals", "for", "the", "input", "data" ]
jakevdp/supersmoother
python
https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/smoother.py#L60-L65
[ "def", "cv_error", "(", "self", ",", "cv", "=", "True", ",", "skip_endpoints", "=", "True", ")", ":", "resids", "=", "self", ".", "cv_residuals", "(", "cv", ")", "if", "skip_endpoints", ":", "resids", "=", "resids", "[", "1", ":", "-", "1", "]", "r...
0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f
train
arcfour
Return a generator for the ARCFOUR/RC4 pseudorandom keystream for the key provided. Keys should be byte strings or sequences of ints.
audiogen/noise.py
def arcfour(key, csbN=1): '''Return a generator for the ARCFOUR/RC4 pseudorandom keystream for the key provided. Keys should be byte strings or sequences of ints.''' if isinstance(key, str): key = [ord(c) for c in key] s = range(256) j = 0 for n in range(csbN): for i in range(256): j = (j + s[i] + key[...
def arcfour(key, csbN=1): '''Return a generator for the ARCFOUR/RC4 pseudorandom keystream for the key provided. Keys should be byte strings or sequences of ints.''' if isinstance(key, str): key = [ord(c) for c in key] s = range(256) j = 0 for n in range(csbN): for i in range(256): j = (j + s[i] + key[...
[ "Return", "a", "generator", "for", "the", "ARCFOUR", "/", "RC4", "pseudorandom", "keystream", "for", "the", "key", "provided", ".", "Keys", "should", "be", "byte", "strings", "or", "sequences", "of", "ints", "." ]
casebeer/audiogen
python
https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/noise.py#L5-L26
[ "def", "arcfour", "(", "key", ",", "csbN", "=", "1", ")", ":", "if", "isinstance", "(", "key", ",", "str", ")", ":", "key", "=", "[", "ord", "(", "c", ")", "for", "c", "in", "key", "]", "s", "=", "range", "(", "256", ")", "j", "=", "0", "...
184dee2ca32c2bb4315a0f18e62288728fcd7881
train
arcfour_drop
Return a generator for the RC4-drop pseudorandom keystream given by the key and number of bytes to drop passed as arguments. Dropped bytes default to the more conservative 3072, NOT the SCAN default of 768.
audiogen/noise.py
def arcfour_drop(key, n=3072): '''Return a generator for the RC4-drop pseudorandom keystream given by the key and number of bytes to drop passed as arguments. Dropped bytes default to the more conservative 3072, NOT the SCAN default of 768.''' af = arcfour(key) [af.next() for c in range(n)] return af
def arcfour_drop(key, n=3072): '''Return a generator for the RC4-drop pseudorandom keystream given by the key and number of bytes to drop passed as arguments. Dropped bytes default to the more conservative 3072, NOT the SCAN default of 768.''' af = arcfour(key) [af.next() for c in range(n)] return af
[ "Return", "a", "generator", "for", "the", "RC4", "-", "drop", "pseudorandom", "keystream", "given", "by", "the", "key", "and", "number", "of", "bytes", "to", "drop", "passed", "as", "arguments", ".", "Dropped", "bytes", "default", "to", "the", "more", "con...
casebeer/audiogen
python
https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/noise.py#L28-L34
[ "def", "arcfour_drop", "(", "key", ",", "n", "=", "3072", ")", ":", "af", "=", "arcfour", "(", "key", ")", "[", "af", ".", "next", "(", ")", "for", "c", "in", "range", "(", "n", ")", "]", "return", "af" ]
184dee2ca32c2bb4315a0f18e62288728fcd7881
train
resolve_ssl_protocol_version
Look up an SSL protocol version by name. If *version* is not specified, then the strongest protocol available will be returned. :param str version: The name of the version to look up. :return: A protocol constant from the :py:mod:`ssl` module. :rtype: int
advancedhttpserver.py
def resolve_ssl_protocol_version(version=None): """ Look up an SSL protocol version by name. If *version* is not specified, then the strongest protocol available will be returned. :param str version: The name of the version to look up. :return: A protocol constant from the :py:mod:`ssl` module. :rtype: int """ ...
def resolve_ssl_protocol_version(version=None): """ Look up an SSL protocol version by name. If *version* is not specified, then the strongest protocol available will be returned. :param str version: The name of the version to look up. :return: A protocol constant from the :py:mod:`ssl` module. :rtype: int """ ...
[ "Look", "up", "an", "SSL", "protocol", "version", "by", "name", ".", "If", "*", "version", "*", "is", "not", "specified", "then", "the", "strongest", "protocol", "available", "will", "be", "returned", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L215-L234
[ "def", "resolve_ssl_protocol_version", "(", "version", "=", "None", ")", ":", "if", "version", "is", "None", ":", "protocol_preference", "=", "(", "'TLSv1_2'", ",", "'TLSv1_1'", ",", "'TLSv1'", ",", "'SSLv3'", ",", "'SSLv23'", ",", "'SSLv2'", ")", "for", "pr...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
build_server_from_argparser
Build a server from command line arguments. If a ServerClass or HandlerClass is specified, then the object must inherit from the corresponding AdvancedHTTPServer base class. :param str description: Description string to be passed to the argument parser. :param server_klass: Alternative server class to use. :type ...
advancedhttpserver.py
def build_server_from_argparser(description=None, server_klass=None, handler_klass=None): """ Build a server from command line arguments. If a ServerClass or HandlerClass is specified, then the object must inherit from the corresponding AdvancedHTTPServer base class. :param str description: Description string to ...
def build_server_from_argparser(description=None, server_klass=None, handler_klass=None): """ Build a server from command line arguments. If a ServerClass or HandlerClass is specified, then the object must inherit from the corresponding AdvancedHTTPServer base class. :param str description: Description string to ...
[ "Build", "a", "server", "from", "command", "line", "arguments", ".", "If", "a", "ServerClass", "or", "HandlerClass", "is", "specified", "then", "the", "object", "must", "inherit", "from", "the", "corresponding", "AdvancedHTTPServer", "base", "class", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L236-L321
[ "def", "build_server_from_argparser", "(", "description", "=", "None", ",", "server_klass", "=", "None", ",", "handler_klass", "=", "None", ")", ":", "import", "argparse", "def", "_argp_dir_type", "(", "arg", ")", ":", "if", "not", "os", ".", "path", ".", ...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
build_server_from_config
Build a server from a provided :py:class:`configparser.ConfigParser` instance. If a ServerClass or HandlerClass is specified, then the object must inherit from the corresponding AdvancedHTTPServer base class. :param config: Configuration to retrieve settings from. :type config: :py:class:`configparser.ConfigParse...
advancedhttpserver.py
def build_server_from_config(config, section_name, server_klass=None, handler_klass=None): """ Build a server from a provided :py:class:`configparser.ConfigParser` instance. If a ServerClass or HandlerClass is specified, then the object must inherit from the corresponding AdvancedHTTPServer base class. :param co...
def build_server_from_config(config, section_name, server_klass=None, handler_klass=None): """ Build a server from a provided :py:class:`configparser.ConfigParser` instance. If a ServerClass or HandlerClass is specified, then the object must inherit from the corresponding AdvancedHTTPServer base class. :param co...
[ "Build", "a", "server", "from", "a", "provided", ":", "py", ":", "class", ":", "configparser", ".", "ConfigParser", "instance", ".", "If", "a", "ServerClass", "or", "HandlerClass", "is", "specified", "then", "the", "object", "must", "inherit", "from", "the",...
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L323-L395
[ "def", "build_server_from_config", "(", "config", ",", "section_name", ",", "server_klass", "=", "None", ",", "handler_klass", "=", "None", ")", ":", "server_klass", "=", "(", "server_klass", "or", "AdvancedHTTPServer", ")", "handler_klass", "=", "(", "handler_kla...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RPCClient.set_serializer
Configure the serializer to use for communication with the server. The serializer specified must be valid and in the :py:data:`.g_serializer_drivers` map. :param str serializer_name: The name of the serializer to use. :param str compression: The name of a compression library to use.
advancedhttpserver.py
def set_serializer(self, serializer_name, compression=None): """ Configure the serializer to use for communication with the server. The serializer specified must be valid and in the :py:data:`.g_serializer_drivers` map. :param str serializer_name: The name of the serializer to use. :param str compression: ...
def set_serializer(self, serializer_name, compression=None): """ Configure the serializer to use for communication with the server. The serializer specified must be valid and in the :py:data:`.g_serializer_drivers` map. :param str serializer_name: The name of the serializer to use. :param str compression: ...
[ "Configure", "the", "serializer", "to", "use", "for", "communication", "with", "the", "server", ".", "The", "serializer", "specified", "must", "be", "valid", "and", "in", "the", ":", "py", ":", "data", ":", ".", "g_serializer_drivers", "map", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L548-L558
[ "def", "set_serializer", "(", "self", ",", "serializer_name", ",", "compression", "=", "None", ")", ":", "self", ".", "serializer", "=", "Serializer", "(", "serializer_name", ",", "charset", "=", "'UTF-8'", ",", "compression", "=", "compression", ")", "self", ...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RPCClient.reconnect
Reconnect to the remote server.
advancedhttpserver.py
def reconnect(self): """Reconnect to the remote server.""" self.lock.acquire() if self.use_ssl: self.client = http.client.HTTPSConnection(self.host, self.port, context=self.ssl_context) else: self.client = http.client.HTTPConnection(self.host, self.port) self.lock.release()
def reconnect(self): """Reconnect to the remote server.""" self.lock.acquire() if self.use_ssl: self.client = http.client.HTTPSConnection(self.host, self.port, context=self.ssl_context) else: self.client = http.client.HTTPConnection(self.host, self.port) self.lock.release()
[ "Reconnect", "to", "the", "remote", "server", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L571-L578
[ "def", "reconnect", "(", "self", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "if", "self", ".", "use_ssl", ":", "self", ".", "client", "=", "http", ".", "client", ".", "HTTPSConnection", "(", "self", ".", "host", ",", "self", ".", "por...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RPCClient.call
Issue a call to the remote end point to execute the specified procedure. :param str method: The name of the remote procedure to execute. :return: The return value from the remote function.
advancedhttpserver.py
def call(self, method, *args, **kwargs): """ Issue a call to the remote end point to execute the specified procedure. :param str method: The name of the remote procedure to execute. :return: The return value from the remote function. """ if kwargs: options = self.encode(dict(args=args, kwargs=kwargs))...
def call(self, method, *args, **kwargs): """ Issue a call to the remote end point to execute the specified procedure. :param str method: The name of the remote procedure to execute. :return: The return value from the remote function. """ if kwargs: options = self.encode(dict(args=args, kwargs=kwargs))...
[ "Issue", "a", "call", "to", "the", "remote", "end", "point", "to", "execute", "the", "specified", "procedure", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L580-L620
[ "def", "call", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "options", "=", "self", ".", "encode", "(", "dict", "(", "args", "=", "args", ",", "kwargs", "=", "kwargs", ")", ")", "else", "...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RPCClientCached.cache_call
Call a remote method and store the result locally. Subsequent calls to the same method with the same arguments will return the cached result without invoking the remote procedure. Cached results are kept indefinitely and must be manually refreshed with a call to :py:meth:`.cache_call_refresh`. :param str met...
advancedhttpserver.py
def cache_call(self, method, *options): """ Call a remote method and store the result locally. Subsequent calls to the same method with the same arguments will return the cached result without invoking the remote procedure. Cached results are kept indefinitely and must be manually refreshed with a call to :...
def cache_call(self, method, *options): """ Call a remote method and store the result locally. Subsequent calls to the same method with the same arguments will return the cached result without invoking the remote procedure. Cached results are kept indefinitely and must be manually refreshed with a call to :...
[ "Call", "a", "remote", "method", "and", "store", "the", "result", "locally", ".", "Subsequent", "calls", "to", "the", "same", "method", "with", "the", "same", "arguments", "will", "return", "the", "cached", "result", "without", "invoking", "the", "remote", "...
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L636-L665
[ "def", "cache_call", "(", "self", ",", "method", ",", "*", "options", ")", ":", "options_hash", "=", "self", ".", "encode", "(", "options", ")", "if", "len", "(", "options_hash", ")", ">", "20", ":", "options_hash", "=", "hashlib", ".", "new", "(", "...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RPCClientCached.cache_call_refresh
Call a remote method and update the local cache with the result if it already existed. :param str method: The name of the remote procedure to execute. :return: The return value from the remote function.
advancedhttpserver.py
def cache_call_refresh(self, method, *options): """ Call a remote method and update the local cache with the result if it already existed. :param str method: The name of the remote procedure to execute. :return: The return value from the remote function. """ options_hash = self.encode(options) if len(o...
def cache_call_refresh(self, method, *options): """ Call a remote method and update the local cache with the result if it already existed. :param str method: The name of the remote procedure to execute. :return: The return value from the remote function. """ options_hash = self.encode(options) if len(o...
[ "Call", "a", "remote", "method", "and", "update", "the", "local", "cache", "with", "the", "result", "if", "it", "already", "existed", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L667-L689
[ "def", "cache_call_refresh", "(", "self", ",", "method", ",", "*", "options", ")", ":", "options_hash", "=", "self", ".", "encode", "(", "options", ")", "if", "len", "(", "options_hash", ")", ">", "20", ":", "options_hash", "=", "hashlib", ".", "new", ...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RPCClientCached.cache_clear
Purge the local store of all cached function information.
advancedhttpserver.py
def cache_clear(self): """Purge the local store of all cached function information.""" with self.cache_lock: cursor = self.cache_db.cursor() cursor.execute('DELETE FROM cache') self.cache_db.commit() self.logger.info('the RPC cache has been purged') return
def cache_clear(self): """Purge the local store of all cached function information.""" with self.cache_lock: cursor = self.cache_db.cursor() cursor.execute('DELETE FROM cache') self.cache_db.commit() self.logger.info('the RPC cache has been purged') return
[ "Purge", "the", "local", "store", "of", "all", "cached", "function", "information", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L691-L698
[ "def", "cache_clear", "(", "self", ")", ":", "with", "self", ".", "cache_lock", ":", "cursor", "=", "self", ".", "cache_db", ".", "cursor", "(", ")", "cursor", ".", "execute", "(", "'DELETE FROM cache'", ")", "self", ".", "cache_db", ".", "commit", "(", ...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.respond_file
Respond to the client by serving a file, either directly or as an attachment. :param str file_path: The path to the file to serve, this does not need to be in the web root. :param bool attachment: Whether to serve the file as a download by setting the Content-Disposition header.
advancedhttpserver.py
def respond_file(self, file_path, attachment=False, query=None): """ Respond to the client by serving a file, either directly or as an attachment. :param str file_path: The path to the file to serve, this does not need to be in the web root. :param bool attachment: Whether to serve the file as a download by ...
def respond_file(self, file_path, attachment=False, query=None): """ Respond to the client by serving a file, either directly or as an attachment. :param str file_path: The path to the file to serve, this does not need to be in the web root. :param bool attachment: Whether to serve the file as a download by ...
[ "Respond", "to", "the", "client", "by", "serving", "a", "file", "either", "directly", "or", "as", "an", "attachment", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L892-L918
[ "def", "respond_file", "(", "self", ",", "file_path", ",", "attachment", "=", "False", ",", "query", "=", "None", ")", ":", "del", "query", "file_path", "=", "os", ".", "path", ".", "abspath", "(", "file_path", ")", "try", ":", "file_obj", "=", "open",...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.respond_list_directory
Respond to the client with an HTML page listing the contents of the specified directory. :param str dir_path: The path of the directory to list the contents of.
advancedhttpserver.py
def respond_list_directory(self, dir_path, query=None): """ Respond to the client with an HTML page listing the contents of the specified directory. :param str dir_path: The path of the directory to list the contents of. """ del query try: dir_contents = os.listdir(dir_path) except os.error: self...
def respond_list_directory(self, dir_path, query=None): """ Respond to the client with an HTML page listing the contents of the specified directory. :param str dir_path: The path of the directory to list the contents of. """ del query try: dir_contents = os.listdir(dir_path) except os.error: self...
[ "Respond", "to", "the", "client", "with", "an", "HTML", "page", "listing", "the", "contents", "of", "the", "specified", "directory", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L920-L965
[ "def", "respond_list_directory", "(", "self", ",", "dir_path", ",", "query", "=", "None", ")", ":", "del", "query", "try", ":", "dir_contents", "=", "os", ".", "listdir", "(", "dir_path", ")", "except", "os", ".", "error", ":", "self", ".", "respond_not_...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.respond_redirect
Respond to the client with a 301 message and redirect them with a Location header. :param str location: The new location to redirect the client to.
advancedhttpserver.py
def respond_redirect(self, location='/'): """ Respond to the client with a 301 message and redirect them with a Location header. :param str location: The new location to redirect the client to. """ self.send_response(301) self.send_header('Content-Length', 0) self.send_header('Location', location) se...
def respond_redirect(self, location='/'): """ Respond to the client with a 301 message and redirect them with a Location header. :param str location: The new location to redirect the client to. """ self.send_response(301) self.send_header('Content-Length', 0) self.send_header('Location', location) se...
[ "Respond", "to", "the", "client", "with", "a", "301", "message", "and", "redirect", "them", "with", "a", "Location", "header", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L972-L983
[ "def", "respond_redirect", "(", "self", ",", "location", "=", "'/'", ")", ":", "self", ".", "send_response", "(", "301", ")", "self", ".", "send_header", "(", "'Content-Length'", ",", "0", ")", "self", ".", "send_header", "(", "'Location'", ",", "location"...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.respond_server_error
Handle an internal server error, logging a traceback if executed within an exception handler. :param int status: The status code to respond to the client with. :param str status_line: The status message to respond to the client with. :param str message: The body of the response that is sent to the client.
advancedhttpserver.py
def respond_server_error(self, status=None, status_line=None, message=None): """ Handle an internal server error, logging a traceback if executed within an exception handler. :param int status: The status code to respond to the client with. :param str status_line: The status message to respond to the client ...
def respond_server_error(self, status=None, status_line=None, message=None): """ Handle an internal server error, logging a traceback if executed within an exception handler. :param int status: The status code to respond to the client with. :param str status_line: The status message to respond to the client ...
[ "Handle", "an", "internal", "server", "error", "logging", "a", "traceback", "if", "executed", "within", "an", "exception", "handler", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L985-L1018
[ "def", "respond_server_error", "(", "self", ",", "status", "=", "None", ",", "status_line", "=", "None", ",", "message", "=", "None", ")", ":", "(", "ex_type", ",", "ex_value", ",", "ex_traceback", ")", "=", "sys", ".", "exc_info", "(", ")", "if", "ex_...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.respond_unauthorized
Respond to the client that the request is unauthorized. :param bool request_authentication: Whether to request basic authentication information by sending a WWW-Authenticate header.
advancedhttpserver.py
def respond_unauthorized(self, request_authentication=False): """ Respond to the client that the request is unauthorized. :param bool request_authentication: Whether to request basic authentication information by sending a WWW-Authenticate header. """ headers = {} if request_authentication: headers['WWW...
def respond_unauthorized(self, request_authentication=False): """ Respond to the client that the request is unauthorized. :param bool request_authentication: Whether to request basic authentication information by sending a WWW-Authenticate header. """ headers = {} if request_authentication: headers['WWW...
[ "Respond", "to", "the", "client", "that", "the", "request", "is", "unauthorized", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1020-L1030
[ "def", "respond_unauthorized", "(", "self", ",", "request_authentication", "=", "False", ")", ":", "headers", "=", "{", "}", "if", "request_authentication", ":", "headers", "[", "'WWW-Authenticate'", "]", "=", "'Basic realm=\"'", "+", "self", ".", "__config", "[...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.dispatch_handler
Dispatch functions based on the established handler_map. It is generally not necessary to override this function and doing so will prevent any handlers from being executed. This function is executed automatically when requests of either GET, HEAD, or POST are received. :param dict query: Parsed query paramet...
advancedhttpserver.py
def dispatch_handler(self, query=None): """ Dispatch functions based on the established handler_map. It is generally not necessary to override this function and doing so will prevent any handlers from being executed. This function is executed automatically when requests of either GET, HEAD, or POST are rece...
def dispatch_handler(self, query=None): """ Dispatch functions based on the established handler_map. It is generally not necessary to override this function and doing so will prevent any handlers from being executed. This function is executed automatically when requests of either GET, HEAD, or POST are rece...
[ "Dispatch", "functions", "based", "on", "the", "established", "handler_map", ".", "It", "is", "generally", "not", "necessary", "to", "override", "this", "function", "and", "doing", "so", "will", "prevent", "any", "handlers", "from", "being", "executed", ".", "...
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1032-L1099
[ "def", "dispatch_handler", "(", "self", ",", "query", "=", "None", ")", ":", "query", "=", "(", "query", "or", "{", "}", ")", "# normalize the path", "# abandon query parameters", "self", ".", "path", "=", "self", ".", "path", ".", "split", "(", "'?'", "...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.guess_mime_type
Guess an appropriate MIME type based on the extension of the provided path. :param str path: The of the file to analyze. :return: The guessed MIME type of the default if non are found. :rtype: str
advancedhttpserver.py
def guess_mime_type(self, path): """ Guess an appropriate MIME type based on the extension of the provided path. :param str path: The of the file to analyze. :return: The guessed MIME type of the default if non are found. :rtype: str """ _, ext = posixpath.splitext(path) if ext in self.extensions_map...
def guess_mime_type(self, path): """ Guess an appropriate MIME type based on the extension of the provided path. :param str path: The of the file to analyze. :return: The guessed MIME type of the default if non are found. :rtype: str """ _, ext = posixpath.splitext(path) if ext in self.extensions_map...
[ "Guess", "an", "appropriate", "MIME", "type", "based", "on", "the", "extension", "of", "the", "provided", "path", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1135-L1148
[ "def", "guess_mime_type", "(", "self", ",", "path", ")", ":", "_", ",", "ext", "=", "posixpath", ".", "splitext", "(", "path", ")", "if", "ext", "in", "self", ".", "extensions_map", ":", "return", "self", ".", "extensions_map", "[", "ext", "]", "ext", ...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.check_authorization
Check for the presence of a basic auth Authorization header and if the credentials contained within in are valid. :return: Whether or not the credentials are valid. :rtype: bool
advancedhttpserver.py
def check_authorization(self): """ Check for the presence of a basic auth Authorization header and if the credentials contained within in are valid. :return: Whether or not the credentials are valid. :rtype: bool """ try: store = self.__config.get('basic_auth') if store is None: return True ...
def check_authorization(self): """ Check for the presence of a basic auth Authorization header and if the credentials contained within in are valid. :return: Whether or not the credentials are valid. :rtype: bool """ try: store = self.__config.get('basic_auth') if store is None: return True ...
[ "Check", "for", "the", "presence", "of", "a", "basic", "auth", "Authorization", "header", "and", "if", "the", "credentials", "contained", "within", "in", "are", "valid", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1162-L1204
[ "def", "check_authorization", "(", "self", ")", ":", "try", ":", "store", "=", "self", ".", "__config", ".", "get", "(", "'basic_auth'", ")", "if", "store", "is", "None", ":", "return", "True", "auth_info", "=", "self", ".", "headers", ".", "get", "(",...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.cookie_get
Check for a cookie value by name. :param str name: Name of the cookie value to retreive. :return: Returns the cookie value if it's set or None if it's not found.
advancedhttpserver.py
def cookie_get(self, name): """ Check for a cookie value by name. :param str name: Name of the cookie value to retreive. :return: Returns the cookie value if it's set or None if it's not found. """ if not hasattr(self, 'cookies'): return None if self.cookies.get(name): return self.cookies.get(name)...
def cookie_get(self, name): """ Check for a cookie value by name. :param str name: Name of the cookie value to retreive. :return: Returns the cookie value if it's set or None if it's not found. """ if not hasattr(self, 'cookies'): return None if self.cookies.get(name): return self.cookies.get(name)...
[ "Check", "for", "a", "cookie", "value", "by", "name", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1206-L1217
[ "def", "cookie_get", "(", "self", ",", "name", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'cookies'", ")", ":", "return", "None", "if", "self", ".", "cookies", ".", "get", "(", "name", ")", ":", "return", "self", ".", "cookies", ".", "get...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.cookie_set
Set the value of a client cookie. This can only be called while headers can be sent. :param str name: The name of the cookie value to set. :param str value: The value of the cookie to set.
advancedhttpserver.py
def cookie_set(self, name, value): """ Set the value of a client cookie. This can only be called while headers can be sent. :param str name: The name of the cookie value to set. :param str value: The value of the cookie to set. """ if not self.headers_active: raise RuntimeError('headers have already b...
def cookie_set(self, name, value): """ Set the value of a client cookie. This can only be called while headers can be sent. :param str name: The name of the cookie value to set. :param str value: The value of the cookie to set. """ if not self.headers_active: raise RuntimeError('headers have already b...
[ "Set", "the", "value", "of", "a", "client", "cookie", ".", "This", "can", "only", "be", "called", "while", "headers", "can", "be", "sent", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1219-L1230
[ "def", "cookie_set", "(", "self", ",", "name", ",", "value", ")", ":", "if", "not", "self", ".", "headers_active", ":", "raise", "RuntimeError", "(", "'headers have already been ended'", ")", "cookie", "=", "\"{0}={1}; Path=/; HttpOnly\"", ".", "format", "(", "n...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
RequestHandler.get_content_type_charset
Inspect the Content-Type header to retrieve the charset that the client has specified. :param str default: The default charset to return if none exists. :return: The charset of the request. :rtype: str
advancedhttpserver.py
def get_content_type_charset(self, default='UTF-8'): """ Inspect the Content-Type header to retrieve the charset that the client has specified. :param str default: The default charset to return if none exists. :return: The charset of the request. :rtype: str """ encoding = default header = self.heade...
def get_content_type_charset(self, default='UTF-8'): """ Inspect the Content-Type header to retrieve the charset that the client has specified. :param str default: The default charset to return if none exists. :return: The charset of the request. :rtype: str """ encoding = default header = self.heade...
[ "Inspect", "the", "Content", "-", "Type", "header", "to", "retrieve", "the", "charset", "that", "the", "client", "has", "specified", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1373-L1387
[ "def", "get_content_type_charset", "(", "self", ",", "default", "=", "'UTF-8'", ")", ":", "encoding", "=", "default", "header", "=", "self", ".", "headers", ".", "get", "(", "'Content-Type'", ",", "''", ")", "idx", "=", "header", ".", "find", "(", "'char...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
WebSocketHandler.close
Close the web socket connection and stop processing results. If the connection is still open, a WebSocket close message will be sent to the peer.
advancedhttpserver.py
def close(self): """ Close the web socket connection and stop processing results. If the connection is still open, a WebSocket close message will be sent to the peer. """ if not self.connected: return self.connected = False if self.handler.wfile.closed: return if select.select([], [self.handler....
def close(self): """ Close the web socket connection and stop processing results. If the connection is still open, a WebSocket close message will be sent to the peer. """ if not self.connected: return self.connected = False if self.handler.wfile.closed: return if select.select([], [self.handler....
[ "Close", "the", "web", "socket", "connection", "and", "stop", "processing", "results", ".", "If", "the", "connection", "is", "still", "open", "a", "WebSocket", "close", "message", "will", "be", "sent", "to", "the", "peer", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1521-L1536
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "connected", ":", "return", "self", ".", "connected", "=", "False", "if", "self", ".", "handler", ".", "wfile", ".", "closed", ":", "return", "if", "select", ".", "select", "(", "[", ...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
WebSocketHandler.send_message
Send a message to the peer over the socket. :param int opcode: The opcode for the message to send. :param bytes message: The message data to send.
advancedhttpserver.py
def send_message(self, opcode, message): """ Send a message to the peer over the socket. :param int opcode: The opcode for the message to send. :param bytes message: The message data to send. """ if not isinstance(message, bytes): message = message.encode('utf-8') length = len(message) if not select...
def send_message(self, opcode, message): """ Send a message to the peer over the socket. :param int opcode: The opcode for the message to send. :param bytes message: The message data to send. """ if not isinstance(message, bytes): message = message.encode('utf-8') length = len(message) if not select...
[ "Send", "a", "message", "to", "the", "peer", "over", "the", "socket", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1538-L1570
[ "def", "send_message", "(", "self", ",", "opcode", ",", "message", ")", ":", "if", "not", "isinstance", "(", "message", ",", "bytes", ")", ":", "message", "=", "message", ".", "encode", "(", "'utf-8'", ")", "length", "=", "len", "(", "message", ")", ...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
WebSocketHandler.on_message
The primary dispatch function to handle incoming WebSocket messages. :param int opcode: The opcode of the message that was received. :param bytes message: The data contained within the message.
advancedhttpserver.py
def on_message(self, opcode, message): """ The primary dispatch function to handle incoming WebSocket messages. :param int opcode: The opcode of the message that was received. :param bytes message: The data contained within the message. """ self.logger.debug("processing {0} (opcode: 0x{1:02x}) message".for...
def on_message(self, opcode, message): """ The primary dispatch function to handle incoming WebSocket messages. :param int opcode: The opcode of the message that was received. :param bytes message: The data contained within the message. """ self.logger.debug("processing {0} (opcode: 0x{1:02x}) message".for...
[ "The", "primary", "dispatch", "function", "to", "handle", "incoming", "WebSocket", "messages", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1595-L1626
[ "def", "on_message", "(", "self", ",", "opcode", ",", "message", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"processing {0} (opcode: 0x{1:02x}) message\"", ".", "format", "(", "self", ".", "_opcode_names", ".", "get", "(", "opcode", ",", "'UNKNOWN'"...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
Serializer.from_content_type
Build a serializer object from a MIME Content-Type string. :param str content_type: The Content-Type string to parse. :return: A new serializer instance. :rtype: :py:class:`.Serializer`
advancedhttpserver.py
def from_content_type(cls, content_type): """ Build a serializer object from a MIME Content-Type string. :param str content_type: The Content-Type string to parse. :return: A new serializer instance. :rtype: :py:class:`.Serializer` """ name = content_type options = {} if ';' in content_type: name,...
def from_content_type(cls, content_type): """ Build a serializer object from a MIME Content-Type string. :param str content_type: The Content-Type string to parse. :return: A new serializer instance. :rtype: :py:class:`.Serializer` """ name = content_type options = {} if ';' in content_type: name,...
[ "Build", "a", "serializer", "object", "from", "a", "MIME", "Content", "-", "Type", "string", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1669-L1692
[ "def", "from_content_type", "(", "cls", ",", "content_type", ")", ":", "name", "=", "content_type", "options", "=", "{", "}", "if", "';'", "in", "content_type", ":", "name", ",", "options_str", "=", "content_type", ".", "split", "(", "';'", ",", "1", ")"...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
Serializer.dumps
Serialize a python data type for transmission or storage. :param data: The python object to serialize. :return: The serialized representation of the object. :rtype: bytes
advancedhttpserver.py
def dumps(self, data): """ Serialize a python data type for transmission or storage. :param data: The python object to serialize. :return: The serialized representation of the object. :rtype: bytes """ data = g_serializer_drivers[self.name]['dumps'](data) if sys.version_info[0] == 3 and isinstance(data...
def dumps(self, data): """ Serialize a python data type for transmission or storage. :param data: The python object to serialize. :return: The serialized representation of the object. :rtype: bytes """ data = g_serializer_drivers[self.name]['dumps'](data) if sys.version_info[0] == 3 and isinstance(data...
[ "Serialize", "a", "python", "data", "type", "for", "transmission", "or", "storage", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1694-L1708
[ "def", "dumps", "(", "self", ",", "data", ")", ":", "data", "=", "g_serializer_drivers", "[", "self", ".", "name", "]", "[", "'dumps'", "]", "(", "data", ")", "if", "sys", ".", "version_info", "[", "0", "]", "==", "3", "and", "isinstance", "(", "da...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
Serializer.loads
Deserialize the data into it's original python object. :param bytes data: The serialized object to load. :return: The original python object.
advancedhttpserver.py
def loads(self, data): """ Deserialize the data into it's original python object. :param bytes data: The serialized object to load. :return: The original python object. """ if not isinstance(data, bytes): raise TypeError("loads() argument 1 must be bytes, not {0}".format(type(data).__name__)) if self....
def loads(self, data): """ Deserialize the data into it's original python object. :param bytes data: The serialized object to load. :return: The original python object. """ if not isinstance(data, bytes): raise TypeError("loads() argument 1 must be bytes, not {0}".format(type(data).__name__)) if self....
[ "Deserialize", "the", "data", "into", "it", "s", "original", "python", "object", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1710-L1726
[ "def", "loads", "(", "self", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "bytes", ")", ":", "raise", "TypeError", "(", "\"loads() argument 1 must be bytes, not {0}\"", ".", "format", "(", "type", "(", "data", ")", ".", "__name__", "...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
AdvancedHTTPServer.add_sni_cert
Add an SSL certificate for a specific hostname as supported by SSL's Server Name Indicator (SNI) extension. See :rfc:`3546` for more details on SSL extensions. In order to use this method, the server instance must have been initialized with at least one address configured for SSL. .. warning:: This method ...
advancedhttpserver.py
def add_sni_cert(self, hostname, ssl_certfile=None, ssl_keyfile=None, ssl_version=None): """ Add an SSL certificate for a specific hostname as supported by SSL's Server Name Indicator (SNI) extension. See :rfc:`3546` for more details on SSL extensions. In order to use this method, the server instance must hav...
def add_sni_cert(self, hostname, ssl_certfile=None, ssl_keyfile=None, ssl_version=None): """ Add an SSL certificate for a specific hostname as supported by SSL's Server Name Indicator (SNI) extension. See :rfc:`3546` for more details on SSL extensions. In order to use this method, the server instance must hav...
[ "Add", "an", "SSL", "certificate", "for", "a", "specific", "hostname", "as", "supported", "by", "SSL", "s", "Server", "Name", "Indicator", "(", "SNI", ")", "extension", ".", "See", ":", "rfc", ":", "3546", "for", "more", "details", "on", "SSL", "extensio...
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1844-L1878
[ "def", "add_sni_cert", "(", "self", ",", "hostname", ",", "ssl_certfile", "=", "None", ",", "ssl_keyfile", "=", "None", ",", "ssl_version", "=", "None", ")", ":", "if", "not", "g_ssl_has_server_sni", ":", "raise", "RuntimeError", "(", "'the ssl server name indic...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
AdvancedHTTPServer.remove_sni_cert
Remove the SSL Server Name Indicator (SNI) certificate configuration for the specified *hostname*. .. warning:: This method will raise a :py:exc:`RuntimeError` if either the SNI extension is not available in the :py:mod:`ssl` module or if SSL was not enabled at initialization time through the use of argu...
advancedhttpserver.py
def remove_sni_cert(self, hostname): """ Remove the SSL Server Name Indicator (SNI) certificate configuration for the specified *hostname*. .. warning:: This method will raise a :py:exc:`RuntimeError` if either the SNI extension is not available in the :py:mod:`ssl` module or if SSL was not enabled a...
def remove_sni_cert(self, hostname): """ Remove the SSL Server Name Indicator (SNI) certificate configuration for the specified *hostname*. .. warning:: This method will raise a :py:exc:`RuntimeError` if either the SNI extension is not available in the :py:mod:`ssl` module or if SSL was not enabled a...
[ "Remove", "the", "SSL", "Server", "Name", "Indicator", "(", "SNI", ")", "certificate", "configuration", "for", "the", "specified", "*", "hostname", "*", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1880-L1902
[ "def", "remove_sni_cert", "(", "self", ",", "hostname", ")", ":", "if", "not", "g_ssl_has_server_sni", ":", "raise", "RuntimeError", "(", "'the ssl server name indicator extension is unavailable'", ")", "if", "self", ".", "_ssl_sni_entries", "is", "None", ":", "raise"...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
AdvancedHTTPServer.sni_certs
.. versionadded:: 2.2.0 :return: Return a tuple of :py:class:`~.SSLSNICertificate` instances for each of the certificates that are configured. :rtype: tuple
advancedhttpserver.py
def sni_certs(self): """ .. versionadded:: 2.2.0 :return: Return a tuple of :py:class:`~.SSLSNICertificate` instances for each of the certificates that are configured. :rtype: tuple """ if not g_ssl_has_server_sni or self._ssl_sni_entries is None: return tuple() return tuple(entry.certificate for entr...
def sni_certs(self): """ .. versionadded:: 2.2.0 :return: Return a tuple of :py:class:`~.SSLSNICertificate` instances for each of the certificates that are configured. :rtype: tuple """ if not g_ssl_has_server_sni or self._ssl_sni_entries is None: return tuple() return tuple(entry.certificate for entr...
[ "..", "versionadded", "::", "2", ".", "2", ".", "0" ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1905-L1914
[ "def", "sni_certs", "(", "self", ")", ":", "if", "not", "g_ssl_has_server_sni", "or", "self", ".", "_ssl_sni_entries", "is", "None", ":", "return", "tuple", "(", ")", "return", "tuple", "(", "entry", ".", "certificate", "for", "entry", "in", "self", ".", ...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
AdvancedHTTPServer.serve_forever
Start handling requests. This method must be called and does not return unless the :py:meth:`.shutdown` method is called from another thread. :param bool fork: Whether to fork or not before serving content. :return: The child processes PID if *fork* is set to True. :rtype: int
advancedhttpserver.py
def serve_forever(self, fork=False): """ Start handling requests. This method must be called and does not return unless the :py:meth:`.shutdown` method is called from another thread. :param bool fork: Whether to fork or not before serving content. :return: The child processes PID if *fork* is set to True. ...
def serve_forever(self, fork=False): """ Start handling requests. This method must be called and does not return unless the :py:meth:`.shutdown` method is called from another thread. :param bool fork: Whether to fork or not before serving content. :return: The child processes PID if *fork* is set to True. ...
[ "Start", "handling", "requests", ".", "This", "method", "must", "be", "called", "and", "does", "not", "return", "unless", "the", ":", "py", ":", "meth", ":", ".", "shutdown", "method", "is", "called", "from", "another", "thread", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1929-L1959
[ "def", "serve_forever", "(", "self", ",", "fork", "=", "False", ")", ":", "if", "fork", ":", "if", "not", "hasattr", "(", "os", ",", "'fork'", ")", ":", "raise", "OSError", "(", "'os.fork is not available'", ")", "child_pid", "=", "os", ".", "fork", "(...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
AdvancedHTTPServer.shutdown
Shutdown the server and stop responding to requests.
advancedhttpserver.py
def shutdown(self): """Shutdown the server and stop responding to requests.""" self.__should_stop.set() if self.__server_thread == threading.current_thread(): self.__is_shutdown.set() self.__is_running.clear() else: if self.__wakeup_fd is not None: os.write(self.__wakeup_fd.write_fd, b'\x00') se...
def shutdown(self): """Shutdown the server and stop responding to requests.""" self.__should_stop.set() if self.__server_thread == threading.current_thread(): self.__is_shutdown.set() self.__is_running.clear() else: if self.__wakeup_fd is not None: os.write(self.__wakeup_fd.write_fd, b'\x00') se...
[ "Shutdown", "the", "server", "and", "stop", "responding", "to", "requests", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1961-L1975
[ "def", "shutdown", "(", "self", ")", ":", "self", ".", "__should_stop", ".", "set", "(", ")", "if", "self", ".", "__server_thread", "==", "threading", ".", "current_thread", "(", ")", ":", "self", ".", "__is_shutdown", ".", "set", "(", ")", "self", "."...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
AdvancedHTTPServer.auth_set
Enable or disable requiring authentication on all incoming requests. :param bool status: Whether to enable or disable requiring authentication.
advancedhttpserver.py
def auth_set(self, status): """ Enable or disable requiring authentication on all incoming requests. :param bool status: Whether to enable or disable requiring authentication. """ if not bool(status): self.__config['basic_auth'] = None self.logger.info('basic authentication has been disabled') else: ...
def auth_set(self, status): """ Enable or disable requiring authentication on all incoming requests. :param bool status: Whether to enable or disable requiring authentication. """ if not bool(status): self.__config['basic_auth'] = None self.logger.info('basic authentication has been disabled') else: ...
[ "Enable", "or", "disable", "requiring", "authentication", "on", "all", "incoming", "requests", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L2050-L2061
[ "def", "auth_set", "(", "self", ",", "status", ")", ":", "if", "not", "bool", "(", "status", ")", ":", "self", ".", "__config", "[", "'basic_auth'", "]", "=", "None", "self", ".", "logger", ".", "info", "(", "'basic authentication has been disabled'", ")",...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a
train
AdvancedHTTPServer.auth_delete_creds
Delete the credentials for a specific username if specified or all stored credentials. :param str username: The username of the credentials to delete.
advancedhttpserver.py
def auth_delete_creds(self, username=None): """ Delete the credentials for a specific username if specified or all stored credentials. :param str username: The username of the credentials to delete. """ if not username: self.__config['basic_auth'] = {} self.logger.info('basic authentication database ...
def auth_delete_creds(self, username=None): """ Delete the credentials for a specific username if specified or all stored credentials. :param str username: The username of the credentials to delete. """ if not username: self.__config['basic_auth'] = {} self.logger.info('basic authentication database ...
[ "Delete", "the", "credentials", "for", "a", "specific", "username", "if", "specified", "or", "all", "stored", "credentials", "." ]
zeroSteiner/AdvancedHTTPServer
python
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L2063-L2074
[ "def", "auth_delete_creds", "(", "self", ",", "username", "=", "None", ")", ":", "if", "not", "username", ":", "self", ".", "__config", "[", "'basic_auth'", "]", "=", "{", "}", "self", ".", "logger", ".", "info", "(", "'basic authentication database has been...
8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a