repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
tamasgal/km3pipe | km3pipe/controlhost.py | Client._reconnect | def _reconnect(self):
"""Reconnect to JLigier and subscribe to the tags."""
log.debug("Reconnecting to JLigier...")
self._disconnect()
self._connect()
self._update_subscriptions() | python | def _reconnect(self):
"""Reconnect to JLigier and subscribe to the tags."""
log.debug("Reconnecting to JLigier...")
self._disconnect()
self._connect()
self._update_subscriptions() | [
"def",
"_reconnect",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"Reconnecting to JLigier...\"",
")",
"self",
".",
"_disconnect",
"(",
")",
"self",
".",
"_connect",
"(",
")",
"self",
".",
"_update_subscriptions",
"(",
")"
] | Reconnect to JLigier and subscribe to the tags. | [
"Reconnect",
"to",
"JLigier",
"and",
"subscribe",
"to",
"the",
"tags",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/controlhost.py#L136-L141 | train |
tamasgal/km3pipe | km3pipe/controlhost.py | Tag.data | def data(self, value):
"""Set the byte data and fill up the bytes to fit the size."""
if not value:
value = b''
if len(value) > self.SIZE:
raise ValueError("The maximum tag size is {0}".format(self.SIZE))
self._data = value
while len(self._data) < self.SIZ... | python | def data(self, value):
"""Set the byte data and fill up the bytes to fit the size."""
if not value:
value = b''
if len(value) > self.SIZE:
raise ValueError("The maximum tag size is {0}".format(self.SIZE))
self._data = value
while len(self._data) < self.SIZ... | [
"def",
"data",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"value",
"=",
"b''",
"if",
"len",
"(",
"value",
")",
">",
"self",
".",
"SIZE",
":",
"raise",
"ValueError",
"(",
"\"The maximum tag size is {0}\"",
".",
"format",
"(",
"self"... | Set the byte data and fill up the bytes to fit the size. | [
"Set",
"the",
"byte",
"data",
"and",
"fill",
"up",
"the",
"bytes",
"to",
"fit",
"the",
"size",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/controlhost.py#L177-L185 | train |
valdergallo/pyconst | pyconst/const.py | Const.add | def add(self, name, attr=None, value=None):
"Set values in constant"
if isinstance(name, tuple) or isinstance(name, list):
name, attr, value = self.__set_iter_value(name)
if attr is None:
attr = name
if value is None:
value = attr
self.__da... | python | def add(self, name, attr=None, value=None):
"Set values in constant"
if isinstance(name, tuple) or isinstance(name, list):
name, attr, value = self.__set_iter_value(name)
if attr is None:
attr = name
if value is None:
value = attr
self.__da... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"attr",
"=",
"None",
",",
"value",
"=",
"None",
")",
":",
"\"Set values in constant\"",
"if",
"isinstance",
"(",
"name",
",",
"tuple",
")",
"or",
"isinstance",
"(",
"name",
",",
"list",
")",
":",
"name",
"... | Set values in constant | [
"Set",
"values",
"in",
"constant"
] | af4cbc8d91ffab601ac5e45e5480f20c5462064d | https://github.com/valdergallo/pyconst/blob/af4cbc8d91ffab601ac5e45e5480f20c5462064d/pyconst/const.py#L54-L68 | train |
breerly/threadloop | threadloop/threadloop.py | ThreadLoop.start | def start(self):
"""Start IOLoop in daemonized thread."""
assert self._thread is None, 'thread already started'
# configure thread
self._thread = Thread(target=self._start_io_loop)
self._thread.daemon = True
# begin thread and block until ready
self._thread.star... | python | def start(self):
"""Start IOLoop in daemonized thread."""
assert self._thread is None, 'thread already started'
# configure thread
self._thread = Thread(target=self._start_io_loop)
self._thread.daemon = True
# begin thread and block until ready
self._thread.star... | [
"def",
"start",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_thread",
"is",
"None",
",",
"'thread already started'",
"self",
".",
"_thread",
"=",
"Thread",
"(",
"target",
"=",
"self",
".",
"_start_io_loop",
")",
"self",
".",
"_thread",
".",
"daemon",
... | Start IOLoop in daemonized thread. | [
"Start",
"IOLoop",
"in",
"daemonized",
"thread",
"."
] | 9d4f83660fd79fe15d741b831be9ee28dccacc30 | https://github.com/breerly/threadloop/blob/9d4f83660fd79fe15d741b831be9ee28dccacc30/threadloop/threadloop.py#L56-L66 | train |
breerly/threadloop | threadloop/threadloop.py | ThreadLoop._start_io_loop | def _start_io_loop(self):
"""Start IOLoop then set ready threading.Event."""
def mark_as_ready():
self._ready.set()
if not self._io_loop:
self._io_loop = ioloop.IOLoop()
self._io_loop.add_callback(mark_as_ready)
self._io_loop.start() | python | def _start_io_loop(self):
"""Start IOLoop then set ready threading.Event."""
def mark_as_ready():
self._ready.set()
if not self._io_loop:
self._io_loop = ioloop.IOLoop()
self._io_loop.add_callback(mark_as_ready)
self._io_loop.start() | [
"def",
"_start_io_loop",
"(",
"self",
")",
":",
"def",
"mark_as_ready",
"(",
")",
":",
"self",
".",
"_ready",
".",
"set",
"(",
")",
"if",
"not",
"self",
".",
"_io_loop",
":",
"self",
".",
"_io_loop",
"=",
"ioloop",
".",
"IOLoop",
"(",
")",
"self",
... | Start IOLoop then set ready threading.Event. | [
"Start",
"IOLoop",
"then",
"set",
"ready",
"threading",
".",
"Event",
"."
] | 9d4f83660fd79fe15d741b831be9ee28dccacc30 | https://github.com/breerly/threadloop/blob/9d4f83660fd79fe15d741b831be9ee28dccacc30/threadloop/threadloop.py#L68-L78 | train |
breerly/threadloop | threadloop/threadloop.py | ThreadLoop.is_ready | def is_ready(self):
"""Is thread & ioloop ready.
:returns bool:
"""
if not self._thread:
return False
if not self._ready.is_set():
return False
return True | python | def is_ready(self):
"""Is thread & ioloop ready.
:returns bool:
"""
if not self._thread:
return False
if not self._ready.is_set():
return False
return True | [
"def",
"is_ready",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_thread",
":",
"return",
"False",
"if",
"not",
"self",
".",
"_ready",
".",
"is_set",
"(",
")",
":",
"return",
"False",
"return",
"True"
] | Is thread & ioloop ready.
:returns bool: | [
"Is",
"thread",
"&",
"ioloop",
"ready",
"."
] | 9d4f83660fd79fe15d741b831be9ee28dccacc30 | https://github.com/breerly/threadloop/blob/9d4f83660fd79fe15d741b831be9ee28dccacc30/threadloop/threadloop.py#L80-L91 | train |
breerly/threadloop | threadloop/threadloop.py | ThreadLoop.submit | def submit(self, fn, *args, **kwargs):
"""Submit Tornado Coroutine to IOLoop in daemonized thread.
:param fn: Tornado Coroutine to execute
:param args: Args to pass to coroutine
:param kwargs: Kwargs to pass to coroutine
:returns concurrent.futures.Future: future result of corou... | python | def submit(self, fn, *args, **kwargs):
"""Submit Tornado Coroutine to IOLoop in daemonized thread.
:param fn: Tornado Coroutine to execute
:param args: Args to pass to coroutine
:param kwargs: Kwargs to pass to coroutine
:returns concurrent.futures.Future: future result of corou... | [
"def",
"submit",
"(",
"self",
",",
"fn",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"is_ready",
"(",
")",
":",
"raise",
"ThreadNotStartedError",
"(",
"\"The thread has not been started yet, \"",
"\"make sure you call start() first\"... | Submit Tornado Coroutine to IOLoop in daemonized thread.
:param fn: Tornado Coroutine to execute
:param args: Args to pass to coroutine
:param kwargs: Kwargs to pass to coroutine
:returns concurrent.futures.Future: future result of coroutine | [
"Submit",
"Tornado",
"Coroutine",
"to",
"IOLoop",
"in",
"daemonized",
"thread",
"."
] | 9d4f83660fd79fe15d741b831be9ee28dccacc30 | https://github.com/breerly/threadloop/blob/9d4f83660fd79fe15d741b831be9ee28dccacc30/threadloop/threadloop.py#L98-L160 | train |
tamasgal/km3pipe | km3pipe/sys.py | peak_memory_usage | def peak_memory_usage():
"""Return peak memory usage in MB"""
if sys.platform.startswith('win'):
p = psutil.Process()
return p.memory_info().peak_wset / 1024 / 1024
mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
factor_mb = 1 / 1024
if sys.platform == 'darwin':
fac... | python | def peak_memory_usage():
"""Return peak memory usage in MB"""
if sys.platform.startswith('win'):
p = psutil.Process()
return p.memory_info().peak_wset / 1024 / 1024
mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
factor_mb = 1 / 1024
if sys.platform == 'darwin':
fac... | [
"def",
"peak_memory_usage",
"(",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win'",
")",
":",
"p",
"=",
"psutil",
".",
"Process",
"(",
")",
"return",
"p",
".",
"memory_info",
"(",
")",
".",
"peak_wset",
"/",
"1024",
"/",
"1024",... | Return peak memory usage in MB | [
"Return",
"peak",
"memory",
"usage",
"in",
"MB"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/sys.py#L41-L51 | train |
PrefPy/prefpy | prefpy/profile.py | Profile.getPreferenceCounts | def getPreferenceCounts(self):
"""
Returns a list of the number of times each preference is given.
"""
preferenceCounts = []
for preference in self.preferences:
preferenceCounts.append(preference.count)
return preferenceCounts | python | def getPreferenceCounts(self):
"""
Returns a list of the number of times each preference is given.
"""
preferenceCounts = []
for preference in self.preferences:
preferenceCounts.append(preference.count)
return preferenceCounts | [
"def",
"getPreferenceCounts",
"(",
"self",
")",
":",
"preferenceCounts",
"=",
"[",
"]",
"for",
"preference",
"in",
"self",
".",
"preferences",
":",
"preferenceCounts",
".",
"append",
"(",
"preference",
".",
"count",
")",
"return",
"preferenceCounts"
] | Returns a list of the number of times each preference is given. | [
"Returns",
"a",
"list",
"of",
"the",
"number",
"of",
"times",
"each",
"preference",
"is",
"given",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L64-L72 | train |
PrefPy/prefpy | prefpy/profile.py | Profile.getRankMaps | def getRankMaps(self):
"""
Returns a list of dictionaries, one for each preference, that associates the integer
representation of each candidate with its position in the ranking, starting from 1 and
returns a list of the number of times each preference is given.
"""
ran... | python | def getRankMaps(self):
"""
Returns a list of dictionaries, one for each preference, that associates the integer
representation of each candidate with its position in the ranking, starting from 1 and
returns a list of the number of times each preference is given.
"""
ran... | [
"def",
"getRankMaps",
"(",
"self",
")",
":",
"rankMaps",
"=",
"[",
"]",
"for",
"preference",
"in",
"self",
".",
"preferences",
":",
"rankMaps",
".",
"append",
"(",
"preference",
".",
"getRankMap",
"(",
")",
")",
"return",
"rankMaps"
] | Returns a list of dictionaries, one for each preference, that associates the integer
representation of each candidate with its position in the ranking, starting from 1 and
returns a list of the number of times each preference is given. | [
"Returns",
"a",
"list",
"of",
"dictionaries",
"one",
"for",
"each",
"preference",
"that",
"associates",
"the",
"integer",
"representation",
"of",
"each",
"candidate",
"with",
"its",
"position",
"in",
"the",
"ranking",
"starting",
"from",
"1",
"and",
"returns",
... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L74-L84 | train |
PrefPy/prefpy | prefpy/profile.py | Profile.getReverseRankMaps | def getReverseRankMaps(self):
"""
Returns a list of dictionaries, one for each preference, that associates each position in
the ranking with a list of integer representations of the candidates ranked at that
position and returns a list of the number of times each preference is given.
... | python | def getReverseRankMaps(self):
"""
Returns a list of dictionaries, one for each preference, that associates each position in
the ranking with a list of integer representations of the candidates ranked at that
position and returns a list of the number of times each preference is given.
... | [
"def",
"getReverseRankMaps",
"(",
"self",
")",
":",
"reverseRankMaps",
"=",
"[",
"]",
"for",
"preference",
"in",
"self",
".",
"preferences",
":",
"reverseRankMaps",
".",
"append",
"(",
"preference",
".",
"getReverseRankMap",
"(",
")",
")",
"return",
"reverseRa... | Returns a list of dictionaries, one for each preference, that associates each position in
the ranking with a list of integer representations of the candidates ranked at that
position and returns a list of the number of times each preference is given. | [
"Returns",
"a",
"list",
"of",
"dictionaries",
"one",
"for",
"each",
"preference",
"that",
"associates",
"each",
"position",
"in",
"the",
"ranking",
"with",
"a",
"list",
"of",
"integer",
"representations",
"of",
"the",
"candidates",
"ranked",
"at",
"that",
"pos... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L85-L95 | train |
PrefPy/prefpy | prefpy/profile.py | Profile.exportPreflibFile | def exportPreflibFile(self, fileName):
"""
Exports a preflib format file that contains all the information of the current Profile.
:ivar str fileName: The name of the output file to be exported.
"""
elecType = self.getElecType()
if elecType != "soc" and elecType != "to... | python | def exportPreflibFile(self, fileName):
"""
Exports a preflib format file that contains all the information of the current Profile.
:ivar str fileName: The name of the output file to be exported.
"""
elecType = self.getElecType()
if elecType != "soc" and elecType != "to... | [
"def",
"exportPreflibFile",
"(",
"self",
",",
"fileName",
")",
":",
"elecType",
"=",
"self",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType",
"!=",
"\"toc\"",
"and",
"elecType",
"!=",
"\"soi\"",
"and",
"elecType",
"!=",
"... | Exports a preflib format file that contains all the information of the current Profile.
:ivar str fileName: The name of the output file to be exported. | [
"Exports",
"a",
"preflib",
"format",
"file",
"that",
"contains",
"all",
"the",
"information",
"of",
"the",
"current",
"Profile",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L201-L259 | train |
PrefPy/prefpy | prefpy/profile.py | Profile.importPreflibFile | def importPreflibFile(self, fileName):
"""
Imports a preflib format file that contains all the information of a Profile. This function
will completely override all members of the current Profile object. Currently, we assume
that in an election where incomplete ordering are allowed, if a... | python | def importPreflibFile(self, fileName):
"""
Imports a preflib format file that contains all the information of a Profile. This function
will completely override all members of the current Profile object. Currently, we assume
that in an election where incomplete ordering are allowed, if a... | [
"def",
"importPreflibFile",
"(",
"self",
",",
"fileName",
")",
":",
"elecFileObj",
"=",
"open",
"(",
"fileName",
",",
"'r'",
")",
"self",
".",
"candMap",
",",
"rankMaps",
",",
"wmgMapsCounts",
",",
"self",
".",
"numVoters",
"=",
"prefpy_io",
".",
"read_ele... | Imports a preflib format file that contains all the information of a Profile. This function
will completely override all members of the current Profile object. Currently, we assume
that in an election where incomplete ordering are allowed, if a voter ranks only one
candidate, then the voter di... | [
"Imports",
"a",
"preflib",
"format",
"file",
"that",
"contains",
"all",
"the",
"information",
"of",
"a",
"Profile",
".",
"This",
"function",
"will",
"completely",
"override",
"all",
"members",
"of",
"the",
"current",
"Profile",
"object",
".",
"Currently",
"we"... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L261-L284 | train |
PrefPy/prefpy | prefpy/profile.py | Profile.exportJsonFile | def exportJsonFile(self, fileName):
"""
Exports a json file that contains all the information of the current Profile.
:ivar str fileName: The name of the output file to be exported.
"""
# Because our Profile class is not directly JSON serializable, we exporrt the underlying
... | python | def exportJsonFile(self, fileName):
"""
Exports a json file that contains all the information of the current Profile.
:ivar str fileName: The name of the output file to be exported.
"""
# Because our Profile class is not directly JSON serializable, we exporrt the underlying
... | [
"def",
"exportJsonFile",
"(",
"self",
",",
"fileName",
")",
":",
"data",
"=",
"dict",
"(",
")",
"for",
"key",
"in",
"self",
".",
"__dict__",
".",
"keys",
"(",
")",
":",
"if",
"key",
"!=",
"\"preferences\"",
":",
"data",
"[",
"key",
"]",
"=",
"self"... | Exports a json file that contains all the information of the current Profile.
:ivar str fileName: The name of the output file to be exported. | [
"Exports",
"a",
"json",
"file",
"that",
"contains",
"all",
"the",
"information",
"of",
"the",
"current",
"Profile",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L286-L312 | train |
PrefPy/prefpy | prefpy/profile.py | Profile.importJsonFile | def importJsonFile(self, fileName):
"""
Imports a json file that contains all the information of a Profile. This function will
completely override all members of the current Profile object.
:ivar str fileName: The name of the input file to be imported.
"""
infile = open... | python | def importJsonFile(self, fileName):
"""
Imports a json file that contains all the information of a Profile. This function will
completely override all members of the current Profile object.
:ivar str fileName: The name of the input file to be imported.
"""
infile = open... | [
"def",
"importJsonFile",
"(",
"self",
",",
"fileName",
")",
":",
"infile",
"=",
"open",
"(",
"fileName",
")",
"data",
"=",
"json",
".",
"load",
"(",
"infile",
")",
"infile",
".",
"close",
"(",
")",
"self",
".",
"numCands",
"=",
"int",
"(",
"data",
... | Imports a json file that contains all the information of a Profile. This function will
completely override all members of the current Profile object.
:ivar str fileName: The name of the input file to be imported. | [
"Imports",
"a",
"json",
"file",
"that",
"contains",
"all",
"the",
"information",
"of",
"a",
"Profile",
".",
"This",
"function",
"will",
"completely",
"override",
"all",
"members",
"of",
"the",
"current",
"Profile",
"object",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L314-L353 | train |
PrefPy/prefpy | prefpy/mmgbtl.py | main | def main():
"""Driver function for the computation of the MM algorithm"""
# test example below taken from GMMRA by Azari, Chen, Parkes, & Xia
cand_set = [0, 1, 2]
votes = [[0, 1, 2], [1, 2, 0]]
mmagg = MMPLAggregator(cand_set)
gamma = mmagg.aggregate(votes, epsilon=1e-7, max_iters=20)
... | python | def main():
"""Driver function for the computation of the MM algorithm"""
# test example below taken from GMMRA by Azari, Chen, Parkes, & Xia
cand_set = [0, 1, 2]
votes = [[0, 1, 2], [1, 2, 0]]
mmagg = MMPLAggregator(cand_set)
gamma = mmagg.aggregate(votes, epsilon=1e-7, max_iters=20)
... | [
"def",
"main",
"(",
")",
":",
"cand_set",
"=",
"[",
"0",
",",
"1",
",",
"2",
"]",
"votes",
"=",
"[",
"[",
"0",
",",
"1",
",",
"2",
"]",
",",
"[",
"1",
",",
"2",
",",
"0",
"]",
"]",
"mmagg",
"=",
"MMPLAggregator",
"(",
"cand_set",
")",
"ga... | Driver function for the computation of the MM algorithm | [
"Driver",
"function",
"for",
"the",
"computation",
"of",
"the",
"MM",
"algorithm"
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mmgbtl.py#L73-L84 | train |
aouyar/healthgraph-api | healthgraph/authmgr.py | AuthManager.get_login_url | def get_login_url(self, state=None):
"""Generates and returns URL for redirecting to Login Page of RunKeeper,
which is the Authorization Endpoint of Health Graph API.
@param state: State string. Passed to client web application at the end
of the Login Process.
... | python | def get_login_url(self, state=None):
"""Generates and returns URL for redirecting to Login Page of RunKeeper,
which is the Authorization Endpoint of Health Graph API.
@param state: State string. Passed to client web application at the end
of the Login Process.
... | [
"def",
"get_login_url",
"(",
"self",
",",
"state",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'response_type'",
":",
"'code'",
",",
"'client_id'",
":",
"self",
".",
"_client_id",
",",
"'redirect_uri'",
":",
"self",
".",
"_redirect_uri",
",",
"}",
"if",
... | Generates and returns URL for redirecting to Login Page of RunKeeper,
which is the Authorization Endpoint of Health Graph API.
@param state: State string. Passed to client web application at the end
of the Login Process.
@return: URL for redirecting to RunKeep... | [
"Generates",
"and",
"returns",
"URL",
"for",
"redirecting",
"to",
"Login",
"Page",
"of",
"RunKeeper",
"which",
"is",
"the",
"Authorization",
"Endpoint",
"of",
"Health",
"Graph",
"API",
"."
] | fc5135ab353ca1f05e8a70ec784ff921e686c072 | https://github.com/aouyar/healthgraph-api/blob/fc5135ab353ca1f05e8a70ec784ff921e686c072/healthgraph/authmgr.py#L47-L62 | train |
aouyar/healthgraph-api | healthgraph/authmgr.py | AuthManager.get_login_button_url | def get_login_button_url(self, button_color=None, caption_color=None, button_size=None):
"""Return URL for image used for RunKeeper Login button.
@param button_color: Button color. Either 'blue', 'grey' or 'black'.
Default: 'blue'.
@param caption_color: Bu... | python | def get_login_button_url(self, button_color=None, caption_color=None, button_size=None):
"""Return URL for image used for RunKeeper Login button.
@param button_color: Button color. Either 'blue', 'grey' or 'black'.
Default: 'blue'.
@param caption_color: Bu... | [
"def",
"get_login_button_url",
"(",
"self",
",",
"button_color",
"=",
"None",
",",
"caption_color",
"=",
"None",
",",
"button_size",
"=",
"None",
")",
":",
"if",
"not",
"button_color",
"in",
"settings",
".",
"LOGIN_BUTTON_COLORS",
":",
"button_color",
"=",
"se... | Return URL for image used for RunKeeper Login button.
@param button_color: Button color. Either 'blue', 'grey' or 'black'.
Default: 'blue'.
@param caption_color: Button text color. Either 'white' or 'black'.
Default: 'white'
@... | [
"Return",
"URL",
"for",
"image",
"used",
"for",
"RunKeeper",
"Login",
"button",
"."
] | fc5135ab353ca1f05e8a70ec784ff921e686c072 | https://github.com/aouyar/healthgraph-api/blob/fc5135ab353ca1f05e8a70ec784ff921e686c072/healthgraph/authmgr.py#L64-L86 | train |
aouyar/healthgraph-api | healthgraph/authmgr.py | AuthManager.get_access_token | def get_access_token(self, code):
"""Returns Access Token retrieved from the Health Graph API Token
Endpoint following the login to RunKeeper.
to RunKeeper.
@param code: Code returned by Health Graph API at the Authorization or
RunKeeper Login phase.
... | python | def get_access_token(self, code):
"""Returns Access Token retrieved from the Health Graph API Token
Endpoint following the login to RunKeeper.
to RunKeeper.
@param code: Code returned by Health Graph API at the Authorization or
RunKeeper Login phase.
... | [
"def",
"get_access_token",
"(",
"self",
",",
"code",
")",
":",
"payload",
"=",
"{",
"'grant_type'",
":",
"'authorization_code'",
",",
"'code'",
":",
"code",
",",
"'client_id'",
":",
"self",
".",
"_client_id",
",",
"'client_secret'",
":",
"self",
".",
"_clien... | Returns Access Token retrieved from the Health Graph API Token
Endpoint following the login to RunKeeper.
to RunKeeper.
@param code: Code returned by Health Graph API at the Authorization or
RunKeeper Login phase.
@return: Access Token for querying the... | [
"Returns",
"Access",
"Token",
"retrieved",
"from",
"the",
"Health",
"Graph",
"API",
"Token",
"Endpoint",
"following",
"the",
"login",
"to",
"RunKeeper",
".",
"to",
"RunKeeper",
"."
] | fc5135ab353ca1f05e8a70ec784ff921e686c072 | https://github.com/aouyar/healthgraph-api/blob/fc5135ab353ca1f05e8a70ec784ff921e686c072/healthgraph/authmgr.py#L88-L105 | train |
aouyar/healthgraph-api | healthgraph/authmgr.py | AuthManager.revoke_access_token | def revoke_access_token(self, access_token):
"""Revokes the Access Token by accessing the De-authorization Endpoint
of Health Graph API.
@param access_token: Access Token for querying Health Graph API.
"""
payload = {'access_token': access_token,}
req = ... | python | def revoke_access_token(self, access_token):
"""Revokes the Access Token by accessing the De-authorization Endpoint
of Health Graph API.
@param access_token: Access Token for querying Health Graph API.
"""
payload = {'access_token': access_token,}
req = ... | [
"def",
"revoke_access_token",
"(",
"self",
",",
"access_token",
")",
":",
"payload",
"=",
"{",
"'access_token'",
":",
"access_token",
",",
"}",
"req",
"=",
"requests",
".",
"post",
"(",
"settings",
".",
"API_DEAUTHORIZATION_URL",
",",
"data",
"=",
"payload",
... | Revokes the Access Token by accessing the De-authorization Endpoint
of Health Graph API.
@param access_token: Access Token for querying Health Graph API. | [
"Revokes",
"the",
"Access",
"Token",
"by",
"accessing",
"the",
"De",
"-",
"authorization",
"Endpoint",
"of",
"Health",
"Graph",
"API",
"."
] | fc5135ab353ca1f05e8a70ec784ff921e686c072 | https://github.com/aouyar/healthgraph-api/blob/fc5135ab353ca1f05e8a70ec784ff921e686c072/healthgraph/authmgr.py#L107-L115 | train |
IRC-SPHERE/HyperStream | hyperstream/time_interval.py | TimeIntervals.split | def split(self, points):
'''Splits the list of time intervals in the specified points
The function assumes that the time intervals do not overlap and ignores
points that are not inside of any interval.
Parameters
==========
points: list of datetime
'''
f... | python | def split(self, points):
'''Splits the list of time intervals in the specified points
The function assumes that the time intervals do not overlap and ignores
points that are not inside of any interval.
Parameters
==========
points: list of datetime
'''
f... | [
"def",
"split",
"(",
"self",
",",
"points",
")",
":",
"for",
"p",
"in",
"points",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"intervals",
")",
")",
":",
"if",
"(",
"self",
".",
"intervals",
"[",
"i",
"]",
".",
"start",
"<",
... | Splits the list of time intervals in the specified points
The function assumes that the time intervals do not overlap and ignores
points that are not inside of any interval.
Parameters
==========
points: list of datetime | [
"Splits",
"the",
"list",
"of",
"time",
"intervals",
"in",
"the",
"specified",
"points"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/time_interval.py#L118-L135 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/api.py | WorkflowObject.create | def create(cls, data, **kwargs):
"""Create a new Workflow Object with given content."""
with db.session.begin_nested():
model = cls.dbmodel(**kwargs)
model.data = data
obj = cls(model)
db.session.add(obj.model)
return obj | python | def create(cls, data, **kwargs):
"""Create a new Workflow Object with given content."""
with db.session.begin_nested():
model = cls.dbmodel(**kwargs)
model.data = data
obj = cls(model)
db.session.add(obj.model)
return obj | [
"def",
"create",
"(",
"cls",
",",
"data",
",",
"**",
"kwargs",
")",
":",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"model",
"=",
"cls",
".",
"dbmodel",
"(",
"**",
"kwargs",
")",
"model",
".",
"data",
"=",
"data",
"obj",
"=... | Create a new Workflow Object with given content. | [
"Create",
"a",
"new",
"Workflow",
"Object",
"with",
"given",
"content",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L139-L146 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/api.py | WorkflowObject.get | def get(cls, id_):
"""Return a workflow object from id."""
with db.session.no_autoflush:
query = cls.dbmodel.query.filter_by(id=id_)
try:
model = query.one()
except NoResultFound:
raise WorkflowsMissingObject("No object for for id {0}".... | python | def get(cls, id_):
"""Return a workflow object from id."""
with db.session.no_autoflush:
query = cls.dbmodel.query.filter_by(id=id_)
try:
model = query.one()
except NoResultFound:
raise WorkflowsMissingObject("No object for for id {0}".... | [
"def",
"get",
"(",
"cls",
",",
"id_",
")",
":",
"with",
"db",
".",
"session",
".",
"no_autoflush",
":",
"query",
"=",
"cls",
".",
"dbmodel",
".",
"query",
".",
"filter_by",
"(",
"id",
"=",
"id_",
")",
"try",
":",
"model",
"=",
"query",
".",
"one"... | Return a workflow object from id. | [
"Return",
"a",
"workflow",
"object",
"from",
"id",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L149-L159 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/api.py | WorkflowObject.query | def query(cls, *criteria, **filters):
"""Wrap sqlalchemy query methods.
A wrapper for the filter and filter_by functions of sqlalchemy.
Define a dict with which columns should be filtered by which values.
.. codeblock:: python
WorkflowObject.query(id=123)
Workf... | python | def query(cls, *criteria, **filters):
"""Wrap sqlalchemy query methods.
A wrapper for the filter and filter_by functions of sqlalchemy.
Define a dict with which columns should be filtered by which values.
.. codeblock:: python
WorkflowObject.query(id=123)
Workf... | [
"def",
"query",
"(",
"cls",
",",
"*",
"criteria",
",",
"**",
"filters",
")",
":",
"query",
"=",
"cls",
".",
"dbmodel",
".",
"query",
".",
"filter",
"(",
"*",
"criteria",
")",
".",
"filter_by",
"(",
"**",
"filters",
")",
"return",
"[",
"cls",
"(",
... | Wrap sqlalchemy query methods.
A wrapper for the filter and filter_by functions of sqlalchemy.
Define a dict with which columns should be filtered by which values.
.. codeblock:: python
WorkflowObject.query(id=123)
WorkflowObject.query(status=ObjectStatus.COMPLETED)
... | [
"Wrap",
"sqlalchemy",
"query",
"methods",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L162-L187 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/api.py | WorkflowObject.delete | def delete(self, force=False):
"""Delete a workflow object.
If `force` is ``False``, the record is soft-deleted, i.e. the record
stays in the database. This ensures e.g. that the same record
identifier cannot be used twice, and that you can still retrieve the
history of an objec... | python | def delete(self, force=False):
"""Delete a workflow object.
If `force` is ``False``, the record is soft-deleted, i.e. the record
stays in the database. This ensures e.g. that the same record
identifier cannot be used twice, and that you can still retrieve the
history of an objec... | [
"def",
"delete",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"model",
"is",
"None",
":",
"raise",
"WorkflowsMissingModel",
"(",
")",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"db",
".",
"session",
"."... | Delete a workflow object.
If `force` is ``False``, the record is soft-deleted, i.e. the record
stays in the database. This ensures e.g. that the same record
identifier cannot be used twice, and that you can still retrieve the
history of an object. If `force` is True, the record is compl... | [
"Delete",
"a",
"workflow",
"object",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L189-L206 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/api.py | WorkflowObject.set_action | def set_action(self, action, message):
"""Set the action to be taken for this object.
Assign an special "action" to this object to be taken
in consideration in Holding Pen. The widget is referred to
by a string with the filename minus extension.
A message is also needed to tell... | python | def set_action(self, action, message):
"""Set the action to be taken for this object.
Assign an special "action" to this object to be taken
in consideration in Holding Pen. The widget is referred to
by a string with the filename minus extension.
A message is also needed to tell... | [
"def",
"set_action",
"(",
"self",
",",
"action",
",",
"message",
")",
":",
"self",
".",
"extra_data",
"[",
"\"_action\"",
"]",
"=",
"action",
"self",
".",
"extra_data",
"[",
"\"_message\"",
"]",
"=",
"message"
] | Set the action to be taken for this object.
Assign an special "action" to this object to be taken
in consideration in Holding Pen. The widget is referred to
by a string with the filename minus extension.
A message is also needed to tell the user the action
required in a textual... | [
"Set",
"the",
"action",
"to",
"be",
"taken",
"for",
"this",
"object",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L280-L297 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/api.py | WorkflowObject.start_workflow | def start_workflow(self, workflow_name, delayed=False, **kwargs):
"""Run the workflow specified on the object.
:param workflow_name: name of workflow to run
:type workflow_name: str
:param delayed: should the workflow run asynchronously?
:type delayed: bool
:return: UU... | python | def start_workflow(self, workflow_name, delayed=False, **kwargs):
"""Run the workflow specified on the object.
:param workflow_name: name of workflow to run
:type workflow_name: str
:param delayed: should the workflow run asynchronously?
:type delayed: bool
:return: UU... | [
"def",
"start_workflow",
"(",
"self",
",",
"workflow_name",
",",
"delayed",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"from",
".",
"tasks",
"import",
"start",
"if",
"delayed",
":",
"self",
".",
"save",
"(",
")",
"db",
".",
"session",
".",
"commit",
... | Run the workflow specified on the object.
:param workflow_name: name of workflow to run
:type workflow_name: str
:param delayed: should the workflow run asynchronously?
:type delayed: bool
:return: UUID of WorkflowEngine (or AsyncResult). | [
"Run",
"the",
"workflow",
"specified",
"on",
"the",
"object",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L327-L345 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/api.py | WorkflowObject.continue_workflow | def continue_workflow(self, start_point="continue_next",
delayed=False, **kwargs):
"""Continue the workflow for this object.
The parameter `start_point` allows you to specify the point of where
the workflow shall continue:
* restart_prev: will restart from the... | python | def continue_workflow(self, start_point="continue_next",
delayed=False, **kwargs):
"""Continue the workflow for this object.
The parameter `start_point` allows you to specify the point of where
the workflow shall continue:
* restart_prev: will restart from the... | [
"def",
"continue_workflow",
"(",
"self",
",",
"start_point",
"=",
"\"continue_next\"",
",",
"delayed",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"from",
".",
"tasks",
"import",
"resume",
"self",
".",
"save",
"(",
")",
"if",
"not",
"self",
".",
"id_wor... | Continue the workflow for this object.
The parameter `start_point` allows you to specify the point of where
the workflow shall continue:
* restart_prev: will restart from the previous task
* continue_next: will continue to the next task
* restart_task: will restart the curren... | [
"Continue",
"the",
"workflow",
"for",
"this",
"object",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L347-L378 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/api.py | WorkflowObject.get_current_task_info | def get_current_task_info(self):
"""Return dictionary of current task function info for this object."""
name = self.model.workflow.name
if not name:
return
current_task = workflows[name].workflow
for step in self.callback_pos:
current_task = current_task[... | python | def get_current_task_info(self):
"""Return dictionary of current task function info for this object."""
name = self.model.workflow.name
if not name:
return
current_task = workflows[name].workflow
for step in self.callback_pos:
current_task = current_task[... | [
"def",
"get_current_task_info",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"model",
".",
"workflow",
".",
"name",
"if",
"not",
"name",
":",
"return",
"current_task",
"=",
"workflows",
"[",
"name",
"]",
".",
"workflow",
"for",
"step",
"in",
"self",
... | Return dictionary of current task function info for this object. | [
"Return",
"dictionary",
"of",
"current",
"task",
"function",
"info",
"for",
"this",
"object",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L380-L390 | train |
rsgalloway/grit | grit/server/git_http_backend.py | BaseWSGIClass.canned_handlers | def canned_handlers(self, environ, start_response, code = '200', headers = []):
'''
We convert an error code into
certain action over start_response and return a WSGI-compliant payload.
'''
headerbase = [('Content-Type', 'text/plain')]
if headers:
hObj ... | python | def canned_handlers(self, environ, start_response, code = '200', headers = []):
'''
We convert an error code into
certain action over start_response and return a WSGI-compliant payload.
'''
headerbase = [('Content-Type', 'text/plain')]
if headers:
hObj ... | [
"def",
"canned_handlers",
"(",
"self",
",",
"environ",
",",
"start_response",
",",
"code",
"=",
"'200'",
",",
"headers",
"=",
"[",
"]",
")",
":",
"headerbase",
"=",
"[",
"(",
"'Content-Type'",
",",
"'text/plain'",
")",
"]",
"if",
"headers",
":",
"hObj",
... | We convert an error code into
certain action over start_response and return a WSGI-compliant payload. | [
"We",
"convert",
"an",
"error",
"code",
"into",
"certain",
"action",
"over",
"start_response",
"and",
"return",
"a",
"WSGI",
"-",
"compliant",
"payload",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/git_http_backend.py#L79-L90 | train |
cloudmesh-cmd3/cmd3 | cmd3/plugins/shell_scope.py | shell_scope.info_shell_scope | def info_shell_scope(self):
"""prints some information about the shell scope"""
Console.ok("{:>20} = {:}".format("ECHO", self.echo))
Console.ok("{:>20} = {:}".format("DEBUG", self.debug))
Console.ok("{:>20} = {:}".format("LOGLEVEL", self.loglevel))
Console.ok("{:>20} = {:}".forma... | python | def info_shell_scope(self):
"""prints some information about the shell scope"""
Console.ok("{:>20} = {:}".format("ECHO", self.echo))
Console.ok("{:>20} = {:}".format("DEBUG", self.debug))
Console.ok("{:>20} = {:}".format("LOGLEVEL", self.loglevel))
Console.ok("{:>20} = {:}".forma... | [
"def",
"info_shell_scope",
"(",
"self",
")",
":",
"Console",
".",
"ok",
"(",
"\"{:>20} = {:}\"",
".",
"format",
"(",
"\"ECHO\"",
",",
"self",
".",
"echo",
")",
")",
"Console",
".",
"ok",
"(",
"\"{:>20} = {:}\"",
".",
"format",
"(",
"\"DEBUG\"",
",",
"sel... | prints some information about the shell scope | [
"prints",
"some",
"information",
"about",
"the",
"shell",
"scope"
] | 92e33c96032fd3921f159198a0e57917c4dc34ed | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/shell_scope.py#L28-L38 | train |
cloudmesh-cmd3/cmd3 | cmd3/plugins/shell_scope.py | shell_scope.activate_shell_scope | def activate_shell_scope(self):
"""activates the shell scope"""
self.variables = {}
self.prompt = 'cm> '
self.active_scope = ""
self.scopes = []
self.scopeless = ['load', 'info', 'var', 'use', 'quit', 'q', 'help'] | python | def activate_shell_scope(self):
"""activates the shell scope"""
self.variables = {}
self.prompt = 'cm> '
self.active_scope = ""
self.scopes = []
self.scopeless = ['load', 'info', 'var', 'use', 'quit', 'q', 'help'] | [
"def",
"activate_shell_scope",
"(",
"self",
")",
":",
"self",
".",
"variables",
"=",
"{",
"}",
"self",
".",
"prompt",
"=",
"'cm> '",
"self",
".",
"active_scope",
"=",
"\"\"",
"self",
".",
"scopes",
"=",
"[",
"]",
"self",
".",
"scopeless",
"=",
"[",
"... | activates the shell scope | [
"activates",
"the",
"shell",
"scope"
] | 92e33c96032fd3921f159198a0e57917c4dc34ed | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/shell_scope.py#L40-L46 | train |
BernardFW/bernard | src/bernard/middleware/_manager.py | Caller._build_stack | def _build_stack(self) -> List[Callable]:
"""
Generates the stack of functions to call. It looks at the ordered list
of all middlewares and only keeps those which have the method we're
trying to call.
"""
stack = []
for m in self.manager.middlewares:
... | python | def _build_stack(self) -> List[Callable]:
"""
Generates the stack of functions to call. It looks at the ordered list
of all middlewares and only keeps those which have the method we're
trying to call.
"""
stack = []
for m in self.manager.middlewares:
... | [
"def",
"_build_stack",
"(",
"self",
")",
"->",
"List",
"[",
"Callable",
"]",
":",
"stack",
"=",
"[",
"]",
"for",
"m",
"in",
"self",
".",
"manager",
".",
"middlewares",
":",
"try",
":",
"stack",
".",
"append",
"(",
"getattr",
"(",
"m",
"(",
"self",
... | Generates the stack of functions to call. It looks at the ordered list
of all middlewares and only keeps those which have the method we're
trying to call. | [
"Generates",
"the",
"stack",
"of",
"functions",
"to",
"call",
".",
"It",
"looks",
"at",
"the",
"ordered",
"list",
"of",
"all",
"middlewares",
"and",
"only",
"keeps",
"those",
"which",
"have",
"the",
"method",
"we",
"re",
"trying",
"to",
"call",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_manager.py#L53-L68 | train |
BernardFW/bernard | src/bernard/middleware/_manager.py | MiddlewareManager.instance | def instance(cls) -> 'MiddlewareManager':
"""
Creates, initializes and returns a unique MiddlewareManager instance.
"""
if cls._instance is None:
cls._instance = cls()
cls._instance.init()
return cls._instance | python | def instance(cls) -> 'MiddlewareManager':
"""
Creates, initializes and returns a unique MiddlewareManager instance.
"""
if cls._instance is None:
cls._instance = cls()
cls._instance.init()
return cls._instance | [
"def",
"instance",
"(",
"cls",
")",
"->",
"'MiddlewareManager'",
":",
"if",
"cls",
".",
"_instance",
"is",
"None",
":",
"cls",
".",
"_instance",
"=",
"cls",
"(",
")",
"cls",
".",
"_instance",
".",
"init",
"(",
")",
"return",
"cls",
".",
"_instance"
] | Creates, initializes and returns a unique MiddlewareManager instance. | [
"Creates",
"initializes",
"and",
"returns",
"a",
"unique",
"MiddlewareManager",
"instance",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_manager.py#L124-L132 | train |
BernardFW/bernard | src/bernard/middleware/_manager.py | MiddlewareManager.health_check | def health_check(cls):
"""
Checks that the configuration makes sense.
"""
try:
assert isinstance(settings.MIDDLEWARES, list)
except AssertionError:
yield HealthCheckFail(
'00005',
'The "MIDDLEWARES" configuration key should... | python | def health_check(cls):
"""
Checks that the configuration makes sense.
"""
try:
assert isinstance(settings.MIDDLEWARES, list)
except AssertionError:
yield HealthCheckFail(
'00005',
'The "MIDDLEWARES" configuration key should... | [
"def",
"health_check",
"(",
"cls",
")",
":",
"try",
":",
"assert",
"isinstance",
"(",
"settings",
".",
"MIDDLEWARES",
",",
"list",
")",
"except",
"AssertionError",
":",
"yield",
"HealthCheckFail",
"(",
"'00005'",
",",
"'The \"MIDDLEWARES\" configuration key should b... | Checks that the configuration makes sense. | [
"Checks",
"that",
"the",
"configuration",
"makes",
"sense",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_manager.py#L135-L164 | train |
BernardFW/bernard | src/bernard/middleware/_manager.py | MiddlewareManager.get | def get(self, name: Text, final: C) -> C:
"""
Get the function to call which will run all middlewares.
:param name: Name of the function to be called
:param final: Function to call at the bottom of the stack (that's the
one provided by the implementer).
:re... | python | def get(self, name: Text, final: C) -> C:
"""
Get the function to call which will run all middlewares.
:param name: Name of the function to be called
:param final: Function to call at the bottom of the stack (that's the
one provided by the implementer).
:re... | [
"def",
"get",
"(",
"self",
",",
"name",
":",
"Text",
",",
"final",
":",
"C",
")",
"->",
"C",
":",
"return",
"Caller",
"(",
"self",
",",
"name",
",",
"final",
")"
] | Get the function to call which will run all middlewares.
:param name: Name of the function to be called
:param final: Function to call at the bottom of the stack (that's the
one provided by the implementer).
:return: | [
"Get",
"the",
"function",
"to",
"call",
"which",
"will",
"run",
"all",
"middlewares",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_manager.py#L173-L184 | train |
openvax/varlens | varlens/loci_util.py | load_from_args | def load_from_args(args):
"""
Return a Loci object giving the loci specified on the command line.
If no loci-related arguments are specified, return None. This makes it
possible to distinguish an empty set of loci, for example due to filters
removing all loci, from the case where the user didn't sp... | python | def load_from_args(args):
"""
Return a Loci object giving the loci specified on the command line.
If no loci-related arguments are specified, return None. This makes it
possible to distinguish an empty set of loci, for example due to filters
removing all loci, from the case where the user didn't sp... | [
"def",
"load_from_args",
"(",
"args",
")",
":",
"if",
"not",
"args",
".",
"locus",
":",
"return",
"None",
"loci_iterator",
"=",
"(",
"Locus",
".",
"parse",
"(",
"locus",
")",
"for",
"locus",
"in",
"args",
".",
"locus",
")",
"return",
"Loci",
"(",
"lo... | Return a Loci object giving the loci specified on the command line.
If no loci-related arguments are specified, return None. This makes it
possible to distinguish an empty set of loci, for example due to filters
removing all loci, from the case where the user didn't specify any
arguments. | [
"Return",
"a",
"Loci",
"object",
"giving",
"the",
"loci",
"specified",
"on",
"the",
"command",
"line",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/loci_util.py#L30-L48 | train |
polyaxon/hestia | hestia/date_formatter.py | DateTimeFormatter.format_date | def format_date(cls, timestamp):
"""
Creates a string representing the date information provided by the
given `timestamp` object.
"""
if not timestamp:
raise DateTimeFormatterException('timestamp must a valid string {}'.format(timestamp))
return timestamp.str... | python | def format_date(cls, timestamp):
"""
Creates a string representing the date information provided by the
given `timestamp` object.
"""
if not timestamp:
raise DateTimeFormatterException('timestamp must a valid string {}'.format(timestamp))
return timestamp.str... | [
"def",
"format_date",
"(",
"cls",
",",
"timestamp",
")",
":",
"if",
"not",
"timestamp",
":",
"raise",
"DateTimeFormatterException",
"(",
"'timestamp must a valid string {}'",
".",
"format",
"(",
"timestamp",
")",
")",
"return",
"timestamp",
".",
"strftime",
"(",
... | Creates a string representing the date information provided by the
given `timestamp` object. | [
"Creates",
"a",
"string",
"representing",
"the",
"date",
"information",
"provided",
"by",
"the",
"given",
"timestamp",
"object",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/date_formatter.py#L30-L38 | train |
polyaxon/hestia | hestia/date_formatter.py | DateTimeFormatter.format_datetime | def format_datetime(cls, timestamp):
"""
Creates a string representing the date and time information provided by
the given `timestamp` object.
"""
if not timestamp:
raise DateTimeFormatterException('timestamp must a valid string {}'.format(timestamp))
return ... | python | def format_datetime(cls, timestamp):
"""
Creates a string representing the date and time information provided by
the given `timestamp` object.
"""
if not timestamp:
raise DateTimeFormatterException('timestamp must a valid string {}'.format(timestamp))
return ... | [
"def",
"format_datetime",
"(",
"cls",
",",
"timestamp",
")",
":",
"if",
"not",
"timestamp",
":",
"raise",
"DateTimeFormatterException",
"(",
"'timestamp must a valid string {}'",
".",
"format",
"(",
"timestamp",
")",
")",
"return",
"timestamp",
".",
"strftime",
"(... | Creates a string representing the date and time information provided by
the given `timestamp` object. | [
"Creates",
"a",
"string",
"representing",
"the",
"date",
"and",
"time",
"information",
"provided",
"by",
"the",
"given",
"timestamp",
"object",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/date_formatter.py#L41-L49 | train |
polyaxon/hestia | hestia/date_formatter.py | DateTimeFormatter.extract_date | def extract_date(cls, date_str):
"""
Tries to extract a `datetime` object from the given string, expecting
date information only.
Raises `DateTimeFormatterException` if the extraction fails.
"""
if not date_str:
raise DateTimeFormatterException('date_str must... | python | def extract_date(cls, date_str):
"""
Tries to extract a `datetime` object from the given string, expecting
date information only.
Raises `DateTimeFormatterException` if the extraction fails.
"""
if not date_str:
raise DateTimeFormatterException('date_str must... | [
"def",
"extract_date",
"(",
"cls",
",",
"date_str",
")",
":",
"if",
"not",
"date_str",
":",
"raise",
"DateTimeFormatterException",
"(",
"'date_str must a valid string {}.'",
".",
"format",
"(",
"date_str",
")",
")",
"try",
":",
"return",
"cls",
".",
"_extract_ti... | Tries to extract a `datetime` object from the given string, expecting
date information only.
Raises `DateTimeFormatterException` if the extraction fails. | [
"Tries",
"to",
"extract",
"a",
"datetime",
"object",
"from",
"the",
"given",
"string",
"expecting",
"date",
"information",
"only",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/date_formatter.py#L52-L65 | train |
polyaxon/hestia | hestia/date_formatter.py | DateTimeFormatter.extract_datetime | def extract_datetime(cls, datetime_str):
"""
Tries to extract a `datetime` object from the given string, including
time information.
Raises `DateTimeFormatterException` if the extraction fails.
"""
if not datetime_str:
raise DateTimeFormatterException('dateti... | python | def extract_datetime(cls, datetime_str):
"""
Tries to extract a `datetime` object from the given string, including
time information.
Raises `DateTimeFormatterException` if the extraction fails.
"""
if not datetime_str:
raise DateTimeFormatterException('dateti... | [
"def",
"extract_datetime",
"(",
"cls",
",",
"datetime_str",
")",
":",
"if",
"not",
"datetime_str",
":",
"raise",
"DateTimeFormatterException",
"(",
"'datetime_str must a valid string'",
")",
"try",
":",
"return",
"cls",
".",
"_extract_timestamp",
"(",
"datetime_str",
... | Tries to extract a `datetime` object from the given string, including
time information.
Raises `DateTimeFormatterException` if the extraction fails. | [
"Tries",
"to",
"extract",
"a",
"datetime",
"object",
"from",
"the",
"given",
"string",
"including",
"time",
"information",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/date_formatter.py#L68-L81 | train |
polyaxon/hestia | hestia/date_formatter.py | DateTimeFormatter.extract_datetime_hour | def extract_datetime_hour(cls, datetime_str):
"""
Tries to extract a `datetime` object from the given string, including only hours.
Raises `DateTimeFormatterException` if the extraction fails.
"""
if not datetime_str:
raise DateTimeFormatterException('datetime_str mu... | python | def extract_datetime_hour(cls, datetime_str):
"""
Tries to extract a `datetime` object from the given string, including only hours.
Raises `DateTimeFormatterException` if the extraction fails.
"""
if not datetime_str:
raise DateTimeFormatterException('datetime_str mu... | [
"def",
"extract_datetime_hour",
"(",
"cls",
",",
"datetime_str",
")",
":",
"if",
"not",
"datetime_str",
":",
"raise",
"DateTimeFormatterException",
"(",
"'datetime_str must a valid string'",
")",
"try",
":",
"return",
"cls",
".",
"_extract_timestamp",
"(",
"datetime_s... | Tries to extract a `datetime` object from the given string, including only hours.
Raises `DateTimeFormatterException` if the extraction fails. | [
"Tries",
"to",
"extract",
"a",
"datetime",
"object",
"from",
"the",
"given",
"string",
"including",
"only",
"hours",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/date_formatter.py#L84-L96 | train |
polyaxon/hestia | hestia/date_formatter.py | DateTimeFormatter.extract | def extract(cls, timestamp_str):
"""
Tries to extract a `datetime` object from the given string. First the
datetime format is tried, if it fails, the date format is used for
extraction.
Raises `DateTimeFormatterException` if the extraction fails.
"""
if not times... | python | def extract(cls, timestamp_str):
"""
Tries to extract a `datetime` object from the given string. First the
datetime format is tried, if it fails, the date format is used for
extraction.
Raises `DateTimeFormatterException` if the extraction fails.
"""
if not times... | [
"def",
"extract",
"(",
"cls",
",",
"timestamp_str",
")",
":",
"if",
"not",
"timestamp_str",
":",
"raise",
"DateTimeFormatterException",
"(",
"'timestamp_str must a valid string {}'",
".",
"format",
"(",
"timestamp_str",
")",
")",
"if",
"isinstance",
"(",
"timestamp_... | Tries to extract a `datetime` object from the given string. First the
datetime format is tried, if it fails, the date format is used for
extraction.
Raises `DateTimeFormatterException` if the extraction fails. | [
"Tries",
"to",
"extract",
"a",
"datetime",
"object",
"from",
"the",
"given",
"string",
".",
"First",
"the",
"datetime",
"format",
"is",
"tried",
"if",
"it",
"fails",
"the",
"date",
"format",
"is",
"used",
"for",
"extraction",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/date_formatter.py#L99-L127 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/tasks.py | restart | def restart(uuid, **kwargs):
"""Restart the workflow from a given workflow engine UUID."""
from .worker_engine import restart_worker
return text_type(restart_worker(uuid, **kwargs).uuid) | python | def restart(uuid, **kwargs):
"""Restart the workflow from a given workflow engine UUID."""
from .worker_engine import restart_worker
return text_type(restart_worker(uuid, **kwargs).uuid) | [
"def",
"restart",
"(",
"uuid",
",",
"**",
"kwargs",
")",
":",
"from",
".",
"worker_engine",
"import",
"restart_worker",
"return",
"text_type",
"(",
"restart_worker",
"(",
"uuid",
",",
"**",
"kwargs",
")",
".",
"uuid",
")"
] | Restart the workflow from a given workflow engine UUID. | [
"Restart",
"the",
"workflow",
"from",
"a",
"given",
"workflow",
"engine",
"UUID",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/tasks.py#L107-L110 | train |
polyaxon/hestia | hestia/imports.py | import_submodules | def import_submodules(context, root_module, path):
"""
Import all submodules and register them in the ``context`` namespace.
>>> import_submodules(locals(), __name__, __path__)
"""
for _, module_name, _ in pkgutil.walk_packages(path, root_module + '.'):
# this causes a Runtime error with mo... | python | def import_submodules(context, root_module, path):
"""
Import all submodules and register them in the ``context`` namespace.
>>> import_submodules(locals(), __name__, __path__)
"""
for _, module_name, _ in pkgutil.walk_packages(path, root_module + '.'):
# this causes a Runtime error with mo... | [
"def",
"import_submodules",
"(",
"context",
",",
"root_module",
",",
"path",
")",
":",
"for",
"_",
",",
"module_name",
",",
"_",
"in",
"pkgutil",
".",
"walk_packages",
"(",
"path",
",",
"root_module",
"+",
"'.'",
")",
":",
"module",
"=",
"__import__",
"(... | Import all submodules and register them in the ``context`` namespace.
>>> import_submodules(locals(), __name__, __path__) | [
"Import",
"all",
"submodules",
"and",
"register",
"them",
"in",
"the",
"context",
"namespace",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/imports.py#L36-L49 | train |
cloudmesh-cmd3/cmd3 | cmd3/shell.py | command | def command(func):
'''
A decorator to create a function with docopt arguments. It also generates a help function
@command
def do_myfunc(self, args):
""" docopts text """
pass
will create
def do_myfunc(self, args, arguments):
""" docopts text """
... | python | def command(func):
'''
A decorator to create a function with docopt arguments. It also generates a help function
@command
def do_myfunc(self, args):
""" docopts text """
pass
will create
def do_myfunc(self, args, arguments):
""" docopts text """
... | [
"def",
"command",
"(",
"func",
")",
":",
"classname",
"=",
"inspect",
".",
"getouterframes",
"(",
"inspect",
".",
"currentframe",
"(",
")",
")",
"[",
"1",
"]",
"[",
"3",
"]",
"name",
"=",
"func",
".",
"__name__",
"help_name",
"=",
"name",
".",
"repla... | A decorator to create a function with docopt arguments. It also generates a help function
@command
def do_myfunc(self, args):
""" docopts text """
pass
will create
def do_myfunc(self, args, arguments):
""" docopts text """
...
def help_myfu... | [
"A",
"decorator",
"to",
"create",
"a",
"function",
"with",
"docopt",
"arguments",
".",
"It",
"also",
"generates",
"a",
"help",
"function"
] | 92e33c96032fd3921f159198a0e57917c4dc34ed | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/shell.py#L224-L260 | train |
rsgalloway/grit | grit/repo/version.py | ItemsMixin.addFile | def addFile(self, path, msg=""):
"""Adds a file to the version"""
item = Item.from_path(repo=self.repo, path=path)
self.addItem(item) | python | def addFile(self, path, msg=""):
"""Adds a file to the version"""
item = Item.from_path(repo=self.repo, path=path)
self.addItem(item) | [
"def",
"addFile",
"(",
"self",
",",
"path",
",",
"msg",
"=",
"\"\"",
")",
":",
"item",
"=",
"Item",
".",
"from_path",
"(",
"repo",
"=",
"self",
".",
"repo",
",",
"path",
"=",
"path",
")",
"self",
".",
"addItem",
"(",
"item",
")"
] | Adds a file to the version | [
"Adds",
"a",
"file",
"to",
"the",
"version"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L32-L35 | train |
rsgalloway/grit | grit/repo/version.py | ItemsMixin.addItem | def addItem(self, item):
"""Adds an item if the tree is mutable"""
try:
self.tree.addItem(item)
except AttributeError, e:
raise VersionError('Saved versions are immutable') | python | def addItem(self, item):
"""Adds an item if the tree is mutable"""
try:
self.tree.addItem(item)
except AttributeError, e:
raise VersionError('Saved versions are immutable') | [
"def",
"addItem",
"(",
"self",
",",
"item",
")",
":",
"try",
":",
"self",
".",
"tree",
".",
"addItem",
"(",
"item",
")",
"except",
"AttributeError",
",",
"e",
":",
"raise",
"VersionError",
"(",
"'Saved versions are immutable'",
")"
] | Adds an item if the tree is mutable | [
"Adds",
"an",
"item",
"if",
"the",
"tree",
"is",
"mutable"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L37-L42 | train |
rsgalloway/grit | grit/repo/version.py | ItemsMixin.removeItem | def removeItem(self, item):
"""Removes an item if the tree is mutable"""
try:
self.tree.removeItem(item)
except AttributeError, e:
raise VersionError('Saved versions are immutable') | python | def removeItem(self, item):
"""Removes an item if the tree is mutable"""
try:
self.tree.removeItem(item)
except AttributeError, e:
raise VersionError('Saved versions are immutable') | [
"def",
"removeItem",
"(",
"self",
",",
"item",
")",
":",
"try",
":",
"self",
".",
"tree",
".",
"removeItem",
"(",
"item",
")",
"except",
"AttributeError",
",",
"e",
":",
"raise",
"VersionError",
"(",
"'Saved versions are immutable'",
")"
] | Removes an item if the tree is mutable | [
"Removes",
"an",
"item",
"if",
"the",
"tree",
"is",
"mutable"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L44-L49 | train |
rsgalloway/grit | grit/repo/version.py | ItemsMixin.iteritems | def iteritems(self):
"""Generator that yields Items"""
if self.type in ['blob']:
raise StopIteration
for path, mode, sha in self.tree.iteritems():
item = Item(self, sha, path, mode)
yield item
for i in item.iteritems():
yield i | python | def iteritems(self):
"""Generator that yields Items"""
if self.type in ['blob']:
raise StopIteration
for path, mode, sha in self.tree.iteritems():
item = Item(self, sha, path, mode)
yield item
for i in item.iteritems():
yield i | [
"def",
"iteritems",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"in",
"[",
"'blob'",
"]",
":",
"raise",
"StopIteration",
"for",
"path",
",",
"mode",
",",
"sha",
"in",
"self",
".",
"tree",
".",
"iteritems",
"(",
")",
":",
"item",
"=",
"Item",
... | Generator that yields Items | [
"Generator",
"that",
"yields",
"Items"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L51-L60 | train |
rsgalloway/grit | grit/repo/version.py | ItemsMixin.items | def items(self, path=None):
"""
Returns set of items.
:param path: Regex filter on item path.
:return: List of Item class objects.
"""
items = list(self.iteritems())
if path is not None:
path += '$'
regex = re.compile(path)
it... | python | def items(self, path=None):
"""
Returns set of items.
:param path: Regex filter on item path.
:return: List of Item class objects.
"""
items = list(self.iteritems())
if path is not None:
path += '$'
regex = re.compile(path)
it... | [
"def",
"items",
"(",
"self",
",",
"path",
"=",
"None",
")",
":",
"items",
"=",
"list",
"(",
"self",
".",
"iteritems",
"(",
")",
")",
"if",
"path",
"is",
"not",
"None",
":",
"path",
"+=",
"'$'",
"regex",
"=",
"re",
".",
"compile",
"(",
"path",
"... | Returns set of items.
:param path: Regex filter on item path.
:return: List of Item class objects. | [
"Returns",
"set",
"of",
"items",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L63-L76 | train |
rsgalloway/grit | grit/repo/version.py | Item._get_blob | def _get_blob(self):
"""read blob on access only because get_object is slow"""
if not self.__blob:
self.__blob = self.repo.get_object(self.id)
return self.__blob | python | def _get_blob(self):
"""read blob on access only because get_object is slow"""
if not self.__blob:
self.__blob = self.repo.get_object(self.id)
return self.__blob | [
"def",
"_get_blob",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__blob",
":",
"self",
".",
"__blob",
"=",
"self",
".",
"repo",
".",
"get_object",
"(",
"self",
".",
"id",
")",
"return",
"self",
".",
"__blob"
] | read blob on access only because get_object is slow | [
"read",
"blob",
"on",
"access",
"only",
"because",
"get_object",
"is",
"slow"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L124-L128 | train |
rsgalloway/grit | grit/repo/version.py | Item.from_path | def from_path(self, repo, path, name=None):
"""
Create a new Item from a file path.
:param repo: Repo object.
:param path: File path.
:param name: Name of item (to override original file name).
:return: New Item class instance.
"""
if name is None:
... | python | def from_path(self, repo, path, name=None):
"""
Create a new Item from a file path.
:param repo: Repo object.
:param path: File path.
:param name: Name of item (to override original file name).
:return: New Item class instance.
"""
if name is None:
... | [
"def",
"from_path",
"(",
"self",
",",
"repo",
",",
"path",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"return",
"Item",
".",
"from_string",
"(",
"repo",
... | Create a new Item from a file path.
:param repo: Repo object.
:param path: File path.
:param name: Name of item (to override original file name).
:return: New Item class instance. | [
"Create",
"a",
"new",
"Item",
"from",
"a",
"file",
"path",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L146-L159 | train |
rsgalloway/grit | grit/repo/version.py | Item.from_string | def from_string(self, repo, name, string):
"""
Create a new Item from a data stream.
:param repo: Repo object.
:param name: Name of item.
:param data: Data stream.
:return: New Item class instance.
"""
try:
log.debug('Creating new item: %s' %... | python | def from_string(self, repo, name, string):
"""
Create a new Item from a data stream.
:param repo: Repo object.
:param name: Name of item.
:param data: Data stream.
:return: New Item class instance.
"""
try:
log.debug('Creating new item: %s' %... | [
"def",
"from_string",
"(",
"self",
",",
"repo",
",",
"name",
",",
"string",
")",
":",
"try",
":",
"log",
".",
"debug",
"(",
"'Creating new item: %s'",
"%",
"name",
")",
"blob",
"=",
"Blob",
".",
"from_string",
"(",
"string",
")",
"item",
"=",
"Item",
... | Create a new Item from a data stream.
:param repo: Repo object.
:param name: Name of item.
:param data: Data stream.
:return: New Item class instance. | [
"Create",
"a",
"new",
"Item",
"from",
"a",
"data",
"stream",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L162-L179 | train |
rsgalloway/grit | grit/repo/version.py | Item.save | def save(self, msg=None):
"""
Modify item data and commit to repo.
Git objects are immutable, to save means adding a new item
:param msg: Commit message.
"""
if msg is None:
msg = 'Saving %s' % self.name
log.debug(msg)
self.repo.addItem(self,... | python | def save(self, msg=None):
"""
Modify item data and commit to repo.
Git objects are immutable, to save means adding a new item
:param msg: Commit message.
"""
if msg is None:
msg = 'Saving %s' % self.name
log.debug(msg)
self.repo.addItem(self,... | [
"def",
"save",
"(",
"self",
",",
"msg",
"=",
"None",
")",
":",
"if",
"msg",
"is",
"None",
":",
"msg",
"=",
"'Saving %s'",
"%",
"self",
".",
"name",
"log",
".",
"debug",
"(",
"msg",
")",
"self",
".",
"repo",
".",
"addItem",
"(",
"self",
",",
"ms... | Modify item data and commit to repo.
Git objects are immutable, to save means adding a new item
:param msg: Commit message. | [
"Modify",
"item",
"data",
"and",
"commit",
"to",
"repo",
".",
"Git",
"objects",
"are",
"immutable",
"to",
"save",
"means",
"adding",
"a",
"new",
"item"
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L193-L203 | train |
rsgalloway/grit | grit/repo/version.py | Item.checkout | def checkout(self, path):
"""
Check out file data to path.
:param path: Filesystem path to check out item to.
:return: True if successful.
"""
if os.path.isdir(path):
path = os.path.join(path, self.name)
try:
log.debug('Checking out %s to... | python | def checkout(self, path):
"""
Check out file data to path.
:param path: Filesystem path to check out item to.
:return: True if successful.
"""
if os.path.isdir(path):
path = os.path.join(path, self.name)
try:
log.debug('Checking out %s to... | [
"def",
"checkout",
"(",
"self",
",",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"self",
".",
"name",
")",
"try",
":",
"log",
".",
"debug",
"("... | Check out file data to path.
:param path: Filesystem path to check out item to.
:return: True if successful. | [
"Check",
"out",
"file",
"data",
"to",
"path",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L205-L222 | train |
rsgalloway/grit | grit/repo/version.py | Version.save | def save(self, message):
"""
Add version to repo object store, set repo head to version sha.
:param message: Message string.
"""
self.commit.message = message
self.commit.tree = self.tree
#TODO: store new blobs only
for item in self.tree.items():
... | python | def save(self, message):
"""
Add version to repo object store, set repo head to version sha.
:param message: Message string.
"""
self.commit.message = message
self.commit.tree = self.tree
#TODO: store new blobs only
for item in self.tree.items():
... | [
"def",
"save",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"commit",
".",
"message",
"=",
"message",
"self",
".",
"commit",
".",
"tree",
"=",
"self",
".",
"tree",
"for",
"item",
"in",
"self",
".",
"tree",
".",
"items",
"(",
")",
":",
"sel... | Add version to repo object store, set repo head to version sha.
:param message: Message string. | [
"Add",
"version",
"to",
"repo",
"object",
"store",
"set",
"repo",
"head",
"to",
"version",
"sha",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L336-L351 | train |
rsgalloway/grit | grit/repo/version.py | Version.new | def new(self, repo):
"""
Create a new version of a repo.Local object.
:param repo: Instance of repo.Local.
:return: New Version instance.
"""
#TODO: subclass Commit, pass parent as init param
try:
# create new commit instance and set metadata
... | python | def new(self, repo):
"""
Create a new version of a repo.Local object.
:param repo: Instance of repo.Local.
:return: New Version instance.
"""
#TODO: subclass Commit, pass parent as init param
try:
# create new commit instance and set metadata
... | [
"def",
"new",
"(",
"self",
",",
"repo",
")",
":",
"try",
":",
"commit",
"=",
"Commit",
"(",
")",
"author",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'USER'",
")",
"commit",
".",
"author",
"=",
"commit",
".",
"committer",
"=",
"author",
"commit",... | Create a new version of a repo.Local object.
:param repo: Instance of repo.Local.
:return: New Version instance. | [
"Create",
"a",
"new",
"version",
"of",
"a",
"repo",
".",
"Local",
"object",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/version.py#L354-L393 | train |
rsgalloway/grit | grit/cmd/cli.py | confirm | def confirm(prompt=None, resp=False):
"""
Prompts user for confirmation.
:param prompt: String to display to user.
:param resp: Default response value.
:return: Boolean response from user, or default value.
"""
if prompt is None:
prompt = 'Confirm'
if resp:
prompt = '%... | python | def confirm(prompt=None, resp=False):
"""
Prompts user for confirmation.
:param prompt: String to display to user.
:param resp: Default response value.
:return: Boolean response from user, or default value.
"""
if prompt is None:
prompt = 'Confirm'
if resp:
prompt = '%... | [
"def",
"confirm",
"(",
"prompt",
"=",
"None",
",",
"resp",
"=",
"False",
")",
":",
"if",
"prompt",
"is",
"None",
":",
"prompt",
"=",
"'Confirm'",
"if",
"resp",
":",
"prompt",
"=",
"'%s [%s]|%s: '",
"%",
"(",
"prompt",
",",
"'y'",
",",
"'n'",
")",
"... | Prompts user for confirmation.
:param prompt: String to display to user.
:param resp: Default response value.
:return: Boolean response from user, or default value. | [
"Prompts",
"user",
"for",
"confirmation",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cli.py#L17-L44 | train |
rsgalloway/grit | grit/cmd/cli.py | prompt | def prompt(name, default):
"""
Prompts user for raw input.
:return: Raw input value from user.
"""
value = raw_input('%s [%s]: ' %(name, default))
if not value:
value = default
return value | python | def prompt(name, default):
"""
Prompts user for raw input.
:return: Raw input value from user.
"""
value = raw_input('%s [%s]: ' %(name, default))
if not value:
value = default
return value | [
"def",
"prompt",
"(",
"name",
",",
"default",
")",
":",
"value",
"=",
"raw_input",
"(",
"'%s [%s]: '",
"%",
"(",
"name",
",",
"default",
")",
")",
"if",
"not",
"value",
":",
"value",
"=",
"default",
"return",
"value"
] | Prompts user for raw input.
:return: Raw input value from user. | [
"Prompts",
"user",
"for",
"raw",
"input",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cli.py#L46-L55 | train |
rsgalloway/grit | grit/cmd/cli.py | new | def new(url):
"""
Creates a new Repo class instance at url.
:param url: URL of new repo
:return: new Repo class instance.
"""
from grit import Repo
return Repo.new(url=url, bare=True) | python | def new(url):
"""
Creates a new Repo class instance at url.
:param url: URL of new repo
:return: new Repo class instance.
"""
from grit import Repo
return Repo.new(url=url, bare=True) | [
"def",
"new",
"(",
"url",
")",
":",
"from",
"grit",
"import",
"Repo",
"return",
"Repo",
".",
"new",
"(",
"url",
"=",
"url",
",",
"bare",
"=",
"True",
")"
] | Creates a new Repo class instance at url.
:param url: URL of new repo
:return: new Repo class instance. | [
"Creates",
"a",
"new",
"Repo",
"class",
"instance",
"at",
"url",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cli.py#L57-L66 | train |
rsgalloway/grit | grit/cmd/cli.py | checkout | def checkout(url, version=None):
"""
Checks out latest version of item or repository.
:param url: URL of repo or item to check out.
:param version: Version number to check out.
"""
from grit import Repo
r = Repo(url)
def _write(item):
log.debug('writing: %s' % item.name)
... | python | def checkout(url, version=None):
"""
Checks out latest version of item or repository.
:param url: URL of repo or item to check out.
:param version: Version number to check out.
"""
from grit import Repo
r = Repo(url)
def _write(item):
log.debug('writing: %s' % item.name)
... | [
"def",
"checkout",
"(",
"url",
",",
"version",
"=",
"None",
")",
":",
"from",
"grit",
"import",
"Repo",
"r",
"=",
"Repo",
"(",
"url",
")",
"def",
"_write",
"(",
"item",
")",
":",
"log",
".",
"debug",
"(",
"'writing: %s'",
"%",
"item",
".",
"name",
... | Checks out latest version of item or repository.
:param url: URL of repo or item to check out.
:param version: Version number to check out. | [
"Checks",
"out",
"latest",
"version",
"of",
"item",
"or",
"repository",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cli.py#L68-L105 | train |
rsgalloway/grit | grit/cmd/cli.py | checkin | def checkin(url, files, message=None):
"""
Check in files to a repository.
:param url: URL of repo to check files into.
:param message: Optional commit message.
"""
from grit import Repo, Item
r = Repo(url)
if not files:
raise GritError('No files')
def _write(path):
... | python | def checkin(url, files, message=None):
"""
Check in files to a repository.
:param url: URL of repo to check files into.
:param message: Optional commit message.
"""
from grit import Repo, Item
r = Repo(url)
if not files:
raise GritError('No files')
def _write(path):
... | [
"def",
"checkin",
"(",
"url",
",",
"files",
",",
"message",
"=",
"None",
")",
":",
"from",
"grit",
"import",
"Repo",
",",
"Item",
"r",
"=",
"Repo",
"(",
"url",
")",
"if",
"not",
"files",
":",
"raise",
"GritError",
"(",
"'No files'",
")",
"def",
"_w... | Check in files to a repository.
:param url: URL of repo to check files into.
:param message: Optional commit message. | [
"Check",
"in",
"files",
"to",
"a",
"repository",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/cmd/cli.py#L107-L140 | train |
transifex/transifex-python-library | txlib/api/base.py | BaseModel.get | def get(cls, **kwargs):
"""Retrieve an object by making a GET request to Transifex.
Each value in `kwargs` that corresponds to a field
defined in `self.url_fields` will be used in the URL path
of the request, so that a particular entry of this model
is identified and retrieved.
... | python | def get(cls, **kwargs):
"""Retrieve an object by making a GET request to Transifex.
Each value in `kwargs` that corresponds to a field
defined in `self.url_fields` will be used in the URL path
of the request, so that a particular entry of this model
is identified and retrieved.
... | [
"def",
"get",
"(",
"cls",
",",
"**",
"kwargs",
")",
":",
"fields",
"=",
"{",
"}",
"for",
"field",
"in",
"cls",
".",
"url_fields",
":",
"value",
"=",
"kwargs",
".",
"pop",
"(",
"field",
",",
"None",
")",
"if",
"value",
"is",
"None",
":",
"cls",
... | Retrieve an object by making a GET request to Transifex.
Each value in `kwargs` that corresponds to a field
defined in `self.url_fields` will be used in the URL path
of the request, so that a particular entry of this model
is identified and retrieved.
Raises:
Attrib... | [
"Retrieve",
"an",
"object",
"by",
"making",
"a",
"GET",
"request",
"to",
"Transifex",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/base.py#L109-L139 | train |
transifex/transifex-python-library | txlib/api/base.py | BaseModel.save | def save(self, **fields):
"""Save the instance to the remote Transifex server.
If it was pre-populated, it updates the instance on the server,
otherwise it creates a new object.
Any values given in `fields` will be attempted to be saved
on the object. The same goes for any othe... | python | def save(self, **fields):
"""Save the instance to the remote Transifex server.
If it was pre-populated, it updates the instance on the server,
otherwise it creates a new object.
Any values given in `fields` will be attempted to be saved
on the object. The same goes for any othe... | [
"def",
"save",
"(",
"self",
",",
"**",
"fields",
")",
":",
"for",
"field",
"in",
"fields",
":",
"if",
"field",
"in",
"self",
".",
"writable_fields",
":",
"setattr",
"(",
"self",
",",
"field",
",",
"fields",
"[",
"field",
"]",
")",
"else",
":",
"sel... | Save the instance to the remote Transifex server.
If it was pre-populated, it updates the instance on the server,
otherwise it creates a new object.
Any values given in `fields` will be attempted to be saved
on the object. The same goes for any other values already set
to the o... | [
"Save",
"the",
"instance",
"to",
"the",
"remote",
"Transifex",
"server",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/base.py#L213-L236 | train |
transifex/transifex-python-library | txlib/api/base.py | BaseModel._get | def _get(self, **kwargs):
"""Get the resource from a remote Transifex server."""
path = self._construct_path_to_item()
return self._http.get(path) | python | def _get(self, **kwargs):
"""Get the resource from a remote Transifex server."""
path = self._construct_path_to_item()
return self._http.get(path) | [
"def",
"_get",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"path",
"=",
"self",
".",
"_construct_path_to_item",
"(",
")",
"return",
"self",
".",
"_http",
".",
"get",
"(",
"path",
")"
] | Get the resource from a remote Transifex server. | [
"Get",
"the",
"resource",
"from",
"a",
"remote",
"Transifex",
"server",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/base.py#L246-L249 | train |
transifex/transifex-python-library | txlib/api/base.py | BaseModel._create | def _create(self, **kwargs):
"""Create a resource in the remote Transifex server."""
path = self._construct_path_to_collection()
# Use the fields for which we have values
for field in self.writable_fields:
try:
value = getattr(self, field)
kwa... | python | def _create(self, **kwargs):
"""Create a resource in the remote Transifex server."""
path = self._construct_path_to_collection()
# Use the fields for which we have values
for field in self.writable_fields:
try:
value = getattr(self, field)
kwa... | [
"def",
"_create",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"path",
"=",
"self",
".",
"_construct_path_to_collection",
"(",
")",
"for",
"field",
"in",
"self",
".",
"writable_fields",
":",
"try",
":",
"value",
"=",
"getattr",
"(",
"self",
",",
"field",
... | Create a resource in the remote Transifex server. | [
"Create",
"a",
"resource",
"in",
"the",
"remote",
"Transifex",
"server",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/base.py#L251-L262 | train |
transifex/transifex-python-library | txlib/api/base.py | BaseModel._update | def _update(self, **kwargs):
"""Update a resource in a remote Transifex server."""
path = self._construct_path_to_item()
if not kwargs:
return
return self._http.put(path, json.dumps(kwargs)) | python | def _update(self, **kwargs):
"""Update a resource in a remote Transifex server."""
path = self._construct_path_to_item()
if not kwargs:
return
return self._http.put(path, json.dumps(kwargs)) | [
"def",
"_update",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"path",
"=",
"self",
".",
"_construct_path_to_item",
"(",
")",
"if",
"not",
"kwargs",
":",
"return",
"return",
"self",
".",
"_http",
".",
"put",
"(",
"path",
",",
"json",
".",
"dumps",
"("... | Update a resource in a remote Transifex server. | [
"Update",
"a",
"resource",
"in",
"a",
"remote",
"Transifex",
"server",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/base.py#L264-L269 | train |
transifex/transifex-python-library | txlib/api/base.py | BaseModel._delete | def _delete(self, **kwargs):
"""Delete a resource from a remote Transifex server."""
path = self._construct_path_to_item()
return self._http.delete(path) | python | def _delete(self, **kwargs):
"""Delete a resource from a remote Transifex server."""
path = self._construct_path_to_item()
return self._http.delete(path) | [
"def",
"_delete",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"path",
"=",
"self",
".",
"_construct_path_to_item",
"(",
")",
"return",
"self",
".",
"_http",
".",
"delete",
"(",
"path",
")"
] | Delete a resource from a remote Transifex server. | [
"Delete",
"a",
"resource",
"from",
"a",
"remote",
"Transifex",
"server",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/base.py#L271-L274 | train |
transifex/transifex-python-library | txlib/api/base.py | BaseModel.get_url_parameters | def get_url_parameters(self):
"""Create a dictionary of parameters used in URLs for this model."""
url_fields = {}
for field in self.url_fields:
url_fields[field] = getattr(self, field)
return url_fields | python | def get_url_parameters(self):
"""Create a dictionary of parameters used in URLs for this model."""
url_fields = {}
for field in self.url_fields:
url_fields[field] = getattr(self, field)
return url_fields | [
"def",
"get_url_parameters",
"(",
"self",
")",
":",
"url_fields",
"=",
"{",
"}",
"for",
"field",
"in",
"self",
".",
"url_fields",
":",
"url_fields",
"[",
"field",
"]",
"=",
"getattr",
"(",
"self",
",",
"field",
")",
"return",
"url_fields"
] | Create a dictionary of parameters used in URLs for this model. | [
"Create",
"a",
"dictionary",
"of",
"parameters",
"used",
"in",
"URLs",
"for",
"this",
"model",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/base.py#L285-L290 | train |
transifex/transifex-python-library | txlib/api/base.py | BaseModel._handle_wrong_field | def _handle_wrong_field(cls, field_name, field_type):
"""Raise an exception whenever an invalid attribute with
the given name was attempted to be set to or retrieved from
this model class.
Assumes that the given field is invalid, without making any checks.
Also adds an entry to... | python | def _handle_wrong_field(cls, field_name, field_type):
"""Raise an exception whenever an invalid attribute with
the given name was attempted to be set to or retrieved from
this model class.
Assumes that the given field is invalid, without making any checks.
Also adds an entry to... | [
"def",
"_handle_wrong_field",
"(",
"cls",
",",
"field_name",
",",
"field_type",
")",
":",
"if",
"field_type",
"==",
"ATTR_TYPE_READ",
":",
"field_type",
"=",
"'readable'",
"elif",
"field_type",
"==",
"ATTR_TYPE_WRITE",
":",
"field_type",
"=",
"'writable'",
"elif",... | Raise an exception whenever an invalid attribute with
the given name was attempted to be set to or retrieved from
this model class.
Assumes that the given field is invalid, without making any checks.
Also adds an entry to the logs. | [
"Raise",
"an",
"exception",
"whenever",
"an",
"invalid",
"attribute",
"with",
"the",
"given",
"name",
"was",
"attempted",
"to",
"be",
"set",
"to",
"or",
"retrieved",
"from",
"this",
"model",
"class",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/base.py#L307-L333 | train |
peopledoc/mock-services | mock_services/rules.py | update_http_rules | def update_http_rules(rules, content_type='text/plain'):
"""Adds rules to global http mock.
It permits to set mock in a more global way than decorators, cf.:
https://github.com/openstack/requests-mock
Here we assume urls in the passed dict are regex we recompile before adding
a rule.
Rules ex... | python | def update_http_rules(rules, content_type='text/plain'):
"""Adds rules to global http mock.
It permits to set mock in a more global way than decorators, cf.:
https://github.com/openstack/requests-mock
Here we assume urls in the passed dict are regex we recompile before adding
a rule.
Rules ex... | [
"def",
"update_http_rules",
"(",
"rules",
",",
"content_type",
"=",
"'text/plain'",
")",
":",
"for",
"kw",
"in",
"deepcopy",
"(",
"rules",
")",
":",
"kw",
"[",
"'url'",
"]",
"=",
"re",
".",
"compile",
"(",
"kw",
"[",
"'url'",
"]",
")",
"if",
"'Conten... | Adds rules to global http mock.
It permits to set mock in a more global way than decorators, cf.:
https://github.com/openstack/requests-mock
Here we assume urls in the passed dict are regex we recompile before adding
a rule.
Rules example:
>>> def fake_duckduckgo_cb(request):
... ret... | [
"Adds",
"rules",
"to",
"global",
"http",
"mock",
"."
] | fd3838280df8869725b538768357435eedf299c1 | https://github.com/peopledoc/mock-services/blob/fd3838280df8869725b538768357435eedf299c1/mock_services/rules.py#L33-L75 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/utils.py | get_task_history | def get_task_history(last_task):
"""Append last task to task history."""
if hasattr(last_task, 'branch') and last_task.branch:
return
elif hasattr(last_task, 'hide') and last_task.hide:
return
else:
return get_func_info(last_task) | python | def get_task_history(last_task):
"""Append last task to task history."""
if hasattr(last_task, 'branch') and last_task.branch:
return
elif hasattr(last_task, 'hide') and last_task.hide:
return
else:
return get_func_info(last_task) | [
"def",
"get_task_history",
"(",
"last_task",
")",
":",
"if",
"hasattr",
"(",
"last_task",
",",
"'branch'",
")",
"and",
"last_task",
".",
"branch",
":",
"return",
"elif",
"hasattr",
"(",
"last_task",
",",
"'hide'",
")",
"and",
"last_task",
".",
"hide",
":",... | Append last task to task history. | [
"Append",
"last",
"task",
"to",
"task",
"history",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/utils.py#L30-L37 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/utils.py | get_func_info | def get_func_info(func):
"""Retrieve a function's information."""
name = func.__name__
doc = func.__doc__ or ""
try:
nicename = func.description
except AttributeError:
if doc:
nicename = doc.split('\n')[0]
if len(nicename) > 80:
nicename = name... | python | def get_func_info(func):
"""Retrieve a function's information."""
name = func.__name__
doc = func.__doc__ or ""
try:
nicename = func.description
except AttributeError:
if doc:
nicename = doc.split('\n')[0]
if len(nicename) > 80:
nicename = name... | [
"def",
"get_func_info",
"(",
"func",
")",
":",
"name",
"=",
"func",
".",
"__name__",
"doc",
"=",
"func",
".",
"__doc__",
"or",
"\"\"",
"try",
":",
"nicename",
"=",
"func",
".",
"description",
"except",
"AttributeError",
":",
"if",
"doc",
":",
"nicename",... | Retrieve a function's information. | [
"Retrieve",
"a",
"function",
"s",
"information",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/utils.py#L40-L75 | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/utils.py | get_workflow_info | def get_workflow_info(func_list):
"""Return function info, go through lists recursively."""
funcs = []
for item in func_list:
if item is None:
continue
if isinstance(item, list):
funcs.append(get_workflow_info(item))
else:
funcs.append(get_func_inf... | python | def get_workflow_info(func_list):
"""Return function info, go through lists recursively."""
funcs = []
for item in func_list:
if item is None:
continue
if isinstance(item, list):
funcs.append(get_workflow_info(item))
else:
funcs.append(get_func_inf... | [
"def",
"get_workflow_info",
"(",
"func_list",
")",
":",
"funcs",
"=",
"[",
"]",
"for",
"item",
"in",
"func_list",
":",
"if",
"item",
"is",
"None",
":",
"continue",
"if",
"isinstance",
"(",
"item",
",",
"list",
")",
":",
"funcs",
".",
"append",
"(",
"... | Return function info, go through lists recursively. | [
"Return",
"function",
"info",
"go",
"through",
"lists",
"recursively",
"."
] | 9c09fd29509a3db975ac2aba337e6760d8cfd3c2 | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/utils.py#L78-L88 | train |
COALAIP/pycoalaip | coalaip/data_formats.py | _copy_context_into_mutable | def _copy_context_into_mutable(context):
"""Copy a properly formatted context into a mutable data structure.
"""
def make_mutable(val):
if isinstance(val, Mapping):
return dict(val)
else:
return val
if not isinstance(context, (str, Mapping)):
try:
... | python | def _copy_context_into_mutable(context):
"""Copy a properly formatted context into a mutable data structure.
"""
def make_mutable(val):
if isinstance(val, Mapping):
return dict(val)
else:
return val
if not isinstance(context, (str, Mapping)):
try:
... | [
"def",
"_copy_context_into_mutable",
"(",
"context",
")",
":",
"def",
"make_mutable",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"Mapping",
")",
":",
"return",
"dict",
"(",
"val",
")",
"else",
":",
"return",
"val",
"if",
"not",
"isinstanc... | Copy a properly formatted context into a mutable data structure. | [
"Copy",
"a",
"properly",
"formatted",
"context",
"into",
"a",
"mutable",
"data",
"structure",
"."
] | cecc8f6ff4733f0525fafcee63647753e832f0be | https://github.com/COALAIP/pycoalaip/blob/cecc8f6ff4733f0525fafcee63647753e832f0be/coalaip/data_formats.py#L17-L31 | train |
seung-lab/EMAnnotationSchemas | emannotationschemas/models.py | make_dataset_models | def make_dataset_models(dataset, schemas_and_tables, metadata_dict = None, version: int = 1, include_contacts=False):
"""make all the models for a dataset
Parameters
----------
dataset: str
name of dataset
table_and_types: list[(schema_name, table_name)]
list of tuples with types an... | python | def make_dataset_models(dataset, schemas_and_tables, metadata_dict = None, version: int = 1, include_contacts=False):
"""make all the models for a dataset
Parameters
----------
dataset: str
name of dataset
table_and_types: list[(schema_name, table_name)]
list of tuples with types an... | [
"def",
"make_dataset_models",
"(",
"dataset",
",",
"schemas_and_tables",
",",
"metadata_dict",
"=",
"None",
",",
"version",
":",
"int",
"=",
"1",
",",
"include_contacts",
"=",
"False",
")",
":",
"if",
"metadata_dict",
"is",
"None",
":",
"metadata_dict",
"=",
... | make all the models for a dataset
Parameters
----------
dataset: str
name of dataset
table_and_types: list[(schema_name, table_name)]
list of tuples with types and model names to make
metadata_dict:
a dictionary with keys of table_names and values of metadata dicts needed
... | [
"make",
"all",
"the",
"models",
"for",
"a",
"dataset"
] | ca81eff0f449bd7eb0392e0982db8f3636446a9e | https://github.com/seung-lab/EMAnnotationSchemas/blob/ca81eff0f449bd7eb0392e0982db8f3636446a9e/emannotationschemas/models.py#L112-L158 | train |
dropseed/configyaml | configyaml/config/base.py | AbstractNode._key_name | def _key_name(self): # type: () -> str
"""Return the key referring to this object
The default value is the lower case version of the class name
:rtype: str
"""
if self._key is not None:
return self._key
return self.__class__.__name__.lower() | python | def _key_name(self): # type: () -> str
"""Return the key referring to this object
The default value is the lower case version of the class name
:rtype: str
"""
if self._key is not None:
return self._key
return self.__class__.__name__.lower() | [
"def",
"_key_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_key",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_key",
"return",
"self",
".",
"__class__",
".",
"__name__",
".",
"lower",
"(",
")"
] | Return the key referring to this object
The default value is the lower case version of the class name
:rtype: str | [
"Return",
"the",
"key",
"referring",
"to",
"this",
"object"
] | d008f251530d054c2d1fb3e8ac1a9030436134c8 | https://github.com/dropseed/configyaml/blob/d008f251530d054c2d1fb3e8ac1a9030436134c8/configyaml/config/base.py#L77-L87 | train |
dropseed/configyaml | configyaml/config/base.py | AbstractNode._path | def _path(self): # type: () -> str
"""Return the dotted path representation of this object
:rtype: str
"""
if self._parent:
return '{}.{}'.format(self._parent._path(), self._key_name())
return self._key_name() | python | def _path(self): # type: () -> str
"""Return the dotted path representation of this object
:rtype: str
"""
if self._parent:
return '{}.{}'.format(self._parent._path(), self._key_name())
return self._key_name() | [
"def",
"_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"_parent",
":",
"return",
"'{}.{}'",
".",
"format",
"(",
"self",
".",
"_parent",
".",
"_path",
"(",
")",
",",
"self",
".",
"_key_name",
"(",
")",
")",
"return",
"self",
".",
"_key_name",
"("... | Return the dotted path representation of this object
:rtype: str | [
"Return",
"the",
"dotted",
"path",
"representation",
"of",
"this",
"object"
] | d008f251530d054c2d1fb3e8ac1a9030436134c8 | https://github.com/dropseed/configyaml/blob/d008f251530d054c2d1fb3e8ac1a9030436134c8/configyaml/config/base.py#L103-L111 | train |
dropseed/configyaml | configyaml/config/base.py | AbstractNode._add_error | def _add_error(self, *args, **kwargs): # type: () -> None
"""Convenience function to add an error to this object, with line numbers
An error title or description should not accidentally leak self._value, for privacy/redaction purposes.
:rtype: None
"""
if kwargs.get('node', No... | python | def _add_error(self, *args, **kwargs): # type: () -> None
"""Convenience function to add an error to this object, with line numbers
An error title or description should not accidentally leak self._value, for privacy/redaction purposes.
:rtype: None
"""
if kwargs.get('node', No... | [
"def",
"_add_error",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"'node'",
",",
"None",
")",
":",
"error",
"=",
"ConfigError",
".",
"create_from_yaml_node",
"(",
"*",
"args",
",",
"**",
"kwargs",
")"... | Convenience function to add an error to this object, with line numbers
An error title or description should not accidentally leak self._value, for privacy/redaction purposes.
:rtype: None | [
"Convenience",
"function",
"to",
"add",
"an",
"error",
"to",
"this",
"object",
"with",
"line",
"numbers"
] | d008f251530d054c2d1fb3e8ac1a9030436134c8 | https://github.com/dropseed/configyaml/blob/d008f251530d054c2d1fb3e8ac1a9030436134c8/configyaml/config/base.py#L113-L137 | train |
dropseed/configyaml | configyaml/config/base.py | AbstractNode._get_descendants_errors | def _get_descendants_errors(self): # type: () -> List(ConfigError)
"""Recursively get errors from descendants
:rtype: list of :ConfigErrors:"""
descendants_errors = []
if hasattr(self, '_children'):
if isinstance(self._children, (list, tuple)):
for c in self... | python | def _get_descendants_errors(self): # type: () -> List(ConfigError)
"""Recursively get errors from descendants
:rtype: list of :ConfigErrors:"""
descendants_errors = []
if hasattr(self, '_children'):
if isinstance(self._children, (list, tuple)):
for c in self... | [
"def",
"_get_descendants_errors",
"(",
"self",
")",
":",
"descendants_errors",
"=",
"[",
"]",
"if",
"hasattr",
"(",
"self",
",",
"'_children'",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_children",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
... | Recursively get errors from descendants
:rtype: list of :ConfigErrors: | [
"Recursively",
"get",
"errors",
"from",
"descendants"
] | d008f251530d054c2d1fb3e8ac1a9030436134c8 | https://github.com/dropseed/configyaml/blob/d008f251530d054c2d1fb3e8ac1a9030436134c8/configyaml/config/base.py#L139-L152 | train |
dropseed/configyaml | configyaml/config/base.py | AbstractNode._validate | def _validate(self): # type: () -> None
"""Run validation, save errors to object in self._errors"""
# class can specify it's empty obj -- list would have empty of []
self._errors = []
self._validate_type()
if self.is_valid():
self._validate_value() | python | def _validate(self): # type: () -> None
"""Run validation, save errors to object in self._errors"""
# class can specify it's empty obj -- list would have empty of []
self._errors = []
self._validate_type()
if self.is_valid():
self._validate_value() | [
"def",
"_validate",
"(",
"self",
")",
":",
"self",
".",
"_errors",
"=",
"[",
"]",
"self",
".",
"_validate_type",
"(",
")",
"if",
"self",
".",
"is_valid",
"(",
")",
":",
"self",
".",
"_validate_value",
"(",
")"
] | Run validation, save errors to object in self._errors | [
"Run",
"validation",
"save",
"errors",
"to",
"object",
"in",
"self",
".",
"_errors"
] | d008f251530d054c2d1fb3e8ac1a9030436134c8 | https://github.com/dropseed/configyaml/blob/d008f251530d054c2d1fb3e8ac1a9030436134c8/configyaml/config/base.py#L163-L171 | train |
dropseed/configyaml | configyaml/config/base.py | AbstractNode._validate_type | def _validate_type(self): # type: () -> None
"""Validation to ensure value is the correct type"""
if not isinstance(self._value, self._type):
title = '{} has an invalid type'.format(self._key_name())
description = '{} must be a {}'.format(self._key_name(), self._type.__name__)
... | python | def _validate_type(self): # type: () -> None
"""Validation to ensure value is the correct type"""
if not isinstance(self._value, self._type):
title = '{} has an invalid type'.format(self._key_name())
description = '{} must be a {}'.format(self._key_name(), self._type.__name__)
... | [
"def",
"_validate_type",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"_value",
",",
"self",
".",
"_type",
")",
":",
"title",
"=",
"'{} has an invalid type'",
".",
"format",
"(",
"self",
".",
"_key_name",
"(",
")",
")",
"descriptio... | Validation to ensure value is the correct type | [
"Validation",
"to",
"ensure",
"value",
"is",
"the",
"correct",
"type"
] | d008f251530d054c2d1fb3e8ac1a9030436134c8 | https://github.com/dropseed/configyaml/blob/d008f251530d054c2d1fb3e8ac1a9030436134c8/configyaml/config/base.py#L173-L179 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.haveSnapshots | def haveSnapshots(self):
"""Check if we have at least one snapshot."""
return os.path.islink(self.latestLink) and os.path.isdir(self.latestLink) | python | def haveSnapshots(self):
"""Check if we have at least one snapshot."""
return os.path.islink(self.latestLink) and os.path.isdir(self.latestLink) | [
"def",
"haveSnapshots",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"islink",
"(",
"self",
".",
"latestLink",
")",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"latestLink",
")"
] | Check if we have at least one snapshot. | [
"Check",
"if",
"we",
"have",
"at",
"least",
"one",
"snapshot",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L71-L73 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.fromScratch | def fromScratch(self):
"""Start a fresh experiment, from scratch.
Returns `self`."""
assert(not os.path.lexists(self.latestLink) or
os.path.islink (self.latestLink))
self.rmR(self.latestLink)
return self | python | def fromScratch(self):
"""Start a fresh experiment, from scratch.
Returns `self`."""
assert(not os.path.lexists(self.latestLink) or
os.path.islink (self.latestLink))
self.rmR(self.latestLink)
return self | [
"def",
"fromScratch",
"(",
"self",
")",
":",
"assert",
"(",
"not",
"os",
".",
"path",
".",
"lexists",
"(",
"self",
".",
"latestLink",
")",
"or",
"os",
".",
"path",
".",
"islink",
"(",
"self",
".",
"latestLink",
")",
")",
"self",
".",
"rmR",
"(",
... | Start a fresh experiment, from scratch.
Returns `self`. | [
"Start",
"a",
"fresh",
"experiment",
"from",
"scratch",
".",
"Returns",
"self",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L112-L120 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.snapshot | def snapshot (self):
"""Take a snapshot of the experiment.
Returns `self`."""
nextSnapshotNum = self.nextSnapshotNum
nextSnapshotPath = self.getFullPathToSnapshot(nextSnapshotNum)
if os.path.lexists(nextSnapshotPath):
self.rmR(nextSnapshotPath)
self.mkdirp(os.path.join(nextSnapshotPath... | python | def snapshot (self):
"""Take a snapshot of the experiment.
Returns `self`."""
nextSnapshotNum = self.nextSnapshotNum
nextSnapshotPath = self.getFullPathToSnapshot(nextSnapshotNum)
if os.path.lexists(nextSnapshotPath):
self.rmR(nextSnapshotPath)
self.mkdirp(os.path.join(nextSnapshotPath... | [
"def",
"snapshot",
"(",
"self",
")",
":",
"nextSnapshotNum",
"=",
"self",
".",
"nextSnapshotNum",
"nextSnapshotPath",
"=",
"self",
".",
"getFullPathToSnapshot",
"(",
"nextSnapshotNum",
")",
"if",
"os",
".",
"path",
".",
"lexists",
"(",
"nextSnapshotPath",
")",
... | Take a snapshot of the experiment.
Returns `self`. | [
"Take",
"a",
"snapshot",
"of",
"the",
"experiment",
".",
"Returns",
"self",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L136-L146 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.rollback | def rollback (self, n=None):
"""Roll back the experiment to the given snapshot number.
Returns `self`."""
if n is None:
if self.haveSnapshots: return self.fromSnapshot(self.latestLink)
else: return self.fromScratch()
elif isinstance(n, int):
loadSnapshotPath = self.ge... | python | def rollback (self, n=None):
"""Roll back the experiment to the given snapshot number.
Returns `self`."""
if n is None:
if self.haveSnapshots: return self.fromSnapshot(self.latestLink)
else: return self.fromScratch()
elif isinstance(n, int):
loadSnapshotPath = self.ge... | [
"def",
"rollback",
"(",
"self",
",",
"n",
"=",
"None",
")",
":",
"if",
"n",
"is",
"None",
":",
"if",
"self",
".",
"haveSnapshots",
":",
"return",
"self",
".",
"fromSnapshot",
"(",
"self",
".",
"latestLink",
")",
"else",
":",
"return",
"self",
".",
... | Roll back the experiment to the given snapshot number.
Returns `self`. | [
"Roll",
"back",
"the",
"experiment",
"to",
"the",
"given",
"snapshot",
"number",
".",
"Returns",
"self",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L148-L161 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.getFullPathToSnapshot | def getFullPathToSnapshot(self, n):
"""Get the full path to snapshot n."""
return os.path.join(self.snapDir, str(n)) | python | def getFullPathToSnapshot(self, n):
"""Get the full path to snapshot n."""
return os.path.join(self.snapDir, str(n)) | [
"def",
"getFullPathToSnapshot",
"(",
"self",
",",
"n",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"snapDir",
",",
"str",
"(",
"n",
")",
")"
] | Get the full path to snapshot n. | [
"Get",
"the",
"full",
"path",
"to",
"snapshot",
"n",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L201-L203 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.strategyLastK | def strategyLastK(kls, n, k=10):
"""Return the directory names to preserve under the LastK purge strategy."""
return set(map(str, filter(lambda x:x>=0, range(n, n-k, -1)))) | python | def strategyLastK(kls, n, k=10):
"""Return the directory names to preserve under the LastK purge strategy."""
return set(map(str, filter(lambda x:x>=0, range(n, n-k, -1)))) | [
"def",
"strategyLastK",
"(",
"kls",
",",
"n",
",",
"k",
"=",
"10",
")",
":",
"return",
"set",
"(",
"map",
"(",
"str",
",",
"filter",
"(",
"lambda",
"x",
":",
"x",
">=",
"0",
",",
"range",
"(",
"n",
",",
"n",
"-",
"k",
",",
"-",
"1",
")",
... | Return the directory names to preserve under the LastK purge strategy. | [
"Return",
"the",
"directory",
"names",
"to",
"preserve",
"under",
"the",
"LastK",
"purge",
"strategy",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L215-L217 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.strategyKLogN | def strategyKLogN(kls, n, k=4):
"""Return the directory names to preserve under the KLogN purge strategy."""
assert(k>1)
s = set([n])
i = 0
while k**i <= n:
s.update(range(n, n-k*k**i, -k**i))
i += 1
n -= n % k**i
return set(map(str, filter(lambda x:x>=0, s))) | python | def strategyKLogN(kls, n, k=4):
"""Return the directory names to preserve under the KLogN purge strategy."""
assert(k>1)
s = set([n])
i = 0
while k**i <= n:
s.update(range(n, n-k*k**i, -k**i))
i += 1
n -= n % k**i
return set(map(str, filter(lambda x:x>=0, s))) | [
"def",
"strategyKLogN",
"(",
"kls",
",",
"n",
",",
"k",
"=",
"4",
")",
":",
"assert",
"(",
"k",
">",
"1",
")",
"s",
"=",
"set",
"(",
"[",
"n",
"]",
")",
"i",
"=",
"0",
"while",
"k",
"**",
"i",
"<=",
"n",
":",
"s",
".",
"update",
"(",
"r... | Return the directory names to preserve under the KLogN purge strategy. | [
"Return",
"the",
"directory",
"names",
"to",
"preserve",
"under",
"the",
"KLogN",
"purge",
"strategy",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L220-L231 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.listSnapshotDir | def listSnapshotDir(kls, path):
"""Return the set of snapshot directories and non-snapshot directories
under the given path."""
snapshotSet = set()
nonsnapshotSet = set()
try:
entryList = os.listdir(path)
for e in entryList:
if kls.isFilenameInteger(e): snapshotSet .add(e)
else: ... | python | def listSnapshotDir(kls, path):
"""Return the set of snapshot directories and non-snapshot directories
under the given path."""
snapshotSet = set()
nonsnapshotSet = set()
try:
entryList = os.listdir(path)
for e in entryList:
if kls.isFilenameInteger(e): snapshotSet .add(e)
else: ... | [
"def",
"listSnapshotDir",
"(",
"kls",
",",
"path",
")",
":",
"snapshotSet",
"=",
"set",
"(",
")",
"nonsnapshotSet",
"=",
"set",
"(",
")",
"try",
":",
"entryList",
"=",
"os",
".",
"listdir",
"(",
"path",
")",
"for",
"e",
"in",
"entryList",
":",
"if",
... | Return the set of snapshot directories and non-snapshot directories
under the given path. | [
"Return",
"the",
"set",
"of",
"snapshot",
"directories",
"and",
"non",
"-",
"snapshot",
"directories",
"under",
"the",
"given",
"path",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L249-L261 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.rmR | def rmR(kls, path):
"""`rm -R path`. Deletes, but does not recurse into, symlinks.
If the path does not exist, silently return."""
if os.path.islink(path) or os.path.isfile(path):
os.unlink(path)
elif os.path.isdir(path):
walker = os.walk(path, topdown=False, followlinks=False)
for dirpath, dirnames,... | python | def rmR(kls, path):
"""`rm -R path`. Deletes, but does not recurse into, symlinks.
If the path does not exist, silently return."""
if os.path.islink(path) or os.path.isfile(path):
os.unlink(path)
elif os.path.isdir(path):
walker = os.walk(path, topdown=False, followlinks=False)
for dirpath, dirnames,... | [
"def",
"rmR",
"(",
"kls",
",",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"islink",
"(",
"path",
")",
"or",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"os",
".",
"unlink",
"(",
"path",
")",
"elif",
"os",
".",
"path",
".",
... | `rm -R path`. Deletes, but does not recurse into, symlinks.
If the path does not exist, silently return. | [
"rm",
"-",
"R",
"path",
".",
"Deletes",
"but",
"does",
"not",
"recurse",
"into",
"symlinks",
".",
"If",
"the",
"path",
"does",
"not",
"exist",
"silently",
"return",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L264-L276 | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | Experiment.atomicSymlink | def atomicSymlink(kls, target, name):
"""Same syntax as os.symlink, except that the new link called `name`
will first be created with the `name` and `target`
`name.ATOMIC` -> `target`
, then be atomically renamed to
`name` -> `target`
, thus overwriting any previous symlink there. If a f... | python | def atomicSymlink(kls, target, name):
"""Same syntax as os.symlink, except that the new link called `name`
will first be created with the `name` and `target`
`name.ATOMIC` -> `target`
, then be atomically renamed to
`name` -> `target`
, thus overwriting any previous symlink there. If a f... | [
"def",
"atomicSymlink",
"(",
"kls",
",",
"target",
",",
"name",
")",
":",
"linkAtomicName",
"=",
"name",
"+",
"\".ATOMIC\"",
"linkFinalName",
"=",
"name",
"linkTarget",
"=",
"target",
"if",
"os",
".",
"path",
".",
"lexists",
"(",
"linkAtomicName",
")",
":"... | Same syntax as os.symlink, except that the new link called `name`
will first be created with the `name` and `target`
`name.ATOMIC` -> `target`
, then be atomically renamed to
`name` -> `target`
, thus overwriting any previous symlink there. If a filesystem entity
called `name.ATOMIC` alr... | [
"Same",
"syntax",
"as",
"os",
".",
"symlink",
"except",
"that",
"the",
"new",
"link",
"called",
"name",
"will",
"first",
"be",
"created",
"with",
"the",
"name",
"and",
"target",
"name",
".",
"ATOMIC",
"-",
">",
"target",
"then",
"be",
"atomically",
"rena... | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L279-L304 | train |
azogue/i2csense | i2csense/bme280.py | BME280._compensate_temperature | def _compensate_temperature(self, adc_t):
"""Compensate temperature.
Formula from datasheet Bosch BME280 Environmental sensor.
8.1 Compensation formulas in double precision floating point
Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015
"""
var_1 = ((adc_t / 16384.0... | python | def _compensate_temperature(self, adc_t):
"""Compensate temperature.
Formula from datasheet Bosch BME280 Environmental sensor.
8.1 Compensation formulas in double precision floating point
Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015
"""
var_1 = ((adc_t / 16384.0... | [
"def",
"_compensate_temperature",
"(",
"self",
",",
"adc_t",
")",
":",
"var_1",
"=",
"(",
"(",
"adc_t",
"/",
"16384.0",
"-",
"self",
".",
"_calibration_t",
"[",
"0",
"]",
"/",
"1024.0",
")",
"*",
"self",
".",
"_calibration_t",
"[",
"1",
"]",
")",
"va... | Compensate temperature.
Formula from datasheet Bosch BME280 Environmental sensor.
8.1 Compensation formulas in double precision floating point
Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015 | [
"Compensate",
"temperature",
"."
] | ecc6806dcee9de827a5414a9e836d271fedca9b9 | https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bme280.py#L61-L79 | train |
azogue/i2csense | i2csense/bme280.py | BME280._compensate_pressure | def _compensate_pressure(self, adc_p):
"""Compensate pressure.
Formula from datasheet Bosch BME280 Environmental sensor.
8.1 Compensation formulas in double precision floating point
Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015.
"""
var_1 = (self._temp_fine / 2.0... | python | def _compensate_pressure(self, adc_p):
"""Compensate pressure.
Formula from datasheet Bosch BME280 Environmental sensor.
8.1 Compensation formulas in double precision floating point
Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015.
"""
var_1 = (self._temp_fine / 2.0... | [
"def",
"_compensate_pressure",
"(",
"self",
",",
"adc_p",
")",
":",
"var_1",
"=",
"(",
"self",
".",
"_temp_fine",
"/",
"2.0",
")",
"-",
"64000.0",
"var_2",
"=",
"(",
"(",
"var_1",
"/",
"4.0",
")",
"*",
"(",
"var_1",
"/",
"4.0",
")",
")",
"/",
"20... | Compensate pressure.
Formula from datasheet Bosch BME280 Environmental sensor.
8.1 Compensation formulas in double precision floating point
Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015. | [
"Compensate",
"pressure",
"."
] | ecc6806dcee9de827a5414a9e836d271fedca9b9 | https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bme280.py#L81-L113 | train |
azogue/i2csense | i2csense/bme280.py | BME280._compensate_humidity | def _compensate_humidity(self, adc_h):
"""Compensate humidity.
Formula from datasheet Bosch BME280 Environmental sensor.
8.1 Compensation formulas in double precision floating point
Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015.
"""
var_h = self._temp_fine - 7680... | python | def _compensate_humidity(self, adc_h):
"""Compensate humidity.
Formula from datasheet Bosch BME280 Environmental sensor.
8.1 Compensation formulas in double precision floating point
Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015.
"""
var_h = self._temp_fine - 7680... | [
"def",
"_compensate_humidity",
"(",
"self",
",",
"adc_h",
")",
":",
"var_h",
"=",
"self",
".",
"_temp_fine",
"-",
"76800.0",
"if",
"var_h",
"==",
"0",
":",
"return",
"0",
"var_h",
"=",
"(",
"(",
"adc_h",
"-",
"(",
"self",
".",
"_calibration_h",
"[",
... | Compensate humidity.
Formula from datasheet Bosch BME280 Environmental sensor.
8.1 Compensation formulas in double precision floating point
Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015. | [
"Compensate",
"humidity",
"."
] | ecc6806dcee9de827a5414a9e836d271fedca9b9 | https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bme280.py#L115-L138 | train |
azogue/i2csense | i2csense/bme280.py | BME280._take_forced_measurement | def _take_forced_measurement(self):
"""Take a forced measurement.
In forced mode, the BME sensor goes back to sleep after each
measurement and we need to set it to forced mode once at this point,
so it will take the next measurement and then return to sleep again.
In normal mode... | python | def _take_forced_measurement(self):
"""Take a forced measurement.
In forced mode, the BME sensor goes back to sleep after each
measurement and we need to set it to forced mode once at this point,
so it will take the next measurement and then return to sleep again.
In normal mode... | [
"def",
"_take_forced_measurement",
"(",
"self",
")",
":",
"self",
".",
"_bus",
".",
"write_byte_data",
"(",
"self",
".",
"_i2c_add",
",",
"0xF4",
",",
"self",
".",
"ctrl_meas_reg",
")",
"while",
"self",
".",
"_bus",
".",
"read_byte_data",
"(",
"self",
".",... | Take a forced measurement.
In forced mode, the BME sensor goes back to sleep after each
measurement and we need to set it to forced mode once at this point,
so it will take the next measurement and then return to sleep again.
In normal mode simply does new measurements periodically. | [
"Take",
"a",
"forced",
"measurement",
"."
] | ecc6806dcee9de827a5414a9e836d271fedca9b9 | https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bme280.py#L202-L213 | train |
azogue/i2csense | i2csense/bme280.py | BME280.update | def update(self, first_reading=False):
"""Read raw data and update compensated variables."""
try:
if first_reading or not self._ok:
self._bus.write_byte_data(self._i2c_add, 0xF2,
self.ctrl_hum_reg)
self._bus.write_byte... | python | def update(self, first_reading=False):
"""Read raw data and update compensated variables."""
try:
if first_reading or not self._ok:
self._bus.write_byte_data(self._i2c_add, 0xF2,
self.ctrl_hum_reg)
self._bus.write_byte... | [
"def",
"update",
"(",
"self",
",",
"first_reading",
"=",
"False",
")",
":",
"try",
":",
"if",
"first_reading",
"or",
"not",
"self",
".",
"_ok",
":",
"self",
".",
"_bus",
".",
"write_byte_data",
"(",
"self",
".",
"_i2c_add",
",",
"0xF2",
",",
"self",
... | Read raw data and update compensated variables. | [
"Read",
"raw",
"data",
"and",
"update",
"compensated",
"variables",
"."
] | ecc6806dcee9de827a5414a9e836d271fedca9b9 | https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bme280.py#L215-L257 | train |
openvax/varlens | varlens/read_evidence/pileup.py | Pileup.append | def append(self, element):
'''
Append a PileupElement to this Pileup. If an identical PileupElement is
already part of this Pileup, do nothing.
'''
assert element.locus == self.locus, (
"Element locus (%s) != Pileup locus (%s)"
% (element.locus, self.locus... | python | def append(self, element):
'''
Append a PileupElement to this Pileup. If an identical PileupElement is
already part of this Pileup, do nothing.
'''
assert element.locus == self.locus, (
"Element locus (%s) != Pileup locus (%s)"
% (element.locus, self.locus... | [
"def",
"append",
"(",
"self",
",",
"element",
")",
":",
"assert",
"element",
".",
"locus",
"==",
"self",
".",
"locus",
",",
"(",
"\"Element locus (%s) != Pileup locus (%s)\"",
"%",
"(",
"element",
".",
"locus",
",",
"self",
".",
"locus",
")",
")",
"self",
... | Append a PileupElement to this Pileup. If an identical PileupElement is
already part of this Pileup, do nothing. | [
"Append",
"a",
"PileupElement",
"to",
"this",
"Pileup",
".",
"If",
"an",
"identical",
"PileupElement",
"is",
"already",
"part",
"of",
"this",
"Pileup",
"do",
"nothing",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup.py#L55-L63 | train |
openvax/varlens | varlens/read_evidence/pileup.py | Pileup.update | def update(self, other):
'''
Add all pileup elements from other into self.
'''
assert self.locus == other.locus
self.elements.update(other.elements) | python | def update(self, other):
'''
Add all pileup elements from other into self.
'''
assert self.locus == other.locus
self.elements.update(other.elements) | [
"def",
"update",
"(",
"self",
",",
"other",
")",
":",
"assert",
"self",
".",
"locus",
"==",
"other",
".",
"locus",
"self",
".",
"elements",
".",
"update",
"(",
"other",
".",
"elements",
")"
] | Add all pileup elements from other into self. | [
"Add",
"all",
"pileup",
"elements",
"from",
"other",
"into",
"self",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup.py#L65-L70 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.