repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
lambdamusic/Ontospy
ontospy/extras/hacks/matcher.py
matcher
def matcher(graph1, graph2, confidence=0.5, output_file="matching_results.csv", class_or_prop="classes", verbose=False): """ takes two graphs and matches its classes based on qname, label etc.. @todo extend to properties and skos etc.. """ printDebug("----------\nNow matching...") f = open(output_file, 'wt') c...
python
def matcher(graph1, graph2, confidence=0.5, output_file="matching_results.csv", class_or_prop="classes", verbose=False): """ takes two graphs and matches its classes based on qname, label etc.. @todo extend to properties and skos etc.. """ printDebug("----------\nNow matching...") f = open(output_file, 'wt') c...
[ "def", "matcher", "(", "graph1", ",", "graph2", ",", "confidence", "=", "0.5", ",", "output_file", "=", "\"matching_results.csv\"", ",", "class_or_prop", "=", "\"classes\"", ",", "verbose", "=", "False", ")", ":", "printDebug", "(", "\"----------\\nNow matching......
takes two graphs and matches its classes based on qname, label etc.. @todo extend to properties and skos etc..
[ "takes", "two", "graphs", "and", "matches", "its", "classes", "based", "on", "qname", "label", "etc", ".." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/hacks/matcher.py#L69-L122
train
lambdamusic/Ontospy
ontospy/core/utils.py
safe_str
def safe_str(u, errors="replace"): """Safely print the given string. If you want to see the code points for unprintable characters then you can use `errors="xmlcharrefreplace"`. http://code.activestate.com/recipes/576602-safe-print/ """ s = u.encode(sys.stdout.encoding or "utf-8", errors) r...
python
def safe_str(u, errors="replace"): """Safely print the given string. If you want to see the code points for unprintable characters then you can use `errors="xmlcharrefreplace"`. http://code.activestate.com/recipes/576602-safe-print/ """ s = u.encode(sys.stdout.encoding or "utf-8", errors) r...
[ "def", "safe_str", "(", "u", ",", "errors", "=", "\"replace\"", ")", ":", "s", "=", "u", ".", "encode", "(", "sys", ".", "stdout", ".", "encoding", "or", "\"utf-8\"", ",", "errors", ")", "return", "s" ]
Safely print the given string. If you want to see the code points for unprintable characters then you can use `errors="xmlcharrefreplace"`. http://code.activestate.com/recipes/576602-safe-print/
[ "Safely", "print", "the", "given", "string", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L41-L49
train
lambdamusic/Ontospy
ontospy/core/utils.py
OLD_printDebug
def OLD_printDebug(s, style=None): """ util for printing in colors to sys.stderr stream """ if style == "comment": s = Style.DIM + s + Style.RESET_ALL elif style == "important": s = Style.BRIGHT + s + Style.RESET_ALL elif style == "normal": s = Style.RESET_ALL + s + Style...
python
def OLD_printDebug(s, style=None): """ util for printing in colors to sys.stderr stream """ if style == "comment": s = Style.DIM + s + Style.RESET_ALL elif style == "important": s = Style.BRIGHT + s + Style.RESET_ALL elif style == "normal": s = Style.RESET_ALL + s + Style...
[ "def", "OLD_printDebug", "(", "s", ",", "style", "=", "None", ")", ":", "if", "style", "==", "\"comment\"", ":", "s", "=", "Style", ".", "DIM", "+", "s", "+", "Style", ".", "RESET_ALL", "elif", "style", "==", "\"important\"", ":", "s", "=", "Style", ...
util for printing in colors to sys.stderr stream
[ "util", "for", "printing", "in", "colors", "to", "sys", ".", "stderr", "stream" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L175-L192
train
lambdamusic/Ontospy
ontospy/core/utils.py
pprint2columns
def pprint2columns(llist, max_length=60): """ llist = a list of strings max_length = if a word is longer than that, for single col display > prints a list in two columns, taking care of alignment too """ if len(llist) == 0: return None col_width = max(len(word) for word in llist) +...
python
def pprint2columns(llist, max_length=60): """ llist = a list of strings max_length = if a word is longer than that, for single col display > prints a list in two columns, taking care of alignment too """ if len(llist) == 0: return None col_width = max(len(word) for word in llist) +...
[ "def", "pprint2columns", "(", "llist", ",", "max_length", "=", "60", ")", ":", "if", "len", "(", "llist", ")", "==", "0", ":", "return", "None", "col_width", "=", "max", "(", "len", "(", "word", ")", "for", "word", "in", "llist", ")", "+", "2", "...
llist = a list of strings max_length = if a word is longer than that, for single col display > prints a list in two columns, taking care of alignment too
[ "llist", "=", "a", "list", "of", "strings", "max_length", "=", "if", "a", "word", "is", "longer", "than", "that", "for", "single", "col", "display" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L195-L219
train
lambdamusic/Ontospy
ontospy/core/utils.py
playSound
def playSound(folder, name=""): """ as easy as that """ try: if not name: onlyfiles = [ f for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f)) ] name = random.choice(onlyfiles) subprocess.call(["afplay", folder...
python
def playSound(folder, name=""): """ as easy as that """ try: if not name: onlyfiles = [ f for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f)) ] name = random.choice(onlyfiles) subprocess.call(["afplay", folder...
[ "def", "playSound", "(", "folder", ",", "name", "=", "\"\"", ")", ":", "try", ":", "if", "not", "name", ":", "onlyfiles", "=", "[", "f", "for", "f", "in", "os", ".", "listdir", "(", "folder", ")", "if", "os", ".", "path", ".", "isfile", "(", "o...
as easy as that
[ "as", "easy", "as", "that" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L344-L356
train
lambdamusic/Ontospy
ontospy/core/utils.py
truncate
def truncate(data, l=20): "truncate a string" info = (data[:l] + '..') if len(data) > l else data return info
python
def truncate(data, l=20): "truncate a string" info = (data[:l] + '..') if len(data) > l else data return info
[ "def", "truncate", "(", "data", ",", "l", "=", "20", ")", ":", "info", "=", "(", "data", "[", ":", "l", "]", "+", "'..'", ")", "if", "len", "(", "data", ")", ">", "l", "else", "data", "return", "info" ]
truncate a string
[ "truncate", "a", "string" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L359-L362
train
lambdamusic/Ontospy
ontospy/core/utils.py
printGenericTree
def printGenericTree(element, level=0, showids=True, labels=False, showtype=True, TYPE_MARGIN=18): """ Print nicely into stdout the taxonomical tree of an ontology. Works irrespectively of whether it's ...
python
def printGenericTree(element, level=0, showids=True, labels=False, showtype=True, TYPE_MARGIN=18): """ Print nicely into stdout the taxonomical tree of an ontology. Works irrespectively of whether it's ...
[ "def", "printGenericTree", "(", "element", ",", "level", "=", "0", ",", "showids", "=", "True", ",", "labels", "=", "False", ",", "showtype", "=", "True", ",", "TYPE_MARGIN", "=", "18", ")", ":", "ID_MARGIN", "=", "5", "SHORT_TYPES", "=", "{", "\"rdf:P...
Print nicely into stdout the taxonomical tree of an ontology. Works irrespectively of whether it's a class or property. Note: indentation is made so that ids up to 3 digits fit in, plus a space. [123]1-- [1]123-- [12]12-- <TYPE_MARGIN> is parametrized so that classes and properties can have d...
[ "Print", "nicely", "into", "stdout", "the", "taxonomical", "tree", "of", "an", "ontology", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L443-L500
train
lambdamusic/Ontospy
ontospy/core/utils.py
firstStringInList
def firstStringInList(literalEntities, prefLanguage="en"): """ from a list of literals, returns the one in prefLanguage if no language specification is available, return first element """ match = "" if len(literalEntities) == 1: match = literalEntities[0] elif len(literalEntities) >...
python
def firstStringInList(literalEntities, prefLanguage="en"): """ from a list of literals, returns the one in prefLanguage if no language specification is available, return first element """ match = "" if len(literalEntities) == 1: match = literalEntities[0] elif len(literalEntities) >...
[ "def", "firstStringInList", "(", "literalEntities", ",", "prefLanguage", "=", "\"en\"", ")", ":", "match", "=", "\"\"", "if", "len", "(", "literalEntities", ")", "==", "1", ":", "match", "=", "literalEntities", "[", "0", "]", "elif", "len", "(", "literalEn...
from a list of literals, returns the one in prefLanguage if no language specification is available, return first element
[ "from", "a", "list", "of", "literals", "returns", "the", "one", "in", "prefLanguage", "if", "no", "language", "specification", "is", "available", "return", "first", "element" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L503-L519
train
lambdamusic/Ontospy
ontospy/core/utils.py
joinStringsInList
def joinStringsInList(literalEntities, prefLanguage="en"): """ from a list of literals, returns the ones in prefLanguage joined up. if the desired language specification is not available, join all up """ match = [] if len(literalEntities) == 1: return literalEntities[0] elif len(lit...
python
def joinStringsInList(literalEntities, prefLanguage="en"): """ from a list of literals, returns the ones in prefLanguage joined up. if the desired language specification is not available, join all up """ match = [] if len(literalEntities) == 1: return literalEntities[0] elif len(lit...
[ "def", "joinStringsInList", "(", "literalEntities", ",", "prefLanguage", "=", "\"en\"", ")", ":", "match", "=", "[", "]", "if", "len", "(", "literalEntities", ")", "==", "1", ":", "return", "literalEntities", "[", "0", "]", "elif", "len", "(", "literalEnti...
from a list of literals, returns the ones in prefLanguage joined up. if the desired language specification is not available, join all up
[ "from", "a", "list", "of", "literals", "returns", "the", "ones", "in", "prefLanguage", "joined", "up", ".", "if", "the", "desired", "language", "specification", "is", "not", "available", "join", "all", "up" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L526-L544
train
lambdamusic/Ontospy
ontospy/core/utils.py
sortByNamespacePrefix
def sortByNamespacePrefix(urisList, nsList): """ Given an ordered list of namespaces prefixes, order a list of uris based on that. Eg In [7]: ll Out[7]: [rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef(u'printGenericTreeorg...
python
def sortByNamespacePrefix(urisList, nsList): """ Given an ordered list of namespaces prefixes, order a list of uris based on that. Eg In [7]: ll Out[7]: [rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef(u'printGenericTreeorg...
[ "def", "sortByNamespacePrefix", "(", "urisList", ",", "nsList", ")", ":", "exit", "=", "[", "]", "urisList", "=", "sort_uri_list_by_name", "(", "urisList", ")", "for", "ns", "in", "nsList", ":", "innerexit", "=", "[", "]", "for", "uri", "in", "urisList", ...
Given an ordered list of namespaces prefixes, order a list of uris based on that. Eg In [7]: ll Out[7]: [rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef(u'printGenericTreeorg/2000/01/rdf-schema#comment'), rdflib.term.URIRef(u'...
[ "Given", "an", "ordered", "list", "of", "namespaces", "prefixes", "order", "a", "list", "of", "uris", "based", "on", "that", ".", "Eg" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L547-L581
train
lambdamusic/Ontospy
ontospy/core/utils.py
sort_uri_list_by_name
def sort_uri_list_by_name(uri_list, bypassNamespace=False): """ Sorts a list of uris bypassNamespace: based on the last bit (usually the name after the namespace) of a uri It checks whether the last bit is specified using a # or just a /, eg: rdflib.URIRef('http://purl.org/on...
python
def sort_uri_list_by_name(uri_list, bypassNamespace=False): """ Sorts a list of uris bypassNamespace: based on the last bit (usually the name after the namespace) of a uri It checks whether the last bit is specified using a # or just a /, eg: rdflib.URIRef('http://purl.org/on...
[ "def", "sort_uri_list_by_name", "(", "uri_list", ",", "bypassNamespace", "=", "False", ")", ":", "def", "get_last_bit", "(", "uri_string", ")", ":", "try", ":", "x", "=", "uri_string", ".", "split", "(", "\"#\"", ")", "[", "1", "]", "except", ":", "x", ...
Sorts a list of uris bypassNamespace: based on the last bit (usually the name after the namespace) of a uri It checks whether the last bit is specified using a # or just a /, eg: rdflib.URIRef('http://purl.org/ontology/mo/Vinyl'), rdflib.URIRef('http://purl.org/vocab/frbr...
[ "Sorts", "a", "list", "of", "uris" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L584-L612
train
lambdamusic/Ontospy
ontospy/core/utils.py
inferNamespacePrefix
def inferNamespacePrefix(aUri): """ From a URI returns the last bit and simulates a namespace prefix when rendering the ontology. eg from <'http://www.w3.org/2008/05/skos#'> it returns the 'skos' string """ stringa = aUri.__str__() try: prefix = stringa.replace("#", "").split("/...
python
def inferNamespacePrefix(aUri): """ From a URI returns the last bit and simulates a namespace prefix when rendering the ontology. eg from <'http://www.w3.org/2008/05/skos#'> it returns the 'skos' string """ stringa = aUri.__str__() try: prefix = stringa.replace("#", "").split("/...
[ "def", "inferNamespacePrefix", "(", "aUri", ")", ":", "stringa", "=", "aUri", ".", "__str__", "(", ")", "try", ":", "prefix", "=", "stringa", ".", "replace", "(", "\"#\"", ",", "\"\"", ")", ".", "split", "(", "\"/\"", ")", "[", "-", "1", "]", "exce...
From a URI returns the last bit and simulates a namespace prefix when rendering the ontology. eg from <'http://www.w3.org/2008/05/skos#'> it returns the 'skos' string
[ "From", "a", "URI", "returns", "the", "last", "bit", "and", "simulates", "a", "namespace", "prefix", "when", "rendering", "the", "ontology", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L636-L648
train
lambdamusic/Ontospy
ontospy/core/utils.py
niceString2uri
def niceString2uri(aUriString, namespaces=None): """ From a string representing a URI possibly with the namespace qname, returns a URI instance. gold:Citation ==> rdflib.term.URIRef(u'http://purl.org/linguistics/gold/Citation') Namespaces are a list [('xml', rdflib.URIRef('http://www.w3.org/XML/...
python
def niceString2uri(aUriString, namespaces=None): """ From a string representing a URI possibly with the namespace qname, returns a URI instance. gold:Citation ==> rdflib.term.URIRef(u'http://purl.org/linguistics/gold/Citation') Namespaces are a list [('xml', rdflib.URIRef('http://www.w3.org/XML/...
[ "def", "niceString2uri", "(", "aUriString", ",", "namespaces", "=", "None", ")", ":", "if", "not", "namespaces", ":", "namespaces", "=", "[", "]", "for", "aNamespaceTuple", "in", "namespaces", ":", "if", "aNamespaceTuple", "[", "0", "]", "and", "aUriString",...
From a string representing a URI possibly with the namespace qname, returns a URI instance. gold:Citation ==> rdflib.term.URIRef(u'http://purl.org/linguistics/gold/Citation') Namespaces are a list [('xml', rdflib.URIRef('http://www.w3.org/XML/1998/namespace')) ('', rdflib.URIRef('http://cohereweb.ne...
[ "From", "a", "string", "representing", "a", "URI", "possibly", "with", "the", "namespace", "qname", "returns", "a", "URI", "instance", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L728-L755
train
lambdamusic/Ontospy
ontospy/core/utils.py
shellPrintOverview
def shellPrintOverview(g, opts={'labels': False}): """ overview of graph invoked from command line @todo add pagination via something like this # import pydoc # pydoc.pager("SOME_VERY_LONG_TEXT") """ ontologies = g.all_ontologies # get opts try: labels = opts['labels']...
python
def shellPrintOverview(g, opts={'labels': False}): """ overview of graph invoked from command line @todo add pagination via something like this # import pydoc # pydoc.pager("SOME_VERY_LONG_TEXT") """ ontologies = g.all_ontologies # get opts try: labels = opts['labels']...
[ "def", "shellPrintOverview", "(", "g", ",", "opts", "=", "{", "'labels'", ":", "False", "}", ")", ":", "ontologies", "=", "g", ".", "all_ontologies", "# get opts", "try", ":", "labels", "=", "opts", "[", "'labels'", "]", "except", ":", "labels", "=", "...
overview of graph invoked from command line @todo add pagination via something like this # import pydoc # pydoc.pager("SOME_VERY_LONG_TEXT")
[ "overview", "of", "graph", "invoked", "from", "command", "line" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L804-L863
train
lambdamusic/Ontospy
ontospy/core/utils.py
try_sort_fmt_opts
def try_sort_fmt_opts(rdf_format_opts_list, uri): """reorder fmt options based on uri file type suffix - if available - so to test most likely serialization first when parsing some RDF NOTE this is not very nice as it is hardcoded and assumes the origin serializations to be this: ['turtle', 'xml', 'n3', 'nt',...
python
def try_sort_fmt_opts(rdf_format_opts_list, uri): """reorder fmt options based on uri file type suffix - if available - so to test most likely serialization first when parsing some RDF NOTE this is not very nice as it is hardcoded and assumes the origin serializations to be this: ['turtle', 'xml', 'n3', 'nt',...
[ "def", "try_sort_fmt_opts", "(", "rdf_format_opts_list", ",", "uri", ")", ":", "filename", ",", "file_extension", "=", "os", ".", "path", ".", "splitext", "(", "uri", ")", "# print(filename, file_extension)", "if", "file_extension", "==", "\".ttl\"", "or", "file_e...
reorder fmt options based on uri file type suffix - if available - so to test most likely serialization first when parsing some RDF NOTE this is not very nice as it is hardcoded and assumes the origin serializations to be this: ['turtle', 'xml', 'n3', 'nt', 'json-ld', 'rdfa']
[ "reorder", "fmt", "options", "based", "on", "uri", "file", "type", "suffix", "-", "if", "available", "-", "so", "to", "test", "most", "likely", "serialization", "first", "when", "parsing", "some", "RDF" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/utils.py#L893-L926
train
lambdamusic/Ontospy
ontospy/ontodocs/builder.py
ask_visualization
def ask_visualization(): """ ask user which viz output to use """ printDebug( "Please choose an output format for the ontology visualization: (q=quit)\n", "important") while True: text = "" for viz in VISUALIZATIONS_LIST: text += "%d) %s\n" % (VISUALIZATIO...
python
def ask_visualization(): """ ask user which viz output to use """ printDebug( "Please choose an output format for the ontology visualization: (q=quit)\n", "important") while True: text = "" for viz in VISUALIZATIONS_LIST: text += "%d) %s\n" % (VISUALIZATIO...
[ "def", "ask_visualization", "(", ")", ":", "printDebug", "(", "\"Please choose an output format for the ontology visualization: (q=quit)\\n\"", ",", "\"important\"", ")", "while", "True", ":", "text", "=", "\"\"", "for", "viz", "in", "VISUALIZATIONS_LIST", ":", "text", ...
ask user which viz output to use
[ "ask", "user", "which", "viz", "output", "to", "use" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/builder.py#L111-L134
train
lambdamusic/Ontospy
ontospy/ontodocs/builder.py
select_visualization
def select_visualization(n): """ get viz choice based on numerical index """ try: n = int(n) - 1 test = VISUALIZATIONS_LIST[n] # throw exception if number wrong return n except: printDebug("Invalid viz-type option. Valid options are:", "red") show_types() ...
python
def select_visualization(n): """ get viz choice based on numerical index """ try: n = int(n) - 1 test = VISUALIZATIONS_LIST[n] # throw exception if number wrong return n except: printDebug("Invalid viz-type option. Valid options are:", "red") show_types() ...
[ "def", "select_visualization", "(", "n", ")", ":", "try", ":", "n", "=", "int", "(", "n", ")", "-", "1", "test", "=", "VISUALIZATIONS_LIST", "[", "n", "]", "# throw exception if number wrong", "return", "n", "except", ":", "printDebug", "(", "\"Invalid viz-t...
get viz choice based on numerical index
[ "get", "viz", "choice", "based", "on", "numerical", "index" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/builder.py#L137-L148
train
lambdamusic/Ontospy
ontospy/core/actions.py
action_analyze
def action_analyze(sources, endpoint=None, print_opts=False, verbose=False, extra=False, raw=False): """ Load up a model into ontospy and analyze it """ for x in sources: click.secho("Parsing...
python
def action_analyze(sources, endpoint=None, print_opts=False, verbose=False, extra=False, raw=False): """ Load up a model into ontospy and analyze it """ for x in sources: click.secho("Parsing...
[ "def", "action_analyze", "(", "sources", ",", "endpoint", "=", "None", ",", "print_opts", "=", "False", ",", "verbose", "=", "False", ",", "extra", "=", "False", ",", "raw", "=", "False", ")", ":", "for", "x", "in", "sources", ":", "click", ".", "sec...
Load up a model into ontospy and analyze it
[ "Load", "up", "a", "model", "into", "ontospy", "and", "analyze", "it" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/actions.py#L64-L111
train
lambdamusic/Ontospy
ontospy/core/actions.py
action_listlocal
def action_listlocal(all_details=True): " select a file from the local repo " options = get_localontologies() counter = 1 # printDebug("------------------", 'comment') if not options: printDebug( "Your local library is empty. Use 'ontospy lib --bootstrap' to add some o...
python
def action_listlocal(all_details=True): " select a file from the local repo " options = get_localontologies() counter = 1 # printDebug("------------------", 'comment') if not options: printDebug( "Your local library is empty. Use 'ontospy lib --bootstrap' to add some o...
[ "def", "action_listlocal", "(", "all_details", "=", "True", ")", ":", "options", "=", "get_localontologies", "(", ")", "counter", "=", "1", "# printDebug(\"------------------\", 'comment')\r", "if", "not", "options", ":", "printDebug", "(", "\"Your local library is empt...
select a file from the local repo
[ "select", "a", "file", "from", "the", "local", "repo" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/actions.py#L156-L192
train
lambdamusic/Ontospy
ontospy/core/actions.py
action_import
def action_import(location, verbose=True): """ Import files into the local repo """ location = str(location) # prevent errors from unicode being passed # 1) extract file from location and save locally ONTOSPY_LOCAL_MODELS = get_home_location() fullpath = "" try: i...
python
def action_import(location, verbose=True): """ Import files into the local repo """ location = str(location) # prevent errors from unicode being passed # 1) extract file from location and save locally ONTOSPY_LOCAL_MODELS = get_home_location() fullpath = "" try: i...
[ "def", "action_import", "(", "location", ",", "verbose", "=", "True", ")", ":", "location", "=", "str", "(", "location", ")", "# prevent errors from unicode being passed\r", "# 1) extract file from location and save locally\r", "ONTOSPY_LOCAL_MODELS", "=", "get_home_location"...
Import files into the local repo
[ "Import", "files", "into", "the", "local", "repo" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/actions.py#L243-L316
train
lambdamusic/Ontospy
ontospy/core/actions.py
action_import_folder
def action_import_folder(location): """Try to import all files from a local folder""" if os.path.isdir(location): onlyfiles = [ f for f in os.listdir(location) if os.path.isfile(os.path.join(location, f)) ] for file in onlyfiles: if not file....
python
def action_import_folder(location): """Try to import all files from a local folder""" if os.path.isdir(location): onlyfiles = [ f for f in os.listdir(location) if os.path.isfile(os.path.join(location, f)) ] for file in onlyfiles: if not file....
[ "def", "action_import_folder", "(", "location", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "location", ")", ":", "onlyfiles", "=", "[", "f", "for", "f", "in", "os", ".", "listdir", "(", "location", ")", "if", "os", ".", "path", ".", "isf...
Try to import all files from a local folder
[ "Try", "to", "import", "all", "files", "from", "a", "local", "folder" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/actions.py#L319-L336
train
lambdamusic/Ontospy
ontospy/core/actions.py
action_webimport
def action_webimport(hrlinetop=False): """ select from the available online directories for import """ DIR_OPTIONS = {1: "http://lov.okfn.org", 2: "http://prefix.cc/popular/"} selection = None while True: if hrlinetop: printDebug("----------") text = "Please select whi...
python
def action_webimport(hrlinetop=False): """ select from the available online directories for import """ DIR_OPTIONS = {1: "http://lov.okfn.org", 2: "http://prefix.cc/popular/"} selection = None while True: if hrlinetop: printDebug("----------") text = "Please select whi...
[ "def", "action_webimport", "(", "hrlinetop", "=", "False", ")", ":", "DIR_OPTIONS", "=", "{", "1", ":", "\"http://lov.okfn.org\"", ",", "2", ":", "\"http://prefix.cc/popular/\"", "}", "selection", "=", "None", "while", "True", ":", "if", "hrlinetop", ":", "pri...
select from the available online directories for import
[ "select", "from", "the", "available", "online", "directories", "for", "import" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/actions.py#L339-L374
train
lambdamusic/Ontospy
ontospy/core/actions.py
action_bootstrap
def action_bootstrap(verbose=False): """Bootstrap the local REPO with a few cool ontologies""" printDebug("The following ontologies will be imported:") printDebug("--------------") count = 0 for s in BOOTSTRAP_ONTOLOGIES: count += 1 print(count, "<%s>" % s) printDebug("...
python
def action_bootstrap(verbose=False): """Bootstrap the local REPO with a few cool ontologies""" printDebug("The following ontologies will be imported:") printDebug("--------------") count = 0 for s in BOOTSTRAP_ONTOLOGIES: count += 1 print(count, "<%s>" % s) printDebug("...
[ "def", "action_bootstrap", "(", "verbose", "=", "False", ")", ":", "printDebug", "(", "\"The following ontologies will be imported:\"", ")", "printDebug", "(", "\"--------------\"", ")", "count", "=", "0", "for", "s", "in", "BOOTSTRAP_ONTOLOGIES", ":", "count", "+="...
Bootstrap the local REPO with a few cool ontologies
[ "Bootstrap", "the", "local", "REPO", "with", "a", "few", "cool", "ontologies" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/actions.py#L487-L514
train
lambdamusic/Ontospy
ontospy/core/actions.py
action_update_library_location
def action_update_library_location(_location): """ Sets the folder that contains models for the local library @todo: add options to move things over etc.. note: this is called from 'manager' """ # if not(os.path.exists(_location)): # os.mkdir(_location) # printDebug("Creating...
python
def action_update_library_location(_location): """ Sets the folder that contains models for the local library @todo: add options to move things over etc.. note: this is called from 'manager' """ # if not(os.path.exists(_location)): # os.mkdir(_location) # printDebug("Creating...
[ "def", "action_update_library_location", "(", "_location", ")", ":", "# if not(os.path.exists(_location)):\r", "# \tos.mkdir(_location)\r", "# \tprintDebug(\"Creating new folder..\", \"comment\")\r", "printDebug", "(", "\"Old location: '%s'\"", "%", "get_home_location", "(", ")", ","...
Sets the folder that contains models for the local library @todo: add options to move things over etc.. note: this is called from 'manager'
[ "Sets", "the", "folder", "that", "contains", "models", "for", "the", "local", "library" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/actions.py#L517-L545
train
lambdamusic/Ontospy
ontospy/core/actions.py
action_cache_reset
def action_cache_reset(): """ Delete all contents from cache folder Then re-generate cached version of all models in the local repo """ printDebug("""The existing cache will be erased and recreated.""") printDebug( """This operation may take several minutes, depending on how man...
python
def action_cache_reset(): """ Delete all contents from cache folder Then re-generate cached version of all models in the local repo """ printDebug("""The existing cache will be erased and recreated.""") printDebug( """This operation may take several minutes, depending on how man...
[ "def", "action_cache_reset", "(", ")", ":", "printDebug", "(", "\"\"\"The existing cache will be erased and recreated.\"\"\"", ")", "printDebug", "(", "\"\"\"This operation may take several minutes, depending on how many files exist in your local library.\"\"\"", ")", "ONTOSPY_LOCAL_MODELS...
Delete all contents from cache folder Then re-generate cached version of all models in the local repo
[ "Delete", "all", "contents", "from", "cache", "folder", "Then", "re", "-", "generate", "cached", "version", "of", "all", "models", "in", "the", "local", "repo" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/actions.py#L548-L589
train
gabrielfalcao/sure
sure/core.py
DeepComparison.compare_ordereddict
def compare_ordereddict(self, X, Y): """Compares two instances of an OrderedDict.""" # check if OrderedDict instances have the same keys and values child = self.compare_dicts(X, Y) if isinstance(child, DeepExplanation): return child # check if the order of the keys ...
python
def compare_ordereddict(self, X, Y): """Compares two instances of an OrderedDict.""" # check if OrderedDict instances have the same keys and values child = self.compare_dicts(X, Y) if isinstance(child, DeepExplanation): return child # check if the order of the keys ...
[ "def", "compare_ordereddict", "(", "self", ",", "X", ",", "Y", ")", ":", "# check if OrderedDict instances have the same keys and values", "child", "=", "self", ".", "compare_dicts", "(", "X", ",", "Y", ")", "if", "isinstance", "(", "child", ",", "DeepExplanation"...
Compares two instances of an OrderedDict.
[ "Compares", "two", "instances", "of", "an", "OrderedDict", "." ]
ac23b6b87306ec502b8719534ab23965d97a95f9
https://github.com/gabrielfalcao/sure/blob/ac23b6b87306ec502b8719534ab23965d97a95f9/sure/core.py#L146-L162
train
gabrielfalcao/sure
sure/stubs.py
stub
def stub(base_class=None, **attributes): """creates a python class on-the-fly with the given keyword-arguments as class-attributes accessible with .attrname. The new class inherits from Use this to mock rather than stub. """ if base_class is None: base_class = object members = { ...
python
def stub(base_class=None, **attributes): """creates a python class on-the-fly with the given keyword-arguments as class-attributes accessible with .attrname. The new class inherits from Use this to mock rather than stub. """ if base_class is None: base_class = object members = { ...
[ "def", "stub", "(", "base_class", "=", "None", ",", "*", "*", "attributes", ")", ":", "if", "base_class", "is", "None", ":", "base_class", "=", "object", "members", "=", "{", "\"__init__\"", ":", "lambda", "self", ":", "None", ",", "\"__new__\"", ":", ...
creates a python class on-the-fly with the given keyword-arguments as class-attributes accessible with .attrname. The new class inherits from Use this to mock rather than stub.
[ "creates", "a", "python", "class", "on", "-", "the", "-", "fly", "with", "the", "given", "keyword", "-", "arguments", "as", "class", "-", "attributes", "accessible", "with", ".", "attrname", "." ]
ac23b6b87306ec502b8719534ab23965d97a95f9
https://github.com/gabrielfalcao/sure/blob/ac23b6b87306ec502b8719534ab23965d97a95f9/sure/stubs.py#L19-L38
train
gabrielfalcao/sure
sure/__init__.py
assertion
def assertion(func): """Extend sure with a custom assertion method.""" func = assertionmethod(func) setattr(AssertionBuilder, func.__name__, func) return func
python
def assertion(func): """Extend sure with a custom assertion method.""" func = assertionmethod(func) setattr(AssertionBuilder, func.__name__, func) return func
[ "def", "assertion", "(", "func", ")", ":", "func", "=", "assertionmethod", "(", "func", ")", "setattr", "(", "AssertionBuilder", ",", "func", ".", "__name__", ",", "func", ")", "return", "func" ]
Extend sure with a custom assertion method.
[ "Extend", "sure", "with", "a", "custom", "assertion", "method", "." ]
ac23b6b87306ec502b8719534ab23965d97a95f9
https://github.com/gabrielfalcao/sure/blob/ac23b6b87306ec502b8719534ab23965d97a95f9/sure/__init__.py#L928-L932
train
gabrielfalcao/sure
sure/__init__.py
chainproperty
def chainproperty(func): """Extend sure with a custom chain property.""" func = assertionproperty(func) setattr(AssertionBuilder, func.fget.__name__, func) return func
python
def chainproperty(func): """Extend sure with a custom chain property.""" func = assertionproperty(func) setattr(AssertionBuilder, func.fget.__name__, func) return func
[ "def", "chainproperty", "(", "func", ")", ":", "func", "=", "assertionproperty", "(", "func", ")", "setattr", "(", "AssertionBuilder", ",", "func", ".", "fget", ".", "__name__", ",", "func", ")", "return", "func" ]
Extend sure with a custom chain property.
[ "Extend", "sure", "with", "a", "custom", "chain", "property", "." ]
ac23b6b87306ec502b8719534ab23965d97a95f9
https://github.com/gabrielfalcao/sure/blob/ac23b6b87306ec502b8719534ab23965d97a95f9/sure/__init__.py#L941-L945
train
gabrielfalcao/sure
sure/__init__.py
AssertionBuilder.equal
def equal(self, what, epsilon=None): """compares given object ``X`` with an expected ``Y`` object. It primarily assures that the compared objects are absolute equal ``==``. :param what: the expected value :param epsilon: a delta to leverage upper-bound floating point permissiveness ...
python
def equal(self, what, epsilon=None): """compares given object ``X`` with an expected ``Y`` object. It primarily assures that the compared objects are absolute equal ``==``. :param what: the expected value :param epsilon: a delta to leverage upper-bound floating point permissiveness ...
[ "def", "equal", "(", "self", ",", "what", ",", "epsilon", "=", "None", ")", ":", "try", ":", "comparison", "=", "DeepComparison", "(", "self", ".", "obj", ",", "what", ",", "epsilon", ")", ".", "compare", "(", ")", "error", "=", "False", "except", ...
compares given object ``X`` with an expected ``Y`` object. It primarily assures that the compared objects are absolute equal ``==``. :param what: the expected value :param epsilon: a delta to leverage upper-bound floating point permissiveness
[ "compares", "given", "object", "X", "with", "an", "expected", "Y", "object", "." ]
ac23b6b87306ec502b8719534ab23965d97a95f9
https://github.com/gabrielfalcao/sure/blob/ac23b6b87306ec502b8719534ab23965d97a95f9/sure/__init__.py#L644-L673
train
aspiers/git-deps
git_deps/detector.py
DependencyDetector.find_dependencies
def find_dependencies(self, dependent_rev, recurse=None): """Find all dependencies of the given revision, recursively traversing the dependency tree if requested. """ if recurse is None: recurse = self.options.recurse try: dependent = self.get_commit(depe...
python
def find_dependencies(self, dependent_rev, recurse=None): """Find all dependencies of the given revision, recursively traversing the dependency tree if requested. """ if recurse is None: recurse = self.options.recurse try: dependent = self.get_commit(depe...
[ "def", "find_dependencies", "(", "self", ",", "dependent_rev", ",", "recurse", "=", "None", ")", ":", "if", "recurse", "is", "None", ":", "recurse", "=", "self", ".", "options", ".", "recurse", "try", ":", "dependent", "=", "self", ".", "get_commit", "("...
Find all dependencies of the given revision, recursively traversing the dependency tree if requested.
[ "Find", "all", "dependencies", "of", "the", "given", "revision", "recursively", "traversing", "the", "dependency", "tree", "if", "requested", "." ]
a00380b8bf1451d8c3405dace8d5927428506eb0
https://github.com/aspiers/git-deps/blob/a00380b8bf1451d8c3405dace8d5927428506eb0/git_deps/detector.py#L84-L132
train
aspiers/git-deps
git_deps/detector.py
DependencyDetector.find_dependencies_with_parent
def find_dependencies_with_parent(self, dependent, parent): """Find all dependencies of the given revision caused by the given parent commit. This will be called multiple times for merge commits which have multiple parents. """ self.logger.info(" Finding dependencies of %s vi...
python
def find_dependencies_with_parent(self, dependent, parent): """Find all dependencies of the given revision caused by the given parent commit. This will be called multiple times for merge commits which have multiple parents. """ self.logger.info(" Finding dependencies of %s vi...
[ "def", "find_dependencies_with_parent", "(", "self", ",", "dependent", ",", "parent", ")", ":", "self", ".", "logger", ".", "info", "(", "\" Finding dependencies of %s via parent %s\"", "%", "(", "dependent", ".", "hex", "[", ":", "8", "]", ",", "parent", "...
Find all dependencies of the given revision caused by the given parent commit. This will be called multiple times for merge commits which have multiple parents.
[ "Find", "all", "dependencies", "of", "the", "given", "revision", "caused", "by", "the", "given", "parent", "commit", ".", "This", "will", "be", "called", "multiple", "times", "for", "merge", "commits", "which", "have", "multiple", "parents", "." ]
a00380b8bf1451d8c3405dace8d5927428506eb0
https://github.com/aspiers/git-deps/blob/a00380b8bf1451d8c3405dace8d5927428506eb0/git_deps/detector.py#L134-L147
train
aspiers/git-deps
git_deps/detector.py
DependencyDetector.blame_diff_hunk
def blame_diff_hunk(self, dependent, parent, path, hunk): """Run git blame on the parts of the hunk which exist in the older commit in the diff. The commits generated by git blame are the commits which the newer commit in the diff depends on, because without the lines from those commits...
python
def blame_diff_hunk(self, dependent, parent, path, hunk): """Run git blame on the parts of the hunk which exist in the older commit in the diff. The commits generated by git blame are the commits which the newer commit in the diff depends on, because without the lines from those commits...
[ "def", "blame_diff_hunk", "(", "self", ",", "dependent", ",", "parent", ",", "path", ",", "hunk", ")", ":", "line_range_before", "=", "\"-%d,%d\"", "%", "(", "hunk", ".", "old_start", ",", "hunk", ".", "old_lines", ")", "line_range_after", "=", "\"+%d,%d\"",...
Run git blame on the parts of the hunk which exist in the older commit in the diff. The commits generated by git blame are the commits which the newer commit in the diff depends on, because without the lines from those commits, the hunk would not apply correctly.
[ "Run", "git", "blame", "on", "the", "parts", "of", "the", "hunk", "which", "exist", "in", "the", "older", "commit", "in", "the", "diff", ".", "The", "commits", "generated", "by", "git", "blame", "are", "the", "commits", "which", "the", "newer", "commit",...
a00380b8bf1451d8c3405dace8d5927428506eb0
https://github.com/aspiers/git-deps/blob/a00380b8bf1451d8c3405dace8d5927428506eb0/git_deps/detector.py#L149-L178
train
aspiers/git-deps
git_deps/detector.py
DependencyDetector.tree_lookup
def tree_lookup(self, target_path, commit): """Navigate to the tree or blob object pointed to by the given target path for the given commit. This is necessary because each git tree only contains entries for the directory it refers to, not recursively for all subdirectories. """ ...
python
def tree_lookup(self, target_path, commit): """Navigate to the tree or blob object pointed to by the given target path for the given commit. This is necessary because each git tree only contains entries for the directory it refers to, not recursively for all subdirectories. """ ...
[ "def", "tree_lookup", "(", "self", ",", "target_path", ",", "commit", ")", ":", "segments", "=", "target_path", ".", "split", "(", "\"/\"", ")", "tree_or_blob", "=", "commit", ".", "tree", "path", "=", "''", "while", "segments", ":", "dirent", "=", "segm...
Navigate to the tree or blob object pointed to by the given target path for the given commit. This is necessary because each git tree only contains entries for the directory it refers to, not recursively for all subdirectories.
[ "Navigate", "to", "the", "tree", "or", "blob", "object", "pointed", "to", "by", "the", "given", "target", "path", "for", "the", "given", "commit", ".", "This", "is", "necessary", "because", "each", "git", "tree", "only", "contains", "entries", "for", "the"...
a00380b8bf1451d8c3405dace8d5927428506eb0
https://github.com/aspiers/git-deps/blob/a00380b8bf1451d8c3405dace8d5927428506eb0/git_deps/detector.py#L331-L359
train
aspiers/git-deps
git_deps/gitutils.py
GitUtils.abbreviate_sha1
def abbreviate_sha1(cls, sha1): """Uniquely abbreviates the given SHA1.""" # For now we invoke git-rev-parse(1), but hopefully eventually # we will be able to do this via pygit2. cmd = ['git', 'rev-parse', '--short', sha1] # cls.logger.debug(" ".join(cmd)) out = subproce...
python
def abbreviate_sha1(cls, sha1): """Uniquely abbreviates the given SHA1.""" # For now we invoke git-rev-parse(1), but hopefully eventually # we will be able to do this via pygit2. cmd = ['git', 'rev-parse', '--short', sha1] # cls.logger.debug(" ".join(cmd)) out = subproce...
[ "def", "abbreviate_sha1", "(", "cls", ",", "sha1", ")", ":", "# For now we invoke git-rev-parse(1), but hopefully eventually", "# we will be able to do this via pygit2.", "cmd", "=", "[", "'git'", ",", "'rev-parse'", ",", "'--short'", ",", "sha1", "]", "# cls.logger.debug(\...
Uniquely abbreviates the given SHA1.
[ "Uniquely", "abbreviates", "the", "given", "SHA1", "." ]
a00380b8bf1451d8c3405dace8d5927428506eb0
https://github.com/aspiers/git-deps/blob/a00380b8bf1451d8c3405dace8d5927428506eb0/git_deps/gitutils.py#L11-L20
train
aspiers/git-deps
git_deps/gitutils.py
GitUtils.describe
def describe(cls, sha1): """Returns a human-readable representation of the given SHA1.""" # For now we invoke git-describe(1), but eventually we will be # able to do this via pygit2, since libgit2 already provides # an API for this: # https://github.com/libgit2/pygit2/pull/459...
python
def describe(cls, sha1): """Returns a human-readable representation of the given SHA1.""" # For now we invoke git-describe(1), but eventually we will be # able to do this via pygit2, since libgit2 already provides # an API for this: # https://github.com/libgit2/pygit2/pull/459...
[ "def", "describe", "(", "cls", ",", "sha1", ")", ":", "# For now we invoke git-describe(1), but eventually we will be", "# able to do this via pygit2, since libgit2 already provides", "# an API for this:", "# https://github.com/libgit2/pygit2/pull/459#issuecomment-68866929", "# https://g...
Returns a human-readable representation of the given SHA1.
[ "Returns", "a", "human", "-", "readable", "representation", "of", "the", "given", "SHA1", "." ]
a00380b8bf1451d8c3405dace8d5927428506eb0
https://github.com/aspiers/git-deps/blob/a00380b8bf1451d8c3405dace8d5927428506eb0/git_deps/gitutils.py#L23-L54
train
aspiers/git-deps
git_deps/gitutils.py
GitUtils.refs_to
def refs_to(cls, sha1, repo): """Returns all refs pointing to the given SHA1.""" matching = [] for refname in repo.listall_references(): symref = repo.lookup_reference(refname) dref = symref.resolve() oid = dref.target commit = repo.get(oid) ...
python
def refs_to(cls, sha1, repo): """Returns all refs pointing to the given SHA1.""" matching = [] for refname in repo.listall_references(): symref = repo.lookup_reference(refname) dref = symref.resolve() oid = dref.target commit = repo.get(oid) ...
[ "def", "refs_to", "(", "cls", ",", "sha1", ",", "repo", ")", ":", "matching", "=", "[", "]", "for", "refname", "in", "repo", ".", "listall_references", "(", ")", ":", "symref", "=", "repo", ".", "lookup_reference", "(", "refname", ")", "dref", "=", "...
Returns all refs pointing to the given SHA1.
[ "Returns", "all", "refs", "pointing", "to", "the", "given", "SHA1", "." ]
a00380b8bf1451d8c3405dace8d5927428506eb0
https://github.com/aspiers/git-deps/blob/a00380b8bf1451d8c3405dace8d5927428506eb0/git_deps/gitutils.py#L69-L80
train
aspiers/git-deps
git_deps/listener/json.py
JSONDependencyListener.add_commit
def add_commit(self, commit): """Adds the commit to the commits array if it doesn't already exist, and returns the commit's index in the array. """ sha1 = commit.hex if sha1 in self._commits: return self._commits[sha1] title, separator, body = commit.message.p...
python
def add_commit(self, commit): """Adds the commit to the commits array if it doesn't already exist, and returns the commit's index in the array. """ sha1 = commit.hex if sha1 in self._commits: return self._commits[sha1] title, separator, body = commit.message.p...
[ "def", "add_commit", "(", "self", ",", "commit", ")", ":", "sha1", "=", "commit", ".", "hex", "if", "sha1", "in", "self", ".", "_commits", ":", "return", "self", ".", "_commits", "[", "sha1", "]", "title", ",", "separator", ",", "body", "=", "commit"...
Adds the commit to the commits array if it doesn't already exist, and returns the commit's index in the array.
[ "Adds", "the", "commit", "to", "the", "commits", "array", "if", "it", "doesn", "t", "already", "exist", "and", "returns", "the", "commit", "s", "index", "in", "the", "array", "." ]
a00380b8bf1451d8c3405dace8d5927428506eb0
https://github.com/aspiers/git-deps/blob/a00380b8bf1451d8c3405dace8d5927428506eb0/git_deps/listener/json.py#L30-L59
train
gocardless/gocardless-pro-python
gocardless_pro/api_client.py
ApiClient.get
def get(self, path, params=None, headers=None): """Perform a GET request, optionally providing query-string params. Args: path (str): A path that gets appended to ``base_url``. params (dict, optional): Dictionary of param names to values. Example: api_client.get('...
python
def get(self, path, params=None, headers=None): """Perform a GET request, optionally providing query-string params. Args: path (str): A path that gets appended to ``base_url``. params (dict, optional): Dictionary of param names to values. Example: api_client.get('...
[ "def", "get", "(", "self", ",", "path", ",", "params", "=", "None", ",", "headers", "=", "None", ")", ":", "response", "=", "requests", ".", "get", "(", "self", ".", "_url_for", "(", "path", ")", ",", "params", "=", "params", ",", "headers", "=", ...
Perform a GET request, optionally providing query-string params. Args: path (str): A path that gets appended to ``base_url``. params (dict, optional): Dictionary of param names to values. Example: api_client.get('/users', params={'active': True}) Returns: ...
[ "Perform", "a", "GET", "request", "optionally", "providing", "query", "-", "string", "params", "." ]
7b57f037d14875eea8d659084eeb524f3ce17f4a
https://github.com/gocardless/gocardless-pro-python/blob/7b57f037d14875eea8d659084eeb524f3ce17f4a/gocardless_pro/api_client.py#L30-L49
train
gocardless/gocardless-pro-python
gocardless_pro/api_client.py
ApiClient.post
def post(self, path, body, headers=None): """Perform a POST request, providing a body, which will be JSON-encoded. Args: path (str): A path that gets appended to ``base_url``. body (dict): Dictionary that will be JSON-encoded and sent as the body. Example: api_cli...
python
def post(self, path, body, headers=None): """Perform a POST request, providing a body, which will be JSON-encoded. Args: path (str): A path that gets appended to ``base_url``. body (dict): Dictionary that will be JSON-encoded and sent as the body. Example: api_cli...
[ "def", "post", "(", "self", ",", "path", ",", "body", ",", "headers", "=", "None", ")", ":", "response", "=", "requests", ".", "post", "(", "self", ".", "_url_for", "(", "path", ")", ",", "data", "=", "json", ".", "dumps", "(", "body", ")", ",", ...
Perform a POST request, providing a body, which will be JSON-encoded. Args: path (str): A path that gets appended to ``base_url``. body (dict): Dictionary that will be JSON-encoded and sent as the body. Example: api_client.post('/users', body={'name': 'Billy Jean'}) ...
[ "Perform", "a", "POST", "request", "providing", "a", "body", "which", "will", "be", "JSON", "-", "encoded", "." ]
7b57f037d14875eea8d659084eeb524f3ce17f4a
https://github.com/gocardless/gocardless-pro-python/blob/7b57f037d14875eea8d659084eeb524f3ce17f4a/gocardless_pro/api_client.py#L51-L71
train
gocardless/gocardless-pro-python
gocardless_pro/services/creditor_bank_accounts_service.py
CreditorBankAccountsService.create
def create(self,params=None, headers=None): """Create a creditor bank account. Creates a new creditor bank account object. Args: params (dict, optional): Request body. Returns: ListResponse of CreditorBankAccount instances """ path = '/credi...
python
def create(self,params=None, headers=None): """Create a creditor bank account. Creates a new creditor bank account object. Args: params (dict, optional): Request body. Returns: ListResponse of CreditorBankAccount instances """ path = '/credi...
[ "def", "create", "(", "self", ",", "params", "=", "None", ",", "headers", "=", "None", ")", ":", "path", "=", "'/creditor_bank_accounts'", "if", "params", "is", "not", "None", ":", "params", "=", "{", "self", ".", "_envelope_key", "(", ")", ":", "param...
Create a creditor bank account. Creates a new creditor bank account object. Args: params (dict, optional): Request body. Returns: ListResponse of CreditorBankAccount instances
[ "Create", "a", "creditor", "bank", "account", "." ]
7b57f037d14875eea8d659084eeb524f3ce17f4a
https://github.com/gocardless/gocardless-pro-python/blob/7b57f037d14875eea8d659084eeb524f3ce17f4a/gocardless_pro/services/creditor_bank_accounts_service.py#L20-L43
train
gocardless/gocardless-pro-python
gocardless_pro/services/creditor_bank_accounts_service.py
CreditorBankAccountsService.list
def list(self,params=None, headers=None): """List creditor bank accounts. Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your creditor bank accounts. Args: params (dict, optional): Query string parameters. Returns: CreditorBankAc...
python
def list(self,params=None, headers=None): """List creditor bank accounts. Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your creditor bank accounts. Args: params (dict, optional): Query string parameters. Returns: CreditorBankAc...
[ "def", "list", "(", "self", ",", "params", "=", "None", ",", "headers", "=", "None", ")", ":", "path", "=", "'/creditor_bank_accounts'", "response", "=", "self", ".", "_perform_request", "(", "'GET'", ",", "path", ",", "params", ",", "headers", ",", "ret...
List creditor bank accounts. Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your creditor bank accounts. Args: params (dict, optional): Query string parameters. Returns: CreditorBankAccount
[ "List", "creditor", "bank", "accounts", "." ]
7b57f037d14875eea8d659084eeb524f3ce17f4a
https://github.com/gocardless/gocardless-pro-python/blob/7b57f037d14875eea8d659084eeb524f3ce17f4a/gocardless_pro/services/creditor_bank_accounts_service.py#L46-L63
train
gocardless/gocardless-pro-python
gocardless_pro/services/creditor_bank_accounts_service.py
CreditorBankAccountsService.get
def get(self,identity,params=None, headers=None): """Get a single creditor bank account. Retrieves the details of an existing creditor bank account. Args: identity (string): Unique identifier, beginning with "BA". params (dict, optional): Query string parameters. ...
python
def get(self,identity,params=None, headers=None): """Get a single creditor bank account. Retrieves the details of an existing creditor bank account. Args: identity (string): Unique identifier, beginning with "BA". params (dict, optional): Query string parameters. ...
[ "def", "get", "(", "self", ",", "identity", ",", "params", "=", "None", ",", "headers", "=", "None", ")", ":", "path", "=", "self", ".", "_sub_url_params", "(", "'/creditor_bank_accounts/:identity'", ",", "{", "'identity'", ":", "identity", ",", "}", ")", ...
Get a single creditor bank account. Retrieves the details of an existing creditor bank account. Args: identity (string): Unique identifier, beginning with "BA". params (dict, optional): Query string parameters. Returns: ListResponse of CreditorBankAcc...
[ "Get", "a", "single", "creditor", "bank", "account", "." ]
7b57f037d14875eea8d659084eeb524f3ce17f4a
https://github.com/gocardless/gocardless-pro-python/blob/7b57f037d14875eea8d659084eeb524f3ce17f4a/gocardless_pro/services/creditor_bank_accounts_service.py#L72-L92
train
gocardless/gocardless-pro-python
gocardless_pro/services/creditor_bank_accounts_service.py
CreditorBankAccountsService.disable
def disable(self,identity,params=None, headers=None): """Disable a creditor bank account. Immediately disables the bank account, no money can be paid out to a disabled account. This will return a `disable_failed` error if the bank account has already been disabled. ...
python
def disable(self,identity,params=None, headers=None): """Disable a creditor bank account. Immediately disables the bank account, no money can be paid out to a disabled account. This will return a `disable_failed` error if the bank account has already been disabled. ...
[ "def", "disable", "(", "self", ",", "identity", ",", "params", "=", "None", ",", "headers", "=", "None", ")", ":", "path", "=", "self", ".", "_sub_url_params", "(", "'/creditor_bank_accounts/:identity/actions/disable'", ",", "{", "'identity'", ":", "identity", ...
Disable a creditor bank account. Immediately disables the bank account, no money can be paid out to a disabled account. This will return a `disable_failed` error if the bank account has already been disabled. A disabled bank account can be re-enabled by creatin...
[ "Disable", "a", "creditor", "bank", "account", "." ]
7b57f037d14875eea8d659084eeb524f3ce17f4a
https://github.com/gocardless/gocardless-pro-python/blob/7b57f037d14875eea8d659084eeb524f3ce17f4a/gocardless_pro/services/creditor_bank_accounts_service.py#L95-L123
train
gocardless/gocardless-pro-python
gocardless_pro/services/mandate_pdfs_service.py
MandatePdfsService.create
def create(self,params=None, headers=None): """Create a mandate PDF. Generates a PDF mandate and returns its temporary URL. Customer and bank account details can be left blank (for a blank mandate), provided manually, or inferred from the ID of an existing [mandate](#co...
python
def create(self,params=None, headers=None): """Create a mandate PDF. Generates a PDF mandate and returns its temporary URL. Customer and bank account details can be left blank (for a blank mandate), provided manually, or inferred from the ID of an existing [mandate](#co...
[ "def", "create", "(", "self", ",", "params", "=", "None", ",", "headers", "=", "None", ")", ":", "path", "=", "'/mandate_pdfs'", "if", "params", "is", "not", "None", ":", "params", "=", "{", "self", ".", "_envelope_key", "(", ")", ":", "params", "}",...
Create a mandate PDF. Generates a PDF mandate and returns its temporary URL. Customer and bank account details can be left blank (for a blank mandate), provided manually, or inferred from the ID of an existing [mandate](#core-endpoints-mandates). By default, we...
[ "Create", "a", "mandate", "PDF", "." ]
7b57f037d14875eea8d659084eeb524f3ce17f4a
https://github.com/gocardless/gocardless-pro-python/blob/7b57f037d14875eea8d659084eeb524f3ce17f4a/gocardless_pro/services/mandate_pdfs_service.py#L20-L77
train
gocardless/gocardless-pro-python
gocardless_pro/services/payments_service.py
PaymentsService.update
def update(self,identity,params=None, headers=None): """Update a payment. Updates a payment object. This accepts only the metadata parameter. Args: identity (string): Unique identifier, beginning with "PM". params (dict, optional): Request body. Returns: ...
python
def update(self,identity,params=None, headers=None): """Update a payment. Updates a payment object. This accepts only the metadata parameter. Args: identity (string): Unique identifier, beginning with "PM". params (dict, optional): Request body. Returns: ...
[ "def", "update", "(", "self", ",", "identity", ",", "params", "=", "None", ",", "headers", "=", "None", ")", ":", "path", "=", "self", ".", "_sub_url_params", "(", "'/payments/:identity'", ",", "{", "'identity'", ":", "identity", ",", "}", ")", "if", "...
Update a payment. Updates a payment object. This accepts only the metadata parameter. Args: identity (string): Unique identifier, beginning with "PM". params (dict, optional): Request body. Returns: ListResponse of Payment instances
[ "Update", "a", "payment", "." ]
7b57f037d14875eea8d659084eeb524f3ce17f4a
https://github.com/gocardless/gocardless-pro-python/blob/7b57f037d14875eea8d659084eeb524f3ce17f4a/gocardless_pro/services/payments_service.py#L101-L123
train
prashnts/hues
hues/console.py
Config.resolve_config
def resolve_config(self): '''Resolve configuration params to native instances''' conf = self.load_config(self.force_default) for k in conf['hues']: conf['hues'][k] = getattr(KEYWORDS, conf['hues'][k]) as_tuples = lambda name, obj: namedtuple(name, obj.keys())(**obj) self.hues = as_tuples('Hue...
python
def resolve_config(self): '''Resolve configuration params to native instances''' conf = self.load_config(self.force_default) for k in conf['hues']: conf['hues'][k] = getattr(KEYWORDS, conf['hues'][k]) as_tuples = lambda name, obj: namedtuple(name, obj.keys())(**obj) self.hues = as_tuples('Hue...
[ "def", "resolve_config", "(", "self", ")", ":", "conf", "=", "self", ".", "load_config", "(", "self", ".", "force_default", ")", "for", "k", "in", "conf", "[", "'hues'", "]", ":", "conf", "[", "'hues'", "]", "[", "k", "]", "=", "getattr", "(", "KEY...
Resolve configuration params to native instances
[ "Resolve", "configuration", "params", "to", "native", "instances" ]
888049a41e3f2bf33546e53ef3c17494ee8c8790
https://github.com/prashnts/hues/blob/888049a41e3f2bf33546e53ef3c17494ee8c8790/hues/console.py#L72-L81
train
prashnts/hues
hues/dpda.py
apply
def apply(funcs, stack): '''Apply functions to the stack, passing the resulting stack to next state.''' return reduce(lambda x, y: y(x), funcs, stack)
python
def apply(funcs, stack): '''Apply functions to the stack, passing the resulting stack to next state.''' return reduce(lambda x, y: y(x), funcs, stack)
[ "def", "apply", "(", "funcs", ",", "stack", ")", ":", "return", "reduce", "(", "lambda", "x", ",", "y", ":", "y", "(", "x", ")", ",", "funcs", ",", "stack", ")" ]
Apply functions to the stack, passing the resulting stack to next state.
[ "Apply", "functions", "to", "the", "stack", "passing", "the", "resulting", "stack", "to", "next", "state", "." ]
888049a41e3f2bf33546e53ef3c17494ee8c8790
https://github.com/prashnts/hues/blob/888049a41e3f2bf33546e53ef3c17494ee8c8790/hues/dpda.py#L41-L43
train
prashnts/hues
hues/huestr.py
colorize
def colorize(string, stack): '''Apply optimal ANSI escape sequences to the string.''' codes = optimize(stack) if len(codes): prefix = SEQ % ';'.join(map(str, codes)) suffix = SEQ % STYLE.reset return prefix + string + suffix else: return string
python
def colorize(string, stack): '''Apply optimal ANSI escape sequences to the string.''' codes = optimize(stack) if len(codes): prefix = SEQ % ';'.join(map(str, codes)) suffix = SEQ % STYLE.reset return prefix + string + suffix else: return string
[ "def", "colorize", "(", "string", ",", "stack", ")", ":", "codes", "=", "optimize", "(", "stack", ")", "if", "len", "(", "codes", ")", ":", "prefix", "=", "SEQ", "%", "';'", ".", "join", "(", "map", "(", "str", ",", "codes", ")", ")", "suffix", ...
Apply optimal ANSI escape sequences to the string.
[ "Apply", "optimal", "ANSI", "escape", "sequences", "to", "the", "string", "." ]
888049a41e3f2bf33546e53ef3c17494ee8c8790
https://github.com/prashnts/hues/blob/888049a41e3f2bf33546e53ef3c17494ee8c8790/hues/huestr.py#L21-L29
train
SpikeInterface/spiketoolkit
spiketoolkit/comparison/comparisontools.py
compute_agreement_score
def compute_agreement_score(num_matches, num1, num2): """ Agreement score is used as a criteria to match unit1 and unit2. """ denom = num1 + num2 - num_matches if denom == 0: return 0 return num_matches / denom
python
def compute_agreement_score(num_matches, num1, num2): """ Agreement score is used as a criteria to match unit1 and unit2. """ denom = num1 + num2 - num_matches if denom == 0: return 0 return num_matches / denom
[ "def", "compute_agreement_score", "(", "num_matches", ",", "num1", ",", "num2", ")", ":", "denom", "=", "num1", "+", "num2", "-", "num_matches", "if", "denom", "==", "0", ":", "return", "0", "return", "num_matches", "/", "denom" ]
Agreement score is used as a criteria to match unit1 and unit2.
[ "Agreement", "score", "is", "used", "as", "a", "criteria", "to", "match", "unit1", "and", "unit2", "." ]
f7c054383d1ebca640966b057c087fa187955d13
https://github.com/SpikeInterface/spiketoolkit/blob/f7c054383d1ebca640966b057c087fa187955d13/spiketoolkit/comparison/comparisontools.py#L25-L32
train
SpikeInterface/spiketoolkit
spiketoolkit/sorters/launcher.py
collect_results
def collect_results(working_folder): """ Collect results in a working_folder. The output is nested dict[rec_name][sorter_name] of SortingExtrator. """ results = {} working_folder = Path(working_folder) output_folders = working_folder/'output_folders' for rec_name in os.listdir(output...
python
def collect_results(working_folder): """ Collect results in a working_folder. The output is nested dict[rec_name][sorter_name] of SortingExtrator. """ results = {} working_folder = Path(working_folder) output_folders = working_folder/'output_folders' for rec_name in os.listdir(output...
[ "def", "collect_results", "(", "working_folder", ")", ":", "results", "=", "{", "}", "working_folder", "=", "Path", "(", "working_folder", ")", "output_folders", "=", "working_folder", "/", "'output_folders'", "for", "rec_name", "in", "os", ".", "listdir", "(", ...
Collect results in a working_folder. The output is nested dict[rec_name][sorter_name] of SortingExtrator.
[ "Collect", "results", "in", "a", "working_folder", "." ]
f7c054383d1ebca640966b057c087fa187955d13
https://github.com/SpikeInterface/spiketoolkit/blob/f7c054383d1ebca640966b057c087fa187955d13/spiketoolkit/sorters/launcher.py#L181-L206
train
SpikeInterface/spiketoolkit
spiketoolkit/sorters/sorterlist.py
run_sorter
def run_sorter(sorter_name_or_class, recording, output_folder=None, delete_output_folder=False, grouping_property=None, parallel=False, debug=False, **params): """ Generic function to run a sorter via function approach. 2 Usage with name or class: by name: >>> sorting = run_sorte...
python
def run_sorter(sorter_name_or_class, recording, output_folder=None, delete_output_folder=False, grouping_property=None, parallel=False, debug=False, **params): """ Generic function to run a sorter via function approach. 2 Usage with name or class: by name: >>> sorting = run_sorte...
[ "def", "run_sorter", "(", "sorter_name_or_class", ",", "recording", ",", "output_folder", "=", "None", ",", "delete_output_folder", "=", "False", ",", "grouping_property", "=", "None", ",", "parallel", "=", "False", ",", "debug", "=", "False", ",", "*", "*", ...
Generic function to run a sorter via function approach. 2 Usage with name or class: by name: >>> sorting = run_sorter('tridesclous', recording) by class: >>> sorting = run_sorter(TridesclousSorter, recording)
[ "Generic", "function", "to", "run", "a", "sorter", "via", "function", "approach", "." ]
f7c054383d1ebca640966b057c087fa187955d13
https://github.com/SpikeInterface/spiketoolkit/blob/f7c054383d1ebca640966b057c087fa187955d13/spiketoolkit/sorters/sorterlist.py#L29-L57
train
SpikeInterface/spiketoolkit
spiketoolkit/comparison/sortingcomparison.py
compute_performance
def compute_performance(SC, verbose=True, output='dict'): """ Return some performance value for comparison. Parameters ------- SC: SortingComparison instance The SortingComparison verbose: bool Display on console or not output: dict or pandas Returns ---------- ...
python
def compute_performance(SC, verbose=True, output='dict'): """ Return some performance value for comparison. Parameters ------- SC: SortingComparison instance The SortingComparison verbose: bool Display on console or not output: dict or pandas Returns ---------- ...
[ "def", "compute_performance", "(", "SC", ",", "verbose", "=", "True", ",", "output", "=", "'dict'", ")", ":", "counts", "=", "SC", ".", "_counts", "tp_rate", "=", "float", "(", "counts", "[", "'TP'", "]", ")", "/", "counts", "[", "'TOT_ST1'", "]", "*...
Return some performance value for comparison. Parameters ------- SC: SortingComparison instance The SortingComparison verbose: bool Display on console or not output: dict or pandas Returns ---------- performance: dict or pandas.Serie depending output param
[ "Return", "some", "performance", "value", "for", "comparison", "." ]
f7c054383d1ebca640966b057c087fa187955d13
https://github.com/SpikeInterface/spiketoolkit/blob/f7c054383d1ebca640966b057c087fa187955d13/spiketoolkit/comparison/sortingcomparison.py#L279-L325
train
uber/rides-python-sdk
uber_rides/errors.py
HTTPError._complex_response_to_error_adapter
def _complex_response_to_error_adapter(self, body): """Convert a list of error responses.""" meta = body.get('meta') errors = body.get('errors') e = [] for error in errors: status = error['status'] code = error['code'] title = error['title'] ...
python
def _complex_response_to_error_adapter(self, body): """Convert a list of error responses.""" meta = body.get('meta') errors = body.get('errors') e = [] for error in errors: status = error['status'] code = error['code'] title = error['title'] ...
[ "def", "_complex_response_to_error_adapter", "(", "self", ",", "body", ")", ":", "meta", "=", "body", ".", "get", "(", "'meta'", ")", "errors", "=", "body", ".", "get", "(", "'errors'", ")", "e", "=", "[", "]", "for", "error", "in", "errors", ":", "s...
Convert a list of error responses.
[ "Convert", "a", "list", "of", "error", "responses", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/errors.py#L53-L66
train
uber/rides-python-sdk
uber_rides/errors.py
ServerError._adapt_response
def _adapt_response(self, response): """Convert various error responses to standardized ErrorDetails.""" errors, meta = super(ServerError, self)._adapt_response(response) return errors[0], meta
python
def _adapt_response(self, response): """Convert various error responses to standardized ErrorDetails.""" errors, meta = super(ServerError, self)._adapt_response(response) return errors[0], meta
[ "def", "_adapt_response", "(", "self", ",", "response", ")", ":", "errors", ",", "meta", "=", "super", "(", "ServerError", ",", "self", ")", ".", "_adapt_response", "(", "response", ")", "return", "errors", "[", "0", "]", ",", "meta" ]
Convert various error responses to standardized ErrorDetails.
[ "Convert", "various", "error", "responses", "to", "standardized", "ErrorDetails", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/errors.py#L141-L144
train
uber/rides-python-sdk
uber_rides/request.py
Request._prepare
def _prepare(self): """Builds a URL and return a PreparedRequest. Returns (requests.PreparedRequest) Raises UberIllegalState (APIError) """ if self.method not in http.ALLOWED_METHODS: raise UberIllegalState('Unsupported HTTP Method.') ...
python
def _prepare(self): """Builds a URL and return a PreparedRequest. Returns (requests.PreparedRequest) Raises UberIllegalState (APIError) """ if self.method not in http.ALLOWED_METHODS: raise UberIllegalState('Unsupported HTTP Method.') ...
[ "def", "_prepare", "(", "self", ")", ":", "if", "self", ".", "method", "not", "in", "http", ".", "ALLOWED_METHODS", ":", "raise", "UberIllegalState", "(", "'Unsupported HTTP Method.'", ")", "api_host", "=", "self", ".", "api_host", "headers", "=", "self", "....
Builds a URL and return a PreparedRequest. Returns (requests.PreparedRequest) Raises UberIllegalState (APIError)
[ "Builds", "a", "URL", "and", "return", "a", "PreparedRequest", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/request.py#L98-L122
train
uber/rides-python-sdk
uber_rides/request.py
Request._send
def _send(self, prepared_request): """Send a PreparedRequest to the server. Parameters prepared_request (requests.PreparedRequest) Returns (Response) A Response object, whichcontains a server's response to an HTTP request. """ ...
python
def _send(self, prepared_request): """Send a PreparedRequest to the server. Parameters prepared_request (requests.PreparedRequest) Returns (Response) A Response object, whichcontains a server's response to an HTTP request. """ ...
[ "def", "_send", "(", "self", ",", "prepared_request", ")", ":", "session", "=", "Session", "(", ")", "response", "=", "session", ".", "send", "(", "prepared_request", ")", "return", "Response", "(", "response", ")" ]
Send a PreparedRequest to the server. Parameters prepared_request (requests.PreparedRequest) Returns (Response) A Response object, whichcontains a server's response to an HTTP request.
[ "Send", "a", "PreparedRequest", "to", "the", "server", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/request.py#L124-L137
train
uber/rides-python-sdk
uber_rides/request.py
Request._build_headers
def _build_headers(self, method, auth_session): """Create headers for the request. Parameters method (str) HTTP method (e.g. 'POST'). auth_session (Session) The Session object containing OAuth 2.0 credentials. Returns headers ...
python
def _build_headers(self, method, auth_session): """Create headers for the request. Parameters method (str) HTTP method (e.g. 'POST'). auth_session (Session) The Session object containing OAuth 2.0 credentials. Returns headers ...
[ "def", "_build_headers", "(", "self", ",", "method", ",", "auth_session", ")", ":", "token_type", "=", "auth_session", ".", "token_type", "if", "auth_session", ".", "server_token", ":", "token", "=", "auth_session", ".", "server_token", "else", ":", "token", "...
Create headers for the request. Parameters method (str) HTTP method (e.g. 'POST'). auth_session (Session) The Session object containing OAuth 2.0 credentials. Returns headers (dict) Dictionary of access headers to atta...
[ "Create", "headers", "for", "the", "request", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/request.py#L154-L190
train
uber/rides-python-sdk
example/authorize_driver.py
authorization_code_grant_flow
def authorization_code_grant_flow(credentials, storage_filename): """Get an access token through Authorization Code Grant. Parameters credentials (dict) All your app credentials and information imported from the configuration file. storage_filename (str) File...
python
def authorization_code_grant_flow(credentials, storage_filename): """Get an access token through Authorization Code Grant. Parameters credentials (dict) All your app credentials and information imported from the configuration file. storage_filename (str) File...
[ "def", "authorization_code_grant_flow", "(", "credentials", ",", "storage_filename", ")", ":", "auth_flow", "=", "AuthorizationCodeGrant", "(", "credentials", ".", "get", "(", "'client_id'", ")", ",", "credentials", ".", "get", "(", "'scopes'", ")", ",", "credenti...
Get an access token through Authorization Code Grant. Parameters credentials (dict) All your app credentials and information imported from the configuration file. storage_filename (str) Filename to store OAuth 2.0 Credentials. Returns (UberRidesClien...
[ "Get", "an", "access", "token", "through", "Authorization", "Code", "Grant", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/example/authorize_driver.py#L58-L110
train
uber/rides-python-sdk
uber_rides/auth.py
_request_access_token
def _request_access_token( grant_type, client_id=None, client_secret=None, scopes=None, code=None, redirect_url=None, refresh_token=None ): """Make an HTTP POST to request an access token. Parameters grant_type (str) Either 'client_credientials' (Client Credentia...
python
def _request_access_token( grant_type, client_id=None, client_secret=None, scopes=None, code=None, redirect_url=None, refresh_token=None ): """Make an HTTP POST to request an access token. Parameters grant_type (str) Either 'client_credientials' (Client Credentia...
[ "def", "_request_access_token", "(", "grant_type", ",", "client_id", "=", "None", ",", "client_secret", "=", "None", ",", "scopes", "=", "None", ",", "code", "=", "None", ",", "redirect_url", "=", "None", ",", "refresh_token", "=", "None", ")", ":", "url",...
Make an HTTP POST to request an access token. Parameters grant_type (str) Either 'client_credientials' (Client Credentials Grant) or 'authorization_code' (Authorization Code Grant). client_id (str) Your app's Client ID. client_secret (str) You...
[ "Make", "an", "HTTP", "POST", "to", "request", "an", "access", "token", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L447-L509
train
uber/rides-python-sdk
uber_rides/auth.py
refresh_access_token
def refresh_access_token(credential): """Use a refresh token to request a new access token. Not suported for access tokens obtained via Implicit Grant. Parameters credential (OAuth2Credential) An authorized user's OAuth 2.0 credentials. Returns (Session) A new ...
python
def refresh_access_token(credential): """Use a refresh token to request a new access token. Not suported for access tokens obtained via Implicit Grant. Parameters credential (OAuth2Credential) An authorized user's OAuth 2.0 credentials. Returns (Session) A new ...
[ "def", "refresh_access_token", "(", "credential", ")", ":", "if", "credential", ".", "grant_type", "==", "auth", ".", "AUTHORIZATION_CODE_GRANT", ":", "response", "=", "_request_access_token", "(", "grant_type", "=", "auth", ".", "REFRESH_TOKEN", ",", "client_id", ...
Use a refresh token to request a new access token. Not suported for access tokens obtained via Implicit Grant. Parameters credential (OAuth2Credential) An authorized user's OAuth 2.0 credentials. Returns (Session) A new Session object with refreshed OAuth 2.0 crede...
[ "Use", "a", "refresh", "token", "to", "request", "a", "new", "access", "token", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L512-L568
train
uber/rides-python-sdk
uber_rides/auth.py
OAuth2._build_authorization_request_url
def _build_authorization_request_url( self, response_type, redirect_url, state=None ): """Form URL to request an auth code or access token. Parameters response_type (str) Either 'code' (Authorization Code Grant) or 'token' ...
python
def _build_authorization_request_url( self, response_type, redirect_url, state=None ): """Form URL to request an auth code or access token. Parameters response_type (str) Either 'code' (Authorization Code Grant) or 'token' ...
[ "def", "_build_authorization_request_url", "(", "self", ",", "response_type", ",", "redirect_url", ",", "state", "=", "None", ")", ":", "if", "response_type", "not", "in", "auth", ".", "VALID_RESPONSE_TYPES", ":", "message", "=", "'{} is not a valid response type.'", ...
Form URL to request an auth code or access token. Parameters response_type (str) Either 'code' (Authorization Code Grant) or 'token' (Implicit Grant) redirect_url (str) The URL that the Uber server will redirect the user to after ...
[ "Form", "URL", "to", "request", "an", "auth", "code", "or", "access", "token", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L78-L118
train
uber/rides-python-sdk
uber_rides/auth.py
OAuth2._extract_query
def _extract_query(self, redirect_url): """Extract query parameters from a url. Parameters redirect_url (str) The full URL that the Uber server redirected to after the user authorized your app. Returns (dict) A dictionary ...
python
def _extract_query(self, redirect_url): """Extract query parameters from a url. Parameters redirect_url (str) The full URL that the Uber server redirected to after the user authorized your app. Returns (dict) A dictionary ...
[ "def", "_extract_query", "(", "self", ",", "redirect_url", ")", ":", "qs", "=", "urlparse", "(", "redirect_url", ")", "# Implicit Grant redirect_urls have data after fragment identifier (#)", "# All other redirect_urls return data after query identifier (?)", "qs", "=", "qs", "...
Extract query parameters from a url. Parameters redirect_url (str) The full URL that the Uber server redirected to after the user authorized your app. Returns (dict) A dictionary of query parameters.
[ "Extract", "query", "parameters", "from", "a", "url", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L120-L141
train
uber/rides-python-sdk
uber_rides/auth.py
AuthorizationCodeGrant._generate_state_token
def _generate_state_token(self, length=32): """Generate CSRF State Token. CSRF State Tokens are passed as a parameter in the authorization URL and are checked when receiving responses from the Uber Auth server to prevent request forgery. """ choices = ascii_letters + dig...
python
def _generate_state_token(self, length=32): """Generate CSRF State Token. CSRF State Tokens are passed as a parameter in the authorization URL and are checked when receiving responses from the Uber Auth server to prevent request forgery. """ choices = ascii_letters + dig...
[ "def", "_generate_state_token", "(", "self", ",", "length", "=", "32", ")", ":", "choices", "=", "ascii_letters", "+", "digits", "return", "''", ".", "join", "(", "SystemRandom", "(", ")", ".", "choice", "(", "choices", ")", "for", "_", "in", "range", ...
Generate CSRF State Token. CSRF State Tokens are passed as a parameter in the authorization URL and are checked when receiving responses from the Uber Auth server to prevent request forgery.
[ "Generate", "CSRF", "State", "Token", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L194-L202
train
uber/rides-python-sdk
uber_rides/auth.py
AuthorizationCodeGrant.get_authorization_url
def get_authorization_url(self): """Start the Authorization Code Grant process. This function starts the OAuth 2.0 authorization process and builds an authorization URL. You should redirect your user to this URL, where they can grant your application access to their Uber account. ...
python
def get_authorization_url(self): """Start the Authorization Code Grant process. This function starts the OAuth 2.0 authorization process and builds an authorization URL. You should redirect your user to this URL, where they can grant your application access to their Uber account. ...
[ "def", "get_authorization_url", "(", "self", ")", ":", "return", "self", ".", "_build_authorization_request_url", "(", "response_type", "=", "auth", ".", "CODE_RESPONSE_TYPE", ",", "redirect_url", "=", "self", ".", "redirect_url", ",", "state", "=", "self", ".", ...
Start the Authorization Code Grant process. This function starts the OAuth 2.0 authorization process and builds an authorization URL. You should redirect your user to this URL, where they can grant your application access to their Uber account. Returns (str) ...
[ "Start", "the", "Authorization", "Code", "Grant", "process", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L204-L220
train
uber/rides-python-sdk
uber_rides/auth.py
AuthorizationCodeGrant._verify_query
def _verify_query(self, query_params): """Verify response from the Uber Auth server. Parameters query_params (dict) Dictionary of query parameters attached to your redirect URL after user approved your app and was redirected. Returns auth...
python
def _verify_query(self, query_params): """Verify response from the Uber Auth server. Parameters query_params (dict) Dictionary of query parameters attached to your redirect URL after user approved your app and was redirected. Returns auth...
[ "def", "_verify_query", "(", "self", ",", "query_params", ")", ":", "error_message", "=", "None", "if", "self", ".", "state_token", "is", "not", "False", ":", "# Check CSRF State Token against state token from GET request", "received_state_token", "=", "query_params", "...
Verify response from the Uber Auth server. Parameters query_params (dict) Dictionary of query parameters attached to your redirect URL after user approved your app and was redirected. Returns authorization_code (str) Code received...
[ "Verify", "response", "from", "the", "Uber", "Auth", "server", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L222-L275
train
uber/rides-python-sdk
uber_rides/auth.py
ImplicitGrant.get_authorization_url
def get_authorization_url(self): """Build URL for authorization request. Returns (str) The fully constructed authorization request URL. """ return self._build_authorization_request_url( response_type=auth.TOKEN_RESPONSE_TYPE, redirect_...
python
def get_authorization_url(self): """Build URL for authorization request. Returns (str) The fully constructed authorization request URL. """ return self._build_authorization_request_url( response_type=auth.TOKEN_RESPONSE_TYPE, redirect_...
[ "def", "get_authorization_url", "(", "self", ")", ":", "return", "self", ".", "_build_authorization_request_url", "(", "response_type", "=", "auth", ".", "TOKEN_RESPONSE_TYPE", ",", "redirect_url", "=", "self", ".", "redirect_url", ",", ")" ]
Build URL for authorization request. Returns (str) The fully constructed authorization request URL.
[ "Build", "URL", "for", "authorization", "request", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L346-L356
train
uber/rides-python-sdk
uber_rides/client.py
surge_handler
def surge_handler(response, **kwargs): """Error Handler to surface 409 Surge Conflict errors. Attached as a callback hook on the Request object. Parameters response (requests.Response) The HTTP response from an API request. **kwargs Arbitrary keyword arguments. ...
python
def surge_handler(response, **kwargs): """Error Handler to surface 409 Surge Conflict errors. Attached as a callback hook on the Request object. Parameters response (requests.Response) The HTTP response from an API request. **kwargs Arbitrary keyword arguments. ...
[ "def", "surge_handler", "(", "response", ",", "*", "*", "kwargs", ")", ":", "if", "response", ".", "status_code", "==", "codes", ".", "conflict", ":", "json", "=", "response", ".", "json", "(", ")", "errors", "=", "json", ".", "get", "(", "'errors'", ...
Error Handler to surface 409 Surge Conflict errors. Attached as a callback hook on the Request object. Parameters response (requests.Response) The HTTP response from an API request. **kwargs Arbitrary keyword arguments.
[ "Error", "Handler", "to", "surface", "409", "Surge", "Conflict", "errors", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L879-L898
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.get_products
def get_products(self, latitude, longitude): """Get information about the Uber products offered at a given location. Parameters latitude (float) The latitude component of a location. longitude (float) The longitude component of a location. ...
python
def get_products(self, latitude, longitude): """Get information about the Uber products offered at a given location. Parameters latitude (float) The latitude component of a location. longitude (float) The longitude component of a location. ...
[ "def", "get_products", "(", "self", ",", "latitude", ",", "longitude", ")", ":", "args", "=", "OrderedDict", "(", "[", "(", "'latitude'", ",", "latitude", ")", ",", "(", "'longitude'", ",", "longitude", ")", ",", "]", ")", "return", "self", ".", "_api_...
Get information about the Uber products offered at a given location. Parameters latitude (float) The latitude component of a location. longitude (float) The longitude component of a location. Returns (Response) A Respo...
[ "Get", "information", "about", "the", "Uber", "products", "offered", "at", "a", "given", "location", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L109-L127
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.get_price_estimates
def get_price_estimates( self, start_latitude, start_longitude, end_latitude, end_longitude, seat_count=None, ): """Get price estimates for products at a given location. Parameters start_latitude (float) The latitude compon...
python
def get_price_estimates( self, start_latitude, start_longitude, end_latitude, end_longitude, seat_count=None, ): """Get price estimates for products at a given location. Parameters start_latitude (float) The latitude compon...
[ "def", "get_price_estimates", "(", "self", ",", "start_latitude", ",", "start_longitude", ",", "end_latitude", ",", "end_longitude", ",", "seat_count", "=", "None", ",", ")", ":", "args", "=", "OrderedDict", "(", "[", "(", "'start_latitude'", ",", "start_latitud...
Get price estimates for products at a given location. Parameters start_latitude (float) The latitude component of a start location. start_longitude (float) The longitude component of a start location. end_latitude (float) The l...
[ "Get", "price", "estimates", "for", "products", "at", "a", "given", "location", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L144-L179
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.get_pickup_time_estimates
def get_pickup_time_estimates( self, start_latitude, start_longitude, product_id=None, ): """Get pickup time estimates for products at a given location. Parameters start_latitude (float) The latitude component of a start location. ...
python
def get_pickup_time_estimates( self, start_latitude, start_longitude, product_id=None, ): """Get pickup time estimates for products at a given location. Parameters start_latitude (float) The latitude component of a start location. ...
[ "def", "get_pickup_time_estimates", "(", "self", ",", "start_latitude", ",", "start_longitude", ",", "product_id", "=", "None", ",", ")", ":", "args", "=", "OrderedDict", "(", "[", "(", "'start_latitude'", ",", "start_latitude", ")", ",", "(", "'start_longitude'...
Get pickup time estimates for products at a given location. Parameters start_latitude (float) The latitude component of a start location. start_longitude (float) The longitude component of a start location. product_id (str) The...
[ "Get", "pickup", "time", "estimates", "for", "products", "at", "a", "given", "location", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L181-L209
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.get_promotions
def get_promotions( self, start_latitude, start_longitude, end_latitude, end_longitude, ): """Get information about the promotions available to a user. Parameters start_latitude (float) The latitude component of a start location. ...
python
def get_promotions( self, start_latitude, start_longitude, end_latitude, end_longitude, ): """Get information about the promotions available to a user. Parameters start_latitude (float) The latitude component of a start location. ...
[ "def", "get_promotions", "(", "self", ",", "start_latitude", ",", "start_longitude", ",", "end_latitude", ",", "end_longitude", ",", ")", ":", "args", "=", "OrderedDict", "(", "[", "(", "'start_latitude'", ",", "start_latitude", ")", ",", "(", "'start_longitude'...
Get information about the promotions available to a user. Parameters start_latitude (float) The latitude component of a start location. start_longitude (float) The longitude component of a start location. end_latitude (float) T...
[ "Get", "information", "about", "the", "promotions", "available", "to", "a", "user", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L211-L242
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.get_user_activity
def get_user_activity(self, offset=None, limit=None): """Get activity about the user's lifetime activity with Uber. Parameters offset (int) The integer offset for activity results. Default is 0. limit (int) Integer amount of results to return. Max...
python
def get_user_activity(self, offset=None, limit=None): """Get activity about the user's lifetime activity with Uber. Parameters offset (int) The integer offset for activity results. Default is 0. limit (int) Integer amount of results to return. Max...
[ "def", "get_user_activity", "(", "self", ",", "offset", "=", "None", ",", "limit", "=", "None", ")", ":", "args", "=", "{", "'offset'", ":", "offset", ",", "'limit'", ":", "limit", ",", "}", "return", "self", ".", "_api_call", "(", "'GET'", ",", "'v1...
Get activity about the user's lifetime activity with Uber. Parameters offset (int) The integer offset for activity results. Default is 0. limit (int) Integer amount of results to return. Maximum is 50. Default is 5. Returns ...
[ "Get", "activity", "about", "the", "user", "s", "lifetime", "activity", "with", "Uber", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L244-L263
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.estimate_ride
def estimate_ride( self, product_id=None, start_latitude=None, start_longitude=None, start_place_id=None, end_latitude=None, end_longitude=None, end_place_id=None, seat_count=None, ): """Estimate ride details given a product, start, and...
python
def estimate_ride( self, product_id=None, start_latitude=None, start_longitude=None, start_place_id=None, end_latitude=None, end_longitude=None, end_place_id=None, seat_count=None, ): """Estimate ride details given a product, start, and...
[ "def", "estimate_ride", "(", "self", ",", "product_id", "=", "None", ",", "start_latitude", "=", "None", ",", "start_longitude", "=", "None", ",", "start_place_id", "=", "None", ",", "end_latitude", "=", "None", ",", "end_longitude", "=", "None", ",", "end_p...
Estimate ride details given a product, start, and end location. Only pickup time estimates and surge pricing information are provided if no end location is provided. Parameters product_id (str) The unique ID of the product being requested. If none is ...
[ "Estimate", "ride", "details", "given", "a", "product", "start", "and", "end", "location", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L319-L374
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.request_ride
def request_ride( self, product_id=None, start_latitude=None, start_longitude=None, start_place_id=None, start_address=None, start_nickname=None, end_latitude=None, end_longitude=None, end_place_id=None, end_address=None, en...
python
def request_ride( self, product_id=None, start_latitude=None, start_longitude=None, start_place_id=None, start_address=None, start_nickname=None, end_latitude=None, end_longitude=None, end_place_id=None, end_address=None, en...
[ "def", "request_ride", "(", "self", ",", "product_id", "=", "None", ",", "start_latitude", "=", "None", ",", "start_longitude", "=", "None", ",", "start_place_id", "=", "None", ",", "start_address", "=", "None", ",", "start_nickname", "=", "None", ",", "end_...
Request a ride on behalf of an Uber user. When specifying pickup and dropoff locations, you can either use latitude/longitude pairs or place ID (but not both). Parameters product_id (str) The unique ID of the product being requested. If none is provi...
[ "Request", "a", "ride", "on", "behalf", "of", "an", "Uber", "user", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L376-L466
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.update_ride
def update_ride( self, ride_id, end_latitude=None, end_longitude=None, end_place_id=None, ): """Update an ongoing ride's destination. To specify a new dropoff location, you can either use a latitude/longitude pair or place ID (but not both). ...
python
def update_ride( self, ride_id, end_latitude=None, end_longitude=None, end_place_id=None, ): """Update an ongoing ride's destination. To specify a new dropoff location, you can either use a latitude/longitude pair or place ID (but not both). ...
[ "def", "update_ride", "(", "self", ",", "ride_id", ",", "end_latitude", "=", "None", ",", "end_longitude", "=", "None", ",", "end_place_id", "=", "None", ",", ")", ":", "args", "=", "{", "}", "if", "end_latitude", "is", "not", "None", ":", "args", ".",...
Update an ongoing ride's destination. To specify a new dropoff location, you can either use a latitude/longitude pair or place ID (but not both). Params ride_id (str) The unique ID of the Ride Request. end_latitude (float) The latitude co...
[ "Update", "an", "ongoing", "ride", "s", "destination", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L498-L539
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.update_sandbox_ride
def update_sandbox_ride(self, ride_id, new_status): """Update the status of an ongoing sandbox request. Params ride_id (str) The unique ID of the Ride Request. new_status (str) Status from VALID_PRODUCT_STATUS. Returns (Respon...
python
def update_sandbox_ride(self, ride_id, new_status): """Update the status of an ongoing sandbox request. Params ride_id (str) The unique ID of the Ride Request. new_status (str) Status from VALID_PRODUCT_STATUS. Returns (Respon...
[ "def", "update_sandbox_ride", "(", "self", ",", "ride_id", ",", "new_status", ")", ":", "if", "new_status", "not", "in", "VALID_PRODUCT_STATUS", ":", "message", "=", "'{} is not a valid product status.'", "raise", "UberIllegalState", "(", "message", ".", "format", "...
Update the status of an ongoing sandbox request. Params ride_id (str) The unique ID of the Ride Request. new_status (str) Status from VALID_PRODUCT_STATUS. Returns (Response) A Response object with successful status_co...
[ "Update", "the", "status", "of", "an", "ongoing", "sandbox", "request", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L602-L622
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.update_sandbox_product
def update_sandbox_product( self, product_id, surge_multiplier=None, drivers_available=None, ): """Update sandbox product availability. Params product_id (str) Unique identifier representing a specific product for a given l...
python
def update_sandbox_product( self, product_id, surge_multiplier=None, drivers_available=None, ): """Update sandbox product availability. Params product_id (str) Unique identifier representing a specific product for a given l...
[ "def", "update_sandbox_product", "(", "self", ",", "product_id", ",", "surge_multiplier", "=", "None", ",", "drivers_available", "=", "None", ",", ")", ":", "args", "=", "{", "'surge_multiplier'", ":", "surge_multiplier", ",", "'drivers_available'", ":", "drivers_...
Update sandbox product availability. Params product_id (str) Unique identifier representing a specific product for a given location. surge_multiplier (float) Optional surge multiplier to manipulate pricing of product. drivers_a...
[ "Update", "sandbox", "product", "availability", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L624-L652
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.revoke_oauth_credential
def revoke_oauth_credential(self): """Revoke the session's OAuth 2.0 credentials.""" if self.session.token_type == auth.SERVER_TOKEN_TYPE: return credential = self.session.oauth2credential revoke_access_token(credential)
python
def revoke_oauth_credential(self): """Revoke the session's OAuth 2.0 credentials.""" if self.session.token_type == auth.SERVER_TOKEN_TYPE: return credential = self.session.oauth2credential revoke_access_token(credential)
[ "def", "revoke_oauth_credential", "(", "self", ")", ":", "if", "self", ".", "session", ".", "token_type", "==", "auth", ".", "SERVER_TOKEN_TYPE", ":", "return", "credential", "=", "self", ".", "session", ".", "oauth2credential", "revoke_access_token", "(", "cred...
Revoke the session's OAuth 2.0 credentials.
[ "Revoke", "the", "session", "s", "OAuth", "2", ".", "0", "credentials", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L722-L728
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.get_driver_trips
def get_driver_trips(self, offset=None, limit=None, from_time=None, to_time=None ): """Get trips about the authorized Uber driver. Parameters offset (int) ...
python
def get_driver_trips(self, offset=None, limit=None, from_time=None, to_time=None ): """Get trips about the authorized Uber driver. Parameters offset (int) ...
[ "def", "get_driver_trips", "(", "self", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "from_time", "=", "None", ",", "to_time", "=", "None", ")", ":", "args", "=", "{", "'offset'", ":", "offset", ",", "'limit'", ":", "limit", ",", "'fro...
Get trips about the authorized Uber driver. Parameters offset (int) The integer offset for activity results. Offset the list of returned results by this amount. Default is zero. limit (int) Integer amount of results to return. Number of it...
[ "Get", "trips", "about", "the", "authorized", "Uber", "driver", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L739-L771
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.get_driver_payments
def get_driver_payments(self, offset=None, limit=None, from_time=None, to_time=None ): """Get payments about the authorized Uber driver. Parameters off...
python
def get_driver_payments(self, offset=None, limit=None, from_time=None, to_time=None ): """Get payments about the authorized Uber driver. Parameters off...
[ "def", "get_driver_payments", "(", "self", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "from_time", "=", "None", ",", "to_time", "=", "None", ")", ":", "args", "=", "{", "'offset'", ":", "offset", ",", "'limit'", ":", "limit", ",", "'...
Get payments about the authorized Uber driver. Parameters offset (int) The integer offset for activity results. Offset the list of returned results by this amount. Default is zero. limit (int) Integer amount of results to return. Number of...
[ "Get", "payments", "about", "the", "authorized", "Uber", "driver", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L773-L805
train
uber/rides-python-sdk
uber_rides/client.py
UberRidesClient.validiate_webhook_signature
def validiate_webhook_signature(self, webhook, signature): """Validates a webhook signature from a webhook body + client secret Parameters webhook (string) The request body of the webhook. signature (string) The webhook signature specified in X-Ub...
python
def validiate_webhook_signature(self, webhook, signature): """Validates a webhook signature from a webhook body + client secret Parameters webhook (string) The request body of the webhook. signature (string) The webhook signature specified in X-Ub...
[ "def", "validiate_webhook_signature", "(", "self", ",", "webhook", ",", "signature", ")", ":", "digester", "=", "hmac", ".", "new", "(", "self", ".", "session", ".", "oauth2credential", ".", "client_secret", ",", "webhook", ",", "hashlib", ".", "sha256", ")"...
Validates a webhook signature from a webhook body + client secret Parameters webhook (string) The request body of the webhook. signature (string) The webhook signature specified in X-Uber-Signature header.
[ "Validates", "a", "webhook", "signature", "from", "a", "webhook", "body", "+", "client", "secret" ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L863-L876
train
uber/rides-python-sdk
uber_rides/client.py
SurgeError.adapt_meta
def adapt_meta(self, meta): """Convert meta from error response to href and surge_id attributes.""" surge = meta.get('surge_confirmation') href = surge.get('href') surge_id = surge.get('surge_confirmation_id') return href, surge_id
python
def adapt_meta(self, meta): """Convert meta from error response to href and surge_id attributes.""" surge = meta.get('surge_confirmation') href = surge.get('href') surge_id = surge.get('surge_confirmation_id') return href, surge_id
[ "def", "adapt_meta", "(", "self", ",", "meta", ")", ":", "surge", "=", "meta", ".", "get", "(", "'surge_confirmation'", ")", "href", "=", "surge", ".", "get", "(", "'href'", ")", "surge_id", "=", "surge", ".", "get", "(", "'surge_confirmation_id'", ")", ...
Convert meta from error response to href and surge_id attributes.
[ "Convert", "meta", "from", "error", "response", "to", "href", "and", "surge_id", "attributes", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/client.py#L928-L935
train
uber/rides-python-sdk
example/request_ride.py
estimate_ride
def estimate_ride(api_client): """Use an UberRidesClient to fetch a ride estimate and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. """ try: estimate = api_client.estimate_ride( product_id=SURGE_PRO...
python
def estimate_ride(api_client): """Use an UberRidesClient to fetch a ride estimate and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. """ try: estimate = api_client.estimate_ride( product_id=SURGE_PRO...
[ "def", "estimate_ride", "(", "api_client", ")", ":", "try", ":", "estimate", "=", "api_client", ".", "estimate_ride", "(", "product_id", "=", "SURGE_PRODUCT_ID", ",", "start_latitude", "=", "START_LAT", ",", "start_longitude", "=", "START_LNG", ",", "end_latitude"...
Use an UberRidesClient to fetch a ride estimate and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope.
[ "Use", "an", "UberRidesClient", "to", "fetch", "a", "ride", "estimate", "and", "print", "the", "results", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/example/request_ride.py#L75-L96
train
uber/rides-python-sdk
example/request_ride.py
update_surge
def update_surge(api_client, surge_multiplier): """Use an UberRidesClient to update surge and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. surge_mutliplier (float) The surge multiple for a sandbox product....
python
def update_surge(api_client, surge_multiplier): """Use an UberRidesClient to update surge and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. surge_mutliplier (float) The surge multiple for a sandbox product....
[ "def", "update_surge", "(", "api_client", ",", "surge_multiplier", ")", ":", "try", ":", "update_surge", "=", "api_client", ".", "update_sandbox_product", "(", "SURGE_PRODUCT_ID", ",", "surge_multiplier", "=", "surge_multiplier", ",", ")", "except", "(", "ClientErro...
Use an UberRidesClient to update surge and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. surge_mutliplier (float) The surge multiple for a sandbox product. A multiplier greater than or equal to 2.0 ...
[ "Use", "an", "UberRidesClient", "to", "update", "surge", "and", "print", "the", "results", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/example/request_ride.py#L99-L119
train
uber/rides-python-sdk
example/request_ride.py
update_ride
def update_ride(api_client, ride_status, ride_id): """Use an UberRidesClient to update ride status and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. ride_status (str) New ride status to update to. r...
python
def update_ride(api_client, ride_status, ride_id): """Use an UberRidesClient to update ride status and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. ride_status (str) New ride status to update to. r...
[ "def", "update_ride", "(", "api_client", ",", "ride_status", ",", "ride_id", ")", ":", "try", ":", "update_product", "=", "api_client", ".", "update_sandbox_ride", "(", "ride_id", ",", "ride_status", ")", "except", "(", "ClientError", ",", "ServerError", ")", ...
Use an UberRidesClient to update ride status and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. ride_status (str) New ride status to update to. ride_id (str) Unique identifier for ride to upd...
[ "Use", "an", "UberRidesClient", "to", "update", "ride", "status", "and", "print", "the", "results", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/example/request_ride.py#L122-L142
train
uber/rides-python-sdk
example/request_ride.py
get_ride_details
def get_ride_details(api_client, ride_id): """Use an UberRidesClient to get ride details and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. ride_id (str) Unique ride identifier. """ try: ride...
python
def get_ride_details(api_client, ride_id): """Use an UberRidesClient to get ride details and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. ride_id (str) Unique ride identifier. """ try: ride...
[ "def", "get_ride_details", "(", "api_client", ",", "ride_id", ")", ":", "try", ":", "ride_details", "=", "api_client", ".", "get_ride_details", "(", "ride_id", ")", "except", "(", "ClientError", ",", "ServerError", ")", "as", "error", ":", "fail_print", "(", ...
Use an UberRidesClient to get ride details and print the results. Parameters api_client (UberRidesClient) An authorized UberRidesClient with 'request' scope. ride_id (str) Unique ride identifier.
[ "Use", "an", "UberRidesClient", "to", "get", "ride", "details", "and", "print", "the", "results", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/example/request_ride.py#L238-L254
train
uber/rides-python-sdk
uber_rides/utils/request.py
generate_data
def generate_data(method, args): """Assign arguments to body or URL of an HTTP request. Parameters method (str) HTTP Method. (e.g. 'POST') args (dict) Dictionary of data to attach to each Request. e.g. {'latitude': 37.561, 'longitude': -122.742} Returns ...
python
def generate_data(method, args): """Assign arguments to body or URL of an HTTP request. Parameters method (str) HTTP Method. (e.g. 'POST') args (dict) Dictionary of data to attach to each Request. e.g. {'latitude': 37.561, 'longitude': -122.742} Returns ...
[ "def", "generate_data", "(", "method", ",", "args", ")", ":", "data", "=", "{", "}", "params", "=", "{", "}", "if", "method", "in", "http", ".", "BODY_METHODS", ":", "data", "=", "dumps", "(", "args", ")", "else", ":", "params", "=", "args", "retur...
Assign arguments to body or URL of an HTTP request. Parameters method (str) HTTP Method. (e.g. 'POST') args (dict) Dictionary of data to attach to each Request. e.g. {'latitude': 37.561, 'longitude': -122.742} Returns (str or dict) Either...
[ "Assign", "arguments", "to", "body", "or", "URL", "of", "an", "HTTP", "request", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/utils/request.py#L42-L64
train
uber/rides-python-sdk
uber_rides/utils/request.py
generate_prepared_request
def generate_prepared_request(method, url, headers, data, params, handlers): """Add handlers and prepare a Request. Parameters method (str) HTTP Method. (e.g. 'POST') headers (dict) Headers to send. data (JSON-formatted str) Body to attach to the requ...
python
def generate_prepared_request(method, url, headers, data, params, handlers): """Add handlers and prepare a Request. Parameters method (str) HTTP Method. (e.g. 'POST') headers (dict) Headers to send. data (JSON-formatted str) Body to attach to the requ...
[ "def", "generate_prepared_request", "(", "method", ",", "url", ",", "headers", ",", "data", ",", "params", ",", "handlers", ")", ":", "request", "=", "Request", "(", "method", "=", "method", ",", "url", "=", "url", ",", "headers", "=", "headers", ",", ...
Add handlers and prepare a Request. Parameters method (str) HTTP Method. (e.g. 'POST') headers (dict) Headers to send. data (JSON-formatted str) Body to attach to the request. params (dict) Dictionary of URL parameters to append to the...
[ "Add", "handlers", "and", "prepare", "a", "Request", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/utils/request.py#L67-L100
train
uber/rides-python-sdk
uber_rides/utils/request.py
build_url
def build_url(host, path, params=None): """Build a URL. This method encodes the parameters and adds them to the end of the base URL, then adds scheme and hostname. Parameters host (str) Base URL of the Uber Server that handles API calls. path (str) Target path t...
python
def build_url(host, path, params=None): """Build a URL. This method encodes the parameters and adds them to the end of the base URL, then adds scheme and hostname. Parameters host (str) Base URL of the Uber Server that handles API calls. path (str) Target path t...
[ "def", "build_url", "(", "host", ",", "path", ",", "params", "=", "None", ")", ":", "path", "=", "quote", "(", "path", ")", "params", "=", "params", "or", "{", "}", "if", "params", ":", "path", "=", "'/{}?{}'", ".", "format", "(", "path", ",", "u...
Build a URL. This method encodes the parameters and adds them to the end of the base URL, then adds scheme and hostname. Parameters host (str) Base URL of the Uber Server that handles API calls. path (str) Target path to add to the host (e.g. 'v1.2/products'). ...
[ "Build", "a", "URL", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/utils/request.py#L103-L132
train
uber/rides-python-sdk
uber_rides/utils/handlers.py
error_handler
def error_handler(response, **kwargs): """Error Handler to surface 4XX and 5XX errors. Attached as a callback hook on the Request object. Parameters response (requests.Response) The HTTP response from an API request. **kwargs Arbitrary keyword arguments. Raises...
python
def error_handler(response, **kwargs): """Error Handler to surface 4XX and 5XX errors. Attached as a callback hook on the Request object. Parameters response (requests.Response) The HTTP response from an API request. **kwargs Arbitrary keyword arguments. Raises...
[ "def", "error_handler", "(", "response", ",", "*", "*", "kwargs", ")", ":", "try", ":", "body", "=", "response", ".", "json", "(", ")", "except", "ValueError", ":", "body", "=", "{", "}", "status_code", "=", "response", ".", "status_code", "message", "...
Error Handler to surface 4XX and 5XX errors. Attached as a callback hook on the Request object. Parameters response (requests.Response) The HTTP response from an API request. **kwargs Arbitrary keyword arguments. Raises ClientError (ApiError) Ra...
[ "Error", "Handler", "to", "surface", "4XX", "and", "5XX", "errors", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/utils/handlers.py#L30-L65
train
uber/rides-python-sdk
example/utils.py
import_app_credentials
def import_app_credentials(filename=CREDENTIALS_FILENAME): """Import app credentials from configuration file. Parameters filename (str) Name of configuration file. Returns credentials (dict) All your app credentials and information imported from the conf...
python
def import_app_credentials(filename=CREDENTIALS_FILENAME): """Import app credentials from configuration file. Parameters filename (str) Name of configuration file. Returns credentials (dict) All your app credentials and information imported from the conf...
[ "def", "import_app_credentials", "(", "filename", "=", "CREDENTIALS_FILENAME", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "config_file", ":", "config", "=", "safe_load", "(", "config_file", ")", "client_id", "=", "config", "[", "'client_...
Import app credentials from configuration file. Parameters filename (str) Name of configuration file. Returns credentials (dict) All your app credentials and information imported from the configuration file.
[ "Import", "app", "credentials", "from", "configuration", "file", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/example/utils.py#L98-L130
train
uber/rides-python-sdk
example/utils.py
create_uber_client
def create_uber_client(credentials): """Create an UberRidesClient from OAuth 2.0 credentials. Parameters credentials (dict) Dictionary of OAuth 2.0 credentials. Returns (UberRidesClient) An authorized UberRidesClient to access API resources. """ oauth2creden...
python
def create_uber_client(credentials): """Create an UberRidesClient from OAuth 2.0 credentials. Parameters credentials (dict) Dictionary of OAuth 2.0 credentials. Returns (UberRidesClient) An authorized UberRidesClient to access API resources. """ oauth2creden...
[ "def", "create_uber_client", "(", "credentials", ")", ":", "oauth2credential", "=", "OAuth2Credential", "(", "client_id", "=", "credentials", ".", "get", "(", "'client_id'", ")", ",", "access_token", "=", "credentials", ".", "get", "(", "'access_token'", ")", ",...
Create an UberRidesClient from OAuth 2.0 credentials. Parameters credentials (dict) Dictionary of OAuth 2.0 credentials. Returns (UberRidesClient) An authorized UberRidesClient to access API resources.
[ "Create", "an", "UberRidesClient", "from", "OAuth", "2", ".", "0", "credentials", "." ]
76ecd75ab5235d792ec1010e36eca679ba285127
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/example/utils.py#L167-L189
train
kigawas/eciespy
ecies/__init__.py
encrypt
def encrypt(receiver_pubhex: str, msg: bytes) -> bytes: """ Encrypt with eth public key Parameters ---------- receiver_pubhex: str Receiver's ethereum public key hex string msg: bytes Data to encrypt Returns ------- bytes Encrypted data """ disposabl...
python
def encrypt(receiver_pubhex: str, msg: bytes) -> bytes: """ Encrypt with eth public key Parameters ---------- receiver_pubhex: str Receiver's ethereum public key hex string msg: bytes Data to encrypt Returns ------- bytes Encrypted data """ disposabl...
[ "def", "encrypt", "(", "receiver_pubhex", ":", "str", ",", "msg", ":", "bytes", ")", "->", "bytes", ":", "disposable_key", "=", "generate_key", "(", ")", "receiver_pubkey", "=", "hex2pub", "(", "receiver_pubhex", ")", "aes_key", "=", "derive", "(", "disposab...
Encrypt with eth public key Parameters ---------- receiver_pubhex: str Receiver's ethereum public key hex string msg: bytes Data to encrypt Returns ------- bytes Encrypted data
[ "Encrypt", "with", "eth", "public", "key" ]
233f3d7726bf03465a6b2470e83f34cc457eea6c
https://github.com/kigawas/eciespy/blob/233f3d7726bf03465a6b2470e83f34cc457eea6c/ecies/__init__.py#L6-L26
train
kigawas/eciespy
ecies/__init__.py
decrypt
def decrypt(receiver_prvhex: str, msg: bytes) -> bytes: """ Decrypt with eth private key Parameters ---------- receiver_pubhex: str Receiver's ethereum private key hex string msg: bytes Data to decrypt Returns ------- bytes Plain text """ pubkey = ms...
python
def decrypt(receiver_prvhex: str, msg: bytes) -> bytes: """ Decrypt with eth private key Parameters ---------- receiver_pubhex: str Receiver's ethereum private key hex string msg: bytes Data to decrypt Returns ------- bytes Plain text """ pubkey = ms...
[ "def", "decrypt", "(", "receiver_prvhex", ":", "str", ",", "msg", ":", "bytes", ")", "->", "bytes", ":", "pubkey", "=", "msg", "[", "0", ":", "65", "]", "# pubkey's length is 65 bytes", "encrypted", "=", "msg", "[", "65", ":", "]", "sender_public_key", "...
Decrypt with eth private key Parameters ---------- receiver_pubhex: str Receiver's ethereum private key hex string msg: bytes Data to decrypt Returns ------- bytes Plain text
[ "Decrypt", "with", "eth", "private", "key" ]
233f3d7726bf03465a6b2470e83f34cc457eea6c
https://github.com/kigawas/eciespy/blob/233f3d7726bf03465a6b2470e83f34cc457eea6c/ecies/__init__.py#L29-L50
train
kigawas/eciespy
ecies/utils.py
hex2pub
def hex2pub(pub_hex: str) -> PublicKey: """ Convert ethereum hex to EllipticCurvePublicKey The hex should be 65 bytes, but ethereum public key only has 64 bytes So have to add \x04 Parameters ---------- pub_hex: str Ethereum public key hex string Returns ------- coincur...
python
def hex2pub(pub_hex: str) -> PublicKey: """ Convert ethereum hex to EllipticCurvePublicKey The hex should be 65 bytes, but ethereum public key only has 64 bytes So have to add \x04 Parameters ---------- pub_hex: str Ethereum public key hex string Returns ------- coincur...
[ "def", "hex2pub", "(", "pub_hex", ":", "str", ")", "->", "PublicKey", ":", "uncompressed", "=", "decode_hex", "(", "pub_hex", ")", "if", "len", "(", "uncompressed", ")", "==", "64", ":", "uncompressed", "=", "b\"\\x04\"", "+", "uncompressed", "return", "Pu...
Convert ethereum hex to EllipticCurvePublicKey The hex should be 65 bytes, but ethereum public key only has 64 bytes So have to add \x04 Parameters ---------- pub_hex: str Ethereum public key hex string Returns ------- coincurve.PublicKey A secp256k1 public key calculat...
[ "Convert", "ethereum", "hex", "to", "EllipticCurvePublicKey", "The", "hex", "should", "be", "65", "bytes", "but", "ethereum", "public", "key", "only", "has", "64", "bytes", "So", "have", "to", "add", "\\", "x04" ]
233f3d7726bf03465a6b2470e83f34cc457eea6c
https://github.com/kigawas/eciespy/blob/233f3d7726bf03465a6b2470e83f34cc457eea6c/ecies/utils.py#L73-L104
train
kigawas/eciespy
ecies/utils.py
aes_encrypt
def aes_encrypt(key: bytes, plain_text: bytes) -> bytes: """ AES-GCM encryption Parameters ---------- key: bytes AES session key, which derived from two secp256k1 keys plain_text: bytes Plain text to encrypt Returns ------- bytes nonce(16 bytes) + tag(16 byt...
python
def aes_encrypt(key: bytes, plain_text: bytes) -> bytes: """ AES-GCM encryption Parameters ---------- key: bytes AES session key, which derived from two secp256k1 keys plain_text: bytes Plain text to encrypt Returns ------- bytes nonce(16 bytes) + tag(16 byt...
[ "def", "aes_encrypt", "(", "key", ":", "bytes", ",", "plain_text", ":", "bytes", ")", "->", "bytes", ":", "aes_cipher", "=", "AES", ".", "new", "(", "key", ",", "AES_CIPHER_MODE", ")", "encrypted", ",", "tag", "=", "aes_cipher", ".", "encrypt_and_digest", ...
AES-GCM encryption Parameters ---------- key: bytes AES session key, which derived from two secp256k1 keys plain_text: bytes Plain text to encrypt Returns ------- bytes nonce(16 bytes) + tag(16 bytes) + encrypted data
[ "AES", "-", "GCM", "encryption" ]
233f3d7726bf03465a6b2470e83f34cc457eea6c
https://github.com/kigawas/eciespy/blob/233f3d7726bf03465a6b2470e83f34cc457eea6c/ecies/utils.py#L159-L182
train
kigawas/eciespy
ecies/utils.py
aes_decrypt
def aes_decrypt(key: bytes, cipher_text: bytes) -> bytes: """ AES-GCM decryption Parameters ---------- key: bytes AES session key, which derived from two secp256k1 keys cipher_text: bytes Encrypted text: nonce(16 bytes) + tag(16 bytes) + encrypted data Returns ...
python
def aes_decrypt(key: bytes, cipher_text: bytes) -> bytes: """ AES-GCM decryption Parameters ---------- key: bytes AES session key, which derived from two secp256k1 keys cipher_text: bytes Encrypted text: nonce(16 bytes) + tag(16 bytes) + encrypted data Returns ...
[ "def", "aes_decrypt", "(", "key", ":", "bytes", ",", "cipher_text", ":", "bytes", ")", "->", "bytes", ":", "nonce", "=", "cipher_text", "[", ":", "16", "]", "tag", "=", "cipher_text", "[", "16", ":", "32", "]", "ciphered_data", "=", "cipher_text", "[",...
AES-GCM decryption Parameters ---------- key: bytes AES session key, which derived from two secp256k1 keys cipher_text: bytes Encrypted text: nonce(16 bytes) + tag(16 bytes) + encrypted data Returns ------- bytes Plain text >>> data = b'this is test...
[ "AES", "-", "GCM", "decryption" ]
233f3d7726bf03465a6b2470e83f34cc457eea6c
https://github.com/kigawas/eciespy/blob/233f3d7726bf03465a6b2470e83f34cc457eea6c/ecies/utils.py#L185-L216
train
wtolson/pysis
pysis/cubefile.py
CubeFile.apply_scaling
def apply_scaling(self, copy=True): """Scale pixel values to there true DN. :param copy: whether to apply the scalling to a copy of the pixel data and leave the orginial unaffected :returns: a scalled version of the pixel data """ if copy: return self.mu...
python
def apply_scaling(self, copy=True): """Scale pixel values to there true DN. :param copy: whether to apply the scalling to a copy of the pixel data and leave the orginial unaffected :returns: a scalled version of the pixel data """ if copy: return self.mu...
[ "def", "apply_scaling", "(", "self", ",", "copy", "=", "True", ")", ":", "if", "copy", ":", "return", "self", ".", "multiplier", "*", "self", ".", "data", "+", "self", ".", "base", "if", "self", ".", "multiplier", "!=", "1", ":", "self", ".", "data...
Scale pixel values to there true DN. :param copy: whether to apply the scalling to a copy of the pixel data and leave the orginial unaffected :returns: a scalled version of the pixel data
[ "Scale", "pixel", "values", "to", "there", "true", "DN", "." ]
7b907c8104bddfbb14c603de4d666c2101e1f999
https://github.com/wtolson/pysis/blob/7b907c8104bddfbb14c603de4d666c2101e1f999/pysis/cubefile.py#L65-L82
train
wtolson/pysis
pysis/cubefile.py
CubeFile.specials_mask
def specials_mask(self): """Create a pixel map for special pixels. :returns: an array where the value is `False` if the pixel is special and `True` otherwise """ mask = self.data >= self.specials['Min'] mask &= self.data <= self.specials['Max'] return mask
python
def specials_mask(self): """Create a pixel map for special pixels. :returns: an array where the value is `False` if the pixel is special and `True` otherwise """ mask = self.data >= self.specials['Min'] mask &= self.data <= self.specials['Max'] return mask
[ "def", "specials_mask", "(", "self", ")", ":", "mask", "=", "self", ".", "data", ">=", "self", ".", "specials", "[", "'Min'", "]", "mask", "&=", "self", ".", "data", "<=", "self", ".", "specials", "[", "'Max'", "]", "return", "mask" ]
Create a pixel map for special pixels. :returns: an array where the value is `False` if the pixel is special and `True` otherwise
[ "Create", "a", "pixel", "map", "for", "special", "pixels", "." ]
7b907c8104bddfbb14c603de4d666c2101e1f999
https://github.com/wtolson/pysis/blob/7b907c8104bddfbb14c603de4d666c2101e1f999/pysis/cubefile.py#L122-L130
train