repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
spookey/photon
photon/meta.py
Meta.log
def log(self, elem): ''' .. seealso:: :attr:`log` ''' if elem: self.__meta['log'].update({get_timestamp(precice=True): elem}) mfile = self.__meta['header']['stage'] self.__lock.acquire() try: j = read_json(mfile) if j != self....
python
def log(self, elem): ''' .. seealso:: :attr:`log` ''' if elem: self.__meta['log'].update({get_timestamp(precice=True): elem}) mfile = self.__meta['header']['stage'] self.__lock.acquire() try: j = read_json(mfile) if j != self....
[ "def", "log", "(", "self", ",", "elem", ")", ":", "if", "elem", ":", "self", ".", "__meta", "[", "'log'", "]", ".", "update", "(", "{", "get_timestamp", "(", "precice", "=", "True", ")", ":", "elem", "}", ")", "mfile", "=", "self", ".", "__meta",...
.. seealso:: :attr:`log`
[ "..", "seealso", "::", ":", "attr", ":", "log" ]
train
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/meta.py#L127-L142
minhhoit/yacms
yacms/forms/admin.py
FormAdmin.get_urls
def get_urls(self): """ Add the entries view to urls. """ urls = super(FormAdmin, self).get_urls() extra_urls = [ url("^(?P<form_id>\d+)/entries/$", self.admin_site.admin_view(self.entries_view), name="form_entries"), url("^...
python
def get_urls(self): """ Add the entries view to urls. """ urls = super(FormAdmin, self).get_urls() extra_urls = [ url("^(?P<form_id>\d+)/entries/$", self.admin_site.admin_view(self.entries_view), name="form_entries"), url("^...
[ "def", "get_urls", "(", "self", ")", ":", "urls", "=", "super", "(", "FormAdmin", ",", "self", ")", ".", "get_urls", "(", ")", "extra_urls", "=", "[", "url", "(", "\"^(?P<form_id>\\d+)/entries/$\"", ",", "self", ".", "admin_site", ".", "admin_view", "(", ...
Add the entries view to urls.
[ "Add", "the", "entries", "view", "to", "urls", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/forms/admin.py#L69-L82
minhhoit/yacms
yacms/forms/admin.py
FormAdmin.entries_view
def entries_view(self, request, form_id): """ Displays the form entries in a HTML table with option to export as CSV file. """ if request.POST.get("back"): change_url = admin_url(Form, "change", form_id) return HttpResponseRedirect(change_url) form...
python
def entries_view(self, request, form_id): """ Displays the form entries in a HTML table with option to export as CSV file. """ if request.POST.get("back"): change_url = admin_url(Form, "change", form_id) return HttpResponseRedirect(change_url) form...
[ "def", "entries_view", "(", "self", ",", "request", ",", "form_id", ")", ":", "if", "request", ".", "POST", ".", "get", "(", "\"back\"", ")", ":", "change_url", "=", "admin_url", "(", "Form", ",", "\"change\"", ",", "form_id", ")", "return", "HttpRespons...
Displays the form entries in a HTML table with option to export as CSV file.
[ "Displays", "the", "form", "entries", "in", "a", "HTML", "table", "with", "option", "to", "export", "as", "CSV", "file", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/forms/admin.py#L84-L136
jeremylow/pyshk
pyshk/api.py
Api.get_user
def get_user(self, user_id=None, user_name=None): """ Get a user object from the API. If no ``user_id`` or ``user_name`` is specified, it will return the User object for the currently authenticated user. Args: user_id (int): User ID of the user for whom you want to get ...
python
def get_user(self, user_id=None, user_name=None): """ Get a user object from the API. If no ``user_id`` or ``user_name`` is specified, it will return the User object for the currently authenticated user. Args: user_id (int): User ID of the user for whom you want to get ...
[ "def", "get_user", "(", "self", ",", "user_id", "=", "None", ",", "user_name", "=", "None", ")", ":", "if", "user_id", ":", "endpoint", "=", "'/api/user_id/{0}'", ".", "format", "(", "user_id", ")", "elif", "user_name", ":", "endpoint", "=", "'/api/user_na...
Get a user object from the API. If no ``user_id`` or ``user_name`` is specified, it will return the User object for the currently authenticated user. Args: user_id (int): User ID of the user for whom you want to get information. [Optional] user_name(str):...
[ "Get", "a", "user", "object", "from", "the", "API", ".", "If", "no", "user_id", "or", "user_name", "is", "specified", "it", "will", "return", "the", "User", "object", "for", "the", "currently", "authenticated", "user", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L267-L295
jeremylow/pyshk
pyshk/api.py
Api.get_user_shakes
def get_user_shakes(self): """ Get a list of Shake objects for the currently authenticated user. Returns: A list of Shake objects. """ endpoint = '/api/shakes' data = self._make_request(verb="GET", endpoint=endpoint) shakes = [Shake.NewFromJSON(shk) for shk ...
python
def get_user_shakes(self): """ Get a list of Shake objects for the currently authenticated user. Returns: A list of Shake objects. """ endpoint = '/api/shakes' data = self._make_request(verb="GET", endpoint=endpoint) shakes = [Shake.NewFromJSON(shk) for shk ...
[ "def", "get_user_shakes", "(", "self", ")", ":", "endpoint", "=", "'/api/shakes'", "data", "=", "self", ".", "_make_request", "(", "verb", "=", "\"GET\"", ",", "endpoint", "=", "endpoint", ")", "shakes", "=", "[", "Shake", ".", "NewFromJSON", "(", "shk", ...
Get a list of Shake objects for the currently authenticated user. Returns: A list of Shake objects.
[ "Get", "a", "list", "of", "Shake", "objects", "for", "the", "currently", "authenticated", "user", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L297-L307
jeremylow/pyshk
pyshk/api.py
Api.get_shared_files_from_shake
def get_shared_files_from_shake(self, shake_id=None, before=None, after=None): """ Returns a list of SharedFile objects from a particular shake. Args: shake_id (int): Shake fr...
python
def get_shared_files_from_shake(self, shake_id=None, before=None, after=None): """ Returns a list of SharedFile objects from a particular shake. Args: shake_id (int): Shake fr...
[ "def", "get_shared_files_from_shake", "(", "self", ",", "shake_id", "=", "None", ",", "before", "=", "None", ",", "after", "=", "None", ")", ":", "if", "before", "and", "after", ":", "raise", "Exception", "(", "\"You cannot specify both before and after keys\"", ...
Returns a list of SharedFile objects from a particular shake. Args: shake_id (int): Shake from which to get a list of SharedFiles before (str): get 10 SharedFile objects before (but not including) the SharedFile given by `before` for the given Shake. after (s...
[ "Returns", "a", "list", "of", "SharedFile", "objects", "from", "a", "particular", "shake", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L309-L340
jeremylow/pyshk
pyshk/api.py
Api.get_shared_file
def get_shared_file(self, sharekey=None): """ Returns a SharedFile object given by the sharekey. Args: sharekey (str): Sharekey of the SharedFile you want to retrieve. Returns: SharedFile """ if not sharekey: raise Exception("You must...
python
def get_shared_file(self, sharekey=None): """ Returns a SharedFile object given by the sharekey. Args: sharekey (str): Sharekey of the SharedFile you want to retrieve. Returns: SharedFile """ if not sharekey: raise Exception("You must...
[ "def", "get_shared_file", "(", "self", ",", "sharekey", "=", "None", ")", ":", "if", "not", "sharekey", ":", "raise", "Exception", "(", "\"You must specify a sharekey.\"", ")", "endpoint", "=", "'/api/sharedfile/{0}'", ".", "format", "(", "sharekey", ")", "data"...
Returns a SharedFile object given by the sharekey. Args: sharekey (str): Sharekey of the SharedFile you want to retrieve. Returns: SharedFile
[ "Returns", "a", "SharedFile", "object", "given", "by", "the", "sharekey", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L342-L356
jeremylow/pyshk
pyshk/api.py
Api.like_shared_file
def like_shared_file(self, sharekey=None): """ 'Like' a SharedFile. mlkshk doesn't allow you to unlike a sharedfile, so this is ~~permanent~~. Args: sharekey (str): Sharekey for the file you want to 'like'. Returns: Either a SharedFile on success, or an exceptio...
python
def like_shared_file(self, sharekey=None): """ 'Like' a SharedFile. mlkshk doesn't allow you to unlike a sharedfile, so this is ~~permanent~~. Args: sharekey (str): Sharekey for the file you want to 'like'. Returns: Either a SharedFile on success, or an exceptio...
[ "def", "like_shared_file", "(", "self", ",", "sharekey", "=", "None", ")", ":", "if", "not", "sharekey", ":", "raise", "Exception", "(", "\"You must specify a sharekey of the file you\"", "\"want to 'like'.\"", ")", "endpoint", "=", "'/api/sharedfile/{sharekey}/like'", ...
'Like' a SharedFile. mlkshk doesn't allow you to unlike a sharedfile, so this is ~~permanent~~. Args: sharekey (str): Sharekey for the file you want to 'like'. Returns: Either a SharedFile on success, or an exception on error.
[ "Like", "a", "SharedFile", ".", "mlkshk", "doesn", "t", "allow", "you", "to", "unlike", "a", "sharedfile", "so", "this", "is", "~~permanent~~", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L358-L382
jeremylow/pyshk
pyshk/api.py
Api.save_shared_file
def save_shared_file(self, sharekey=None): """ Save a SharedFile to your Shake. Args: sharekey (str): Sharekey for the file to save. Returns: SharedFile saved to your shake. """ endpoint = '/api/sharedfile/{sharekey}/save'.format(sharekey=shareke...
python
def save_shared_file(self, sharekey=None): """ Save a SharedFile to your Shake. Args: sharekey (str): Sharekey for the file to save. Returns: SharedFile saved to your shake. """ endpoint = '/api/sharedfile/{sharekey}/save'.format(sharekey=shareke...
[ "def", "save_shared_file", "(", "self", ",", "sharekey", "=", "None", ")", ":", "endpoint", "=", "'/api/sharedfile/{sharekey}/save'", ".", "format", "(", "sharekey", "=", "sharekey", ")", "data", "=", "self", ".", "_make_request", "(", "\"POST\"", ",", "endpoi...
Save a SharedFile to your Shake. Args: sharekey (str): Sharekey for the file to save. Returns: SharedFile saved to your shake.
[ "Save", "a", "SharedFile", "to", "your", "Shake", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L384-L402
jeremylow/pyshk
pyshk/api.py
Api.get_friends_shake
def get_friends_shake(self, before=None, after=None): """ Contrary to the endpoint naming, this resource is for a list of SharedFiles from your friends on mlkshk. Returns: List of SharedFiles. """ if before and after: raise Exception("You cannot s...
python
def get_friends_shake(self, before=None, after=None): """ Contrary to the endpoint naming, this resource is for a list of SharedFiles from your friends on mlkshk. Returns: List of SharedFiles. """ if before and after: raise Exception("You cannot s...
[ "def", "get_friends_shake", "(", "self", ",", "before", "=", "None", ",", "after", "=", "None", ")", ":", "if", "before", "and", "after", ":", "raise", "Exception", "(", "\"You cannot specify both before and after keys\"", ")", "endpoint", "=", "'/api/friends'", ...
Contrary to the endpoint naming, this resource is for a list of SharedFiles from your friends on mlkshk. Returns: List of SharedFiles.
[ "Contrary", "to", "the", "endpoint", "naming", "this", "resource", "is", "for", "a", "list", "of", "SharedFiles", "from", "your", "friends", "on", "mlkshk", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L404-L423
jeremylow/pyshk
pyshk/api.py
Api.get_magic_shake
def get_magic_shake(self, before=None, after=None): """ From the API: Returns the 10 most recent files accepted by the 'magic' file selection algorithm. Currently any files with 10 or more likes are magic. Returns: List of SharedFile objects """ if b...
python
def get_magic_shake(self, before=None, after=None): """ From the API: Returns the 10 most recent files accepted by the 'magic' file selection algorithm. Currently any files with 10 or more likes are magic. Returns: List of SharedFile objects """ if b...
[ "def", "get_magic_shake", "(", "self", ",", "before", "=", "None", ",", "after", "=", "None", ")", ":", "if", "before", "and", "after", ":", "raise", "Exception", "(", "\"You cannot specify both before and after keys\"", ")", "endpoint", "=", "'/api/magicfiles'", ...
From the API: Returns the 10 most recent files accepted by the 'magic' file selection algorithm. Currently any files with 10 or more likes are magic. Returns: List of SharedFile objects
[ "From", "the", "API", ":" ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L451-L472
jeremylow/pyshk
pyshk/api.py
Api.get_comments
def get_comments(self, sharekey=None): """ Retrieve comments on a SharedFile Args: sharekey (str): Sharekey for the file from which you want to return the set of comments. Returns: List of Comment objects. """ if not sharekey: ...
python
def get_comments(self, sharekey=None): """ Retrieve comments on a SharedFile Args: sharekey (str): Sharekey for the file from which you want to return the set of comments. Returns: List of Comment objects. """ if not sharekey: ...
[ "def", "get_comments", "(", "self", ",", "sharekey", "=", "None", ")", ":", "if", "not", "sharekey", ":", "raise", "Exception", "(", "\"You must specify a sharekey of the file you\"", "\"want to 'like'.\"", ")", "endpoint", "=", "'/api/sharedfile/{0}/comments'", ".", ...
Retrieve comments on a SharedFile Args: sharekey (str): Sharekey for the file from which you want to return the set of comments. Returns: List of Comment objects.
[ "Retrieve", "comments", "on", "a", "SharedFile" ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L474-L494
jeremylow/pyshk
pyshk/api.py
Api.post_comment
def post_comment(self, sharekey=None, comment=None): """ Post a comment on behalf of the current user to the SharedFile with the given sharekey. Args: sharekey (str): Sharekey of the SharedFile to which you'd like to post a comment. comment (str):...
python
def post_comment(self, sharekey=None, comment=None): """ Post a comment on behalf of the current user to the SharedFile with the given sharekey. Args: sharekey (str): Sharekey of the SharedFile to which you'd like to post a comment. comment (str):...
[ "def", "post_comment", "(", "self", ",", "sharekey", "=", "None", ",", "comment", "=", "None", ")", ":", "endpoint", "=", "'/api/sharedfile/{0}/comments'", ".", "format", "(", "sharekey", ")", "post_data", "=", "{", "'body'", ":", "comment", "}", "data", "...
Post a comment on behalf of the current user to the SharedFile with the given sharekey. Args: sharekey (str): Sharekey of the SharedFile to which you'd like to post a comment. comment (str): Text of the comment to post. Returns: Comment objec...
[ "Post", "a", "comment", "on", "behalf", "of", "the", "current", "user", "to", "the", "SharedFile", "with", "the", "given", "sharekey", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L496-L514
jeremylow/pyshk
pyshk/api.py
Api.post_shared_file
def post_shared_file(self, image_file=None, source_link=None, shake_id=None, title=None, description=None): """ Upload an image. TODO: Don't have a pro account to test (o...
python
def post_shared_file(self, image_file=None, source_link=None, shake_id=None, title=None, description=None): """ Upload an image. TODO: Don't have a pro account to test (o...
[ "def", "post_shared_file", "(", "self", ",", "image_file", "=", "None", ",", "source_link", "=", "None", ",", "shake_id", "=", "None", ",", "title", "=", "None", ",", "description", "=", "None", ")", ":", "if", "image_file", "and", "source_link", ":", "r...
Upload an image. TODO: Don't have a pro account to test (or even write) code to upload a shared filed to a particular shake. Args: image_file (str): path to an image (jpg/gif) on your computer. source_link (str): URL of a source (youtube/vine/etc.) s...
[ "Upload", "an", "image", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L516-L557
jeremylow/pyshk
pyshk/api.py
Api.update_shared_file
def update_shared_file(self, sharekey=None, title=None, description=None): """ Update the editable details (just the title and description) of a SharedFile. Args: sharekey (str): Sharekey of the...
python
def update_shared_file(self, sharekey=None, title=None, description=None): """ Update the editable details (just the title and description) of a SharedFile. Args: sharekey (str): Sharekey of the...
[ "def", "update_shared_file", "(", "self", ",", "sharekey", "=", "None", ",", "title", "=", "None", ",", "description", "=", "None", ")", ":", "if", "not", "sharekey", ":", "raise", "Exception", "(", "\"You must specify a sharekey for the sharedfile\"", "\"you wish...
Update the editable details (just the title and description) of a SharedFile. Args: sharekey (str): Sharekey of the SharedFile to update. title (Optional[str]): Title of the SharedFile. description (Optional[str]): Description of the SharedFile Returns: ...
[ "Update", "the", "editable", "details", "(", "just", "the", "title", "and", "description", ")", "of", "a", "SharedFile", "." ]
train
https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L559-L595
benwbooth/python-findmodules
findmodules.py
init
def init(script=sys.argv[0], base='lib', append=True, ignore=['/','/usr'], realpath=False, pythonpath=False, throw=False): """ Parameters: * `script`: Path to script file. Default is currently running script file * `base`: Name of base module directory to add to sys.path. Default is "lib". ...
python
def init(script=sys.argv[0], base='lib', append=True, ignore=['/','/usr'], realpath=False, pythonpath=False, throw=False): """ Parameters: * `script`: Path to script file. Default is currently running script file * `base`: Name of base module directory to add to sys.path. Default is "lib". ...
[ "def", "init", "(", "script", "=", "sys", ".", "argv", "[", "0", "]", ",", "base", "=", "'lib'", ",", "append", "=", "True", ",", "ignore", "=", "[", "'/'", ",", "'/usr'", "]", ",", "realpath", "=", "False", ",", "pythonpath", "=", "False", ",", ...
Parameters: * `script`: Path to script file. Default is currently running script file * `base`: Name of base module directory to add to sys.path. Default is "lib". * `append`: Append module directory to the end of sys.path, or insert at the beginning? Default is to append. * `ignore`: Li...
[ "Parameters", ":", "*", "script", ":", "Path", "to", "script", "file", ".", "Default", "is", "currently", "running", "script", "file", "*", "base", ":", "Name", "of", "base", "module", "directory", "to", "add", "to", "sys", ".", "path", ".", "Default", ...
train
https://github.com/benwbooth/python-findmodules/blob/26d20b70d80694cafc138d3677319af1cc2224af/findmodules.py#L26-L60
svasilev94/GraphLibrary
graphlibrary/graph.py
Graph.add_vertex
def add_vertex(self, vertex, **attr): """ Add vertex and update vertex attributes """ self.vertices[vertex] = [] if attr: self.nodes[vertex] = attr
python
def add_vertex(self, vertex, **attr): """ Add vertex and update vertex attributes """ self.vertices[vertex] = [] if attr: self.nodes[vertex] = attr
[ "def", "add_vertex", "(", "self", ",", "vertex", ",", "*", "*", "attr", ")", ":", "self", ".", "vertices", "[", "vertex", "]", "=", "[", "]", "if", "attr", ":", "self", ".", "nodes", "[", "vertex", "]", "=", "attr" ]
Add vertex and update vertex attributes
[ "Add", "vertex", "and", "update", "vertex", "attributes" ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/graph.py#L49-L55
svasilev94/GraphLibrary
graphlibrary/graph.py
Graph.add_edge
def add_edge(self, u, v, **attr): """ Add an edge between vertices u and v and update edge attributes """ if u not in self.vertices: self.vertices[u] = [] if v not in self.vertices: self.vertices[v] = [] vertex = (u, v) self.edges[...
python
def add_edge(self, u, v, **attr): """ Add an edge between vertices u and v and update edge attributes """ if u not in self.vertices: self.vertices[u] = [] if v not in self.vertices: self.vertices[v] = [] vertex = (u, v) self.edges[...
[ "def", "add_edge", "(", "self", ",", "u", ",", "v", ",", "*", "*", "attr", ")", ":", "if", "u", "not", "in", "self", ".", "vertices", ":", "self", ".", "vertices", "[", "u", "]", "=", "[", "]", "if", "v", "not", "in", "self", ".", "vertices",...
Add an edge between vertices u and v and update edge attributes
[ "Add", "an", "edge", "between", "vertices", "u", "and", "v", "and", "update", "edge", "attributes" ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/graph.py#L57-L70
svasilev94/GraphLibrary
graphlibrary/graph.py
Graph.remove_vertex
def remove_vertex(self, vertex): """ Remove vertex from G """ try: self.vertices.pop(vertex) except KeyError: raise GraphInsertError("Vertex %s doesn't exist." % (vertex,)) if vertex in self.nodes: self.nodes.pop(vertex) ...
python
def remove_vertex(self, vertex): """ Remove vertex from G """ try: self.vertices.pop(vertex) except KeyError: raise GraphInsertError("Vertex %s doesn't exist." % (vertex,)) if vertex in self.nodes: self.nodes.pop(vertex) ...
[ "def", "remove_vertex", "(", "self", ",", "vertex", ")", ":", "try", ":", "self", ".", "vertices", ".", "pop", "(", "vertex", ")", "except", "KeyError", ":", "raise", "GraphInsertError", "(", "\"Vertex %s doesn't exist.\"", "%", "(", "vertex", ",", ")", ")...
Remove vertex from G
[ "Remove", "vertex", "from", "G" ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/graph.py#L72-L90
svasilev94/GraphLibrary
graphlibrary/graph.py
Graph.remove_edge
def remove_edge(self, u, v): """ Remove the edge between vertices u and v """ try: self.edges.pop((u, v)) except KeyError: raise GraphInsertError("Edge %s-%s doesn't exist." % (u, v)) self.vertices[u].remove(v) self.vertices[v].rem...
python
def remove_edge(self, u, v): """ Remove the edge between vertices u and v """ try: self.edges.pop((u, v)) except KeyError: raise GraphInsertError("Edge %s-%s doesn't exist." % (u, v)) self.vertices[u].remove(v) self.vertices[v].rem...
[ "def", "remove_edge", "(", "self", ",", "u", ",", "v", ")", ":", "try", ":", "self", ".", "edges", ".", "pop", "(", "(", "u", ",", "v", ")", ")", "except", "KeyError", ":", "raise", "GraphInsertError", "(", "\"Edge %s-%s doesn't exist.\"", "%", "(", ...
Remove the edge between vertices u and v
[ "Remove", "the", "edge", "between", "vertices", "u", "and", "v" ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/graph.py#L92-L101
svasilev94/GraphLibrary
graphlibrary/graph.py
Graph.degree
def degree(self, vertex): """ Return the degree of a vertex """ try: return len(self.vertices[vertex]) except KeyError: raise GraphInsertError("Vertex %s doesn't exist." % (vertex,))
python
def degree(self, vertex): """ Return the degree of a vertex """ try: return len(self.vertices[vertex]) except KeyError: raise GraphInsertError("Vertex %s doesn't exist." % (vertex,))
[ "def", "degree", "(", "self", ",", "vertex", ")", ":", "try", ":", "return", "len", "(", "self", ".", "vertices", "[", "vertex", "]", ")", "except", "KeyError", ":", "raise", "GraphInsertError", "(", "\"Vertex %s doesn't exist.\"", "%", "(", "vertex", ",",...
Return the degree of a vertex
[ "Return", "the", "degree", "of", "a", "vertex" ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/graph.py#L112-L119
sys-git/certifiable
certifiable/cli_impl/core/certify_int.py
cli_certify_core_integer
def cli_certify_core_integer( config, min_value, max_value, value, ): """Console script for certify_int""" def parser(v): # Attempt a json/pickle decode: try: v = load_json_pickle(v, config) except Exception: pass # Attempt a straight conversion to i...
python
def cli_certify_core_integer( config, min_value, max_value, value, ): """Console script for certify_int""" def parser(v): # Attempt a json/pickle decode: try: v = load_json_pickle(v, config) except Exception: pass # Attempt a straight conversion to i...
[ "def", "cli_certify_core_integer", "(", "config", ",", "min_value", ",", "max_value", ",", "value", ",", ")", ":", "def", "parser", "(", "v", ")", ":", "# Attempt a json/pickle decode:", "try", ":", "v", "=", "load_json_pickle", "(", "v", ",", "config", ")",...
Console script for certify_int
[ "Console", "script", "for", "certify_int" ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/cli_impl/core/certify_int.py#L22-L57
keik/subarg
subarg/subarg.py
parse
def parse(argv, level=0): """ Parse sub-arguments between `[` and `]` recursively. Examples -------- ``` >>> argv = ['--foo', 'bar', '--buz', '[', 'qux', '--quux', 'corge', ']'] >>> subarg.parse(argv) ['--foo', 'bar', '--buz', ['qux', '--quux', 'corge']] ``` Parameters ----...
python
def parse(argv, level=0): """ Parse sub-arguments between `[` and `]` recursively. Examples -------- ``` >>> argv = ['--foo', 'bar', '--buz', '[', 'qux', '--quux', 'corge', ']'] >>> subarg.parse(argv) ['--foo', 'bar', '--buz', ['qux', '--quux', 'corge']] ``` Parameters ----...
[ "def", "parse", "(", "argv", ",", "level", "=", "0", ")", ":", "nargs", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "argv", ")", ")", ":", "if", "argv", "[", "i", "]", "==", "'['", ":", "level", "+=", "1", "if", "level", "=="...
Parse sub-arguments between `[` and `]` recursively. Examples -------- ``` >>> argv = ['--foo', 'bar', '--buz', '[', 'qux', '--quux', 'corge', ']'] >>> subarg.parse(argv) ['--foo', 'bar', '--buz', ['qux', '--quux', 'corge']] ``` Parameters ---------- argv : list of strings ...
[ "Parse", "sub", "-", "arguments", "between", "[", "and", "]", "recursively", "." ]
train
https://github.com/keik/subarg/blob/0c07d1502981e3ee8633e926882b45bd8453f6f7/subarg/subarg.py#L4-L46
ardydedase/pycouchbase
couchbase-python-cffi/couchbase_ffi/bucket.py
Bucket._warn_dupkey
def _warn_dupkey(self, k): """ Really odd function - used to help ensure we actually warn for duplicate keys. """ if self._privflags & PYCBC_CONN_F_WARNEXPLICIT: warnings.warn_explicit( 'Found duplicate keys! {0}'.format(k), RuntimeWarning, ...
python
def _warn_dupkey(self, k): """ Really odd function - used to help ensure we actually warn for duplicate keys. """ if self._privflags & PYCBC_CONN_F_WARNEXPLICIT: warnings.warn_explicit( 'Found duplicate keys! {0}'.format(k), RuntimeWarning, ...
[ "def", "_warn_dupkey", "(", "self", ",", "k", ")", ":", "if", "self", ".", "_privflags", "&", "PYCBC_CONN_F_WARNEXPLICIT", ":", "warnings", ".", "warn_explicit", "(", "'Found duplicate keys! {0}'", ".", "format", "(", "k", ")", ",", "RuntimeWarning", ",", "__f...
Really odd function - used to help ensure we actually warn for duplicate keys.
[ "Really", "odd", "function", "-", "used", "to", "help", "ensure", "we", "actually", "warn", "for", "duplicate", "keys", "." ]
train
https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/bucket.py#L750-L760
minhhoit/yacms
yacms/blog/management/commands/import_wordpress.py
Command.get_text
def get_text(self, xml, name): """ Gets the element's text value from the XML object provided. """ nodes = xml.getElementsByTagName("wp:comment_" + name)[0].childNodes accepted_types = [Node.CDATA_SECTION_NODE, Node.TEXT_NODE] return "".join([n.data for n in nodes if n.no...
python
def get_text(self, xml, name): """ Gets the element's text value from the XML object provided. """ nodes = xml.getElementsByTagName("wp:comment_" + name)[0].childNodes accepted_types = [Node.CDATA_SECTION_NODE, Node.TEXT_NODE] return "".join([n.data for n in nodes if n.no...
[ "def", "get_text", "(", "self", ",", "xml", ",", "name", ")", ":", "nodes", "=", "xml", ".", "getElementsByTagName", "(", "\"wp:comment_\"", "+", "name", ")", "[", "0", "]", ".", "childNodes", "accepted_types", "=", "[", "Node", ".", "CDATA_SECTION_NODE", ...
Gets the element's text value from the XML object provided.
[ "Gets", "the", "element", "s", "text", "value", "from", "the", "XML", "object", "provided", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/commands/import_wordpress.py#L28-L34
minhhoit/yacms
yacms/blog/management/commands/import_wordpress.py
Command.handle_import
def handle_import(self, options): """ Gets the posts from either the provided URL or the path if it is local. """ url = options.get("url") if url is None: raise CommandError("Usage is import_wordpress %s" % self.args) try: import feedparse...
python
def handle_import(self, options): """ Gets the posts from either the provided URL or the path if it is local. """ url = options.get("url") if url is None: raise CommandError("Usage is import_wordpress %s" % self.args) try: import feedparse...
[ "def", "handle_import", "(", "self", ",", "options", ")", ":", "url", "=", "options", ".", "get", "(", "\"url\"", ")", "if", "url", "is", "None", ":", "raise", "CommandError", "(", "\"Usage is import_wordpress %s\"", "%", "self", ".", "args", ")", "try", ...
Gets the posts from either the provided URL or the path if it is local.
[ "Gets", "the", "posts", "from", "either", "the", "provided", "URL", "or", "the", "path", "if", "it", "is", "local", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/commands/import_wordpress.py#L36-L100
minhhoit/yacms
yacms/blog/management/commands/import_wordpress.py
Command.wp_caption
def wp_caption(self, post): """ Filters a Wordpress Post for Image Captions and renders to match HTML. """ for match in re.finditer(r"\[caption (.*?)\](.*?)\[/caption\]", post): meta = '<div ' caption = '' for imatch in re.finditer(r'(\w+)="(.*...
python
def wp_caption(self, post): """ Filters a Wordpress Post for Image Captions and renders to match HTML. """ for match in re.finditer(r"\[caption (.*?)\](.*?)\[/caption\]", post): meta = '<div ' caption = '' for imatch in re.finditer(r'(\w+)="(.*...
[ "def", "wp_caption", "(", "self", ",", "post", ")", ":", "for", "match", "in", "re", ".", "finditer", "(", "r\"\\[caption (.*?)\\](.*?)\\[/caption\\]\"", ",", "post", ")", ":", "meta", "=", "'<div '", "caption", "=", "''", "for", "imatch", "in", "re", ".",...
Filters a Wordpress Post for Image Captions and renders to match HTML.
[ "Filters", "a", "Wordpress", "Post", "for", "Image", "Captions", "and", "renders", "to", "match", "HTML", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/commands/import_wordpress.py#L102-L123
d6e/emotion
emote/emote.py
read_emote_mappings
def read_emote_mappings(json_obj_files=[]): """ Reads the contents of a list of files of json objects and combines them into one large json object. """ super_json = {} for fname in json_obj_files: with open(fname) as f: super_json.update(json.loads(f.read().decode('utf-8'))) retu...
python
def read_emote_mappings(json_obj_files=[]): """ Reads the contents of a list of files of json objects and combines them into one large json object. """ super_json = {} for fname in json_obj_files: with open(fname) as f: super_json.update(json.loads(f.read().decode('utf-8'))) retu...
[ "def", "read_emote_mappings", "(", "json_obj_files", "=", "[", "]", ")", ":", "super_json", "=", "{", "}", "for", "fname", "in", "json_obj_files", ":", "with", "open", "(", "fname", ")", "as", "f", ":", "super_json", ".", "update", "(", "json", ".", "l...
Reads the contents of a list of files of json objects and combines them into one large json object.
[ "Reads", "the", "contents", "of", "a", "list", "of", "files", "of", "json", "objects", "and", "combines", "them", "into", "one", "large", "json", "object", "." ]
train
https://github.com/d6e/emotion/blob/8ea84935a9103c3079579b3d9b9db85e12710af2/emote/emote.py#L9-L16
jmgilman/Neolib
neolib/inventory/ShopWizardResult.py
ShopWizardResult.shop
def shop(self, index): """ Return's the user shop the indexed item is in Parameters: index (int) -- The item index Returns UserShopFront - User shop item is in """ return UserShopFront(self.usr, item.owner, item.id, str(item.price))
python
def shop(self, index): """ Return's the user shop the indexed item is in Parameters: index (int) -- The item index Returns UserShopFront - User shop item is in """ return UserShopFront(self.usr, item.owner, item.id, str(item.price))
[ "def", "shop", "(", "self", ",", "index", ")", ":", "return", "UserShopFront", "(", "self", ".", "usr", ",", "item", ".", "owner", ",", "item", ".", "id", ",", "str", "(", "item", ".", "price", ")", ")" ]
Return's the user shop the indexed item is in Parameters: index (int) -- The item index Returns UserShopFront - User shop item is in
[ "Return", "s", "the", "user", "shop", "the", "indexed", "item", "is", "in", "Parameters", ":", "index", "(", "int", ")", "--", "The", "item", "index", "Returns", "UserShopFront", "-", "User", "shop", "item", "is", "in" ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/inventory/ShopWizardResult.py#L70-L79
jmgilman/Neolib
neolib/inventory/ShopWizardResult.py
ShopWizardResult.buy
def buy(self, index): """ Attempts to buy indexed item, returns result Parameters: index (int) -- The item index Returns bool - True if item was bought, false otherwise """ item = self.items[index] us = UserShopFront(self.usr,...
python
def buy(self, index): """ Attempts to buy indexed item, returns result Parameters: index (int) -- The item index Returns bool - True if item was bought, false otherwise """ item = self.items[index] us = UserShopFront(self.usr,...
[ "def", "buy", "(", "self", ",", "index", ")", ":", "item", "=", "self", ".", "items", "[", "index", "]", "us", "=", "UserShopFront", "(", "self", ".", "usr", ",", "item", ".", "owner", ",", "item", ".", "id", ",", "str", "(", "item", ".", "pric...
Attempts to buy indexed item, returns result Parameters: index (int) -- The item index Returns bool - True if item was bought, false otherwise
[ "Attempts", "to", "buy", "indexed", "item", "returns", "result", "Parameters", ":", "index", "(", "int", ")", "--", "The", "item", "index", "Returns", "bool", "-", "True", "if", "item", "was", "bought", "false", "otherwise" ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/inventory/ShopWizardResult.py#L81-L100
sternoru/goscalecms
goscale/themes/site_middleware.py
make_tls_property
def make_tls_property(default=None): """Creates a class-wide instance property with a thread-specific value.""" class TLSProperty(object): def __init__(self): from threading import local self.local = local() def __get__(self, instance, cls): if not instance: ...
python
def make_tls_property(default=None): """Creates a class-wide instance property with a thread-specific value.""" class TLSProperty(object): def __init__(self): from threading import local self.local = local() def __get__(self, instance, cls): if not instance: ...
[ "def", "make_tls_property", "(", "default", "=", "None", ")", ":", "class", "TLSProperty", "(", "object", ")", ":", "def", "__init__", "(", "self", ")", ":", "from", "threading", "import", "local", "self", ".", "local", "=", "local", "(", ")", "def", "...
Creates a class-wide instance property with a thread-specific value.
[ "Creates", "a", "class", "-", "wide", "instance", "property", "with", "a", "thread", "-", "specific", "value", "." ]
train
https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/themes/site_middleware.py#L7-L28
sternoru/goscalecms
goscale/themes/site_middleware.py
SiteOnFlyDetectionMiddleware.get_domain_and_port
def get_domain_and_port(self): """ Django's request.get_host() returns the requested host and possibly the port number. Return a tuple of domain, port number. Domain will be lowercased """ host = self.request.get_host() if ':' in host: domain, port = ...
python
def get_domain_and_port(self): """ Django's request.get_host() returns the requested host and possibly the port number. Return a tuple of domain, port number. Domain will be lowercased """ host = self.request.get_host() if ':' in host: domain, port = ...
[ "def", "get_domain_and_port", "(", "self", ")", ":", "host", "=", "self", ".", "request", ".", "get_host", "(", ")", "if", "':'", "in", "host", ":", "domain", ",", "port", "=", "host", ".", "split", "(", "':'", ")", "else", ":", "domain", "=", "hos...
Django's request.get_host() returns the requested host and possibly the port number. Return a tuple of domain, port number. Domain will be lowercased
[ "Django", "s", "request", ".", "get_host", "()", "returns", "the", "requested", "host", "and", "possibly", "the", "port", "number", ".", "Return", "a", "tuple", "of", "domain", "port", "number", ".", "Domain", "will", "be", "lowercased" ]
train
https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/themes/site_middleware.py#L54-L68
sternoru/goscalecms
goscale/themes/site_middleware.py
SiteOnFlyDetectionMiddleware.lookup
def lookup(self): """ The meat of this middleware. Returns None and sets settings.SITE_ID if able to find a Site object by domain and its subdomain is valid. Returns an HttpResponsePermanentRedirect to the Site's default subdomain if a site is found but the requested su...
python
def lookup(self): """ The meat of this middleware. Returns None and sets settings.SITE_ID if able to find a Site object by domain and its subdomain is valid. Returns an HttpResponsePermanentRedirect to the Site's default subdomain if a site is found but the requested su...
[ "def", "lookup", "(", "self", ")", ":", "# check to see if this hostname is actually a env hostname", "if", "self", ".", "domain", ":", "if", "self", ".", "subdomain", ":", "self", ".", "domain_unsplit", "=", "'%s.%s'", "%", "(", "self", ".", "subdomain", ",", ...
The meat of this middleware. Returns None and sets settings.SITE_ID if able to find a Site object by domain and its subdomain is valid. Returns an HttpResponsePermanentRedirect to the Site's default subdomain if a site is found but the requested subdomain is not supported, or i...
[ "The", "meat", "of", "this", "middleware", "." ]
train
https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/themes/site_middleware.py#L70-L118
sternoru/goscalecms
goscale/themes/site_middleware.py
SiteOnFlyDetectionMiddleware.theme_lookup
def theme_lookup(self): """ Returns theme based on site Returns None and sets settings.THEME if able to find a theme object by site. Otherwise, returns False. """ # check cache cache_key = 'theme:%s' % self.domain_unsplit theme = cache.get(cache_key) ...
python
def theme_lookup(self): """ Returns theme based on site Returns None and sets settings.THEME if able to find a theme object by site. Otherwise, returns False. """ # check cache cache_key = 'theme:%s' % self.domain_unsplit theme = cache.get(cache_key) ...
[ "def", "theme_lookup", "(", "self", ")", ":", "# check cache", "cache_key", "=", "'theme:%s'", "%", "self", ".", "domain_unsplit", "theme", "=", "cache", ".", "get", "(", "cache_key", ")", "if", "theme", ":", "THEME", ".", "value", "=", "theme", "return", ...
Returns theme based on site Returns None and sets settings.THEME if able to find a theme object by site. Otherwise, returns False.
[ "Returns", "theme", "based", "on", "site" ]
train
https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/themes/site_middleware.py#L120-L144
uw-it-aca/uw-restclients-iasystem
uw_iasystem/evaluation.py
search_evaluations
def search_evaluations(domain, **kwargs): """ domain: seattle, bothell, tacoma, pce_ap, pce_ol, pce_ielp, pce (case insensitive) args: year (required) term_name (required): Winter|Spring|Summer|Autumn curriculum_abbreviation course_number section_id student_id...
python
def search_evaluations(domain, **kwargs): """ domain: seattle, bothell, tacoma, pce_ap, pce_ol, pce_ielp, pce (case insensitive) args: year (required) term_name (required): Winter|Spring|Summer|Autumn curriculum_abbreviation course_number section_id student_id...
[ "def", "search_evaluations", "(", "domain", ",", "*", "*", "kwargs", ")", ":", "url", "=", "\"{}?{}\"", ".", "format", "(", "IAS_PREFIX", ",", "urlencode", "(", "kwargs", ")", ")", "data", "=", "get_resource", "(", "url", ",", "domain", ")", "evaluations...
domain: seattle, bothell, tacoma, pce_ap, pce_ol, pce_ielp, pce (case insensitive) args: year (required) term_name (required): Winter|Spring|Summer|Autumn curriculum_abbreviation course_number section_id student_id (student number) instructor_id (employee identi...
[ "domain", ":", "seattle", "bothell", "tacoma", "pce_ap", "pce_ol", "pce_ielp", "pce", "(", "case", "insensitive", ")", "args", ":", "year", "(", "required", ")", "term_name", "(", "required", ")", ":", "Winter|Spring|Summer|Autumn", "curriculum_abbreviation", "cou...
train
https://github.com/uw-it-aca/uw-restclients-iasystem/blob/f65f169d54b0d39e2d732cba529ccd8b6cb49f8a/uw_iasystem/evaluation.py#L16-L35
uw-it-aca/uw-restclients-iasystem
uw_iasystem/evaluation.py
_json_to_evaluation
def _json_to_evaluation(data): """ Only keep the data for online evaluations. Two scenarios for multiple instructors: 1) all of the co-instructors may be evaluated online as a group, sharing the eval URL. 2) each co-instructor may be evaluated individually, with separate eval URLs. ...
python
def _json_to_evaluation(data): """ Only keep the data for online evaluations. Two scenarios for multiple instructors: 1) all of the co-instructors may be evaluated online as a group, sharing the eval URL. 2) each co-instructor may be evaluated individually, with separate eval URLs. ...
[ "def", "_json_to_evaluation", "(", "data", ")", ":", "if", "data", "is", "None", ":", "return", "None", "evaluations", "=", "[", "]", "collection_items", "=", "data", ".", "get", "(", "'collection'", ")", ".", "get", "(", "'items'", ")", "for", "item", ...
Only keep the data for online evaluations. Two scenarios for multiple instructors: 1) all of the co-instructors may be evaluated online as a group, sharing the eval URL. 2) each co-instructor may be evaluated individually, with separate eval URLs.
[ "Only", "keep", "the", "data", "for", "online", "evaluations", ".", "Two", "scenarios", "for", "multiple", "instructors", ":", "1", ")", "all", "of", "the", "co", "-", "instructors", "may", "be", "evaluated", "online", "as", "a", "group", "sharing", "the",...
train
https://github.com/uw-it-aca/uw-restclients-iasystem/blob/f65f169d54b0d39e2d732cba529ccd8b6cb49f8a/uw_iasystem/evaluation.py#L43-L84
Valuehorizon/valuehorizon-people
people/models.py
Person.age
def age(self, as_at_date=None): """ Compute the person's age """ if self.date_of_death != None or self.is_deceased == True: return None as_at_date = date.today() if as_at_date == None else as_at_date if self.date_of_birth != None: if (as_...
python
def age(self, as_at_date=None): """ Compute the person's age """ if self.date_of_death != None or self.is_deceased == True: return None as_at_date = date.today() if as_at_date == None else as_at_date if self.date_of_birth != None: if (as_...
[ "def", "age", "(", "self", ",", "as_at_date", "=", "None", ")", ":", "if", "self", ".", "date_of_death", "!=", "None", "or", "self", ".", "is_deceased", "==", "True", ":", "return", "None", "as_at_date", "=", "date", ".", "today", "(", ")", "if", "as...
Compute the person's age
[ "Compute", "the", "person", "s", "age" ]
train
https://github.com/Valuehorizon/valuehorizon-people/blob/f32d9f1349c1a9384bae5ea61d10c1b1e0318401/people/models.py#L53-L68
Valuehorizon/valuehorizon-people
people/models.py
Person.name
def name(self): """ Return the person's name. If we have special titles, use them, otherwise, don't include the title. """ if self.title in ["DR", "SIR", "LORD"]: return "%s %s %s" % (self.get_title_display(), self.first_name, self.last_name) else: ...
python
def name(self): """ Return the person's name. If we have special titles, use them, otherwise, don't include the title. """ if self.title in ["DR", "SIR", "LORD"]: return "%s %s %s" % (self.get_title_display(), self.first_name, self.last_name) else: ...
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "title", "in", "[", "\"DR\"", ",", "\"SIR\"", ",", "\"LORD\"", "]", ":", "return", "\"%s %s %s\"", "%", "(", "self", ".", "get_title_display", "(", ")", ",", "self", ".", "first_name", ",", "se...
Return the person's name. If we have special titles, use them, otherwise, don't include the title.
[ "Return", "the", "person", "s", "name", ".", "If", "we", "have", "special", "titles", "use", "them", "otherwise", "don", "t", "include", "the", "title", "." ]
train
https://github.com/Valuehorizon/valuehorizon-people/blob/f32d9f1349c1a9384bae5ea61d10c1b1e0318401/people/models.py#L78-L86
Valuehorizon/valuehorizon-people
people/models.py
Person.full_name
def full_name(self): """ Return the title and full name """ return "%s %s %s %s" % (self.get_title_display(), self.first_name, self.other_names.replace(",", ""), self.last_name)
python
def full_name(self): """ Return the title and full name """ return "%s %s %s %s" % (self.get_title_display(), self.first_name, self.other_names.replace(",", ""), self.last_name)
[ "def", "full_name", "(", "self", ")", ":", "return", "\"%s %s %s %s\"", "%", "(", "self", ".", "get_title_display", "(", ")", ",", "self", ".", "first_name", ",", "self", ".", "other_names", ".", "replace", "(", "\",\"", ",", "\"\"", ")", ",", "self", ...
Return the title and full name
[ "Return", "the", "title", "and", "full", "name" ]
train
https://github.com/Valuehorizon/valuehorizon-people/blob/f32d9f1349c1a9384bae5ea61d10c1b1e0318401/people/models.py#L89-L96
Valuehorizon/valuehorizon-people
people/models.py
Person.save
def save(self, *args, **kwargs): """ If date of death is specified, set is_deceased to true """ if self.date_of_death != None: self.is_deceased = True # Since we often copy and paste names from strange sources, do some basic cleanup self.first_nam...
python
def save(self, *args, **kwargs): """ If date of death is specified, set is_deceased to true """ if self.date_of_death != None: self.is_deceased = True # Since we often copy and paste names from strange sources, do some basic cleanup self.first_nam...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "date_of_death", "!=", "None", ":", "self", ".", "is_deceased", "=", "True", "# Since we often copy and paste names from strange sources, do some basic cleanup", "s...
If date of death is specified, set is_deceased to true
[ "If", "date", "of", "death", "is", "specified", "set", "is_deceased", "to", "true" ]
train
https://github.com/Valuehorizon/valuehorizon-people/blob/f32d9f1349c1a9384bae5ea61d10c1b1e0318401/people/models.py#L102-L115
awacha/credolib
credolib/persistence.py
storedata
def storedata(filename=None): """Store the state of the current credolib workspace in a pickle file.""" if filename is None: filename = 'credolib_state.pickle' ns = get_ipython().user_ns with open(filename, 'wb') as f: d = {} for var in ['_headers', '_loaders', '_data1d', '_data2...
python
def storedata(filename=None): """Store the state of the current credolib workspace in a pickle file.""" if filename is None: filename = 'credolib_state.pickle' ns = get_ipython().user_ns with open(filename, 'wb') as f: d = {} for var in ['_headers', '_loaders', '_data1d', '_data2...
[ "def", "storedata", "(", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "filename", "=", "'credolib_state.pickle'", "ns", "=", "get_ipython", "(", ")", ".", "user_ns", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "f",...
Store the state of the current credolib workspace in a pickle file.
[ "Store", "the", "state", "of", "the", "current", "credolib", "workspace", "in", "a", "pickle", "file", "." ]
train
https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/persistence.py#L8-L24
awacha/credolib
credolib/persistence.py
restoredata
def restoredata(filename=None): """Restore the state of the credolib workspace from a pickle file.""" if filename is None: filename = 'credolib_state.pickle' ns = get_ipython().user_ns with open(filename, 'rb') as f: d = pickle.load(f) for k in d.keys(): ns[k] = d[k]
python
def restoredata(filename=None): """Restore the state of the credolib workspace from a pickle file.""" if filename is None: filename = 'credolib_state.pickle' ns = get_ipython().user_ns with open(filename, 'rb') as f: d = pickle.load(f) for k in d.keys(): ns[k] = d[k]
[ "def", "restoredata", "(", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "filename", "=", "'credolib_state.pickle'", "ns", "=", "get_ipython", "(", ")", ".", "user_ns", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "f...
Restore the state of the credolib workspace from a pickle file.
[ "Restore", "the", "state", "of", "the", "credolib", "workspace", "from", "a", "pickle", "file", "." ]
train
https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/persistence.py#L27-L35
TheOneHyer/arandomness
build/lib.linux-x86_64-3.6/arandomness/str/autocorrect.py
autocorrect
def autocorrect(query, possibilities, delta=0.75): """Attempts to figure out what possibility the query is This autocorrect function is rather simple right now with plans for later improvement. Right now, it just attempts to finish spelling a word as much as possible, and then determines which possibil...
python
def autocorrect(query, possibilities, delta=0.75): """Attempts to figure out what possibility the query is This autocorrect function is rather simple right now with plans for later improvement. Right now, it just attempts to finish spelling a word as much as possible, and then determines which possibil...
[ "def", "autocorrect", "(", "query", ",", "possibilities", ",", "delta", "=", "0.75", ")", ":", "# TODO: Make this way more robust and awesome using probability, n-grams?", "possibilities", "=", "[", "possibility", ".", "lower", "(", ")", "for", "possibility", "in", "p...
Attempts to figure out what possibility the query is This autocorrect function is rather simple right now with plans for later improvement. Right now, it just attempts to finish spelling a word as much as possible, and then determines which possibility is closest to said word. Args: query (un...
[ "Attempts", "to", "figure", "out", "what", "possibility", "the", "query", "is" ]
train
https://github.com/TheOneHyer/arandomness/blob/ae9f630e9a1d67b0eb6d61644a49756de8a5268c/build/lib.linux-x86_64-3.6/arandomness/str/autocorrect.py#L34-L88
nir0s/serv
serv/init/base.py
Base.generate
def generate(self, overwrite): """Generate service files. This exposes several comforts. `self.files` is a list into which all generated file paths will be appended. It is later returned by `generate` to be consumed by any program that wants to do something with it. `s...
python
def generate(self, overwrite): """Generate service files. This exposes several comforts. `self.files` is a list into which all generated file paths will be appended. It is later returned by `generate` to be consumed by any program that wants to do something with it. `s...
[ "def", "generate", "(", "self", ",", "overwrite", ")", ":", "self", ".", "files", "=", "[", "]", "tmp", "=", "utils", ".", "get_tmp_dir", "(", "self", ".", "init_system", ",", "self", ".", "name", ")", "self", ".", "templates", "=", "os", ".", "pat...
Generate service files. This exposes several comforts. `self.files` is a list into which all generated file paths will be appended. It is later returned by `generate` to be consumed by any program that wants to do something with it. `self.templates` is the directory in which a...
[ "Generate", "service", "files", "." ]
train
https://github.com/nir0s/serv/blob/7af724ed49c0eb766c37c4b5287b043a8cf99e9c/serv/init/base.py#L78-L109
nir0s/serv
serv/init/base.py
Base.status
def status(self, **kwargs): """Retrieve the status of a service `name` or all services for the current init system. """ self.services = dict( init_system=self.init_system, services=[] )
python
def status(self, **kwargs): """Retrieve the status of a service `name` or all services for the current init system. """ self.services = dict( init_system=self.init_system, services=[] )
[ "def", "status", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "services", "=", "dict", "(", "init_system", "=", "self", ".", "init_system", ",", "services", "=", "[", "]", ")" ]
Retrieve the status of a service `name` or all services for the current init system.
[ "Retrieve", "the", "status", "of", "a", "service", "name", "or", "all", "services", "for", "the", "current", "init", "system", "." ]
train
https://github.com/nir0s/serv/blob/7af724ed49c0eb766c37c4b5287b043a8cf99e9c/serv/init/base.py#L139-L146
nir0s/serv
serv/init/base.py
Base.generate_file_from_template
def generate_file_from_template(self, template, destination): """Generate a file from a Jinja2 `template` and writes it to `destination` using `params`. `overwrite` allows to overwrite existing files. It is passed to the `generate` method. This is used by the different init imp...
python
def generate_file_from_template(self, template, destination): """Generate a file from a Jinja2 `template` and writes it to `destination` using `params`. `overwrite` allows to overwrite existing files. It is passed to the `generate` method. This is used by the different init imp...
[ "def", "generate_file_from_template", "(", "self", ",", "template", ",", "destination", ")", ":", "# We cast the object to a string before passing it on as py3.x", "# will fail on Jinja2 if there are ints/bytes (not strings) in the", "# template which will not allow `env.from_string(template...
Generate a file from a Jinja2 `template` and writes it to `destination` using `params`. `overwrite` allows to overwrite existing files. It is passed to the `generate` method. This is used by the different init implementations to generate init scripts/configs and deploy them to ...
[ "Generate", "a", "file", "from", "a", "Jinja2", "template", "and", "writes", "it", "to", "destination", "using", "params", "." ]
train
https://github.com/nir0s/serv/blob/7af724ed49c0eb766c37c4b5287b043a8cf99e9c/serv/init/base.py#L163-L198
KnowledgeLinks/rdfframework
rdfframework/rdfclass/esconversion.py
convert_value_to_es
def convert_value_to_es(value, ranges, obj, method=None): """ Takes an value and converts it to an elasticsearch representation args: value: the value to convert ranges: the list of ranges method: convertion method to use 'None': default -> converts the value to its ...
python
def convert_value_to_es(value, ranges, obj, method=None): """ Takes an value and converts it to an elasticsearch representation args: value: the value to convert ranges: the list of ranges method: convertion method to use 'None': default -> converts the value to its ...
[ "def", "convert_value_to_es", "(", "value", ",", "ranges", ",", "obj", ",", "method", "=", "None", ")", ":", "def", "sub_convert", "(", "val", ")", ":", "\"\"\"\n Returns the json value for a simple datatype or the subject uri if the\n value is a rdfclass\n\n ...
Takes an value and converts it to an elasticsearch representation args: value: the value to convert ranges: the list of ranges method: convertion method to use 'None': default -> converts the value to its json value 'missing_obj': adds attributes as if the va...
[ "Takes", "an", "value", "and", "converts", "it", "to", "an", "elasticsearch", "representation" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L24-L65
KnowledgeLinks/rdfframework
rdfframework/rdfclass/esconversion.py
get_idx_types
def get_idx_types(rng_def, ranges): """ Returns the elasticsearch index types for the obj args: rng_def: the range defintion dictionay ranges: rdfproperty ranges """ idx_types = rng_def.get('kds_esIndexType', []).copy() if not idx_types: nested = False for rng in...
python
def get_idx_types(rng_def, ranges): """ Returns the elasticsearch index types for the obj args: rng_def: the range defintion dictionay ranges: rdfproperty ranges """ idx_types = rng_def.get('kds_esIndexType', []).copy() if not idx_types: nested = False for rng in...
[ "def", "get_idx_types", "(", "rng_def", ",", "ranges", ")", ":", "idx_types", "=", "rng_def", ".", "get", "(", "'kds_esIndexType'", ",", "[", "]", ")", ".", "copy", "(", ")", "if", "not", "idx_types", ":", "nested", "=", "False", "for", "rng", "in", ...
Returns the elasticsearch index types for the obj args: rng_def: the range defintion dictionay ranges: rdfproperty ranges
[ "Returns", "the", "elasticsearch", "index", "types", "for", "the", "obj" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L67-L83
KnowledgeLinks/rdfframework
rdfframework/rdfclass/esconversion.py
get_prop_range_defs
def get_prop_range_defs(class_names, def_list): """ Filters the range defitions based on the bound class args: obj: the rdffroperty instance """ try: cls_options = set(class_names + ['kdr_AllClasses']) return [rng_def for rng_def in def_list \ if not isinsta...
python
def get_prop_range_defs(class_names, def_list): """ Filters the range defitions based on the bound class args: obj: the rdffroperty instance """ try: cls_options = set(class_names + ['kdr_AllClasses']) return [rng_def for rng_def in def_list \ if not isinsta...
[ "def", "get_prop_range_defs", "(", "class_names", ",", "def_list", ")", ":", "try", ":", "cls_options", "=", "set", "(", "class_names", "+", "[", "'kdr_AllClasses'", "]", ")", "return", "[", "rng_def", "for", "rng_def", "in", "def_list", "if", "not", "isinst...
Filters the range defitions based on the bound class args: obj: the rdffroperty instance
[ "Filters", "the", "range", "defitions", "based", "on", "the", "bound", "class" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L85-L101
KnowledgeLinks/rdfframework
rdfframework/rdfclass/esconversion.py
range_is_obj
def range_is_obj(rng, rdfclass): """ Test to see if range for the class should be an object or a litteral """ if rng == 'rdfs_Literal': return False if hasattr(rdfclass, rng): mod_class = getattr(rdfclass, rng) for item in mod_class.cls_defs['rdf_type']: try: ...
python
def range_is_obj(rng, rdfclass): """ Test to see if range for the class should be an object or a litteral """ if rng == 'rdfs_Literal': return False if hasattr(rdfclass, rng): mod_class = getattr(rdfclass, rng) for item in mod_class.cls_defs['rdf_type']: try: ...
[ "def", "range_is_obj", "(", "rng", ",", "rdfclass", ")", ":", "if", "rng", "==", "'rdfs_Literal'", ":", "return", "False", "if", "hasattr", "(", "rdfclass", ",", "rng", ")", ":", "mod_class", "=", "getattr", "(", "rdfclass", ",", "rng", ")", "for", "it...
Test to see if range for the class should be an object or a litteral
[ "Test", "to", "see", "if", "range", "for", "the", "class", "should", "be", "an", "object", "or", "a", "litteral" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L118-L135
KnowledgeLinks/rdfframework
rdfframework/rdfclass/esconversion.py
get_es_value
def get_es_value(obj, def_obj): """ Returns the value for an object that goes into the elacticsearch 'value' field args: obj: data object to update def_obj: the class instance that has defintion values """ def get_dict_val(item): """ Returns the string representa...
python
def get_es_value(obj, def_obj): """ Returns the value for an object that goes into the elacticsearch 'value' field args: obj: data object to update def_obj: the class instance that has defintion values """ def get_dict_val(item): """ Returns the string representa...
[ "def", "get_es_value", "(", "obj", ",", "def_obj", ")", ":", "def", "get_dict_val", "(", "item", ")", ":", "\"\"\"\n Returns the string representation of the dict item\n \"\"\"", "if", "isinstance", "(", "item", ",", "dict", ")", ":", "return", "str", ...
Returns the value for an object that goes into the elacticsearch 'value' field args: obj: data object to update def_obj: the class instance that has defintion values
[ "Returns", "the", "value", "for", "an", "object", "that", "goes", "into", "the", "elacticsearch", "value", "field" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L141-L184
KnowledgeLinks/rdfframework
rdfframework/rdfclass/esconversion.py
get_es_label
def get_es_label(obj, def_obj): """ Returns object with label for an object that goes into the elacticsearch 'label' field args: obj: data object to update def_obj: the class instance that has defintion values """ label_flds = LABEL_FIELDS if def_obj.es_defs.get('kds_esLabel...
python
def get_es_label(obj, def_obj): """ Returns object with label for an object that goes into the elacticsearch 'label' field args: obj: data object to update def_obj: the class instance that has defintion values """ label_flds = LABEL_FIELDS if def_obj.es_defs.get('kds_esLabel...
[ "def", "get_es_label", "(", "obj", ",", "def_obj", ")", ":", "label_flds", "=", "LABEL_FIELDS", "if", "def_obj", ".", "es_defs", ".", "get", "(", "'kds_esLabel'", ")", ":", "label_flds", "=", "def_obj", ".", "es_defs", "[", "'kds_esLabel'", "]", "+", "LABE...
Returns object with label for an object that goes into the elacticsearch 'label' field args: obj: data object to update def_obj: the class instance that has defintion values
[ "Returns", "object", "with", "label", "for", "an", "object", "that", "goes", "into", "the", "elacticsearch", "label", "field" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L186-L213
KnowledgeLinks/rdfframework
rdfframework/rdfclass/esconversion.py
get_es_ids
def get_es_ids(obj, def_obj): """ Returns the object updated with the 'id' and 'uri' fields for the elasticsearch document args: obj: data object to update def_obj: the class instance that has defintion values """ try: path = "" for base in [def_obj.__class__] + ...
python
def get_es_ids(obj, def_obj): """ Returns the object updated with the 'id' and 'uri' fields for the elasticsearch document args: obj: data object to update def_obj: the class instance that has defintion values """ try: path = "" for base in [def_obj.__class__] + ...
[ "def", "get_es_ids", "(", "obj", ",", "def_obj", ")", ":", "try", ":", "path", "=", "\"\"", "for", "base", "in", "[", "def_obj", ".", "__class__", "]", "+", "list", "(", "def_obj", ".", "__class__", ".", "__bases__", ")", ":", "if", "hasattr", "(", ...
Returns the object updated with the 'id' and 'uri' fields for the elasticsearch document args: obj: data object to update def_obj: the class instance that has defintion values
[ "Returns", "the", "object", "updated", "with", "the", "id", "and", "uri", "fields", "for", "the", "elasticsearch", "document" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L215-L241
KnowledgeLinks/rdfframework
rdfframework/rdfclass/esconversion.py
make_es_id
def make_es_id(uri): """ Creates the id based off of the uri value Args: ----- uri: the uri to conver to an elasticsearch id """ try: uri = uri.clean_uri except AttributeError: pass return sha1(uri.encode()).hexdigest()
python
def make_es_id(uri): """ Creates the id based off of the uri value Args: ----- uri: the uri to conver to an elasticsearch id """ try: uri = uri.clean_uri except AttributeError: pass return sha1(uri.encode()).hexdigest()
[ "def", "make_es_id", "(", "uri", ")", ":", "try", ":", "uri", "=", "uri", ".", "clean_uri", "except", "AttributeError", ":", "pass", "return", "sha1", "(", "uri", ".", "encode", "(", ")", ")", ".", "hexdigest", "(", ")" ]
Creates the id based off of the uri value Args: ----- uri: the uri to conver to an elasticsearch id
[ "Creates", "the", "id", "based", "off", "of", "the", "uri", "value" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/esconversion.py#L243-L255
tschaume/ccsgp_get_started
ccsgp_get_started/examples/gp_background.py
gp_background
def gp_background(): """ plot background methods and S/B vs energy """ inDir, outDir = getWorkDirs() data, REBIN = OrderedDict(), None titles = [ 'SE_{+-}', 'SE@^{corr}_{/Symbol \\261\\261}', 'ME@^{N}_{+-}' ] Apm = OrderedDict([ ('19', 0.026668), ('27', 0.026554), ('39', 0.026816), ('62', 0....
python
def gp_background(): """ plot background methods and S/B vs energy """ inDir, outDir = getWorkDirs() data, REBIN = OrderedDict(), None titles = [ 'SE_{+-}', 'SE@^{corr}_{/Symbol \\261\\261}', 'ME@^{N}_{+-}' ] Apm = OrderedDict([ ('19', 0.026668), ('27', 0.026554), ('39', 0.026816), ('62', 0....
[ "def", "gp_background", "(", ")", ":", "inDir", ",", "outDir", "=", "getWorkDirs", "(", ")", "data", ",", "REBIN", "=", "OrderedDict", "(", ")", ",", "None", "titles", "=", "[", "'SE_{+-}'", ",", "'SE@^{corr}_{/Symbol \\\\261\\\\261}'", ",", "'ME@^{N}_{+-}'", ...
plot background methods and S/B vs energy
[ "plot", "background", "methods", "and", "S", "/", "B", "vs", "energy" ]
train
https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/gp_background.py#L26-L121
tschaume/ccsgp_get_started
ccsgp_get_started/examples/gp_background.py
gp_norm
def gp_norm(infile): """indentify normalization region""" inDir, outDir = getWorkDirs() data, titles = [], [] for eidx,energy in enumerate(['19', '27', '39', '62']): file_url = os.path.realpath(os.path.join( inDir, 'rawdata', energy, 'pt-integrated', infile+'.dat' )) ...
python
def gp_norm(infile): """indentify normalization region""" inDir, outDir = getWorkDirs() data, titles = [], [] for eidx,energy in enumerate(['19', '27', '39', '62']): file_url = os.path.realpath(os.path.join( inDir, 'rawdata', energy, 'pt-integrated', infile+'.dat' )) ...
[ "def", "gp_norm", "(", "infile", ")", ":", "inDir", ",", "outDir", "=", "getWorkDirs", "(", ")", "data", ",", "titles", "=", "[", "]", ",", "[", "]", "for", "eidx", ",", "energy", "in", "enumerate", "(", "[", "'19'", ",", "'27'", ",", "'39'", ","...
indentify normalization region
[ "indentify", "normalization", "region" ]
train
https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/gp_background.py#L201-L245
pydsigner/taskit
daemonizing/port_expander.py
get_ports
def get_ports(ports): """ Ports should one of: 'number' 'number,number2,number3...' 'number-number2' """ if '-' in ports: # example: '10-15' at this point start, stop = ports.split('-') # start, stop = '10', '15' # return range(10, 16) --> iter([10, 11, ...
python
def get_ports(ports): """ Ports should one of: 'number' 'number,number2,number3...' 'number-number2' """ if '-' in ports: # example: '10-15' at this point start, stop = ports.split('-') # start, stop = '10', '15' # return range(10, 16) --> iter([10, 11, ...
[ "def", "get_ports", "(", "ports", ")", ":", "if", "'-'", "in", "ports", ":", "# example: '10-15' at this point", "start", ",", "stop", "=", "ports", ".", "split", "(", "'-'", ")", "# start, stop = '10', '15'", "# return range(10, 16) --> iter([10, 11, 12, 13, 14, 15])",...
Ports should one of: 'number' 'number,number2,number3...' 'number-number2'
[ "Ports", "should", "one", "of", ":", "number", "number", "number2", "number3", "...", "number", "-", "number2" ]
train
https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/daemonizing/port_expander.py#L4-L19
KnowledgeLinks/rdfframework
rdfframework/datatypes/xsdtypes.py
pyrdf2
def pyrdf2(value, class_type=None, datatype=None, lang=None, **kwargs): """ Coverts an input to one of the rdfdatatypes classes Args: value: any rdfdatatype, json dict or vlaue class_type: "literal", "uri" or "blanknode" datatype: "xsd:string", "xsd:int" , etc """ ...
python
def pyrdf2(value, class_type=None, datatype=None, lang=None, **kwargs): """ Coverts an input to one of the rdfdatatypes classes Args: value: any rdfdatatype, json dict or vlaue class_type: "literal", "uri" or "blanknode" datatype: "xsd:string", "xsd:int" , etc """ ...
[ "def", "pyrdf2", "(", "value", ",", "class_type", "=", "None", ",", "datatype", "=", "None", ",", "lang", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "# test to see if the type is...
Coverts an input to one of the rdfdatatypes classes Args: value: any rdfdatatype, json dict or vlaue class_type: "literal", "uri" or "blanknode" datatype: "xsd:string", "xsd:int" , etc
[ "Coverts", "an", "input", "to", "one", "of", "the", "rdfdatatypes", "classes" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/xsdtypes.py#L416-L453
KnowledgeLinks/rdfframework
rdfframework/datatypes/xsdtypes.py
pyrdf
def pyrdf(value, class_type=None, datatype=None, **kwargs): """ Coverts an input to one of the rdfdatatypes classes Args: value: any rdfdatatype, json dict or vlaue class_type: "literal", "uri" or "blanknode" datatype: "xsd:string", "xsd:int" , etc kwargs: ...
python
def pyrdf(value, class_type=None, datatype=None, **kwargs): """ Coverts an input to one of the rdfdatatypes classes Args: value: any rdfdatatype, json dict or vlaue class_type: "literal", "uri" or "blanknode" datatype: "xsd:string", "xsd:int" , etc kwargs: ...
[ "def", "pyrdf", "(", "value", ",", "class_type", "=", "None", ",", "datatype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "value", ",", "BaseRdfDataType", ")", ":", "return", "value", "if", "isinstance", "(", "value", ",",...
Coverts an input to one of the rdfdatatypes classes Args: value: any rdfdatatype, json dict or vlaue class_type: "literal", "uri" or "blanknode" datatype: "xsd:string", "xsd:int" , etc kwargs: lang: language tag
[ "Coverts", "an", "input", "to", "one", "of", "the", "rdfdatatypes", "classes" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/xsdtypes.py#L464-L495
KnowledgeLinks/rdfframework
rdfframework/datatypes/xsdtypes.py
XsdInteger._internal_add
def _internal_add(self, other): """ Used for specifing addition methods for __add__, __iadd__, __radd__ """ if hasattr(other, "datatype"): if other.datatype == self.datatype: rtn_val = self.value + other.value else: rtn_val = sel...
python
def _internal_add(self, other): """ Used for specifing addition methods for __add__, __iadd__, __radd__ """ if hasattr(other, "datatype"): if other.datatype == self.datatype: rtn_val = self.value + other.value else: rtn_val = sel...
[ "def", "_internal_add", "(", "self", ",", "other", ")", ":", "if", "hasattr", "(", "other", ",", "\"datatype\"", ")", ":", "if", "other", ".", "datatype", "==", "self", ".", "datatype", ":", "rtn_val", "=", "self", ".", "value", "+", "other", ".", "v...
Used for specifing addition methods for __add__, __iadd__, __radd__
[ "Used", "for", "specifing", "addition", "methods", "for", "__add__", "__iadd__", "__radd__" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/xsdtypes.py#L273-L284
KnowledgeLinks/rdfframework
rdfframework/datatypes/xsdtypes.py
XsdInteger._internal_sub
def _internal_sub(self, other, method=None): """ Used for specifing addition methods for __add__, __iadd__, __radd__ """ if hasattr(other, "datatype"): if other.datatype == self.datatype: oval = other.value else: oval = int(other...
python
def _internal_sub(self, other, method=None): """ Used for specifing addition methods for __add__, __iadd__, __radd__ """ if hasattr(other, "datatype"): if other.datatype == self.datatype: oval = other.value else: oval = int(other...
[ "def", "_internal_sub", "(", "self", ",", "other", ",", "method", "=", "None", ")", ":", "if", "hasattr", "(", "other", ",", "\"datatype\"", ")", ":", "if", "other", ".", "datatype", "==", "self", ".", "datatype", ":", "oval", "=", "other", ".", "val...
Used for specifing addition methods for __add__, __iadd__, __radd__
[ "Used", "for", "specifing", "addition", "methods", "for", "__add__", "__iadd__", "__radd__" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/xsdtypes.py#L286-L301
KnowledgeLinks/rdfframework
rdfframework/datatypes/xsdtypes.py
XsdDecimal._internal_add
def _internal_add(self, other): """ Used for specifing addition methods for __add__, __iadd__, __radd__ """ if hasattr(other, "datatype"): if other.datatype == "xsd:decimal": rtn_val = self.value + Decimal(str(other.value)) else: ...
python
def _internal_add(self, other): """ Used for specifing addition methods for __add__, __iadd__, __radd__ """ if hasattr(other, "datatype"): if other.datatype == "xsd:decimal": rtn_val = self.value + Decimal(str(other.value)) else: ...
[ "def", "_internal_add", "(", "self", ",", "other", ")", ":", "if", "hasattr", "(", "other", ",", "\"datatype\"", ")", ":", "if", "other", ".", "datatype", "==", "\"xsd:decimal\"", ":", "rtn_val", "=", "self", ".", "value", "+", "Decimal", "(", "str", "...
Used for specifing addition methods for __add__, __iadd__, __radd__
[ "Used", "for", "specifing", "addition", "methods", "for", "__add__", "__iadd__", "__radd__" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/xsdtypes.py#L342-L353
hamfist/sj
setup.py
get_version
def get_version(): """ Get the version from the source, but without importing. """ with open('sj.py') as source: for node in ast.walk(ast.parse(source.read(), 'sj.py')): if node.__class__.__name__ == 'Assign' and \ node.targets[0].__class__.__name__ == 'Name' and \ ...
python
def get_version(): """ Get the version from the source, but without importing. """ with open('sj.py') as source: for node in ast.walk(ast.parse(source.read(), 'sj.py')): if node.__class__.__name__ == 'Assign' and \ node.targets[0].__class__.__name__ == 'Name' and \ ...
[ "def", "get_version", "(", ")", ":", "with", "open", "(", "'sj.py'", ")", "as", "source", ":", "for", "node", "in", "ast", ".", "walk", "(", "ast", ".", "parse", "(", "source", ".", "read", "(", ")", ",", "'sj.py'", ")", ")", ":", "if", "node", ...
Get the version from the source, but without importing.
[ "Get", "the", "version", "from", "the", "source", "but", "without", "importing", "." ]
train
https://github.com/hamfist/sj/blob/a4c4b30285723651a1fe82c6d85b85a979d85cfc/setup.py#L12-L21
minhhoit/yacms
yacms/conf/forms.py
SettingsForm._init_field
def _init_field(self, setting, field_class, name, code=None): """ Initialize a field whether it is built with a custom name for a specific translation language or not. """ kwargs = { "label": setting["label"] + ":", "required": setting["type"] in (int, flo...
python
def _init_field(self, setting, field_class, name, code=None): """ Initialize a field whether it is built with a custom name for a specific translation language or not. """ kwargs = { "label": setting["label"] + ":", "required": setting["type"] in (int, flo...
[ "def", "_init_field", "(", "self", ",", "setting", ",", "field_class", ",", "name", ",", "code", "=", "None", ")", ":", "kwargs", "=", "{", "\"label\"", ":", "setting", "[", "\"label\"", "]", "+", "\":\"", ",", "\"required\"", ":", "setting", "[", "\"t...
Initialize a field whether it is built with a custom name for a specific translation language or not.
[ "Initialize", "a", "field", "whether", "it", "is", "built", "with", "a", "custom", "name", "for", "a", "specific", "translation", "language", "or", "not", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/forms.py#L52-L72
minhhoit/yacms
yacms/conf/forms.py
SettingsForm.save
def save(self): """ Save each of the settings to the DB. """ active_language = get_language() for (name, value) in self.cleaned_data.items(): if name not in registry: name, code = name.rsplit('_modeltranslation_', 1) else: c...
python
def save(self): """ Save each of the settings to the DB. """ active_language = get_language() for (name, value) in self.cleaned_data.items(): if name not in registry: name, code = name.rsplit('_modeltranslation_', 1) else: c...
[ "def", "save", "(", "self", ")", ":", "active_language", "=", "get_language", "(", ")", "for", "(", "name", ",", "value", ")", "in", "self", ".", "cleaned_data", ".", "items", "(", ")", ":", "if", "name", "not", "in", "registry", ":", "name", ",", ...
Save each of the settings to the DB.
[ "Save", "each", "of", "the", "settings", "to", "the", "DB", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/forms.py#L91-L119
minhhoit/yacms
yacms/conf/forms.py
SettingsForm.format_help
def format_help(self, description): """ Format the setting's description into HTML. """ for bold in ("``", "*"): parts = [] if description is None: description = "" for i, s in enumerate(description.split(bold)): parts.a...
python
def format_help(self, description): """ Format the setting's description into HTML. """ for bold in ("``", "*"): parts = [] if description is None: description = "" for i, s in enumerate(description.split(bold)): parts.a...
[ "def", "format_help", "(", "self", ",", "description", ")", ":", "for", "bold", "in", "(", "\"``\"", ",", "\"*\"", ")", ":", "parts", "=", "[", "]", "if", "description", "is", "None", ":", "description", "=", "\"\"", "for", "i", ",", "s", "in", "en...
Format the setting's description into HTML.
[ "Format", "the", "setting", "s", "description", "into", "HTML", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/forms.py#L121-L133
azogue/dataweb
dataweb/mergedataweb.py
pdmerge_respeta_tz
def pdmerge_respeta_tz(func_merge, tz_ant=None, *args, **kwargs): """ Programación defensiva por issue: pandas BUG (a veces, el index pierde el tz): - issue #7795: concat of objects with the same timezone get reset to UTC; - issue #10567: DataFrame combine_first() loses timezone information for ...
python
def pdmerge_respeta_tz(func_merge, tz_ant=None, *args, **kwargs): """ Programación defensiva por issue: pandas BUG (a veces, el index pierde el tz): - issue #7795: concat of objects with the same timezone get reset to UTC; - issue #10567: DataFrame combine_first() loses timezone information for ...
[ "def", "pdmerge_respeta_tz", "(", "func_merge", ",", "tz_ant", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "df_merged", "=", "func_merge", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "tz_ant", "is", "not", "None", "and...
Programación defensiva por issue: pandas BUG (a veces, el index pierde el tz): - issue #7795: concat of objects with the same timezone get reset to UTC; - issue #10567: DataFrame combine_first() loses timezone information for datetime columns https://github.com/pydata/pandas/issues/10567 ...
[ "Programación", "defensiva", "por", "issue", ":", "pandas", "BUG", "(", "a", "veces", "el", "index", "pierde", "el", "tz", ")", ":", "-", "issue", "#7795", ":", "concat", "of", "objects", "with", "the", "same", "timezone", "get", "reset", "to", "UTC", ...
train
https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/mergedataweb.py#L18-L35
azogue/dataweb
dataweb/mergedataweb.py
merge_data
def merge_data(lista_dfs_o_dict, keys_merge=None): """ Realiza y devuelve el merge de una lista de pandas DataFrame's (o bien de un diccionario de {key:pd.Dataframe}). Coge la primera y en ella va añadiendo el resto, de una en una. Seguramente no sea la mejor opción para realizar la fusión de los datos ...
python
def merge_data(lista_dfs_o_dict, keys_merge=None): """ Realiza y devuelve el merge de una lista de pandas DataFrame's (o bien de un diccionario de {key:pd.Dataframe}). Coge la primera y en ella va añadiendo el resto, de una en una. Seguramente no sea la mejor opción para realizar la fusión de los datos ...
[ "def", "merge_data", "(", "lista_dfs_o_dict", ",", "keys_merge", "=", "None", ")", ":", "def", "_merge_lista", "(", "lista_dfs", ")", ":", "if", "len", "(", "lista_dfs", ")", "==", "2", "and", "lista_dfs", "[", "0", "]", ".", "index", "[", "-", "1", ...
Realiza y devuelve el merge de una lista de pandas DataFrame's (o bien de un diccionario de {key:pd.Dataframe}). Coge la primera y en ella va añadiendo el resto, de una en una. Seguramente no sea la mejor opción para realizar la fusión de los datos de distintos días, pero aguanta bien la superposición de mu...
[ "Realiza", "y", "devuelve", "el", "merge", "de", "una", "lista", "de", "pandas", "DataFrame", "s", "(", "o", "bien", "de", "un", "diccionario", "de", "{", "key", ":", "pd", ".", "Dataframe", "}", ")", ".", "Coge", "la", "primera", "y", "en", "ella", ...
train
https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/mergedataweb.py#L39-L91
calvinku96/labreporthelper
labreporthelper/bestfit/polyfit.py
PolyFit.do_bestfit
def do_bestfit(self): """ Method to get fit_args after getting necessary variables """ self.check_important_variables() self.fit_args = np.polyfit( self.args["x"], self.args["y"], self.args.get("degree", 1)) self.done_bestfit = True return self.fit_arg...
python
def do_bestfit(self): """ Method to get fit_args after getting necessary variables """ self.check_important_variables() self.fit_args = np.polyfit( self.args["x"], self.args["y"], self.args.get("degree", 1)) self.done_bestfit = True return self.fit_arg...
[ "def", "do_bestfit", "(", "self", ")", ":", "self", ".", "check_important_variables", "(", ")", "self", ".", "fit_args", "=", "np", ".", "polyfit", "(", "self", ".", "args", "[", "\"x\"", "]", ",", "self", ".", "args", "[", "\"y\"", "]", ",", "self",...
Method to get fit_args after getting necessary variables
[ "Method", "to", "get", "fit_args", "after", "getting", "necessary", "variables" ]
train
https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/bestfit/polyfit.py#L26-L34
calvinku96/labreporthelper
labreporthelper/bestfit/polyfit.py
PolyFit.bestfit_func
def bestfit_func(self, bestfit_x): """ Returns bestfit_y value args: bestfit_x: scalar, array_like x value return: scalar, array_like bestfit y value """ bestfit_x = np.array(bestfit_x) if not self.done_bestfit: ...
python
def bestfit_func(self, bestfit_x): """ Returns bestfit_y value args: bestfit_x: scalar, array_like x value return: scalar, array_like bestfit y value """ bestfit_x = np.array(bestfit_x) if not self.done_bestfit: ...
[ "def", "bestfit_func", "(", "self", ",", "bestfit_x", ")", ":", "bestfit_x", "=", "np", ".", "array", "(", "bestfit_x", ")", "if", "not", "self", ".", "done_bestfit", ":", "raise", "KeyError", "(", "\"Do do_bestfit first\"", ")", "bestfit_y", "=", "0", "fo...
Returns bestfit_y value args: bestfit_x: scalar, array_like x value return: scalar, array_like bestfit y value
[ "Returns", "bestfit_y", "value" ]
train
https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/bestfit/polyfit.py#L36-L53
minhhoit/yacms
yacms/accounts/views.py
login
def login(request, template="accounts/account_login.html", form_class=LoginForm, extra_context=None): """ Login form. """ form = form_class(request.POST or None) if request.method == "POST" and form.is_valid(): authenticated_user = form.save() info(request, _("Successfully ...
python
def login(request, template="accounts/account_login.html", form_class=LoginForm, extra_context=None): """ Login form. """ form = form_class(request.POST or None) if request.method == "POST" and form.is_valid(): authenticated_user = form.save() info(request, _("Successfully ...
[ "def", "login", "(", "request", ",", "template", "=", "\"accounts/account_login.html\"", ",", "form_class", "=", "LoginForm", ",", "extra_context", "=", "None", ")", ":", "form", "=", "form_class", "(", "request", ".", "POST", "or", "None", ")", "if", "reque...
Login form.
[ "Login", "form", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L22-L35
minhhoit/yacms
yacms/accounts/views.py
logout
def logout(request): """ Log the user out. """ auth_logout(request) info(request, _("Successfully logged out")) return redirect(next_url(request) or get_script_prefix())
python
def logout(request): """ Log the user out. """ auth_logout(request) info(request, _("Successfully logged out")) return redirect(next_url(request) or get_script_prefix())
[ "def", "logout", "(", "request", ")", ":", "auth_logout", "(", "request", ")", "info", "(", "request", ",", "_", "(", "\"Successfully logged out\"", ")", ")", "return", "redirect", "(", "next_url", "(", "request", ")", "or", "get_script_prefix", "(", ")", ...
Log the user out.
[ "Log", "the", "user", "out", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L38-L44
minhhoit/yacms
yacms/accounts/views.py
signup
def signup(request, template="accounts/account_signup.html", extra_context=None): """ Signup form. """ profile_form = get_profile_form() form = profile_form(request.POST or None, request.FILES or None) if request.method == "POST" and form.is_valid(): new_user = form.save() ...
python
def signup(request, template="accounts/account_signup.html", extra_context=None): """ Signup form. """ profile_form = get_profile_form() form = profile_form(request.POST or None, request.FILES or None) if request.method == "POST" and form.is_valid(): new_user = form.save() ...
[ "def", "signup", "(", "request", ",", "template", "=", "\"accounts/account_signup.html\"", ",", "extra_context", "=", "None", ")", ":", "profile_form", "=", "get_profile_form", "(", ")", "form", "=", "profile_form", "(", "request", ".", "POST", "or", "None", "...
Signup form.
[ "Signup", "form", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L47-L72
minhhoit/yacms
yacms/accounts/views.py
signup_verify
def signup_verify(request, uidb36=None, token=None): """ View for the link in the verification email sent to a new user when they create an account and ``ACCOUNTS_VERIFICATION_REQUIRED`` is set to ``True``. Activates the user and logs them in, redirecting to the URL they tried to access when signing...
python
def signup_verify(request, uidb36=None, token=None): """ View for the link in the verification email sent to a new user when they create an account and ``ACCOUNTS_VERIFICATION_REQUIRED`` is set to ``True``. Activates the user and logs them in, redirecting to the URL they tried to access when signing...
[ "def", "signup_verify", "(", "request", ",", "uidb36", "=", "None", ",", "token", "=", "None", ")", ":", "user", "=", "authenticate", "(", "uidb36", "=", "uidb36", ",", "token", "=", "token", ",", "is_active", "=", "False", ")", "if", "user", "is", "...
View for the link in the verification email sent to a new user when they create an account and ``ACCOUNTS_VERIFICATION_REQUIRED`` is set to ``True``. Activates the user and logs them in, redirecting to the URL they tried to access when signing up.
[ "View", "for", "the", "link", "in", "the", "verification", "email", "sent", "to", "a", "new", "user", "when", "they", "create", "an", "account", "and", "ACCOUNTS_VERIFICATION_REQUIRED", "is", "set", "to", "True", ".", "Activates", "the", "user", "and", "logs...
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L75-L91
minhhoit/yacms
yacms/accounts/views.py
profile
def profile(request, username, template="accounts/account_profile.html", extra_context=None): """ Display a profile. """ lookup = {"username__iexact": username, "is_active": True} context = {"profile_user": get_object_or_404(User, **lookup)} context.update(extra_context or {}) re...
python
def profile(request, username, template="accounts/account_profile.html", extra_context=None): """ Display a profile. """ lookup = {"username__iexact": username, "is_active": True} context = {"profile_user": get_object_or_404(User, **lookup)} context.update(extra_context or {}) re...
[ "def", "profile", "(", "request", ",", "username", ",", "template", "=", "\"accounts/account_profile.html\"", ",", "extra_context", "=", "None", ")", ":", "lookup", "=", "{", "\"username__iexact\"", ":", "username", ",", "\"is_active\"", ":", "True", "}", "conte...
Display a profile.
[ "Display", "a", "profile", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L103-L111
minhhoit/yacms
yacms/accounts/views.py
profile_update
def profile_update(request, template="accounts/account_profile_update.html", extra_context=None): """ Profile update form. """ profile_form = get_profile_form() form = profile_form(request.POST or None, request.FILES or None, instance=request.user) if r...
python
def profile_update(request, template="accounts/account_profile_update.html", extra_context=None): """ Profile update form. """ profile_form = get_profile_form() form = profile_form(request.POST or None, request.FILES or None, instance=request.user) if r...
[ "def", "profile_update", "(", "request", ",", "template", "=", "\"accounts/account_profile_update.html\"", ",", "extra_context", "=", "None", ")", ":", "profile_form", "=", "get_profile_form", "(", ")", "form", "=", "profile_form", "(", "request", ".", "POST", "or...
Profile update form.
[ "Profile", "update", "form", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/views.py#L124-L141
jtpaasch/simplygithub
simplygithub/branches.py
get_branch_sha
def get_branch_sha(profile, name): """Get the SHA a branch's HEAD points to. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. ...
python
def get_branch_sha(profile, name): """Get the SHA a branch's HEAD points to. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. ...
[ "def", "get_branch_sha", "(", "profile", ",", "name", ")", ":", "ref", "=", "\"heads/\"", "+", "name", "data", "=", "refs", ".", "get_ref", "(", "profile", ",", "ref", ")", "head", "=", "data", ".", "get", "(", "\"head\"", ")", "sha", "=", "head", ...
Get the SHA a branch's HEAD points to. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name The name of the branch...
[ "Get", "the", "SHA", "a", "branch", "s", "HEAD", "points", "to", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L8-L29
jtpaasch/simplygithub
simplygithub/branches.py
get_branch
def get_branch(profile, name): """Fetch a branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name The nam...
python
def get_branch(profile, name): """Fetch a branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name The nam...
[ "def", "get_branch", "(", "profile", ",", "name", ")", ":", "ref", "=", "\"heads/\"", "+", "name", "data", "=", "refs", ".", "get_ref", "(", "profile", ",", "ref", ")", "return", "data" ]
Fetch a branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name The name of the branch to fetch. Returns...
[ "Fetch", "a", "branch", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L50-L69
jtpaasch/simplygithub
simplygithub/branches.py
create_branch
def create_branch(profile, name, branch_off): """Create a branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name ...
python
def create_branch(profile, name, branch_off): """Create a branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name ...
[ "def", "create_branch", "(", "profile", ",", "name", ",", "branch_off", ")", ":", "branch_off_sha", "=", "get_branch_sha", "(", "profile", ",", "branch_off", ")", "ref", "=", "\"heads/\"", "+", "name", "data", "=", "refs", ".", "create_ref", "(", "profile", ...
Create a branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name The name of the new branch. branch_...
[ "Create", "a", "branch", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L72-L95
jtpaasch/simplygithub
simplygithub/branches.py
update_branch
def update_branch(profile, name, sha): """Move a branch's HEAD to a new SHA. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. ...
python
def update_branch(profile, name, sha): """Move a branch's HEAD to a new SHA. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. ...
[ "def", "update_branch", "(", "profile", ",", "name", ",", "sha", ")", ":", "ref", "=", "\"heads/\"", "+", "name", "data", "=", "refs", ".", "update_ref", "(", "profile", ",", "ref", ",", "sha", ")", "return", "data" ]
Move a branch's HEAD to a new SHA. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name The name of the branch to ...
[ "Move", "a", "branch", "s", "HEAD", "to", "a", "new", "SHA", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L98-L120
jtpaasch/simplygithub
simplygithub/branches.py
delete_branch
def delete_branch(profile, name): """Delete a branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name The...
python
def delete_branch(profile, name): """Delete a branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name The...
[ "def", "delete_branch", "(", "profile", ",", "name", ")", ":", "ref", "=", "\"heads/\"", "+", "name", "data", "=", "refs", ".", "delete_ref", "(", "profile", ",", "ref", ")", "return", "data" ]
Delete a branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. name The name of the branch to delete. Retur...
[ "Delete", "a", "branch", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L123-L142
jtpaasch/simplygithub
simplygithub/branches.py
merge
def merge(profile, branch, merge_into): """Merge a branch into another branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. ...
python
def merge(profile, branch, merge_into): """Merge a branch into another branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. ...
[ "def", "merge", "(", "profile", ",", "branch", ",", "merge_into", ")", ":", "data", "=", "merges", ".", "merge", "(", "profile", ",", "branch", ",", "merge_into", ")", "return", "data" ]
Merge a branch into another branch. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. branch The name of the branch ...
[ "Merge", "a", "branch", "into", "another", "branch", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/branches.py#L145-L166
20c/xbahn
xbahn/mixins.py
EventMixin.has_callbacks
def has_callbacks(self, name): """ Returns True if there are callbacks attached to the specified event name. Returns False if not """ r = self.event_listeners.get(name) if not r: return False return len(r) > 0
python
def has_callbacks(self, name): """ Returns True if there are callbacks attached to the specified event name. Returns False if not """ r = self.event_listeners.get(name) if not r: return False return len(r) > 0
[ "def", "has_callbacks", "(", "self", ",", "name", ")", ":", "r", "=", "self", ".", "event_listeners", ".", "get", "(", "name", ")", "if", "not", "r", ":", "return", "False", "return", "len", "(", "r", ")", ">", "0" ]
Returns True if there are callbacks attached to the specified event name. Returns False if not
[ "Returns", "True", "if", "there", "are", "callbacks", "attached", "to", "the", "specified", "event", "name", "." ]
train
https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/mixins.py#L35-L45
20c/xbahn
xbahn/mixins.py
EventMixin.on
def on(self, name, callback, once=False): """ Adds a callback to the event specified by name once <bool> if True the callback will be removed once it's been triggered """ if name not in self.event_listeners: self.event_listeners[name] = [] self.event...
python
def on(self, name, callback, once=False): """ Adds a callback to the event specified by name once <bool> if True the callback will be removed once it's been triggered """ if name not in self.event_listeners: self.event_listeners[name] = [] self.event...
[ "def", "on", "(", "self", ",", "name", ",", "callback", ",", "once", "=", "False", ")", ":", "if", "name", "not", "in", "self", ".", "event_listeners", ":", "self", ".", "event_listeners", "[", "name", "]", "=", "[", "]", "self", ".", "event_listener...
Adds a callback to the event specified by name once <bool> if True the callback will be removed once it's been triggered
[ "Adds", "a", "callback", "to", "the", "event", "specified", "by", "name" ]
train
https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/mixins.py#L47-L57
20c/xbahn
xbahn/mixins.py
EventMixin.off
def off(self, name, callback, once=False): """ Removes callback to the event specified by name """ if name not in self.event_listeners: return self.event_listeners[name].remove((callback, once))
python
def off(self, name, callback, once=False): """ Removes callback to the event specified by name """ if name not in self.event_listeners: return self.event_listeners[name].remove((callback, once))
[ "def", "off", "(", "self", ",", "name", ",", "callback", ",", "once", "=", "False", ")", ":", "if", "name", "not", "in", "self", ".", "event_listeners", ":", "return", "self", ".", "event_listeners", "[", "name", "]", ".", "remove", "(", "(", "callba...
Removes callback to the event specified by name
[ "Removes", "callback", "to", "the", "event", "specified", "by", "name" ]
train
https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/mixins.py#L59-L67
20c/xbahn
xbahn/mixins.py
EventMixin.trigger
def trigger(self, name, *args, **kwargs): """ Triggers the event specified by name and passes self in keyword argument "event_origin" All additional arguments and keyword arguments are passed through as well """ mark_remove = [] for callback, once in sel...
python
def trigger(self, name, *args, **kwargs): """ Triggers the event specified by name and passes self in keyword argument "event_origin" All additional arguments and keyword arguments are passed through as well """ mark_remove = [] for callback, once in sel...
[ "def", "trigger", "(", "self", ",", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "mark_remove", "=", "[", "]", "for", "callback", ",", "once", "in", "self", ".", "event_listeners", ".", "get", "(", "name", ",", "[", "]", ")", ":",...
Triggers the event specified by name and passes self in keyword argument "event_origin" All additional arguments and keyword arguments are passed through as well
[ "Triggers", "the", "event", "specified", "by", "name", "and", "passes", "self", "in", "keyword", "argument", "event_origin" ]
train
https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/mixins.py#L69-L85
ludeeus/pyruter
pyruter/api.py
Departures.get_departures
async def get_departures(self): """Get departure info from stopid.""" from .common import CommonFunctions common = CommonFunctions(self.loop, self.session) departures = [] endpoint = '{}/StopVisit/GetDepartures/{}'.format(BASE_URL, ...
python
async def get_departures(self): """Get departure info from stopid.""" from .common import CommonFunctions common = CommonFunctions(self.loop, self.session) departures = [] endpoint = '{}/StopVisit/GetDepartures/{}'.format(BASE_URL, ...
[ "async", "def", "get_departures", "(", "self", ")", ":", "from", ".", "common", "import", "CommonFunctions", "common", "=", "CommonFunctions", "(", "self", ".", "loop", ",", "self", ".", "session", ")", "departures", "=", "[", "]", "endpoint", "=", "'{}/St...
Get departure info from stopid.
[ "Get", "departure", "info", "from", "stopid", "." ]
train
https://github.com/ludeeus/pyruter/blob/415d8b9c8bfd48caa82c1a1201bfd3beb670a117/pyruter/api.py#L21-L53
ludeeus/pyruter
pyruter/api.py
Departures.get_final_destination
async def get_final_destination(self): """Get a list of final destinations for a stop.""" dest = [] await self.get_departures() for departure in self._departures: dep = {} dep['line'] = departure.get('line') dep['destination'] = departure.get('destinat...
python
async def get_final_destination(self): """Get a list of final destinations for a stop.""" dest = [] await self.get_departures() for departure in self._departures: dep = {} dep['line'] = departure.get('line') dep['destination'] = departure.get('destinat...
[ "async", "def", "get_final_destination", "(", "self", ")", ":", "dest", "=", "[", "]", "await", "self", ".", "get_departures", "(", ")", "for", "departure", "in", "self", ".", "_departures", ":", "dep", "=", "{", "}", "dep", "[", "'line'", "]", "=", ...
Get a list of final destinations for a stop.
[ "Get", "a", "list", "of", "final", "destinations", "for", "a", "stop", "." ]
train
https://github.com/ludeeus/pyruter/blob/415d8b9c8bfd48caa82c1a1201bfd3beb670a117/pyruter/api.py#L55-L64
cogniteev/docido-python-sdk
docido_sdk/toolbox/loader.py
resolve_name
def resolve_name(name, module=None): """Resolve a dotted name to a module and its parts. This is stolen wholesale from unittest.TestLoader.loadTestByName. """ parts = name.split('.') parts_copy = parts[:] if module is None: while parts_copy: # pragma: no cover try: ...
python
def resolve_name(name, module=None): """Resolve a dotted name to a module and its parts. This is stolen wholesale from unittest.TestLoader.loadTestByName. """ parts = name.split('.') parts_copy = parts[:] if module is None: while parts_copy: # pragma: no cover try: ...
[ "def", "resolve_name", "(", "name", ",", "module", "=", "None", ")", ":", "parts", "=", "name", ".", "split", "(", "'.'", ")", "parts_copy", "=", "parts", "[", ":", "]", "if", "module", "is", "None", ":", "while", "parts_copy", ":", "# pragma: no cover...
Resolve a dotted name to a module and its parts. This is stolen wholesale from unittest.TestLoader.loadTestByName.
[ "Resolve", "a", "dotted", "name", "to", "a", "module", "and", "its", "parts", ".", "This", "is", "stolen", "wholesale", "from", "unittest", ".", "TestLoader", ".", "loadTestByName", "." ]
train
https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/loader.py#L2-L21
cbrand/vpnchooser
src/vpnchooser/cli/configuration_generator.py
ConfigurationGenerator.missing_host_key
def missing_host_key(self, client, hostname, key): """ Called when an `.SSHClient` receives a server key for a server that isn't in either the system or local `.HostKeys` object. To accept the key, simply return. To reject, raised an exception (which will be passed to the calli...
python
def missing_host_key(self, client, hostname, key): """ Called when an `.SSHClient` receives a server key for a server that isn't in either the system or local `.HostKeys` object. To accept the key, simply return. To reject, raised an exception (which will be passed to the calli...
[ "def", "missing_host_key", "(", "self", ",", "client", ",", "hostname", ",", "key", ")", ":", "self", ".", "host_key", "=", "key", ".", "get_base64", "(", ")", "print", "(", "\"Fetched key is: %s\"", "%", "self", ".", "host_key", ")", "return" ]
Called when an `.SSHClient` receives a server key for a server that isn't in either the system or local `.HostKeys` object. To accept the key, simply return. To reject, raised an exception (which will be passed to the calling application).
[ "Called", "when", "an", ".", "SSHClient", "receives", "a", "server", "key", "for", "a", "server", "that", "isn", "t", "in", "either", "the", "system", "or", "local", ".", "HostKeys", "object", ".", "To", "accept", "the", "key", "simply", "return", ".", ...
train
https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/cli/configuration_generator.py#L77-L86
pjuren/pyokit
src/pyokit/io/repeatmaskerAnnotations.py
repeat_masker_iterator
def repeat_masker_iterator(fh, alignment_index=None, header=True, verbose=False): """ Iterator for repeatmasker coordinate annotation files. These files describe the location of repeat occurrences. There is (optionally) a two-line header with the names of the fields (ignored by the it...
python
def repeat_masker_iterator(fh, alignment_index=None, header=True, verbose=False): """ Iterator for repeatmasker coordinate annotation files. These files describe the location of repeat occurrences. There is (optionally) a two-line header with the names of the fields (ignored by the it...
[ "def", "repeat_masker_iterator", "(", "fh", ",", "alignment_index", "=", "None", ",", "header", "=", "True", ",", "verbose", "=", "False", ")", ":", "strm", "=", "fh", "if", "type", "(", "fh", ")", ".", "__name__", "==", "\"str\"", ":", "strm", "=", ...
Iterator for repeatmasker coordinate annotation files. These files describe the location of repeat occurrences. There is (optionally) a two-line header with the names of the fields (ignored by the iterator, if present). Each line is a record of an occurrence. The description of fields for each line is given in ...
[ "Iterator", "for", "repeatmasker", "coordinate", "annotation", "files", ".", "These", "files", "describe", "the", "location", "of", "repeat", "occurrences", ".", "There", "is", "(", "optionally", ")", "a", "two", "-", "line", "header", "with", "the", "names", ...
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/repeatmaskerAnnotations.py#L48-L99
django-xxx/django-mobi2
mobi2/decorators.py
detect_mobile
def detect_mobile(view): """View Decorator that adds a "mobile" attribute to the request which is True or False depending on whether the request should be considered to come from a small-screen device such as a phone or a PDA""" @wraps(view) def detected(request, *args, **kwargs): Mob...
python
def detect_mobile(view): """View Decorator that adds a "mobile" attribute to the request which is True or False depending on whether the request should be considered to come from a small-screen device such as a phone or a PDA""" @wraps(view) def detected(request, *args, **kwargs): Mob...
[ "def", "detect_mobile", "(", "view", ")", ":", "@", "wraps", "(", "view", ")", "def", "detected", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "MobileDetectionMiddleware", ".", "process_request", "(", "request", ")", "return", "vi...
View Decorator that adds a "mobile" attribute to the request which is True or False depending on whether the request should be considered to come from a small-screen device such as a phone or a PDA
[ "View", "Decorator", "that", "adds", "a", "mobile", "attribute", "to", "the", "request", "which", "is", "True", "or", "False", "depending", "on", "whether", "the", "request", "should", "be", "considered", "to", "come", "from", "a", "small", "-", "screen", ...
train
https://github.com/django-xxx/django-mobi2/blob/7ac323faa1a9599f3cd39acd3c49626819ce0538/mobi2/decorators.py#L8-L18
tomnor/channelpack
channelpack/datautils.py
masked
def masked(a, b): """Return a numpy array with values from a where elements in b are not False. Populate with numpy.nan where b is False. When plotting, those elements look like missing, which can be a desired result. """ if np.any([a.dtype.kind.startswith(c) for c in ['i', 'u', 'f', 'c']]): ...
python
def masked(a, b): """Return a numpy array with values from a where elements in b are not False. Populate with numpy.nan where b is False. When plotting, those elements look like missing, which can be a desired result. """ if np.any([a.dtype.kind.startswith(c) for c in ['i', 'u', 'f', 'c']]): ...
[ "def", "masked", "(", "a", ",", "b", ")", ":", "if", "np", ".", "any", "(", "[", "a", ".", "dtype", ".", "kind", ".", "startswith", "(", "c", ")", "for", "c", "in", "[", "'i'", ",", "'u'", ",", "'f'", ",", "'c'", "]", "]", ")", ":", "n", ...
Return a numpy array with values from a where elements in b are not False. Populate with numpy.nan where b is False. When plotting, those elements look like missing, which can be a desired result.
[ "Return", "a", "numpy", "array", "with", "values", "from", "a", "where", "elements", "in", "b", "are", "not", "False", ".", "Populate", "with", "numpy", ".", "nan", "where", "b", "is", "False", ".", "When", "plotting", "those", "elements", "look", "like"...
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L16-L28
tomnor/channelpack
channelpack/datautils.py
duration_bool
def duration_bool(b, rule, samplerate=None): """ Mask the parts in b being True but does not meet the duration rules. Return an updated copy of b. b: 1d array with True or False elements. rule: str The rule including the string 'dur' to be evaled. samplerate: None or float Has...
python
def duration_bool(b, rule, samplerate=None): """ Mask the parts in b being True but does not meet the duration rules. Return an updated copy of b. b: 1d array with True or False elements. rule: str The rule including the string 'dur' to be evaled. samplerate: None or float Has...
[ "def", "duration_bool", "(", "b", ",", "rule", ",", "samplerate", "=", "None", ")", ":", "if", "rule", "is", "None", ":", "return", "b", "slicelst", "=", "slicelist", "(", "b", ")", "b2", "=", "np", ".", "array", "(", "b", ")", "if", "samplerate", ...
Mask the parts in b being True but does not meet the duration rules. Return an updated copy of b. b: 1d array with True or False elements. rule: str The rule including the string 'dur' to be evaled. samplerate: None or float Has an effect on the result. For each part of b that is...
[ "Mask", "the", "parts", "in", "b", "being", "True", "but", "does", "not", "meet", "the", "duration", "rules", ".", "Return", "an", "updated", "copy", "of", "b", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L31-L63
tomnor/channelpack
channelpack/datautils.py
startstop_bool
def startstop_bool(pack): """Make a bool array based on start and stop conditions. pack: pack.ChannelPack instance If there is start conditions but no stop conditions, this is legal, the True section will begin at first start and remain the rest of the array. Likewise, if there is stop con...
python
def startstop_bool(pack): """Make a bool array based on start and stop conditions. pack: pack.ChannelPack instance If there is start conditions but no stop conditions, this is legal, the True section will begin at first start and remain the rest of the array. Likewise, if there is stop con...
[ "def", "startstop_bool", "(", "pack", ")", ":", "b_TRUE", "=", "np", ".", "ones", "(", "pack", ".", "rec_cnt", ")", "==", "True", "# NOQA", "start_list", "=", "pack", ".", "conconf", ".", "conditions_list", "(", "'startcond'", ")", "stop_list", "=", "pac...
Make a bool array based on start and stop conditions. pack: pack.ChannelPack instance If there is start conditions but no stop conditions, this is legal, the True section will begin at first start and remain the rest of the array. Likewise, if there is stop conditions but no start conditio...
[ "Make", "a", "bool", "array", "based", "on", "start", "and", "stop", "conditions", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L66-L113
tomnor/channelpack
channelpack/datautils.py
_startstop_bool
def _startstop_bool(startb, stopb, runflag, stopextend): """Return boolean array based on start and stop conditions. startb, stopb: Numpy 1D arrays of the same length. Boolean arrays for start and stop conditions being fullfilled or not. """ # All false at start res = np.zeros(len(startb))...
python
def _startstop_bool(startb, stopb, runflag, stopextend): """Return boolean array based on start and stop conditions. startb, stopb: Numpy 1D arrays of the same length. Boolean arrays for start and stop conditions being fullfilled or not. """ # All false at start res = np.zeros(len(startb))...
[ "def", "_startstop_bool", "(", "startb", ",", "stopb", ",", "runflag", ",", "stopextend", ")", ":", "# All false at start", "res", "=", "np", ".", "zeros", "(", "len", "(", "startb", ")", ")", "==", "True", "# NOQA", "start_slices", "=", "slicelist", "(", ...
Return boolean array based on start and stop conditions. startb, stopb: Numpy 1D arrays of the same length. Boolean arrays for start and stop conditions being fullfilled or not.
[ "Return", "boolean", "array", "based", "on", "start", "and", "stop", "conditions", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L116-L171
tomnor/channelpack
channelpack/datautils.py
slicelist
def slicelist(b): """Produce a list of slices given the boolean array b. Start and stop in each slice describe the True sections in b.""" slicelst = [] started = False for i, e in enumerate(b): if e and not started: start = i started = True elif not e and st...
python
def slicelist(b): """Produce a list of slices given the boolean array b. Start and stop in each slice describe the True sections in b.""" slicelst = [] started = False for i, e in enumerate(b): if e and not started: start = i started = True elif not e and st...
[ "def", "slicelist", "(", "b", ")", ":", "slicelst", "=", "[", "]", "started", "=", "False", "for", "i", ",", "e", "in", "enumerate", "(", "b", ")", ":", "if", "e", "and", "not", "started", ":", "start", "=", "i", "started", "=", "True", "elif", ...
Produce a list of slices given the boolean array b. Start and stop in each slice describe the True sections in b.
[ "Produce", "a", "list", "of", "slices", "given", "the", "boolean", "array", "b", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/datautils.py#L174-L192
hweickert/indentation
indentation/__init__.py
set
def set( string, target_level, indent_string=" ", indent_empty_lines=False ): """ Sets indentation of a single/multi-line string. """ lines = string.splitlines() set_lines( lines, target_level, indent_string=indent_string, indent_empty_lines=indent_empty_lines ) result = "\n".join(lines) r...
python
def set( string, target_level, indent_string=" ", indent_empty_lines=False ): """ Sets indentation of a single/multi-line string. """ lines = string.splitlines() set_lines( lines, target_level, indent_string=indent_string, indent_empty_lines=indent_empty_lines ) result = "\n".join(lines) r...
[ "def", "set", "(", "string", ",", "target_level", ",", "indent_string", "=", "\" \"", ",", "indent_empty_lines", "=", "False", ")", ":", "lines", "=", "string", ".", "splitlines", "(", ")", "set_lines", "(", "lines", ",", "target_level", ",", "indent_stri...
Sets indentation of a single/multi-line string.
[ "Sets", "indentation", "of", "a", "single", "/", "multi", "-", "line", "string", "." ]
train
https://github.com/hweickert/indentation/blob/4c4e4a21e1b75f9ba6b39967fd3df0a62b7288c6/indentation/__init__.py#L1-L7
hweickert/indentation
indentation/__init__.py
set_lines
def set_lines( lines, target_level, indent_string=" ", indent_empty_lines=False ): """ Sets indentation for the given set of :lines:. """ first_non_empty_line_index = _get_first_non_empty_line_index( lines ) first_line_original_level = get_line_level( lines[first_non_empty_line_index], indent_strin...
python
def set_lines( lines, target_level, indent_string=" ", indent_empty_lines=False ): """ Sets indentation for the given set of :lines:. """ first_non_empty_line_index = _get_first_non_empty_line_index( lines ) first_line_original_level = get_line_level( lines[first_non_empty_line_index], indent_strin...
[ "def", "set_lines", "(", "lines", ",", "target_level", ",", "indent_string", "=", "\" \"", ",", "indent_empty_lines", "=", "False", ")", ":", "first_non_empty_line_index", "=", "_get_first_non_empty_line_index", "(", "lines", ")", "first_line_original_level", "=", ...
Sets indentation for the given set of :lines:.
[ "Sets", "indentation", "for", "the", "given", "set", "of", ":", "lines", ":", "." ]
train
https://github.com/hweickert/indentation/blob/4c4e4a21e1b75f9ba6b39967fd3df0a62b7288c6/indentation/__init__.py#L10-L32
edeposit/edeposit.amqp.storage
src/edeposit/amqp/storage/archive_storage.py
save_archive
def save_archive(archive): """ Save `archive` into database and into proper indexes. Attr: archive (obj): Instance of the :class:`.DBArchive`. Returns: obj: :class:`.DBArchive` without data. Raises: InvalidType: When the `archive` is not instance of :class:`.DBArchive`. ...
python
def save_archive(archive): """ Save `archive` into database and into proper indexes. Attr: archive (obj): Instance of the :class:`.DBArchive`. Returns: obj: :class:`.DBArchive` without data. Raises: InvalidType: When the `archive` is not instance of :class:`.DBArchive`. ...
[ "def", "save_archive", "(", "archive", ")", ":", "_assert_obj_type", "(", "archive", ",", "obj_type", "=", "DBArchive", ")", "_get_handler", "(", ")", ".", "store_object", "(", "archive", ")", "return", "archive", ".", "to_comm", "(", "light_request", "=", "...
Save `archive` into database and into proper indexes. Attr: archive (obj): Instance of the :class:`.DBArchive`. Returns: obj: :class:`.DBArchive` without data. Raises: InvalidType: When the `archive` is not instance of :class:`.DBArchive`. UnindexablePublication: When ther...
[ "Save", "archive", "into", "database", "and", "into", "proper", "indexes", "." ]
train
https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/archive_storage.py#L29-L48