repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
UDST/osmnet
osmnet/load.py
process_node
def process_node(e): """ Process a node element entry into a dict suitable for going into a Pandas DataFrame. Parameters ---------- e : dict individual node element in downloaded OSM json Returns ------- node : dict """ node = {'id': e['id'], 'lat': e['...
python
def process_node(e): """ Process a node element entry into a dict suitable for going into a Pandas DataFrame. Parameters ---------- e : dict individual node element in downloaded OSM json Returns ------- node : dict """ node = {'id': e['id'], 'lat': e['...
[ "def", "process_node", "(", "e", ")", ":", "node", "=", "{", "'id'", ":", "e", "[", "'id'", "]", ",", "'lat'", ":", "e", "[", "'lat'", "]", ",", "'lon'", ":", "e", "[", "'lon'", "]", "}", "if", "'tags'", "in", "e", ":", "if", "e", "[", "'ta...
Process a node element entry into a dict suitable for going into a Pandas DataFrame. Parameters ---------- e : dict individual node element in downloaded OSM json Returns ------- node : dict
[ "Process", "a", "node", "element", "entry", "into", "a", "dict", "suitable", "for", "going", "into", "a", "Pandas", "DataFrame", "." ]
train
https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L514-L539
UDST/osmnet
osmnet/load.py
process_way
def process_way(e): """ Process a way element entry into a list of dicts suitable for going into a Pandas DataFrame. Parameters ---------- e : dict individual way element in downloaded OSM json Returns ------- way : dict waynodes : list of dict """ way = {'id':...
python
def process_way(e): """ Process a way element entry into a list of dicts suitable for going into a Pandas DataFrame. Parameters ---------- e : dict individual way element in downloaded OSM json Returns ------- way : dict waynodes : list of dict """ way = {'id':...
[ "def", "process_way", "(", "e", ")", ":", "way", "=", "{", "'id'", ":", "e", "[", "'id'", "]", "}", "if", "'tags'", "in", "e", ":", "if", "e", "[", "'tags'", "]", "is", "not", "np", ".", "nan", ":", "for", "t", ",", "v", "in", "list", "(", ...
Process a way element entry into a list of dicts suitable for going into a Pandas DataFrame. Parameters ---------- e : dict individual way element in downloaded OSM json Returns ------- way : dict waynodes : list of dict
[ "Process", "a", "way", "element", "entry", "into", "a", "list", "of", "dicts", "suitable", "for", "going", "into", "a", "Pandas", "DataFrame", "." ]
train
https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L542-L572
UDST/osmnet
osmnet/load.py
parse_network_osm_query
def parse_network_osm_query(data): """ Convert OSM query data to DataFrames of ways and way-nodes. Parameters ---------- data : dict Result of an OSM query. Returns ------- nodes, ways, waynodes : pandas.DataFrame """ if len(data['elements']) == 0: raise Runtim...
python
def parse_network_osm_query(data): """ Convert OSM query data to DataFrames of ways and way-nodes. Parameters ---------- data : dict Result of an OSM query. Returns ------- nodes, ways, waynodes : pandas.DataFrame """ if len(data['elements']) == 0: raise Runtim...
[ "def", "parse_network_osm_query", "(", "data", ")", ":", "if", "len", "(", "data", "[", "'elements'", "]", ")", "==", "0", ":", "raise", "RuntimeError", "(", "'OSM query results contain no data.'", ")", "nodes", "=", "[", "]", "ways", "=", "[", "]", "wayno...
Convert OSM query data to DataFrames of ways and way-nodes. Parameters ---------- data : dict Result of an OSM query. Returns ------- nodes, ways, waynodes : pandas.DataFrame
[ "Convert", "OSM", "query", "data", "to", "DataFrames", "of", "ways", "and", "way", "-", "nodes", "." ]
train
https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L575-L608
UDST/osmnet
osmnet/load.py
ways_in_bbox
def ways_in_bbox(lat_min, lng_min, lat_max, lng_max, network_type, timeout=180, memory=None, max_query_area_size=50*1000*50*1000, custom_osm_filter=None): """ Get DataFrames of OSM data in a bounding box. Parameters ---------- lat_min : float ...
python
def ways_in_bbox(lat_min, lng_min, lat_max, lng_max, network_type, timeout=180, memory=None, max_query_area_size=50*1000*50*1000, custom_osm_filter=None): """ Get DataFrames of OSM data in a bounding box. Parameters ---------- lat_min : float ...
[ "def", "ways_in_bbox", "(", "lat_min", ",", "lng_min", ",", "lat_max", ",", "lng_max", ",", "network_type", ",", "timeout", "=", "180", ",", "memory", "=", "None", ",", "max_query_area_size", "=", "50", "*", "1000", "*", "50", "*", "1000", ",", "custom_o...
Get DataFrames of OSM data in a bounding box. Parameters ---------- lat_min : float southern latitude of bounding box lng_min : float eastern longitude of bounding box lat_max : float northern latitude of bounding box lng_max : float western longitude of bounding...
[ "Get", "DataFrames", "of", "OSM", "data", "in", "a", "bounding", "box", "." ]
train
https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L611-L658
UDST/osmnet
osmnet/load.py
intersection_nodes
def intersection_nodes(waynodes): """ Returns a set of all the nodes that appear in 2 or more ways. Parameters ---------- waynodes : pandas.DataFrame Mapping of way IDs to node IDs as returned by `ways_in_bbox`. Returns ------- intersections : set Node IDs that appear i...
python
def intersection_nodes(waynodes): """ Returns a set of all the nodes that appear in 2 or more ways. Parameters ---------- waynodes : pandas.DataFrame Mapping of way IDs to node IDs as returned by `ways_in_bbox`. Returns ------- intersections : set Node IDs that appear i...
[ "def", "intersection_nodes", "(", "waynodes", ")", ":", "counts", "=", "waynodes", ".", "node_id", ".", "value_counts", "(", ")", "return", "set", "(", "counts", "[", "counts", ">", "1", "]", ".", "index", ".", "values", ")" ]
Returns a set of all the nodes that appear in 2 or more ways. Parameters ---------- waynodes : pandas.DataFrame Mapping of way IDs to node IDs as returned by `ways_in_bbox`. Returns ------- intersections : set Node IDs that appear in 2 or more ways.
[ "Returns", "a", "set", "of", "all", "the", "nodes", "that", "appear", "in", "2", "or", "more", "ways", "." ]
train
https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L661-L677
UDST/osmnet
osmnet/load.py
node_pairs
def node_pairs(nodes, ways, waynodes, two_way=True): """ Create a table of node pairs with the distances between them. Parameters ---------- nodes : pandas.DataFrame Must have 'lat' and 'lon' columns. ways : pandas.DataFrame Table of way metadata. waynodes : pandas.DataFrame...
python
def node_pairs(nodes, ways, waynodes, two_way=True): """ Create a table of node pairs with the distances between them. Parameters ---------- nodes : pandas.DataFrame Must have 'lat' and 'lon' columns. ways : pandas.DataFrame Table of way metadata. waynodes : pandas.DataFrame...
[ "def", "node_pairs", "(", "nodes", ",", "ways", ",", "waynodes", ",", "two_way", "=", "True", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "def", "pairwise", "(", "l", ")", ":", "return", "zip", "(", "islice", "(", "l", ",", "0", "...
Create a table of node pairs with the distances between them. Parameters ---------- nodes : pandas.DataFrame Must have 'lat' and 'lon' columns. ways : pandas.DataFrame Table of way metadata. waynodes : pandas.DataFrame Table linking way IDs to node IDs. Way IDs should be in ...
[ "Create", "a", "table", "of", "node", "pairs", "with", "the", "distances", "between", "them", "." ]
train
https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L680-L764
UDST/osmnet
osmnet/load.py
network_from_bbox
def network_from_bbox(lat_min=None, lng_min=None, lat_max=None, lng_max=None, bbox=None, network_type='walk', two_way=True, timeout=180, memory=None, max_query_area_size=50*1000*50*1000, custom_osm_filter=None): """ Make a g...
python
def network_from_bbox(lat_min=None, lng_min=None, lat_max=None, lng_max=None, bbox=None, network_type='walk', two_way=True, timeout=180, memory=None, max_query_area_size=50*1000*50*1000, custom_osm_filter=None): """ Make a g...
[ "def", "network_from_bbox", "(", "lat_min", "=", "None", ",", "lng_min", "=", "None", ",", "lat_max", "=", "None", ",", "lng_max", "=", "None", ",", "bbox", "=", "None", ",", "network_type", "=", "'walk'", ",", "two_way", "=", "True", ",", "timeout", "...
Make a graph network from a bounding lat/lon box composed of nodes and edges for use in Pandana street network accessibility calculations. You may either enter a lat/long box via the four lat_min, lng_min, lat_max, lng_max parameters or the bbox parameter as a tuple. Parameters ---------- lat_m...
[ "Make", "a", "graph", "network", "from", "a", "bounding", "lat", "/", "lon", "box", "composed", "of", "nodes", "and", "edges", "for", "use", "in", "Pandana", "street", "network", "accessibility", "calculations", ".", "You", "may", "either", "enter", "a", "...
train
https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L767-L873
rasbt/markdown-toclify
markdown_toclify/markdown_toclify.py
read_lines
def read_lines(in_file): """Returns a list of lines from a input markdown file.""" with open(in_file, 'r') as inf: in_contents = inf.read().split('\n') return in_contents
python
def read_lines(in_file): """Returns a list of lines from a input markdown file.""" with open(in_file, 'r') as inf: in_contents = inf.read().split('\n') return in_contents
[ "def", "read_lines", "(", "in_file", ")", ":", "with", "open", "(", "in_file", ",", "'r'", ")", "as", "inf", ":", "in_contents", "=", "inf", ".", "read", "(", ")", ".", "split", "(", "'\\n'", ")", "return", "in_contents" ]
Returns a list of lines from a input markdown file.
[ "Returns", "a", "list", "of", "lines", "from", "a", "input", "markdown", "file", "." ]
train
https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L33-L38
rasbt/markdown-toclify
markdown_toclify/markdown_toclify.py
remove_lines
def remove_lines(lines, remove=('[[back to top]', '<a class="mk-toclify"')): """Removes existing [back to top] links and <a id> tags.""" if not remove: return lines[:] out = [] for l in lines: if l.startswith(remove): continue out.append(l) return out
python
def remove_lines(lines, remove=('[[back to top]', '<a class="mk-toclify"')): """Removes existing [back to top] links and <a id> tags.""" if not remove: return lines[:] out = [] for l in lines: if l.startswith(remove): continue out.append(l) return out
[ "def", "remove_lines", "(", "lines", ",", "remove", "=", "(", "'[[back to top]'", ",", "'<a class=\"mk-toclify\"'", ")", ")", ":", "if", "not", "remove", ":", "return", "lines", "[", ":", "]", "out", "=", "[", "]", "for", "l", "in", "lines", ":", "if",...
Removes existing [back to top] links and <a id> tags.
[ "Removes", "existing", "[", "back", "to", "top", "]", "links", "and", "<a", "id", ">", "tags", "." ]
train
https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L41-L52
rasbt/markdown-toclify
markdown_toclify/markdown_toclify.py
slugify_headline
def slugify_headline(line, remove_dashes=False): """ Takes a header line from a Markdown document and returns a tuple of the '#'-stripped version of the head line, a string version for <a id=''></a> anchor tags, and the level of the headline as integer. E.g., >>> dashify_head...
python
def slugify_headline(line, remove_dashes=False): """ Takes a header line from a Markdown document and returns a tuple of the '#'-stripped version of the head line, a string version for <a id=''></a> anchor tags, and the level of the headline as integer. E.g., >>> dashify_head...
[ "def", "slugify_headline", "(", "line", ",", "remove_dashes", "=", "False", ")", ":", "stripped_right", "=", "line", ".", "rstrip", "(", "'#'", ")", "stripped_both", "=", "stripped_right", ".", "lstrip", "(", "'#'", ")", "level", "=", "len", "(", "stripped...
Takes a header line from a Markdown document and returns a tuple of the '#'-stripped version of the head line, a string version for <a id=''></a> anchor tags, and the level of the headline as integer. E.g., >>> dashify_headline('### some header lvl3') ('Some header lvl3', 'some-h...
[ "Takes", "a", "header", "line", "from", "a", "Markdown", "document", "and", "returns", "a", "tuple", "of", "the", "#", "-", "stripped", "version", "of", "the", "head", "line", "a", "string", "version", "for", "<a", "id", "=", ">", "<", "/", "a", ">",...
train
https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L55-L88
rasbt/markdown-toclify
markdown_toclify/markdown_toclify.py
tag_and_collect
def tag_and_collect(lines, id_tag=True, back_links=False, exclude_h=None, remove_dashes=False): """ Gets headlines from the markdown document and creates anchor tags. Keyword arguments: lines: a list of sublists where every sublist represents a line from a Markdown document. id_...
python
def tag_and_collect(lines, id_tag=True, back_links=False, exclude_h=None, remove_dashes=False): """ Gets headlines from the markdown document and creates anchor tags. Keyword arguments: lines: a list of sublists where every sublist represents a line from a Markdown document. id_...
[ "def", "tag_and_collect", "(", "lines", ",", "id_tag", "=", "True", ",", "back_links", "=", "False", ",", "exclude_h", "=", "None", ",", "remove_dashes", "=", "False", ")", ":", "out_contents", "=", "[", "]", "headlines", "=", "[", "]", "for", "l", "in...
Gets headlines from the markdown document and creates anchor tags. Keyword arguments: lines: a list of sublists where every sublist represents a line from a Markdown document. id_tag: if true, creates inserts a the <a id> tags (not req. by GitHub) back_links: if true, adds "back...
[ "Gets", "headlines", "from", "the", "markdown", "document", "and", "creates", "anchor", "tags", "." ]
train
https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L91-L157
rasbt/markdown-toclify
markdown_toclify/markdown_toclify.py
positioning_headlines
def positioning_headlines(headlines): """ Strips unnecessary whitespaces/tabs if first header is not left-aligned """ left_just = False for row in headlines: if row[-1] == 1: left_just = True break if not left_just: for row in headlines: row[-1...
python
def positioning_headlines(headlines): """ Strips unnecessary whitespaces/tabs if first header is not left-aligned """ left_just = False for row in headlines: if row[-1] == 1: left_just = True break if not left_just: for row in headlines: row[-1...
[ "def", "positioning_headlines", "(", "headlines", ")", ":", "left_just", "=", "False", "for", "row", "in", "headlines", ":", "if", "row", "[", "-", "1", "]", "==", "1", ":", "left_just", "=", "True", "break", "if", "not", "left_just", ":", "for", "row"...
Strips unnecessary whitespaces/tabs if first header is not left-aligned
[ "Strips", "unnecessary", "whitespaces", "/", "tabs", "if", "first", "header", "is", "not", "left", "-", "aligned" ]
train
https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L160-L172
rasbt/markdown-toclify
markdown_toclify/markdown_toclify.py
create_toc
def create_toc(headlines, hyperlink=True, top_link=False, no_toc_header=False): """ Creates the table of contents from the headline list that was returned by the tag_and_collect function. Keyword Arguments: headlines: list of lists e.g., ['Some header lvl3', 'some-header-lvl3', 3] ...
python
def create_toc(headlines, hyperlink=True, top_link=False, no_toc_header=False): """ Creates the table of contents from the headline list that was returned by the tag_and_collect function. Keyword Arguments: headlines: list of lists e.g., ['Some header lvl3', 'some-header-lvl3', 3] ...
[ "def", "create_toc", "(", "headlines", ",", "hyperlink", "=", "True", ",", "top_link", "=", "False", ",", "no_toc_header", "=", "False", ")", ":", "processed", "=", "[", "]", "if", "not", "no_toc_header", ":", "if", "top_link", ":", "processed", ".", "ap...
Creates the table of contents from the headline list that was returned by the tag_and_collect function. Keyword Arguments: headlines: list of lists e.g., ['Some header lvl3', 'some-header-lvl3', 3] hyperlink: Creates hyperlinks in Markdown format if True, e.g., '- [Some ...
[ "Creates", "the", "table", "of", "contents", "from", "the", "headline", "list", "that", "was", "returned", "by", "the", "tag_and_collect", "function", "." ]
train
https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L175-L207
rasbt/markdown-toclify
markdown_toclify/markdown_toclify.py
build_markdown
def build_markdown(toc_headlines, body, spacer=0, placeholder=None): """ Returns a string with the Markdown output contents incl. the table of contents. Keyword arguments: toc_headlines: lines for the table of contents as created by the create_toc function. body: contents of...
python
def build_markdown(toc_headlines, body, spacer=0, placeholder=None): """ Returns a string with the Markdown output contents incl. the table of contents. Keyword arguments: toc_headlines: lines for the table of contents as created by the create_toc function. body: contents of...
[ "def", "build_markdown", "(", "toc_headlines", ",", "body", ",", "spacer", "=", "0", ",", "placeholder", "=", "None", ")", ":", "if", "spacer", ":", "spacer_line", "=", "[", "'\\n<div style=\"height:%spx;\"></div>\\n'", "%", "(", "spacer", ")", "]", "toc_markd...
Returns a string with the Markdown output contents incl. the table of contents. Keyword arguments: toc_headlines: lines for the table of contents as created by the create_toc function. body: contents of the Markdown file including ID-anchor tags as returned by the ...
[ "Returns", "a", "string", "with", "the", "Markdown", "output", "contents", "incl", ".", "the", "table", "of", "contents", "." ]
train
https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L210-L241
rasbt/markdown-toclify
markdown_toclify/markdown_toclify.py
output_markdown
def output_markdown(markdown_cont, output_file): """ Writes to an output file if `outfile` is a valid path. """ if output_file: with open(output_file, 'w') as out: out.write(markdown_cont)
python
def output_markdown(markdown_cont, output_file): """ Writes to an output file if `outfile` is a valid path. """ if output_file: with open(output_file, 'w') as out: out.write(markdown_cont)
[ "def", "output_markdown", "(", "markdown_cont", ",", "output_file", ")", ":", "if", "output_file", ":", "with", "open", "(", "output_file", ",", "'w'", ")", "as", "out", ":", "out", ".", "write", "(", "markdown_cont", ")" ]
Writes to an output file if `outfile` is a valid path.
[ "Writes", "to", "an", "output", "file", "if", "outfile", "is", "a", "valid", "path", "." ]
train
https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L244-L251
rasbt/markdown-toclify
markdown_toclify/markdown_toclify.py
markdown_toclify
def markdown_toclify(input_file, output_file=None, github=False, back_to_top=False, nolink=False, no_toc_header=False, spacer=0, placeholder=None, exclude_h=None, remove_dashes=False): """ Function to add table of contents to markdown files. Parame...
python
def markdown_toclify(input_file, output_file=None, github=False, back_to_top=False, nolink=False, no_toc_header=False, spacer=0, placeholder=None, exclude_h=None, remove_dashes=False): """ Function to add table of contents to markdown files. Parame...
[ "def", "markdown_toclify", "(", "input_file", ",", "output_file", "=", "None", ",", "github", "=", "False", ",", "back_to_top", "=", "False", ",", "nolink", "=", "False", ",", "no_toc_header", "=", "False", ",", "spacer", "=", "0", ",", "placeholder", "=",...
Function to add table of contents to markdown files. Parameters ----------- input_file: str Path to the markdown input file. output_file: str (defaul: None) Path to the markdown output file. github: bool (default: False) Uses GitHub TOC syntax if True. back_to...
[ "Function", "to", "add", "table", "of", "contents", "to", "markdown", "files", "." ]
train
https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L254-L326
harshasrinivas/cli-github
cli_github/utils.py
url_parse
def url_parse(name): """parse urls with different prefixes""" position = name.find("github.com") if position >= 0: if position != 0: position_1 = name.find("www.github.com") position_2 = name.find("http://github.com") position_3 = name.find("https://github.com") ...
python
def url_parse(name): """parse urls with different prefixes""" position = name.find("github.com") if position >= 0: if position != 0: position_1 = name.find("www.github.com") position_2 = name.find("http://github.com") position_3 = name.find("https://github.com") ...
[ "def", "url_parse", "(", "name", ")", ":", "position", "=", "name", ".", "find", "(", "\"github.com\"", ")", "if", "position", ">=", "0", ":", "if", "position", "!=", "0", ":", "position_1", "=", "name", ".", "find", "(", "\"www.github.com\"", ")", "po...
parse urls with different prefixes
[ "parse", "urls", "with", "different", "prefixes" ]
train
https://github.com/harshasrinivas/cli-github/blob/33e08d0325b48f908506ca76e501cfb890a9a2cd/cli_github/utils.py#L30-L48
harshasrinivas/cli-github
cli_github/utils.py
get_req
def get_req(url): """simple get request""" request = urllib.request.Request(url) request.add_header('Authorization', 'token %s' % API_TOKEN) try: response = urllib.request.urlopen(request).read().decode('utf-8') return response except urllib.error.HTTPError: exception() ...
python
def get_req(url): """simple get request""" request = urllib.request.Request(url) request.add_header('Authorization', 'token %s' % API_TOKEN) try: response = urllib.request.urlopen(request).read().decode('utf-8') return response except urllib.error.HTTPError: exception() ...
[ "def", "get_req", "(", "url", ")", ":", "request", "=", "urllib", ".", "request", ".", "Request", "(", "url", ")", "request", ".", "add_header", "(", "'Authorization'", ",", "'token %s'", "%", "API_TOKEN", ")", "try", ":", "response", "=", "urllib", ".",...
simple get request
[ "simple", "get", "request" ]
train
https://github.com/harshasrinivas/cli-github/blob/33e08d0325b48f908506ca76e501cfb890a9a2cd/cli_github/utils.py#L53-L62
harshasrinivas/cli-github
cli_github/utils.py
geturl_req
def geturl_req(url): """get request that returns 302""" request = urllib.request.Request(url) request.add_header('Authorization', 'token %s' % API_TOKEN) try: response_url = urllib.request.urlopen(request).geturl() return response_url except urllib.error.HTTPError: exception(...
python
def geturl_req(url): """get request that returns 302""" request = urllib.request.Request(url) request.add_header('Authorization', 'token %s' % API_TOKEN) try: response_url = urllib.request.urlopen(request).geturl() return response_url except urllib.error.HTTPError: exception(...
[ "def", "geturl_req", "(", "url", ")", ":", "request", "=", "urllib", ".", "request", ".", "Request", "(", "url", ")", "request", ".", "add_header", "(", "'Authorization'", ",", "'token %s'", "%", "API_TOKEN", ")", "try", ":", "response_url", "=", "urllib",...
get request that returns 302
[ "get", "request", "that", "returns", "302" ]
train
https://github.com/harshasrinivas/cli-github/blob/33e08d0325b48f908506ca76e501cfb890a9a2cd/cli_github/utils.py#L67-L76
harshasrinivas/cli-github
cli_github/mains.py
main
def main(): """main function""" parser = argparse.ArgumentParser( description='Github within the Command Line') group = parser.add_mutually_exclusive_group() group.add_argument('-n', '--url', type=str, help="Get repos from the user profile's URL") group.add_argument('-...
python
def main(): """main function""" parser = argparse.ArgumentParser( description='Github within the Command Line') group = parser.add_mutually_exclusive_group() group.add_argument('-n', '--url', type=str, help="Get repos from the user profile's URL") group.add_argument('-...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Github within the Command Line'", ")", "group", "=", "parser", ".", "add_mutually_exclusive_group", "(", ")", "group", ".", "add_argument", "(", "'-n'", ",...
main function
[ "main", "function" ]
train
https://github.com/harshasrinivas/cli-github/blob/33e08d0325b48f908506ca76e501cfb890a9a2cd/cli_github/mains.py#L25-L223
edoburu/django-capture-tag
capture_tag/templatetags/capture_tags.py
do_capture
def do_capture(parser, token): """ Capture the contents of a tag output. Usage: .. code-block:: html+django {% capture %}..{% endcapture %} # output in {{ capture }} {% capture silent %}..{% endcapture %} # output in {{ capture }} only {% capture ...
python
def do_capture(parser, token): """ Capture the contents of a tag output. Usage: .. code-block:: html+django {% capture %}..{% endcapture %} # output in {{ capture }} {% capture silent %}..{% endcapture %} # output in {{ capture }} only {% capture ...
[ "def", "do_capture", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "# tokens", "t_as", "=", "'as'", "t_silent", "=", "'silent'", "var", "=", "'capture'", "silent", "=", "False", "num_bits", "=", "len", "(",...
Capture the contents of a tag output. Usage: .. code-block:: html+django {% capture %}..{% endcapture %} # output in {{ capture }} {% capture silent %}..{% endcapture %} # output in {{ capture }} only {% capture as varname %}..{% endcapture %} # o...
[ "Capture", "the", "contents", "of", "a", "tag", "output", ".", "Usage", ":" ]
train
https://github.com/edoburu/django-capture-tag/blob/68b2c635f14dca0d90857d09bde9c4c68e249476/capture_tag/templatetags/capture_tags.py#L7-L59
pawelad/pymonzo
src/pymonzo/api_objects.py
MonzoTransaction._parse_special_fields
def _parse_special_fields(self, data): """ Helper method that parses special fields to Python objects :param data: response from Monzo API request :type data: dict """ self.created = parse_date(data.pop('created')) if data.get('settled'): # Not always returned ...
python
def _parse_special_fields(self, data): """ Helper method that parses special fields to Python objects :param data: response from Monzo API request :type data: dict """ self.created = parse_date(data.pop('created')) if data.get('settled'): # Not always returned ...
[ "def", "_parse_special_fields", "(", "self", ",", "data", ")", ":", "self", ".", "created", "=", "parse_date", "(", "data", ".", "pop", "(", "'created'", ")", ")", "if", "data", ".", "get", "(", "'settled'", ")", ":", "# Not always returned", "self", "."...
Helper method that parses special fields to Python objects :param data: response from Monzo API request :type data: dict
[ "Helper", "method", "that", "parses", "special", "fields", "to", "Python", "objects" ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/api_objects.py#L102-L117
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI._save_token_on_disk
def _save_token_on_disk(self): """Helper function that saves the token on disk""" token = self._token.copy() # Client secret is needed for token refreshing and isn't returned # as a pared of OAuth token by default token.update(client_secret=self._client_secret) with cod...
python
def _save_token_on_disk(self): """Helper function that saves the token on disk""" token = self._token.copy() # Client secret is needed for token refreshing and isn't returned # as a pared of OAuth token by default token.update(client_secret=self._client_secret) with cod...
[ "def", "_save_token_on_disk", "(", "self", ")", ":", "token", "=", "self", ".", "_token", ".", "copy", "(", ")", "# Client secret is needed for token refreshing and isn't returned", "# as a pared of OAuth token by default", "token", ".", "update", "(", "client_secret", "=...
Helper function that saves the token on disk
[ "Helper", "function", "that", "saves", "the", "token", "on", "disk" ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L119-L133
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI._get_oauth_token
def _get_oauth_token(self): """ Get Monzo access token via OAuth2 `authorization code` grant type. Official docs: https://monzo.com/docs/#acquire-an-access-token :returns: OAuth 2 access token :rtype: dict """ url = urljoin(self.api_url, '/oauth2/tok...
python
def _get_oauth_token(self): """ Get Monzo access token via OAuth2 `authorization code` grant type. Official docs: https://monzo.com/docs/#acquire-an-access-token :returns: OAuth 2 access token :rtype: dict """ url = urljoin(self.api_url, '/oauth2/tok...
[ "def", "_get_oauth_token", "(", "self", ")", ":", "url", "=", "urljoin", "(", "self", ".", "api_url", ",", "'/oauth2/token'", ")", "oauth", "=", "OAuth2Session", "(", "client_id", "=", "self", ".", "_client_id", ",", "redirect_uri", "=", "config", ".", "RE...
Get Monzo access token via OAuth2 `authorization code` grant type. Official docs: https://monzo.com/docs/#acquire-an-access-token :returns: OAuth 2 access token :rtype: dict
[ "Get", "Monzo", "access", "token", "via", "OAuth2", "authorization", "code", "grant", "type", "." ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L135-L158
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI._refresh_oath_token
def _refresh_oath_token(self): """ Refresh Monzo OAuth 2 token. Official docs: https://monzo.com/docs/#refreshing-access :raises UnableToRefreshTokenException: when token couldn't be refreshed """ url = urljoin(self.api_url, '/oauth2/token') data = {...
python
def _refresh_oath_token(self): """ Refresh Monzo OAuth 2 token. Official docs: https://monzo.com/docs/#refreshing-access :raises UnableToRefreshTokenException: when token couldn't be refreshed """ url = urljoin(self.api_url, '/oauth2/token') data = {...
[ "def", "_refresh_oath_token", "(", "self", ")", ":", "url", "=", "urljoin", "(", "self", ".", "api_url", ",", "'/oauth2/token'", ")", "data", "=", "{", "'grant_type'", ":", "'refresh_token'", ",", "'client_id'", ":", "self", ".", "_client_id", ",", "'client_...
Refresh Monzo OAuth 2 token. Official docs: https://monzo.com/docs/#refreshing-access :raises UnableToRefreshTokenException: when token couldn't be refreshed
[ "Refresh", "Monzo", "OAuth", "2", "token", "." ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L160-L187
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI._get_response
def _get_response(self, method, endpoint, params=None): """ Helper method to handle HTTP requests and catch API errors :param method: valid HTTP method :type method: str :param endpoint: API endpoint :type endpoint: str :param params: extra parameters passed with...
python
def _get_response(self, method, endpoint, params=None): """ Helper method to handle HTTP requests and catch API errors :param method: valid HTTP method :type method: str :param endpoint: API endpoint :type endpoint: str :param params: extra parameters passed with...
[ "def", "_get_response", "(", "self", ",", "method", ",", "endpoint", ",", "params", "=", "None", ")", ":", "url", "=", "urljoin", "(", "self", ".", "api_url", ",", "endpoint", ")", "try", ":", "response", "=", "getattr", "(", "self", ".", "_session", ...
Helper method to handle HTTP requests and catch API errors :param method: valid HTTP method :type method: str :param endpoint: API endpoint :type endpoint: str :param params: extra parameters passed with the request :type params: dict :returns: API response ...
[ "Helper", "method", "to", "handle", "HTTP", "requests", "and", "catch", "API", "errors" ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L189-L229
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI.whoami
def whoami(self): """ Get information about the access token. Official docs: https://monzo.com/docs/#authenticating-requests :returns: access token details :rtype: dict """ endpoint = '/ping/whoami' response = self._get_response( ...
python
def whoami(self): """ Get information about the access token. Official docs: https://monzo.com/docs/#authenticating-requests :returns: access token details :rtype: dict """ endpoint = '/ping/whoami' response = self._get_response( ...
[ "def", "whoami", "(", "self", ")", ":", "endpoint", "=", "'/ping/whoami'", "response", "=", "self", ".", "_get_response", "(", "method", "=", "'get'", ",", "endpoint", "=", "endpoint", ",", ")", "return", "response", ".", "json", "(", ")" ]
Get information about the access token. Official docs: https://monzo.com/docs/#authenticating-requests :returns: access token details :rtype: dict
[ "Get", "information", "about", "the", "access", "token", "." ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L231-L246
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI.accounts
def accounts(self, refresh=False): """ Returns a list of accounts owned by the currently authorised user. It's often used when deciding whether to require explicit account ID or use the only available one, so we cache the response by default. Official docs: https://m...
python
def accounts(self, refresh=False): """ Returns a list of accounts owned by the currently authorised user. It's often used when deciding whether to require explicit account ID or use the only available one, so we cache the response by default. Official docs: https://m...
[ "def", "accounts", "(", "self", ",", "refresh", "=", "False", ")", ":", "if", "not", "refresh", "and", "self", ".", "_cached_accounts", ":", "return", "self", ".", "_cached_accounts", "endpoint", "=", "'/accounts'", "response", "=", "self", ".", "_get_respon...
Returns a list of accounts owned by the currently authorised user. It's often used when deciding whether to require explicit account ID or use the only available one, so we cache the response by default. Official docs: https://monzo.com/docs/#list-accounts :param refresh: d...
[ "Returns", "a", "list", "of", "accounts", "owned", "by", "the", "currently", "authorised", "user", ".", "It", "s", "often", "used", "when", "deciding", "whether", "to", "require", "explicit", "account", "ID", "or", "use", "the", "only", "available", "one", ...
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L248-L274
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI.balance
def balance(self, account_id=None): """ Returns balance information for a specific account. Official docs: https://monzo.com/docs/#read-balance :param account_id: Monzo account ID :type account_id: str :raises: ValueError :returns: Monzo balance inst...
python
def balance(self, account_id=None): """ Returns balance information for a specific account. Official docs: https://monzo.com/docs/#read-balance :param account_id: Monzo account ID :type account_id: str :raises: ValueError :returns: Monzo balance inst...
[ "def", "balance", "(", "self", ",", "account_id", "=", "None", ")", ":", "if", "not", "account_id", ":", "if", "len", "(", "self", ".", "accounts", "(", ")", ")", "==", "1", ":", "account_id", "=", "self", ".", "accounts", "(", ")", "[", "0", "]"...
Returns balance information for a specific account. Official docs: https://monzo.com/docs/#read-balance :param account_id: Monzo account ID :type account_id: str :raises: ValueError :returns: Monzo balance instance :rtype: MonzoBalance
[ "Returns", "balance", "information", "for", "a", "specific", "account", "." ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L276-L303
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI.pots
def pots(self, refresh=False): """ Returns a list of pots owned by the currently authorised user. Official docs: https://monzo.com/docs/#pots :param refresh: decides if the pots information should be refreshed. :type refresh: bool :returns: list of Monzo pot...
python
def pots(self, refresh=False): """ Returns a list of pots owned by the currently authorised user. Official docs: https://monzo.com/docs/#pots :param refresh: decides if the pots information should be refreshed. :type refresh: bool :returns: list of Monzo pot...
[ "def", "pots", "(", "self", ",", "refresh", "=", "False", ")", ":", "if", "not", "refresh", "and", "self", ".", "_cached_pots", ":", "return", "self", ".", "_cached_pots", "endpoint", "=", "'/pots/listV1'", "response", "=", "self", ".", "_get_response", "(...
Returns a list of pots owned by the currently authorised user. Official docs: https://monzo.com/docs/#pots :param refresh: decides if the pots information should be refreshed. :type refresh: bool :returns: list of Monzo pots :rtype: list of MonzoPot
[ "Returns", "a", "list", "of", "pots", "owned", "by", "the", "currently", "authorised", "user", "." ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L305-L329
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI.transactions
def transactions(self, account_id=None, reverse=True, limit=None): """ Returns a list of transactions on the user's account. Official docs: https://monzo.com/docs/#list-transactions :param account_id: Monzo account ID :type account_id: str :param reverse: wh...
python
def transactions(self, account_id=None, reverse=True, limit=None): """ Returns a list of transactions on the user's account. Official docs: https://monzo.com/docs/#list-transactions :param account_id: Monzo account ID :type account_id: str :param reverse: wh...
[ "def", "transactions", "(", "self", ",", "account_id", "=", "None", ",", "reverse", "=", "True", ",", "limit", "=", "None", ")", ":", "if", "not", "account_id", ":", "if", "len", "(", "self", ".", "accounts", "(", ")", ")", "==", "1", ":", "account...
Returns a list of transactions on the user's account. Official docs: https://monzo.com/docs/#list-transactions :param account_id: Monzo account ID :type account_id: str :param reverse: whether transactions should be in in descending order :type reverse: bool ...
[ "Returns", "a", "list", "of", "transactions", "on", "the", "user", "s", "account", "." ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L331-L372
pawelad/pymonzo
src/pymonzo/monzo_api.py
MonzoAPI.transaction
def transaction(self, transaction_id, expand_merchant=False): """ Returns an individual transaction, fetched by its id. Official docs: https://monzo.com/docs/#retrieve-transaction :param transaction_id: Monzo transaction ID :type transaction_id: str :param e...
python
def transaction(self, transaction_id, expand_merchant=False): """ Returns an individual transaction, fetched by its id. Official docs: https://monzo.com/docs/#retrieve-transaction :param transaction_id: Monzo transaction ID :type transaction_id: str :param e...
[ "def", "transaction", "(", "self", ",", "transaction_id", ",", "expand_merchant", "=", "False", ")", ":", "endpoint", "=", "'/transactions/{}'", ".", "format", "(", "transaction_id", ")", "data", "=", "dict", "(", ")", "if", "expand_merchant", ":", "data", "...
Returns an individual transaction, fetched by its id. Official docs: https://monzo.com/docs/#retrieve-transaction :param transaction_id: Monzo transaction ID :type transaction_id: str :param expand_merchant: whether merchant data should be included :type expand_merc...
[ "Returns", "an", "individual", "transaction", "fetched", "by", "its", "id", "." ]
train
https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L374-L398
cluther/snmposter
snmposter/scripts.py
launcher
def launcher(): """Launch it.""" parser = OptionParser() parser.add_option( '-f', '--file', dest='filename', default='agents.csv', help='snmposter configuration file' ) options, args = parser.parse_args() factory = SNMPosterFactory() snmpd_status = s...
python
def launcher(): """Launch it.""" parser = OptionParser() parser.add_option( '-f', '--file', dest='filename', default='agents.csv', help='snmposter configuration file' ) options, args = parser.parse_args() factory = SNMPosterFactory() snmpd_status = s...
[ "def", "launcher", "(", ")", ":", "parser", "=", "OptionParser", "(", ")", "parser", ".", "add_option", "(", "'-f'", ",", "'--file'", ",", "dest", "=", "'filename'", ",", "default", "=", "'agents.csv'", ",", "help", "=", "'snmposter configuration file'", ")"...
Launch it.
[ "Launch", "it", "." ]
train
https://github.com/cluther/snmposter/blob/3d9fb122368893cc71374442da6d49cde19aac75/snmposter/scripts.py#L22-L52
cgoldberg/sauceclient
sauceclient.py
SauceClient.get_auth_string
def get_auth_string(self): """Create auth string from credentials.""" auth_info = '{}:{}'.format(self.sauce_username, self.sauce_access_key) return base64.b64encode(auth_info.encode('utf-8')).decode('utf-8')
python
def get_auth_string(self): """Create auth string from credentials.""" auth_info = '{}:{}'.format(self.sauce_username, self.sauce_access_key) return base64.b64encode(auth_info.encode('utf-8')).decode('utf-8')
[ "def", "get_auth_string", "(", "self", ")", ":", "auth_info", "=", "'{}:{}'", ".", "format", "(", "self", ".", "sauce_username", ",", "self", ".", "sauce_access_key", ")", "return", "base64", ".", "b64encode", "(", "auth_info", ".", "encode", "(", "'utf-8'",...
Create auth string from credentials.
[ "Create", "auth", "string", "from", "credentials", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L59-L62
cgoldberg/sauceclient
sauceclient.py
SauceClient.make_auth_headers
def make_auth_headers(self, content_type): """Add authorization header.""" headers = self.make_headers(content_type) headers['Authorization'] = 'Basic {}'.format(self.get_auth_string()) return headers
python
def make_auth_headers(self, content_type): """Add authorization header.""" headers = self.make_headers(content_type) headers['Authorization'] = 'Basic {}'.format(self.get_auth_string()) return headers
[ "def", "make_auth_headers", "(", "self", ",", "content_type", ")", ":", "headers", "=", "self", ".", "make_headers", "(", "content_type", ")", "headers", "[", "'Authorization'", "]", "=", "'Basic {}'", ".", "format", "(", "self", ".", "get_auth_string", "(", ...
Add authorization header.
[ "Add", "authorization", "header", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L70-L74
cgoldberg/sauceclient
sauceclient.py
SauceClient.request
def request(self, method, url, body=None, content_type='application/json'): """Send http request.""" headers = self.make_auth_headers(content_type) connection = http_client.HTTPSConnection(self.apibase) connection.request(method, url, body, headers=headers) response = connection....
python
def request(self, method, url, body=None, content_type='application/json'): """Send http request.""" headers = self.make_auth_headers(content_type) connection = http_client.HTTPSConnection(self.apibase) connection.request(method, url, body, headers=headers) response = connection....
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "body", "=", "None", ",", "content_type", "=", "'application/json'", ")", ":", "headers", "=", "self", ".", "make_auth_headers", "(", "content_type", ")", "connection", "=", "http_client", ".", ...
Send http request.
[ "Send", "http", "request", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L76-L87
cgoldberg/sauceclient
sauceclient.py
Account.get_user
def get_user(self): """Access basic account information.""" method = 'GET' endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username) return self.client.request(method, endpoint)
python
def get_user(self): """Access basic account information.""" method = 'GET' endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "get_user", "(", "self", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/users/{}'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "method", ",", "endpoint"...
Access basic account information.
[ "Access", "basic", "account", "information", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L100-L104
cgoldberg/sauceclient
sauceclient.py
Account.create_user
def create_user(self, username, password, name, email): """Create a sub account.""" method = 'POST' endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username) body = json.dumps({'username': username, 'password': password, 'name': name, 'email': email, })...
python
def create_user(self, username, password, name, email): """Create a sub account.""" method = 'POST' endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username) body = json.dumps({'username': username, 'password': password, 'name': name, 'email': email, })...
[ "def", "create_user", "(", "self", ",", "username", ",", "password", ",", "name", ",", "email", ")", ":", "method", "=", "'POST'", "endpoint", "=", "'/rest/v1/users/{}'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "body", "=", ...
Create a sub account.
[ "Create", "a", "sub", "account", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L106-L112
cgoldberg/sauceclient
sauceclient.py
Account.get_concurrency
def get_concurrency(self): """Check account concurrency limits.""" method = 'GET' endpoint = '/rest/v1.1/users/{}/concurrency'.format( self.client.sauce_username) return self.client.request(method, endpoint)
python
def get_concurrency(self): """Check account concurrency limits.""" method = 'GET' endpoint = '/rest/v1.1/users/{}/concurrency'.format( self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "get_concurrency", "(", "self", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1.1/users/{}/concurrency'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "method"...
Check account concurrency limits.
[ "Check", "account", "concurrency", "limits", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L114-L119
cgoldberg/sauceclient
sauceclient.py
Account.get_subaccounts
def get_subaccounts(self): """Get a list of sub accounts associated with a parent account.""" method = 'GET' endpoint = '/rest/v1/users/{}/list-subaccounts'.format( self.client.sauce_username) return self.client.request(method, endpoint)
python
def get_subaccounts(self): """Get a list of sub accounts associated with a parent account.""" method = 'GET' endpoint = '/rest/v1/users/{}/list-subaccounts'.format( self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "get_subaccounts", "(", "self", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/users/{}/list-subaccounts'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "meth...
Get a list of sub accounts associated with a parent account.
[ "Get", "a", "list", "of", "sub", "accounts", "associated", "with", "a", "parent", "account", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L121-L126
cgoldberg/sauceclient
sauceclient.py
Account.get_siblings
def get_siblings(self): """Get a list of sibling accounts associated with provided account.""" method = 'GET' endpoint = '/rest/v1.1/users/{}/siblings'.format( self.client.sauce_username) return self.client.request(method, endpoint)
python
def get_siblings(self): """Get a list of sibling accounts associated with provided account.""" method = 'GET' endpoint = '/rest/v1.1/users/{}/siblings'.format( self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "get_siblings", "(", "self", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1.1/users/{}/siblings'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "method", ",...
Get a list of sibling accounts associated with provided account.
[ "Get", "a", "list", "of", "sibling", "accounts", "associated", "with", "provided", "account", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L128-L133
cgoldberg/sauceclient
sauceclient.py
Account.get_subaccount_info
def get_subaccount_info(self): """Get information about a sub account.""" method = 'GET' endpoint = '/rest/v1/users/{}/subaccounts'.format( self.client.sauce_username) return self.client.request(method, endpoint)
python
def get_subaccount_info(self): """Get information about a sub account.""" method = 'GET' endpoint = '/rest/v1/users/{}/subaccounts'.format( self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "get_subaccount_info", "(", "self", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/users/{}/subaccounts'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "metho...
Get information about a sub account.
[ "Get", "information", "about", "a", "sub", "account", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L135-L140
cgoldberg/sauceclient
sauceclient.py
Account.change_access_key
def change_access_key(self): """Change access key of your account.""" method = 'POST' endpoint = '/rest/v1/users/{}/accesskey/change'.format( self.client.sauce_username) return self.client.request(method, endpoint)
python
def change_access_key(self): """Change access key of your account.""" method = 'POST' endpoint = '/rest/v1/users/{}/accesskey/change'.format( self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "change_access_key", "(", "self", ")", ":", "method", "=", "'POST'", "endpoint", "=", "'/rest/v1/users/{}/accesskey/change'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "m...
Change access key of your account.
[ "Change", "access", "key", "of", "your", "account", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L142-L147
cgoldberg/sauceclient
sauceclient.py
Account.get_activity
def get_activity(self): """Check account concurrency limits.""" method = 'GET' endpoint = '/rest/v1/{}/activity'.format(self.client.sauce_username) return self.client.request(method, endpoint)
python
def get_activity(self): """Check account concurrency limits.""" method = 'GET' endpoint = '/rest/v1/{}/activity'.format(self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "get_activity", "(", "self", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/{}/activity'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "method", ",", "en...
Check account concurrency limits.
[ "Check", "account", "concurrency", "limits", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L149-L153
cgoldberg/sauceclient
sauceclient.py
Account.get_usage
def get_usage(self, start=None, end=None): """Access historical account usage data.""" method = 'GET' endpoint = '/rest/v1/users/{}/usage'.format(self.client.sauce_username) data = {} if start: data['start'] = start if end: data['end'] = end ...
python
def get_usage(self, start=None, end=None): """Access historical account usage data.""" method = 'GET' endpoint = '/rest/v1/users/{}/usage'.format(self.client.sauce_username) data = {} if start: data['start'] = start if end: data['end'] = end ...
[ "def", "get_usage", "(", "self", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/users/{}/usage'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "data", "=", "{", ...
Access historical account usage data.
[ "Access", "historical", "account", "usage", "data", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L155-L166
cgoldberg/sauceclient
sauceclient.py
Information.get_platforms
def get_platforms(self, automation_api='all'): """Get a list of objects describing all the OS and browser platforms currently supported on Sauce Labs.""" method = 'GET' endpoint = '/rest/v1/info/platforms/{}'.format(automation_api) return self.client.request(method, endpoint)
python
def get_platforms(self, automation_api='all'): """Get a list of objects describing all the OS and browser platforms currently supported on Sauce Labs.""" method = 'GET' endpoint = '/rest/v1/info/platforms/{}'.format(automation_api) return self.client.request(method, endpoint)
[ "def", "get_platforms", "(", "self", ",", "automation_api", "=", "'all'", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/info/platforms/{}'", ".", "format", "(", "automation_api", ")", "return", "self", ".", "client", ".", "request", "(", "metho...
Get a list of objects describing all the OS and browser platforms currently supported on Sauce Labs.
[ "Get", "a", "list", "of", "objects", "describing", "all", "the", "OS", "and", "browser", "platforms", "currently", "supported", "on", "Sauce", "Labs", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L351-L356
cgoldberg/sauceclient
sauceclient.py
Jobs.get_jobs
def get_jobs(self, full=None, limit=None, skip=None, start=None, end=None, output_format=None): """List jobs belonging to a specific user.""" method = 'GET' endpoint = '/rest/v1/{}/jobs'.format(self.client.sauce_username) data = {} if full is not None: ...
python
def get_jobs(self, full=None, limit=None, skip=None, start=None, end=None, output_format=None): """List jobs belonging to a specific user.""" method = 'GET' endpoint = '/rest/v1/{}/jobs'.format(self.client.sauce_username) data = {} if full is not None: ...
[ "def", "get_jobs", "(", "self", ",", "full", "=", "None", ",", "limit", "=", "None", ",", "skip", "=", "None", ",", "start", "=", "None", ",", "end", "=", "None", ",", "output_format", "=", "None", ")", ":", "method", "=", "'GET'", "endpoint", "=",...
List jobs belonging to a specific user.
[ "List", "jobs", "belonging", "to", "a", "specific", "user", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L403-L423
cgoldberg/sauceclient
sauceclient.py
Jobs.update_job
def update_job(self, job_id, build=None, custom_data=None, name=None, passed=None, public=None, tags=None): """Edit an existing job.""" method = 'PUT' endpoint = '/rest/v1/{}/jobs/{}'.format(self.client.sauce_username, job_id) ...
python
def update_job(self, job_id, build=None, custom_data=None, name=None, passed=None, public=None, tags=None): """Edit an existing job.""" method = 'PUT' endpoint = '/rest/v1/{}/jobs/{}'.format(self.client.sauce_username, job_id) ...
[ "def", "update_job", "(", "self", ",", "job_id", ",", "build", "=", "None", ",", "custom_data", "=", "None", ",", "name", "=", "None", ",", "passed", "=", "None", ",", "public", "=", "None", ",", "tags", "=", "None", ")", ":", "method", "=", "'PUT'...
Edit an existing job.
[ "Edit", "an", "existing", "job", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L432-L452
cgoldberg/sauceclient
sauceclient.py
Jobs.stop_job
def stop_job(self, job_id): """Terminates a running job.""" method = 'PUT' endpoint = '/rest/v1/{}/jobs/{}/stop'.format( self.client.sauce_username, job_id) return self.client.request(method, endpoint)
python
def stop_job(self, job_id): """Terminates a running job.""" method = 'PUT' endpoint = '/rest/v1/{}/jobs/{}/stop'.format( self.client.sauce_username, job_id) return self.client.request(method, endpoint)
[ "def", "stop_job", "(", "self", ",", "job_id", ")", ":", "method", "=", "'PUT'", "endpoint", "=", "'/rest/v1/{}/jobs/{}/stop'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ",", "job_id", ")", "return", "self", ".", "client", ".", "req...
Terminates a running job.
[ "Terminates", "a", "running", "job", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L461-L466
cgoldberg/sauceclient
sauceclient.py
Jobs.get_job_asset_url
def get_job_asset_url(self, job_id, filename): """Get details about the static assets collected for a specific job.""" return 'https://saucelabs.com/rest/v1/{}/jobs/{}/assets/{}'.format( self.client.sauce_username, job_id, filename)
python
def get_job_asset_url(self, job_id, filename): """Get details about the static assets collected for a specific job.""" return 'https://saucelabs.com/rest/v1/{}/jobs/{}/assets/{}'.format( self.client.sauce_username, job_id, filename)
[ "def", "get_job_asset_url", "(", "self", ",", "job_id", ",", "filename", ")", ":", "return", "'https://saucelabs.com/rest/v1/{}/jobs/{}/assets/{}'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ",", "job_id", ",", "filename", ")" ]
Get details about the static assets collected for a specific job.
[ "Get", "details", "about", "the", "static", "assets", "collected", "for", "a", "specific", "job", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L475-L478
cgoldberg/sauceclient
sauceclient.py
Jobs.get_auth_token
def get_auth_token(self, job_id, date_range=None): """Get an auth token to access protected job resources. https://wiki.saucelabs.com/display/DOCS/Building+Links+to+Test+Results """ key = '{}:{}'.format(self.client.sauce_username, self.client.sauce_access_ke...
python
def get_auth_token(self, job_id, date_range=None): """Get an auth token to access protected job resources. https://wiki.saucelabs.com/display/DOCS/Building+Links+to+Test+Results """ key = '{}:{}'.format(self.client.sauce_username, self.client.sauce_access_ke...
[ "def", "get_auth_token", "(", "self", ",", "job_id", ",", "date_range", "=", "None", ")", ":", "key", "=", "'{}:{}'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ",", "self", ".", "client", ".", "sauce_access_key", ")", "if", "date_...
Get an auth token to access protected job resources. https://wiki.saucelabs.com/display/DOCS/Building+Links+to+Test+Results
[ "Get", "an", "auth", "token", "to", "access", "protected", "job", "resources", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L487-L497
cgoldberg/sauceclient
sauceclient.py
Storage.upload_file
def upload_file(self, filepath, overwrite=True): """Uploads a file to the temporary sauce storage.""" method = 'POST' filename = os.path.split(filepath)[1] endpoint = '/rest/v1/storage/{}/{}?overwrite={}'.format( self.client.sauce_username, filename, "true" if overwrite else ...
python
def upload_file(self, filepath, overwrite=True): """Uploads a file to the temporary sauce storage.""" method = 'POST' filename = os.path.split(filepath)[1] endpoint = '/rest/v1/storage/{}/{}?overwrite={}'.format( self.client.sauce_username, filename, "true" if overwrite else ...
[ "def", "upload_file", "(", "self", ",", "filepath", ",", "overwrite", "=", "True", ")", ":", "method", "=", "'POST'", "filename", "=", "os", ".", "path", ".", "split", "(", "filepath", ")", "[", "1", "]", "endpoint", "=", "'/rest/v1/storage/{}/{}?overwrite...
Uploads a file to the temporary sauce storage.
[ "Uploads", "a", "file", "to", "the", "temporary", "sauce", "storage", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L509-L518
cgoldberg/sauceclient
sauceclient.py
Storage.get_stored_files
def get_stored_files(self): """Check which files are in your temporary storage.""" method = 'GET' endpoint = '/rest/v1/storage/{}'.format(self.client.sauce_username) return self.client.request(method, endpoint)
python
def get_stored_files(self): """Check which files are in your temporary storage.""" method = 'GET' endpoint = '/rest/v1/storage/{}'.format(self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "get_stored_files", "(", "self", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/storage/{}'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "method", ",", ...
Check which files are in your temporary storage.
[ "Check", "which", "files", "are", "in", "your", "temporary", "storage", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L520-L524
cgoldberg/sauceclient
sauceclient.py
Tunnels.get_tunnels
def get_tunnels(self): """Retrieves all running tunnels for a specific user.""" method = 'GET' endpoint = '/rest/v1/{}/tunnels'.format(self.client.sauce_username) return self.client.request(method, endpoint)
python
def get_tunnels(self): """Retrieves all running tunnels for a specific user.""" method = 'GET' endpoint = '/rest/v1/{}/tunnels'.format(self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "get_tunnels", "(", "self", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/{}/tunnels'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "method", ",", "endp...
Retrieves all running tunnels for a specific user.
[ "Retrieves", "all", "running", "tunnels", "for", "a", "specific", "user", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L536-L540
cgoldberg/sauceclient
sauceclient.py
Tunnels.get_tunnel
def get_tunnel(self, tunnel_id): """Get information for a tunnel given its ID.""" method = 'GET' endpoint = '/rest/v1/{}/tunnels/{}'.format( self.client.sauce_username, tunnel_id) return self.client.request(method, endpoint)
python
def get_tunnel(self, tunnel_id): """Get information for a tunnel given its ID.""" method = 'GET' endpoint = '/rest/v1/{}/tunnels/{}'.format( self.client.sauce_username, tunnel_id) return self.client.request(method, endpoint)
[ "def", "get_tunnel", "(", "self", ",", "tunnel_id", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/{}/tunnels/{}'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ",", "tunnel_id", ")", "return", "self", ".", "client", ".", ...
Get information for a tunnel given its ID.
[ "Get", "information", "for", "a", "tunnel", "given", "its", "ID", "." ]
train
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L542-L547
christophercrouzet/gorilla
gorilla.py
apply
def apply(patch): """Apply a patch. The patch's :attr:`~Patch.obj` attribute is injected into the patch's :attr:`~Patch.destination` under the patch's :attr:`~Patch.name`. This is a wrapper around calling ``setattr(patch.destination, patch.name, patch.obj)``. Parameters ---------- pat...
python
def apply(patch): """Apply a patch. The patch's :attr:`~Patch.obj` attribute is injected into the patch's :attr:`~Patch.destination` under the patch's :attr:`~Patch.name`. This is a wrapper around calling ``setattr(patch.destination, patch.name, patch.obj)``. Parameters ---------- pat...
[ "def", "apply", "(", "patch", ")", ":", "settings", "=", "Settings", "(", ")", "if", "patch", ".", "settings", "is", "None", "else", "patch", ".", "settings", "# When a hit occurs due to an attribute at the destination already existing", "# with the patch's name, the exis...
Apply a patch. The patch's :attr:`~Patch.obj` attribute is injected into the patch's :attr:`~Patch.destination` under the patch's :attr:`~Patch.name`. This is a wrapper around calling ``setattr(patch.destination, patch.name, patch.obj)``. Parameters ---------- patch : gorilla.Patch ...
[ "Apply", "a", "patch", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L231-L283
christophercrouzet/gorilla
gorilla.py
patch
def patch(destination, name=None, settings=None): """Decorator to create a patch. The object being decorated becomes the :attr:`~Patch.obj` attribute of the patch. Parameters ---------- destination : object Patch destination. name : str Name of the attribute at the destinat...
python
def patch(destination, name=None, settings=None): """Decorator to create a patch. The object being decorated becomes the :attr:`~Patch.obj` attribute of the patch. Parameters ---------- destination : object Patch destination. name : str Name of the attribute at the destinat...
[ "def", "patch", "(", "destination", ",", "name", "=", "None", ",", "settings", "=", "None", ")", ":", "def", "decorator", "(", "wrapped", ")", ":", "base", "=", "_get_base", "(", "wrapped", ")", "name_", "=", "base", ".", "__name__", "if", "name", "i...
Decorator to create a patch. The object being decorated becomes the :attr:`~Patch.obj` attribute of the patch. Parameters ---------- destination : object Patch destination. name : str Name of the attribute at the destination. settings : gorilla.Settings Settings. ...
[ "Decorator", "to", "create", "a", "patch", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L286-L319
christophercrouzet/gorilla
gorilla.py
patches
def patches(destination, settings=None, traverse_bases=True, filter=default_filter, recursive=True, use_decorators=True): """Decorator to create a patch for each member of a module or a class. Parameters ---------- destination : object Patch destination. settings : gorilla.Setti...
python
def patches(destination, settings=None, traverse_bases=True, filter=default_filter, recursive=True, use_decorators=True): """Decorator to create a patch for each member of a module or a class. Parameters ---------- destination : object Patch destination. settings : gorilla.Setti...
[ "def", "patches", "(", "destination", ",", "settings", "=", "None", ",", "traverse_bases", "=", "True", ",", "filter", "=", "default_filter", ",", "recursive", "=", "True", ",", "use_decorators", "=", "True", ")", ":", "def", "decorator", "(", "wrapped", "...
Decorator to create a patch for each member of a module or a class. Parameters ---------- destination : object Patch destination. settings : gorilla.Settings Settings. traverse_bases : bool If the object is a class, the base classes are also traversed. filter : function ...
[ "Decorator", "to", "create", "a", "patch", "for", "each", "member", "of", "a", "module", "or", "a", "class", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L322-L372
christophercrouzet/gorilla
gorilla.py
destination
def destination(value): """Modifier decorator to update a patch's destination. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- value : object ...
python
def destination(value): """Modifier decorator to update a patch's destination. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- value : object ...
[ "def", "destination", "(", "value", ")", ":", "def", "decorator", "(", "wrapped", ")", ":", "data", "=", "get_decorator_data", "(", "_get_base", "(", "wrapped", ")", ",", "set_default", "=", "True", ")", "data", ".", "override", "[", "'destination'", "]", ...
Modifier decorator to update a patch's destination. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- value : object Patch destination. ...
[ "Modifier", "decorator", "to", "update", "a", "patch", "s", "destination", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L375-L397
christophercrouzet/gorilla
gorilla.py
settings
def settings(**kwargs): """Modifier decorator to update a patch's settings. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- kwargs Sett...
python
def settings(**kwargs): """Modifier decorator to update a patch's settings. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- kwargs Sett...
[ "def", "settings", "(", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "wrapped", ")", ":", "data", "=", "get_decorator_data", "(", "_get_base", "(", "wrapped", ")", ",", "set_default", "=", "True", ")", "data", ".", "override", ".", "setdefault"...
Modifier decorator to update a patch's settings. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- kwargs Settings to update. See :class:`Set...
[ "Modifier", "decorator", "to", "update", "a", "patch", "s", "settings", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L425-L447
christophercrouzet/gorilla
gorilla.py
filter
def filter(value): """Modifier decorator to force the inclusion or exclusion of an attribute. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- v...
python
def filter(value): """Modifier decorator to force the inclusion or exclusion of an attribute. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- v...
[ "def", "filter", "(", "value", ")", ":", "def", "decorator", "(", "wrapped", ")", ":", "data", "=", "get_decorator_data", "(", "_get_base", "(", "wrapped", ")", ",", "set_default", "=", "True", ")", "data", ".", "filter", "=", "value", "return", "wrapped...
Modifier decorator to force the inclusion or exclusion of an attribute. This only modifies the behaviour of the :func:`create_patches` function and the :func:`patches` decorator, given that their parameter ``use_decorators`` is set to ``True``. Parameters ---------- value : bool ``True...
[ "Modifier", "decorator", "to", "force", "the", "inclusion", "or", "exclusion", "of", "an", "attribute", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L450-L474
christophercrouzet/gorilla
gorilla.py
create_patches
def create_patches(destination, root, settings=None, traverse_bases=True, filter=default_filter, recursive=True, use_decorators=True): """Create a patch for each member of a module or a class. Parameters ---------- destination : object Patch destination. root : object ...
python
def create_patches(destination, root, settings=None, traverse_bases=True, filter=default_filter, recursive=True, use_decorators=True): """Create a patch for each member of a module or a class. Parameters ---------- destination : object Patch destination. root : object ...
[ "def", "create_patches", "(", "destination", ",", "root", ",", "settings", "=", "None", ",", "traverse_bases", "=", "True", ",", "filter", "=", "default_filter", ",", "recursive", "=", "True", ",", "use_decorators", "=", "True", ")", ":", "if", "filter", "...
Create a patch for each member of a module or a class. Parameters ---------- destination : object Patch destination. root : object Root object, either a module or a class. settings : gorilla.Settings Settings. traverse_bases : bool If the object is a class, the b...
[ "Create", "a", "patch", "for", "each", "member", "of", "a", "module", "or", "a", "class", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L477-L559
christophercrouzet/gorilla
gorilla.py
find_patches
def find_patches(modules, recursive=True): """Find all the patches created through decorators. Parameters ---------- modules : list of module Modules and/or packages to search the patches in. recursive : bool ``True`` to search recursively in subpackages. Returns ------- ...
python
def find_patches(modules, recursive=True): """Find all the patches created through decorators. Parameters ---------- modules : list of module Modules and/or packages to search the patches in. recursive : bool ``True`` to search recursively in subpackages. Returns ------- ...
[ "def", "find_patches", "(", "modules", ",", "recursive", "=", "True", ")", ":", "out", "=", "[", "]", "modules", "=", "(", "module", "for", "package", "in", "modules", "for", "module", "in", "_module_iterator", "(", "package", ",", "recursive", "=", "rec...
Find all the patches created through decorators. Parameters ---------- modules : list of module Modules and/or packages to search the patches in. recursive : bool ``True`` to search recursively in subpackages. Returns ------- list of gorilla.Patch Patches found. ...
[ "Find", "all", "the", "patches", "created", "through", "decorators", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L562-L600
christophercrouzet/gorilla
gorilla.py
get_attribute
def get_attribute(obj, name): """Retrieve an attribute while bypassing the descriptor protocol. As per the built-in |getattr()|_ function, if the input object is a class then its base classes might also be searched until the attribute is found. Parameters ---------- obj : object Object...
python
def get_attribute(obj, name): """Retrieve an attribute while bypassing the descriptor protocol. As per the built-in |getattr()|_ function, if the input object is a class then its base classes might also be searched until the attribute is found. Parameters ---------- obj : object Object...
[ "def", "get_attribute", "(", "obj", ",", "name", ")", ":", "objs", "=", "inspect", ".", "getmro", "(", "obj", ")", "if", "isinstance", "(", "obj", ",", "_CLASS_TYPES", ")", "else", "[", "obj", "]", "for", "obj_", "in", "objs", ":", "try", ":", "ret...
Retrieve an attribute while bypassing the descriptor protocol. As per the built-in |getattr()|_ function, if the input object is a class then its base classes might also be searched until the attribute is found. Parameters ---------- obj : object Object to search the attribute in. name...
[ "Retrieve", "an", "attribute", "while", "bypassing", "the", "descriptor", "protocol", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L603-L638
christophercrouzet/gorilla
gorilla.py
get_decorator_data
def get_decorator_data(obj, set_default=False): """Retrieve any decorator data from an object. Parameters ---------- obj : object Object. set_default : bool If no data is found, a default one is set on the object and returned, otherwise ``None`` is returned. Returns ...
python
def get_decorator_data(obj, set_default=False): """Retrieve any decorator data from an object. Parameters ---------- obj : object Object. set_default : bool If no data is found, a default one is set on the object and returned, otherwise ``None`` is returned. Returns ...
[ "def", "get_decorator_data", "(", "obj", ",", "set_default", "=", "False", ")", ":", "if", "isinstance", "(", "obj", ",", "_CLASS_TYPES", ")", ":", "datas", "=", "getattr", "(", "obj", ",", "_DECORATOR_DATA", ",", "{", "}", ")", "data", "=", "datas", "...
Retrieve any decorator data from an object. Parameters ---------- obj : object Object. set_default : bool If no data is found, a default one is set on the object and returned, otherwise ``None`` is returned. Returns ------- gorilla.DecoratorData The decorato...
[ "Retrieve", "any", "decorator", "data", "from", "an", "object", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L668-L697
christophercrouzet/gorilla
gorilla.py
_get_base
def _get_base(obj): """Unwrap decorators to retrieve the base object.""" if hasattr(obj, '__func__'): obj = obj.__func__ elif isinstance(obj, property): obj = obj.fget elif isinstance(obj, (classmethod, staticmethod)): # Fallback for Python < 2.7 back when no `__func__` attribute...
python
def _get_base(obj): """Unwrap decorators to retrieve the base object.""" if hasattr(obj, '__func__'): obj = obj.__func__ elif isinstance(obj, property): obj = obj.fget elif isinstance(obj, (classmethod, staticmethod)): # Fallback for Python < 2.7 back when no `__func__` attribute...
[ "def", "_get_base", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'__func__'", ")", ":", "obj", "=", "obj", ".", "__func__", "elif", "isinstance", "(", "obj", ",", "property", ")", ":", "obj", "=", "obj", ".", "fget", "elif", "isinstance",...
Unwrap decorators to retrieve the base object.
[ "Unwrap", "decorators", "to", "retrieve", "the", "base", "object", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L700-L713
christophercrouzet/gorilla
gorilla.py
_get_members
def _get_members(obj, traverse_bases=True, filter=default_filter, recursive=True): """Retrieve the member attributes of a module or a class. The descriptor protocol is bypassed.""" if filter is None: filter = _true out = [] stack = collections.deque((obj,)) while stack...
python
def _get_members(obj, traverse_bases=True, filter=default_filter, recursive=True): """Retrieve the member attributes of a module or a class. The descriptor protocol is bypassed.""" if filter is None: filter = _true out = [] stack = collections.deque((obj,)) while stack...
[ "def", "_get_members", "(", "obj", ",", "traverse_bases", "=", "True", ",", "filter", "=", "default_filter", ",", "recursive", "=", "True", ")", ":", "if", "filter", "is", "None", ":", "filter", "=", "_true", "out", "=", "[", "]", "stack", "=", "collec...
Retrieve the member attributes of a module or a class. The descriptor protocol is bypassed.
[ "Retrieve", "the", "member", "attributes", "of", "a", "module", "or", "a", "class", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L716-L750
christophercrouzet/gorilla
gorilla.py
_module_iterator
def _module_iterator(root, recursive=True): """Iterate over modules.""" yield root stack = collections.deque((root,)) while stack: package = stack.popleft() # The '__path__' attribute of a package might return a list of paths if # the package is referenced as a namespace. ...
python
def _module_iterator(root, recursive=True): """Iterate over modules.""" yield root stack = collections.deque((root,)) while stack: package = stack.popleft() # The '__path__' attribute of a package might return a list of paths if # the package is referenced as a namespace. ...
[ "def", "_module_iterator", "(", "root", ",", "recursive", "=", "True", ")", ":", "yield", "root", "stack", "=", "collections", ".", "deque", "(", "(", "root", ",", ")", ")", "while", "stack", ":", "package", "=", "stack", ".", "popleft", "(", ")", "#...
Iterate over modules.
[ "Iterate", "over", "modules", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L753-L778
christophercrouzet/gorilla
gorilla.py
Patch._update
def _update(self, **kwargs): """Update some attributes. If a 'settings' attribute is passed as a dict, then it updates the content of the settings, if any, instead of completely overwriting it. """ for key, value in _iteritems(kwargs): if key == 'settings': ...
python
def _update(self, **kwargs): """Update some attributes. If a 'settings' attribute is passed as a dict, then it updates the content of the settings, if any, instead of completely overwriting it. """ for key, value in _iteritems(kwargs): if key == 'settings': ...
[ "def", "_update", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "key", ",", "value", "in", "_iteritems", "(", "kwargs", ")", ":", "if", "key", "==", "'settings'", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "if", "self", ...
Update some attributes. If a 'settings' attribute is passed as a dict, then it updates the content of the settings, if any, instead of completely overwriting it.
[ "Update", "some", "attributes", "." ]
train
https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L212-L228
peshay/tpm
tpm.py
TpmApi.request
def request(self, path, action, data=''): """To make a request to the API.""" # Check if the path includes URL or not. head = self.base_url if path.startswith(head): path = path[len(head):] path = quote_plus(path, safe='/') if not path.startswith(self.api)...
python
def request(self, path, action, data=''): """To make a request to the API.""" # Check if the path includes URL or not. head = self.base_url if path.startswith(head): path = path[len(head):] path = quote_plus(path, safe='/') if not path.startswith(self.api)...
[ "def", "request", "(", "self", ",", "path", ",", "action", ",", "data", "=", "''", ")", ":", "# Check if the path includes URL or not.", "head", "=", "self", ".", "base_url", "if", "path", ".", "startswith", "(", "head", ")", ":", "path", "=", "path", "[...
To make a request to the API.
[ "To", "make", "a", "request", "to", "the", "API", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L126-L207
peshay/tpm
tpm.py
TpmApi.get_collection
def get_collection(self, path): """To get pagewise data.""" while True: items = self.get(path) req = self.req for item in items: yield item if req.links and req.links['next'] and\ req.links['next']['rel'] == 'next': ...
python
def get_collection(self, path): """To get pagewise data.""" while True: items = self.get(path) req = self.req for item in items: yield item if req.links and req.links['next'] and\ req.links['next']['rel'] == 'next': ...
[ "def", "get_collection", "(", "self", ",", "path", ")", ":", "while", "True", ":", "items", "=", "self", ".", "get", "(", "path", ")", "req", "=", "self", ".", "req", "for", "item", "in", "items", ":", "yield", "item", "if", "req", ".", "links", ...
To get pagewise data.
[ "To", "get", "pagewise", "data", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L225-L236
peshay/tpm
tpm.py
TpmApi.collection
def collection(self, path): """To return all items generated by get collection.""" data = [] for item in self.get_collection(path): data.append(item) return data
python
def collection(self, path): """To return all items generated by get collection.""" data = [] for item in self.get_collection(path): data.append(item) return data
[ "def", "collection", "(", "self", ",", "path", ")", ":", "data", "=", "[", "]", "for", "item", "in", "self", ".", "get_collection", "(", "path", ")", ":", "data", ".", "append", "(", "item", ")", "return", "data" ]
To return all items generated by get collection.
[ "To", "return", "all", "items", "generated", "by", "get", "collection", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L238-L243
peshay/tpm
tpm.py
TpmApi.list_projects_search
def list_projects_search(self, searchstring): """List projects with searchstring.""" log.debug('List all projects with: %s' % searchstring) return self.collection('projects/search/%s.json' % quote_plus(searchstring))
python
def list_projects_search(self, searchstring): """List projects with searchstring.""" log.debug('List all projects with: %s' % searchstring) return self.collection('projects/search/%s.json' % quote_plus(searchstring))
[ "def", "list_projects_search", "(", "self", ",", "searchstring", ")", ":", "log", ".", "debug", "(", "'List all projects with: %s'", "%", "searchstring", ")", "return", "self", ".", "collection", "(", "'projects/search/%s.json'", "%", "quote_plus", "(", "searchstrin...
List projects with searchstring.
[ "List", "projects", "with", "searchstring", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L263-L267
peshay/tpm
tpm.py
TpmApi.create_project
def create_project(self, data): """Create a project.""" # http://teampasswordmanager.com/docs/api-projects/#create_project log.info('Create project: %s' % data) NewID = self.post('projects.json', data).get('id') log.info('Project has been created with ID %s' % NewID) retu...
python
def create_project(self, data): """Create a project.""" # http://teampasswordmanager.com/docs/api-projects/#create_project log.info('Create project: %s' % data) NewID = self.post('projects.json', data).get('id') log.info('Project has been created with ID %s' % NewID) retu...
[ "def", "create_project", "(", "self", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-projects/#create_project", "log", ".", "info", "(", "'Create project: %s'", "%", "data", ")", "NewID", "=", "self", ".", "post", "(", "'projects.json'", ",", "dat...
Create a project.
[ "Create", "a", "project", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L287-L293
peshay/tpm
tpm.py
TpmApi.update_project
def update_project(self, ID, data): """Update a project.""" # http://teampasswordmanager.com/docs/api-projects/#update_project log.info('Update project %s with %s' % (ID, data)) self.put('projects/%s.json' % ID, data)
python
def update_project(self, ID, data): """Update a project.""" # http://teampasswordmanager.com/docs/api-projects/#update_project log.info('Update project %s with %s' % (ID, data)) self.put('projects/%s.json' % ID, data)
[ "def", "update_project", "(", "self", ",", "ID", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-projects/#update_project", "log", ".", "info", "(", "'Update project %s with %s'", "%", "(", "ID", ",", "data", ")", ")", "self", ".", "put", "(", ...
Update a project.
[ "Update", "a", "project", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L295-L299
peshay/tpm
tpm.py
TpmApi.change_parent_of_project
def change_parent_of_project(self, ID, NewParrentID): """Change parent of project.""" # http://teampasswordmanager.com/docs/api-projects/#change_parent log.info('Change parrent for project %s to %s' % (ID, NewParrentID)) data = {'parent_id': NewParrentID} self.put('projects/%s/ch...
python
def change_parent_of_project(self, ID, NewParrentID): """Change parent of project.""" # http://teampasswordmanager.com/docs/api-projects/#change_parent log.info('Change parrent for project %s to %s' % (ID, NewParrentID)) data = {'parent_id': NewParrentID} self.put('projects/%s/ch...
[ "def", "change_parent_of_project", "(", "self", ",", "ID", ",", "NewParrentID", ")", ":", "# http://teampasswordmanager.com/docs/api-projects/#change_parent", "log", ".", "info", "(", "'Change parrent for project %s to %s'", "%", "(", "ID", ",", "NewParrentID", ")", ")", ...
Change parent of project.
[ "Change", "parent", "of", "project", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L301-L306
peshay/tpm
tpm.py
TpmApi.update_security_of_project
def update_security_of_project(self, ID, data): """Update security of project.""" # http://teampasswordmanager.com/docs/api-projects/#update_project_security log.info('Update project %s security %s' % (ID, data)) self.put('projects/%s/security.json' % ID, data)
python
def update_security_of_project(self, ID, data): """Update security of project.""" # http://teampasswordmanager.com/docs/api-projects/#update_project_security log.info('Update project %s security %s' % (ID, data)) self.put('projects/%s/security.json' % ID, data)
[ "def", "update_security_of_project", "(", "self", ",", "ID", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-projects/#update_project_security", "log", ".", "info", "(", "'Update project %s security %s'", "%", "(", "ID", ",", "data", ")", ")", "self", ...
Update security of project.
[ "Update", "security", "of", "project", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L308-L312
peshay/tpm
tpm.py
TpmApi.list_passwords_search
def list_passwords_search(self, searchstring): """List passwords with searchstring.""" log.debug('List all passwords with: %s' % searchstring) return self.collection('passwords/search/%s.json' % quote_plus(searchstring))
python
def list_passwords_search(self, searchstring): """List passwords with searchstring.""" log.debug('List all passwords with: %s' % searchstring) return self.collection('passwords/search/%s.json' % quote_plus(searchstring))
[ "def", "list_passwords_search", "(", "self", ",", "searchstring", ")", ":", "log", ".", "debug", "(", "'List all passwords with: %s'", "%", "searchstring", ")", "return", "self", ".", "collection", "(", "'passwords/search/%s.json'", "%", "quote_plus", "(", "searchst...
List passwords with searchstring.
[ "List", "passwords", "with", "searchstring", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L348-L352
peshay/tpm
tpm.py
TpmApi.create_password
def create_password(self, data): """Create a password.""" # http://teampasswordmanager.com/docs/api-passwords/#create_password log.info('Create new password %s' % data) NewID = self.post('passwords.json', data).get('id') log.info('Password has been created with ID %s' % NewID) ...
python
def create_password(self, data): """Create a password.""" # http://teampasswordmanager.com/docs/api-passwords/#create_password log.info('Create new password %s' % data) NewID = self.post('passwords.json', data).get('id') log.info('Password has been created with ID %s' % NewID) ...
[ "def", "create_password", "(", "self", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-passwords/#create_password", "log", ".", "info", "(", "'Create new password %s'", "%", "data", ")", "NewID", "=", "self", ".", "post", "(", "'passwords.json'", ","...
Create a password.
[ "Create", "a", "password", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L366-L372
peshay/tpm
tpm.py
TpmApi.update_password
def update_password(self, ID, data): """Update a password.""" # http://teampasswordmanager.com/docs/api-passwords/#update_password log.info('Update Password %s with %s' % (ID, data)) self.put('passwords/%s.json' % ID, data)
python
def update_password(self, ID, data): """Update a password.""" # http://teampasswordmanager.com/docs/api-passwords/#update_password log.info('Update Password %s with %s' % (ID, data)) self.put('passwords/%s.json' % ID, data)
[ "def", "update_password", "(", "self", ",", "ID", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-passwords/#update_password", "log", ".", "info", "(", "'Update Password %s with %s'", "%", "(", "ID", ",", "data", ")", ")", "self", ".", "put", "("...
Update a password.
[ "Update", "a", "password", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L374-L378
peshay/tpm
tpm.py
TpmApi.update_security_of_password
def update_security_of_password(self, ID, data): """Update security of a password.""" # http://teampasswordmanager.com/docs/api-passwords/#update_security_password log.info('Update security of password %s with %s' % (ID, data)) self.put('passwords/%s/security.json' % ID, data)
python
def update_security_of_password(self, ID, data): """Update security of a password.""" # http://teampasswordmanager.com/docs/api-passwords/#update_security_password log.info('Update security of password %s with %s' % (ID, data)) self.put('passwords/%s/security.json' % ID, data)
[ "def", "update_security_of_password", "(", "self", ",", "ID", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-passwords/#update_security_password", "log", ".", "info", "(", "'Update security of password %s with %s'", "%", "(", "ID", ",", "data", ")", ")"...
Update security of a password.
[ "Update", "security", "of", "a", "password", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L380-L384
peshay/tpm
tpm.py
TpmApi.update_custom_fields_of_password
def update_custom_fields_of_password(self, ID, data): """Update custom fields definitions of a password.""" # http://teampasswordmanager.com/docs/api-passwords/#update_cf_password log.info('Update custom fields of password %s with %s' % (ID, data)) self.put('passwords/%s/custom_fields.js...
python
def update_custom_fields_of_password(self, ID, data): """Update custom fields definitions of a password.""" # http://teampasswordmanager.com/docs/api-passwords/#update_cf_password log.info('Update custom fields of password %s with %s' % (ID, data)) self.put('passwords/%s/custom_fields.js...
[ "def", "update_custom_fields_of_password", "(", "self", ",", "ID", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-passwords/#update_cf_password", "log", ".", "info", "(", "'Update custom fields of password %s with %s'", "%", "(", "ID", ",", "data", ")", ...
Update custom fields definitions of a password.
[ "Update", "custom", "fields", "definitions", "of", "a", "password", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L386-L390
peshay/tpm
tpm.py
TpmApi.unlock_password
def unlock_password(self, ID, reason): """Unlock a password.""" # http://teampasswordmanager.com/docs/api-passwords/#unlock_password log.info('Unlock password %s, Reason: %s' % (ID, reason)) self.unlock_reason = reason self.put('passwords/%s/unlock.json' % ID)
python
def unlock_password(self, ID, reason): """Unlock a password.""" # http://teampasswordmanager.com/docs/api-passwords/#unlock_password log.info('Unlock password %s, Reason: %s' % (ID, reason)) self.unlock_reason = reason self.put('passwords/%s/unlock.json' % ID)
[ "def", "unlock_password", "(", "self", ",", "ID", ",", "reason", ")", ":", "# http://teampasswordmanager.com/docs/api-passwords/#unlock_password", "log", ".", "info", "(", "'Unlock password %s, Reason: %s'", "%", "(", "ID", ",", "reason", ")", ")", "self", ".", "unl...
Unlock a password.
[ "Unlock", "a", "password", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L404-L409
peshay/tpm
tpm.py
TpmApi.list_mypasswords_search
def list_mypasswords_search(self, searchstring): """List my passwords with searchstring.""" # http://teampasswordmanager.com/docs/api-my-passwords/#list_passwords log.debug('List MyPasswords with %s' % searchstring) return self.collection('my_passwords/search/%s.json' % ...
python
def list_mypasswords_search(self, searchstring): """List my passwords with searchstring.""" # http://teampasswordmanager.com/docs/api-my-passwords/#list_passwords log.debug('List MyPasswords with %s' % searchstring) return self.collection('my_passwords/search/%s.json' % ...
[ "def", "list_mypasswords_search", "(", "self", ",", "searchstring", ")", ":", "# http://teampasswordmanager.com/docs/api-my-passwords/#list_passwords", "log", ".", "debug", "(", "'List MyPasswords with %s'", "%", "searchstring", ")", "return", "self", ".", "collection", "("...
List my passwords with searchstring.
[ "List", "my", "passwords", "with", "searchstring", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L417-L422
peshay/tpm
tpm.py
TpmApi.create_mypassword
def create_mypassword(self, data): """Create my password.""" # http://teampasswordmanager.com/docs/api-my-passwords/#create_password log.info('Create MyPassword with %s' % data) NewID = self.post('my_passwords.json', data).get('id') log.info('MyPassword has been created with %s' ...
python
def create_mypassword(self, data): """Create my password.""" # http://teampasswordmanager.com/docs/api-my-passwords/#create_password log.info('Create MyPassword with %s' % data) NewID = self.post('my_passwords.json', data).get('id') log.info('MyPassword has been created with %s' ...
[ "def", "create_mypassword", "(", "self", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-my-passwords/#create_password", "log", ".", "info", "(", "'Create MyPassword with %s'", "%", "data", ")", "NewID", "=", "self", ".", "post", "(", "'my_passwords.js...
Create my password.
[ "Create", "my", "password", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L430-L436
peshay/tpm
tpm.py
TpmApi.update_mypassword
def update_mypassword(self, ID, data): """Update my password.""" # http://teampasswordmanager.com/docs/api-my-passwords/#update_password log.info('Update MyPassword %s with %s' % (ID, data)) self.put('my_passwords/%s.json' % ID, data)
python
def update_mypassword(self, ID, data): """Update my password.""" # http://teampasswordmanager.com/docs/api-my-passwords/#update_password log.info('Update MyPassword %s with %s' % (ID, data)) self.put('my_passwords/%s.json' % ID, data)
[ "def", "update_mypassword", "(", "self", ",", "ID", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-my-passwords/#update_password", "log", ".", "info", "(", "'Update MyPassword %s with %s'", "%", "(", "ID", ",", "data", ")", ")", "self", ".", "put"...
Update my password.
[ "Update", "my", "password", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L438-L442
peshay/tpm
tpm.py
TpmApi.create_user
def create_user(self, data): """Create a User.""" # http://teampasswordmanager.com/docs/api-users/#create_user log.info('Create user with %s' % data) NewID = self.post('users.json', data).get('id') log.info('User has been created with ID %s' % NewID) return NewID
python
def create_user(self, data): """Create a User.""" # http://teampasswordmanager.com/docs/api-users/#create_user log.info('Create user with %s' % data) NewID = self.post('users.json', data).get('id') log.info('User has been created with ID %s' % NewID) return NewID
[ "def", "create_user", "(", "self", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-users/#create_user", "log", ".", "info", "(", "'Create user with %s'", "%", "data", ")", "NewID", "=", "self", ".", "post", "(", "'users.json'", ",", "data", ")", ...
Create a User.
[ "Create", "a", "User", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L496-L502
peshay/tpm
tpm.py
TpmApi.update_user
def update_user(self, ID, data): """Update a User.""" # http://teampasswordmanager.com/docs/api-users/#update_user log.info('Update user %s with %s' % (ID, data)) self.put('users/%s.json' % ID, data)
python
def update_user(self, ID, data): """Update a User.""" # http://teampasswordmanager.com/docs/api-users/#update_user log.info('Update user %s with %s' % (ID, data)) self.put('users/%s.json' % ID, data)
[ "def", "update_user", "(", "self", ",", "ID", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-users/#update_user", "log", ".", "info", "(", "'Update user %s with %s'", "%", "(", "ID", ",", "data", ")", ")", "self", ".", "put", "(", "'users/%s.j...
Update a User.
[ "Update", "a", "User", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L504-L508
peshay/tpm
tpm.py
TpmApi.change_user_password
def change_user_password(self, ID, data): """Change password of a User.""" # http://teampasswordmanager.com/docs/api-users/#change_password log.info('Change user %s password' % ID) self.put('users/%s/change_password.json' % ID, data)
python
def change_user_password(self, ID, data): """Change password of a User.""" # http://teampasswordmanager.com/docs/api-users/#change_password log.info('Change user %s password' % ID) self.put('users/%s/change_password.json' % ID, data)
[ "def", "change_user_password", "(", "self", ",", "ID", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-users/#change_password", "log", ".", "info", "(", "'Change user %s password'", "%", "ID", ")", "self", ".", "put", "(", "'users/%s/change_password.js...
Change password of a User.
[ "Change", "password", "of", "a", "User", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L510-L514
peshay/tpm
tpm.py
TpmApi.convert_user_to_ldap
def convert_user_to_ldap(self, ID, DN): """Convert a normal user to a LDAP user.""" # http://teampasswordmanager.com/docs/api-users/#convert_to_ldap data = {'login_dn': DN} log.info('Convert User %s to LDAP DN %s' % (ID, DN)) self.put('users/%s/convert_to_ldap.json' % ID, data)
python
def convert_user_to_ldap(self, ID, DN): """Convert a normal user to a LDAP user.""" # http://teampasswordmanager.com/docs/api-users/#convert_to_ldap data = {'login_dn': DN} log.info('Convert User %s to LDAP DN %s' % (ID, DN)) self.put('users/%s/convert_to_ldap.json' % ID, data)
[ "def", "convert_user_to_ldap", "(", "self", ",", "ID", ",", "DN", ")", ":", "# http://teampasswordmanager.com/docs/api-users/#convert_to_ldap", "data", "=", "{", "'login_dn'", ":", "DN", "}", "log", ".", "info", "(", "'Convert User %s to LDAP DN %s'", "%", "(", "ID"...
Convert a normal user to a LDAP user.
[ "Convert", "a", "normal", "user", "to", "a", "LDAP", "user", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L528-L533
peshay/tpm
tpm.py
TpmApi.create_group
def create_group(self, data): """Create a Group.""" # http://teampasswordmanager.com/docs/api-groups/#create_group log.info('Create group with %s' % data) NewID = self.post('groups.json', data).get('id') log.info('Group has been created with ID %s' % NewID) return NewID
python
def create_group(self, data): """Create a Group.""" # http://teampasswordmanager.com/docs/api-groups/#create_group log.info('Create group with %s' % data) NewID = self.post('groups.json', data).get('id') log.info('Group has been created with ID %s' % NewID) return NewID
[ "def", "create_group", "(", "self", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-groups/#create_group", "log", ".", "info", "(", "'Create group with %s'", "%", "data", ")", "NewID", "=", "self", ".", "post", "(", "'groups.json'", ",", "data", ...
Create a Group.
[ "Create", "a", "Group", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L558-L564
peshay/tpm
tpm.py
TpmApi.update_group
def update_group(self, ID, data): """Update a Group.""" # http://teampasswordmanager.com/docs/api-groups/#update_group log.info('Update group %s with %s' % (ID, data)) self.put('groups/%s.json' % ID, data)
python
def update_group(self, ID, data): """Update a Group.""" # http://teampasswordmanager.com/docs/api-groups/#update_group log.info('Update group %s with %s' % (ID, data)) self.put('groups/%s.json' % ID, data)
[ "def", "update_group", "(", "self", ",", "ID", ",", "data", ")", ":", "# http://teampasswordmanager.com/docs/api-groups/#update_group", "log", ".", "info", "(", "'Update group %s with %s'", "%", "(", "ID", ",", "data", ")", ")", "self", ".", "put", "(", "'groups...
Update a Group.
[ "Update", "a", "Group", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L566-L570
peshay/tpm
tpm.py
TpmApi.add_user_to_group
def add_user_to_group(self, GroupID, UserID): """Add a user to a group.""" # http://teampasswordmanager.com/docs/api-groups/#add_user log.info('Add User %s to Group %s' % (UserID, GroupID)) self.put('groups/%s/add_user/%s.json' % (GroupID, UserID))
python
def add_user_to_group(self, GroupID, UserID): """Add a user to a group.""" # http://teampasswordmanager.com/docs/api-groups/#add_user log.info('Add User %s to Group %s' % (UserID, GroupID)) self.put('groups/%s/add_user/%s.json' % (GroupID, UserID))
[ "def", "add_user_to_group", "(", "self", ",", "GroupID", ",", "UserID", ")", ":", "# http://teampasswordmanager.com/docs/api-groups/#add_user", "log", ".", "info", "(", "'Add User %s to Group %s'", "%", "(", "UserID", ",", "GroupID", ")", ")", "self", ".", "put", ...
Add a user to a group.
[ "Add", "a", "user", "to", "a", "group", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L572-L576
peshay/tpm
tpm.py
TpmApi.delete_user_from_group
def delete_user_from_group(self, GroupID, UserID): """Delete a user from a group.""" # http://teampasswordmanager.com/docs/api-groups/#del_user log.info('Delete user %s from group %s' % (UserID, GroupID)) self.put('groups/%s/delete_user/%s.json' % (GroupID, UserID))
python
def delete_user_from_group(self, GroupID, UserID): """Delete a user from a group.""" # http://teampasswordmanager.com/docs/api-groups/#del_user log.info('Delete user %s from group %s' % (UserID, GroupID)) self.put('groups/%s/delete_user/%s.json' % (GroupID, UserID))
[ "def", "delete_user_from_group", "(", "self", ",", "GroupID", ",", "UserID", ")", ":", "# http://teampasswordmanager.com/docs/api-groups/#del_user", "log", ".", "info", "(", "'Delete user %s from group %s'", "%", "(", "UserID", ",", "GroupID", ")", ")", "self", ".", ...
Delete a user from a group.
[ "Delete", "a", "user", "from", "a", "group", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L578-L582
peshay/tpm
tpm.py
TpmApi.up_to_date
def up_to_date(self): """Check if Team Password Manager is up to date.""" VersionInfo = self.get_latest_version() CurrentVersion = VersionInfo.get('version') LatestVersion = VersionInfo.get('latest_version') if CurrentVersion == LatestVersion: log.info('TeamPasswordM...
python
def up_to_date(self): """Check if Team Password Manager is up to date.""" VersionInfo = self.get_latest_version() CurrentVersion = VersionInfo.get('version') LatestVersion = VersionInfo.get('latest_version') if CurrentVersion == LatestVersion: log.info('TeamPasswordM...
[ "def", "up_to_date", "(", "self", ")", ":", "VersionInfo", "=", "self", ".", "get_latest_version", "(", ")", "CurrentVersion", "=", "VersionInfo", ".", "get", "(", "'version'", ")", "LatestVersion", "=", "VersionInfo", ".", "get", "(", "'latest_version'", ")",...
Check if Team Password Manager is up to date.
[ "Check", "if", "Team", "Password", "Manager", "is", "up", "to", "date", "." ]
train
https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L608-L620
shazow/unstdlib.py
unstdlib/standard/exception_.py
convert_exception
def convert_exception(from_exception, to_exception, *to_args, **to_kw): """ Decorator: Catch exception ``from_exception`` and instead raise ``to_exception(*to_args, **to_kw)``. Useful when modules you're using in a method throw their own errors that you want to convert to your own exceptions that you h...
python
def convert_exception(from_exception, to_exception, *to_args, **to_kw): """ Decorator: Catch exception ``from_exception`` and instead raise ``to_exception(*to_args, **to_kw)``. Useful when modules you're using in a method throw their own errors that you want to convert to your own exceptions that you h...
[ "def", "convert_exception", "(", "from_exception", ",", "to_exception", ",", "*", "to_args", ",", "*", "*", "to_kw", ")", ":", "def", "wrapper", "(", "fn", ")", ":", "def", "fn_new", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "try", ":", "ret...
Decorator: Catch exception ``from_exception`` and instead raise ``to_exception(*to_args, **to_kw)``. Useful when modules you're using in a method throw their own errors that you want to convert to your own exceptions that you handle higher in the stack. Example: :: class FooError(Exception): ...
[ "Decorator", ":", "Catch", "exception", "from_exception", "and", "instead", "raise", "to_exception", "(", "*", "to_args", "**", "to_kw", ")", "." ]
train
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/exception_.py#L9-L51
shazow/unstdlib.py
unstdlib/standard/datetime_.py
iterate_date_values
def iterate_date_values(d, start_date=None, stop_date=None, default=0): """ Convert (date, value) sorted lists into contiguous value-per-day data sets. Great for sparklines. Example:: [(datetime.date(2011, 1, 1), 1), (datetime.date(2011, 1, 4), 2)] -> [1, 0, 0, 2] """ dataiter = iter(d) ...
python
def iterate_date_values(d, start_date=None, stop_date=None, default=0): """ Convert (date, value) sorted lists into contiguous value-per-day data sets. Great for sparklines. Example:: [(datetime.date(2011, 1, 1), 1), (datetime.date(2011, 1, 4), 2)] -> [1, 0, 0, 2] """ dataiter = iter(d) ...
[ "def", "iterate_date_values", "(", "d", ",", "start_date", "=", "None", ",", "stop_date", "=", "None", ",", "default", "=", "0", ")", ":", "dataiter", "=", "iter", "(", "d", ")", "cur_day", ",", "cur_val", "=", "next", "(", "dataiter", ")", "start_date...
Convert (date, value) sorted lists into contiguous value-per-day data sets. Great for sparklines. Example:: [(datetime.date(2011, 1, 1), 1), (datetime.date(2011, 1, 4), 2)] -> [1, 0, 0, 2]
[ "Convert", "(", "date", "value", ")", "sorted", "lists", "into", "contiguous", "value", "-", "per", "-", "day", "data", "sets", ".", "Great", "for", "sparklines", "." ]
train
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/datetime_.py#L16-L43
shazow/unstdlib.py
unstdlib/standard/datetime_.py
truncate_datetime
def truncate_datetime(t, resolution): """ Given a datetime ``t`` and a ``resolution``, flatten the precision beyond the given resolution. ``resolution`` can be one of: year, month, day, hour, minute, second, microsecond Example:: >>> t = datetime.datetime(2000, 1, 2, 3, 4, 5, 6000) # Or, 2000...
python
def truncate_datetime(t, resolution): """ Given a datetime ``t`` and a ``resolution``, flatten the precision beyond the given resolution. ``resolution`` can be one of: year, month, day, hour, minute, second, microsecond Example:: >>> t = datetime.datetime(2000, 1, 2, 3, 4, 5, 6000) # Or, 2000...
[ "def", "truncate_datetime", "(", "t", ",", "resolution", ")", ":", "resolutions", "=", "[", "'year'", ",", "'month'", ",", "'day'", ",", "'hour'", ",", "'minute'", ",", "'second'", ",", "'microsecond'", "]", "if", "resolution", "not", "in", "resolutions", ...
Given a datetime ``t`` and a ``resolution``, flatten the precision beyond the given resolution. ``resolution`` can be one of: year, month, day, hour, minute, second, microsecond Example:: >>> t = datetime.datetime(2000, 1, 2, 3, 4, 5, 6000) # Or, 2000-01-02 03:04:05.006000 >>> truncate_datet...
[ "Given", "a", "datetime", "t", "and", "a", "resolution", "flatten", "the", "precision", "beyond", "the", "given", "resolution", "." ]
train
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/datetime_.py#L53-L85
shazow/unstdlib.py
unstdlib/standard/datetime_.py
to_timezone
def to_timezone(dt, timezone): """ Return an aware datetime which is ``dt`` converted to ``timezone``. If ``dt`` is naive, it is assumed to be UTC. For example, if ``dt`` is "06:00 UTC+0000" and ``timezone`` is "EDT-0400", then the result will be "02:00 EDT-0400". This method follows the guid...
python
def to_timezone(dt, timezone): """ Return an aware datetime which is ``dt`` converted to ``timezone``. If ``dt`` is naive, it is assumed to be UTC. For example, if ``dt`` is "06:00 UTC+0000" and ``timezone`` is "EDT-0400", then the result will be "02:00 EDT-0400". This method follows the guid...
[ "def", "to_timezone", "(", "dt", ",", "timezone", ")", ":", "if", "dt", ".", "tzinfo", "is", "None", ":", "dt", "=", "dt", ".", "replace", "(", "tzinfo", "=", "_UTC", ")", "return", "timezone", ".", "normalize", "(", "dt", ".", "astimezone", "(", "...
Return an aware datetime which is ``dt`` converted to ``timezone``. If ``dt`` is naive, it is assumed to be UTC. For example, if ``dt`` is "06:00 UTC+0000" and ``timezone`` is "EDT-0400", then the result will be "02:00 EDT-0400". This method follows the guidelines in http://pytz.sourceforge.net/
[ "Return", "an", "aware", "datetime", "which", "is", "dt", "converted", "to", "timezone", "." ]
train
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/datetime_.py#L87-L100
shazow/unstdlib.py
unstdlib/standard/datetime_.py
now
def now(timezone=None): """ Return a naive datetime object for the given ``timezone``. A ``timezone`` is any pytz- like or datetime.tzinfo-like timezone object. If no timezone is given, then UTC is assumed. This method is best used with pytz installed:: pip install pytz """ d = dat...
python
def now(timezone=None): """ Return a naive datetime object for the given ``timezone``. A ``timezone`` is any pytz- like or datetime.tzinfo-like timezone object. If no timezone is given, then UTC is assumed. This method is best used with pytz installed:: pip install pytz """ d = dat...
[ "def", "now", "(", "timezone", "=", "None", ")", ":", "d", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "if", "not", "timezone", ":", "return", "d", "return", "to_timezone", "(", "d", ",", "timezone", ")", ".", "replace", "(", "tzinfo",...
Return a naive datetime object for the given ``timezone``. A ``timezone`` is any pytz- like or datetime.tzinfo-like timezone object. If no timezone is given, then UTC is assumed. This method is best used with pytz installed:: pip install pytz
[ "Return", "a", "naive", "datetime", "object", "for", "the", "given", "timezone", ".", "A", "timezone", "is", "any", "pytz", "-", "like", "or", "datetime", ".", "tzinfo", "-", "like", "timezone", "object", ".", "If", "no", "timezone", "is", "given", "then...
train
https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/datetime_.py#L102-L116