repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
tamasgal/km3pipe
km3pipe/shell.py
Script.iget
def iget(self, irods_path, attempts=1, pause=15): """Add an iget command to retrieve a file from iRODS. Parameters ---------- irods_path: str Filepath which should be fetched using iget attempts: int (default: 1) Number of retries, if iROD...
python
def iget(self, irods_path, attempts=1, pause=15): """Add an iget command to retrieve a file from iRODS. Parameters ---------- irods_path: str Filepath which should be fetched using iget attempts: int (default: 1) Number of retries, if iROD...
[ "def", "iget", "(", "self", ",", "irods_path", ",", "attempts", "=", "1", ",", "pause", "=", "15", ")", ":", "if", "attempts", ">", "1", ":", "cmd", "=", "\"\"\" for i in {{1..{0}}}; do\n ret=$(iget -v {1} 2>&1)\n ...
Add an iget command to retrieve a file from iRODS. Parameters ---------- irods_path: str Filepath which should be fetched using iget attempts: int (default: 1) Number of retries, if iRODS access fails pause: int (default: 15) ...
[ "Add", "an", "iget", "command", "to", "retrieve", "a", "file", "from", "iRODS", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/shell.py#L198-L225
train
Add an iget command to retrieve a file from iRODS.
tamasgal/km3pipe
km3pipe/shell.py
Script._add_two_argument_command
def _add_two_argument_command(self, command, arg1, arg2): """Helper function for two-argument commands""" self.lines.append("{} {} {}".format(command, arg1, arg2))
python
def _add_two_argument_command(self, command, arg1, arg2): """Helper function for two-argument commands""" self.lines.append("{} {} {}".format(command, arg1, arg2))
[ "def", "_add_two_argument_command", "(", "self", ",", "command", ",", "arg1", ",", "arg2", ")", ":", "self", ".", "lines", ".", "append", "(", "\"{} {} {}\"", ".", "format", "(", "command", ",", "arg1", ",", "arg2", ")", ")" ]
Helper function for two-argument commands
[ "Helper", "function", "for", "two", "-", "argument", "commands" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/shell.py#L227-L229
train
Helper function for two - argument commands
dlbroadfoot/pygogogate2
pygogogate2/__init__.py
Gogogate2API.get_devices
def get_devices(self): """List all garage door devices.""" devices = self.make_request('["{username}","{password}","info","",""]'.format( username=self.username, password=self.password)) if devices != False: garage_doors = [] try: ...
python
def get_devices(self): """List all garage door devices.""" devices = self.make_request('["{username}","{password}","info","",""]'.format( username=self.username, password=self.password)) if devices != False: garage_doors = [] try: ...
[ "def", "get_devices", "(", "self", ")", ":", "devices", "=", "self", ".", "make_request", "(", "'[\"{username}\",\"{password}\",\"info\",\"\",\"\"]'", ".", "format", "(", "username", "=", "self", ".", "username", ",", "password", "=", "self", ".", "password", ")...
List all garage door devices.
[ "List", "all", "garage", "door", "devices", "." ]
3cc0a5d9e493024eeb0c07b39b2b90f7b5b7b406
https://github.com/dlbroadfoot/pygogogate2/blob/3cc0a5d9e493024eeb0c07b39b2b90f7b5b7b406/pygogogate2/__init__.py#L70-L102
train
List all garage door devices.
dlbroadfoot/pygogogate2
pygogogate2/__init__.py
Gogogate2API.get_status
def get_status(self, device_id): """List only MyQ garage door devices.""" devices = self.get_devices() if devices != False: for device in devices: if device['door'] == device_id: return device['status'] return False
python
def get_status(self, device_id): """List only MyQ garage door devices.""" devices = self.get_devices() if devices != False: for device in devices: if device['door'] == device_id: return device['status'] return False
[ "def", "get_status", "(", "self", ",", "device_id", ")", ":", "devices", "=", "self", ".", "get_devices", "(", ")", "if", "devices", "!=", "False", ":", "for", "device", "in", "devices", ":", "if", "device", "[", "'door'", "]", "==", "device_id", ":", ...
List only MyQ garage door devices.
[ "List", "only", "MyQ", "garage", "door", "devices", "." ]
3cc0a5d9e493024eeb0c07b39b2b90f7b5b7b406
https://github.com/dlbroadfoot/pygogogate2/blob/3cc0a5d9e493024eeb0c07b39b2b90f7b5b7b406/pygogogate2/__init__.py#L105-L114
train
List only MyQ garage door devices.
lexibank/pylexibank
src/pylexibank/transcription.py
analyze
def analyze(segments, analysis, lookup=dict(bipa={}, dolgo={})): """ Test a sequence for compatibility with CLPA and LingPy. :param analysis: Pass a `TranscriptionAnalysis` instance for cumulative reporting. """ # raise a ValueError in case of empty segments/strings if not segments: rai...
python
def analyze(segments, analysis, lookup=dict(bipa={}, dolgo={})): """ Test a sequence for compatibility with CLPA and LingPy. :param analysis: Pass a `TranscriptionAnalysis` instance for cumulative reporting. """ # raise a ValueError in case of empty segments/strings if not segments: rai...
[ "def", "analyze", "(", "segments", ",", "analysis", ",", "lookup", "=", "dict", "(", "bipa", "=", "{", "}", ",", "dolgo", "=", "{", "}", ")", ")", ":", "# raise a ValueError in case of empty segments/strings", "if", "not", "segments", ":", "raise", "ValueErr...
Test a sequence for compatibility with CLPA and LingPy. :param analysis: Pass a `TranscriptionAnalysis` instance for cumulative reporting.
[ "Test", "a", "sequence", "for", "compatibility", "with", "CLPA", "and", "LingPy", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/transcription.py#L37-L94
train
Test a sequence for compatibility with CLPA and LingPy.
tamasgal/km3pipe
km3pipe/mc.py
most_energetic
def most_energetic(df): """Grab most energetic particle from mc_tracks dataframe.""" idx = df.groupby(['event_id'])['energy'].transform(max) == df['energy'] return df[idx].reindex()
python
def most_energetic(df): """Grab most energetic particle from mc_tracks dataframe.""" idx = df.groupby(['event_id'])['energy'].transform(max) == df['energy'] return df[idx].reindex()
[ "def", "most_energetic", "(", "df", ")", ":", "idx", "=", "df", ".", "groupby", "(", "[", "'event_id'", "]", ")", "[", "'energy'", "]", ".", "transform", "(", "max", ")", "==", "df", "[", "'energy'", "]", "return", "df", "[", "idx", "]", ".", "re...
Grab most energetic particle from mc_tracks dataframe.
[ "Grab", "most", "energetic", "particle", "from", "mc_tracks", "dataframe", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/mc.py#L101-L104
train
Grab most energetic particle from mc_tracks dataframe.
tamasgal/km3pipe
km3pipe/mc.py
leading_particle
def leading_particle(df): """Grab leading particle (neutrino, most energetic bundle muon). Note: selecting the most energetic mc particle does not always select the neutrino! In some sub-percent cases, the post-interaction secondaries can have more energy than the incoming neutrino! aanet conventi...
python
def leading_particle(df): """Grab leading particle (neutrino, most energetic bundle muon). Note: selecting the most energetic mc particle does not always select the neutrino! In some sub-percent cases, the post-interaction secondaries can have more energy than the incoming neutrino! aanet conventi...
[ "def", "leading_particle", "(", "df", ")", ":", "leading", "=", "df", ".", "groupby", "(", "'event_id'", ",", "as_index", "=", "False", ")", ".", "first", "(", ")", "unique", "=", "leading", ".", "type", ".", "unique", "(", ")", "if", "len", "(", "...
Grab leading particle (neutrino, most energetic bundle muon). Note: selecting the most energetic mc particle does not always select the neutrino! In some sub-percent cases, the post-interaction secondaries can have more energy than the incoming neutrino! aanet convention: mc_tracks[0] = neutrino s...
[ "Grab", "leading", "particle", "(", "neutrino", "most", "energetic", "bundle", "muon", ")", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/mc.py#L107-L125
train
Grab leading particle from a dataframe
IRC-SPHERE/HyperStream
hyperstream/channels/assets_file_channel.py
AssetsFileChannel.create_stream
def create_stream(self, stream_id, sandbox=None): """ Create the stream :param stream_id: The stream identifier :param sandbox: The sandbox for this stream :return: None :raises: NotImplementedError """ if sandbox is not None: raise No...
python
def create_stream(self, stream_id, sandbox=None): """ Create the stream :param stream_id: The stream identifier :param sandbox: The sandbox for this stream :return: None :raises: NotImplementedError """ if sandbox is not None: raise No...
[ "def", "create_stream", "(", "self", ",", "stream_id", ",", "sandbox", "=", "None", ")", ":", "if", "sandbox", "is", "not", "None", ":", "raise", "NotImplementedError", "logging", ".", "debug", "(", "\"Creating asset stream {}\"", ".", "format", "(", "stream_i...
Create the stream :param stream_id: The stream identifier :param sandbox: The sandbox for this stream :return: None :raises: NotImplementedError
[ "Create", "the", "stream", ":", "param", "stream_id", ":", "The", "stream", "identifier", ":", "param", "sandbox", ":", "The", "sandbox", "for", "this", "stream", ":", "return", ":", "None", ":", "raises", ":", "NotImplementedError" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/assets_file_channel.py#L108-L128
train
Create the stream with the given identifier.
tamasgal/km3pipe
km3pipe/controlhost.py
Client._connect
def _connect(self): """Connect to JLigier""" log.debug("Connecting to JLigier") self.socket = socket.socket() self.socket.connect((self.host, self.port))
python
def _connect(self): """Connect to JLigier""" log.debug("Connecting to JLigier") self.socket = socket.socket() self.socket.connect((self.host, self.port))
[ "def", "_connect", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Connecting to JLigier\"", ")", "self", ".", "socket", "=", "socket", ".", "socket", "(", ")", "self", ".", "socket", ".", "connect", "(", "(", "self", ".", "host", ",", "self", "....
Connect to JLigier
[ "Connect", "to", "JLigier" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/controlhost.py#L124-L128
train
Connect to JLigier
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
Reconnect to JLigier and subscribe to the tags.
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
Set the byte data and fill up the bytes to fit the size.
IRC-SPHERE/HyperStream
hyperstream/tool/selector_tool.py
SelectorTool.execute
def execute(self, sources, sinks, interval): """ Execute the tool over the given time interval. :param sources: The source streams :param sinks: The sink streams :param interval: The time interval :type sources: list[Stream] | tuple[Stream] :type sinks: list[Stre...
python
def execute(self, sources, sinks, interval): """ Execute the tool over the given time interval. :param sources: The source streams :param sinks: The sink streams :param interval: The time interval :type sources: list[Stream] | tuple[Stream] :type sinks: list[Stre...
[ "def", "execute", "(", "self", ",", "sources", ",", "sinks", ",", "interval", ")", ":", "if", "not", "isinstance", "(", "interval", ",", "TimeInterval", ")", ":", "raise", "TypeError", "(", "'Expected TimeInterval, got {}'", ".", "format", "(", "type", "(", ...
Execute the tool over the given time interval. :param sources: The source streams :param sinks: The sink streams :param interval: The time interval :type sources: list[Stream] | tuple[Stream] :type sinks: list[Stream] | tuple[Stream] :type interval: TimeInterval ...
[ "Execute", "the", "tool", "over", "the", "given", "time", "interval", "." ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/selector_tool.py#L43-L102
train
Execute the tool over the given time interval.
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", ")", ":", "if", "isinstance", "(", "name", ",", "tuple", ")", "or", "isinstance", "(", "name", ",", "list", ")", ":", "name", ",", "attr", ",", "value", ...
Set values in constant
[ "Set", "values", "in", "constant" ]
af4cbc8d91ffab601ac5e45e5480f20c5462064d
https://github.com/valdergallo/pyconst/blob/af4cbc8d91ffab601ac5e45e5480f20c5462064d/pyconst/const.py#L54-L68
train
Set values in constant
IRC-SPHERE/HyperStream
hyperstream/tool/plate_creation_tool.py
PlateCreationTool.execute
def execute(self, source, interval, input_plate_value): """ Execute the tool over the given time interval. :param source: The source stream :param interval: The time interval :param input_plate_value: The value of the plate where data comes from (can be None) :type sourc...
python
def execute(self, source, interval, input_plate_value): """ Execute the tool over the given time interval. :param source: The source stream :param interval: The time interval :param input_plate_value: The value of the plate where data comes from (can be None) :type sourc...
[ "def", "execute", "(", "self", ",", "source", ",", "interval", ",", "input_plate_value", ")", ":", "if", "not", "isinstance", "(", "interval", ",", "TimeInterval", ")", ":", "raise", "TypeError", "(", "'Expected TimeInterval, got {}'", ".", "format", "(", "typ...
Execute the tool over the given time interval. :param source: The source stream :param interval: The time interval :param input_plate_value: The value of the plate where data comes from (can be None) :type source: Stream :type interval: TimeInterval :type input_plate_val...
[ "Execute", "the", "tool", "over", "the", "given", "time", "interval", "." ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/plate_creation_tool.py#L47-L81
train
Execute the tool over the given time interval and return the set of meta data values that were written to the output stream.
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'", "# configure thread", "self", ".", "_thread", "=", "Thread", "(", "target", "=", "self", ".", "_start_io_loop", ")", "self", ".", "_thread...
Start IOLoop in daemonized thread.
[ "Start", "IOLoop", "in", "daemonized", "thread", "." ]
9d4f83660fd79fe15d741b831be9ee28dccacc30
https://github.com/breerly/threadloop/blob/9d4f83660fd79fe15d741b831be9ee28dccacc30/threadloop/threadloop.py#L56-L66
train
Start IOLoop in daemonized thread.
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
Start IOLoop then set ready threading. Event.
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
Is thread & ioloop ready?
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() f...
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
Submit a function on the IOLoop in daemonized thread.
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
Return peak memory usage in MB
PrefPy/prefpy
prefpy/gmmra.py
GMMPLAggregator._full
def _full(self, k): """ Description: Full breaking Parameters: k: not used """ G = np.ones((self.m, self.m)) #np.fill_diagonal(G, 0) # erroneous code from prefpy return G
python
def _full(self, k): """ Description: Full breaking Parameters: k: not used """ G = np.ones((self.m, self.m)) #np.fill_diagonal(G, 0) # erroneous code from prefpy return G
[ "def", "_full", "(", "self", ",", "k", ")", ":", "G", "=", "np", ".", "ones", "(", "(", "self", ".", "m", ",", "self", ".", "m", ")", ")", "#np.fill_diagonal(G, 0) # erroneous code from prefpy\r", "return", "G" ]
Description: Full breaking Parameters: k: not used
[ "Description", ":", "Full", "breaking", "Parameters", ":", "k", ":", "not", "used" ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/gmmra.py#L17-L26
train
Description : Returns a full array of the size of the current set of time items.
PrefPy/prefpy
prefpy/gmmra.py
GMMPLAggregator._top
def _top(self, k): """ Description: Top k breaking Parameters: k: the number of alternatives to break from highest rank """ if k > self.m: raise ValueError("k larger than the number of alternatives") G = np.ones((self.m, self.m...
python
def _top(self, k): """ Description: Top k breaking Parameters: k: the number of alternatives to break from highest rank """ if k > self.m: raise ValueError("k larger than the number of alternatives") G = np.ones((self.m, self.m...
[ "def", "_top", "(", "self", ",", "k", ")", ":", "if", "k", ">", "self", ".", "m", ":", "raise", "ValueError", "(", "\"k larger than the number of alternatives\"", ")", "G", "=", "np", ".", "ones", "(", "(", "self", ".", "m", ",", "self", ".", "m", ...
Description: Top k breaking Parameters: k: the number of alternatives to break from highest rank
[ "Description", ":", "Top", "k", "breaking", "Parameters", ":", "k", ":", "the", "number", "of", "alternatives", "to", "break", "from", "highest", "rank" ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/gmmra.py#L28-L45
train
Returns a new array of the highest rank of the sequence of alternatives in the sequence.
PrefPy/prefpy
prefpy/gmmra.py
GMMPLAggregator._bot
def _bot(self, k): """ Description: Bottom k breaking Parameters: k: the number of alternatives to break from lowest rank """ if k < 2: raise ValueError("k smaller than 2") G = np.ones((self.m, self.m)) np.fill_diagona...
python
def _bot(self, k): """ Description: Bottom k breaking Parameters: k: the number of alternatives to break from lowest rank """ if k < 2: raise ValueError("k smaller than 2") G = np.ones((self.m, self.m)) np.fill_diagona...
[ "def", "_bot", "(", "self", ",", "k", ")", ":", "if", "k", "<", "2", ":", "raise", "ValueError", "(", "\"k smaller than 2\"", ")", "G", "=", "np", ".", "ones", "(", "(", "self", ".", "m", ",", "self", ".", "m", ")", ")", "np", ".", "fill_diagon...
Description: Bottom k breaking Parameters: k: the number of alternatives to break from lowest rank
[ "Description", ":", "Bottom", "k", "breaking", "Parameters", ":", "k", ":", "the", "number", "of", "alternatives", "to", "break", "from", "lowest", "rank" ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/gmmra.py#L47-L64
train
Returns a numpy array of the most recent k alternatives from the lowest rank
PrefPy/prefpy
prefpy/gmmra.py
GMMPLAggregator._adj
def _adj(self, k): """ Description: Adjacent breaking Paramters: k: not used """ G = np.zeros((self.m, self.m)) for i in range(self.m): for j in range(self.m): if i == j+1 or j == i+1: G[i]...
python
def _adj(self, k): """ Description: Adjacent breaking Paramters: k: not used """ G = np.zeros((self.m, self.m)) for i in range(self.m): for j in range(self.m): if i == j+1 or j == i+1: G[i]...
[ "def", "_adj", "(", "self", ",", "k", ")", ":", "G", "=", "np", ".", "zeros", "(", "(", "self", ".", "m", ",", "self", ".", "m", ")", ")", "for", "i", "in", "range", "(", "self", ".", "m", ")", ":", "for", "j", "in", "range", "(", "self",...
Description: Adjacent breaking Paramters: k: not used
[ "Description", ":", "Adjacent", "breaking", "Paramters", ":", "k", ":", "not", "used" ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/gmmra.py#L66-L78
train
Returns a numpy array where the first element in the array is the same size as the other element in the array.
PrefPy/prefpy
prefpy/gmmra.py
GMMPLAggregator._pos
def _pos(self, k): """ Description: Position k breaking Parameters: k: position k is used for the breaking """ if k < 2: raise ValueError("k smaller than 2") G = np.zeros((self.m, self.m)) for i in range(self.m): ...
python
def _pos(self, k): """ Description: Position k breaking Parameters: k: position k is used for the breaking """ if k < 2: raise ValueError("k smaller than 2") G = np.zeros((self.m, self.m)) for i in range(self.m): ...
[ "def", "_pos", "(", "self", ",", "k", ")", ":", "if", "k", "<", "2", ":", "raise", "ValueError", "(", "\"k smaller than 2\"", ")", "G", "=", "np", ".", "zeros", "(", "(", "self", ".", "m", ",", "self", ".", "m", ")", ")", "for", "i", "in", "r...
Description: Position k breaking Parameters: k: position k is used for the breaking
[ "Description", ":", "Position", "k", "breaking", "Parameters", ":", "k", ":", "position", "k", "is", "used", "for", "the", "breaking" ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/gmmra.py#L80-L98
train
Returns a numpy array of the position k in the sequence of words in the sequence.
PrefPy/prefpy
prefpy/gmmra.py
GMMPLAggregator.aggregate
def aggregate(self, rankings, breaking="full", k=None): """ Description: Takes in a set of rankings and computes the Plackett-Luce model aggregate ranking. Parameters: rankings: set of rankings to aggregate breaking: type of breaking to use ...
python
def aggregate(self, rankings, breaking="full", k=None): """ Description: Takes in a set of rankings and computes the Plackett-Luce model aggregate ranking. Parameters: rankings: set of rankings to aggregate breaking: type of breaking to use ...
[ "def", "aggregate", "(", "self", ",", "rankings", ",", "breaking", "=", "\"full\"", ",", "k", "=", "None", ")", ":", "breakings", "=", "{", "\"full\"", ":", "self", ".", "_full", ",", "\"top\"", ":", "self", ".", "_top", ",", "\"bottom\"", ":", "self...
Description: Takes in a set of rankings and computes the Plackett-Luce model aggregate ranking. Parameters: rankings: set of rankings to aggregate breaking: type of breaking to use k: number to be used for top, bottom, and position breakin...
[ "Description", ":", "Takes", "in", "a", "set", "of", "rankings", "and", "computes", "the", "Plackett", "-", "Luce", "model", "aggregate", "ranking", ".", "Parameters", ":", "rankings", ":", "set", "of", "rankings", "to", "aggregate", "breaking", ":", "type",...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/gmmra.py#L100-L147
train
Returns the most recent ranking of the current state of the current state of the current state.
PrefPy/prefpy
prefpy/profile.py
Profile.getElecType
def getElecType(self): """ Determines whether the list of Preference objects represents complete strict orderings over the candidates (soc), incomplete strict orderings (soi), complete orderings with ties (toc), or incomplete orderings with ties (toi). WARNING: elections that do not fa...
python
def getElecType(self): """ Determines whether the list of Preference objects represents complete strict orderings over the candidates (soc), incomplete strict orderings (soi), complete orderings with ties (toc), or incomplete orderings with ties (toi). WARNING: elections that do not fa...
[ "def", "getElecType", "(", "self", ")", ":", "tiesPresent", "=", "False", "incompletePresent", "=", "False", "# Go through the list of Preferences and see if any contain a tie or are incomplete.", "for", "preference", "in", "self", ".", "preferences", ":", "if", "preference...
Determines whether the list of Preference objects represents complete strict orderings over the candidates (soc), incomplete strict orderings (soi), complete orderings with ties (toc), or incomplete orderings with ties (toi). WARNING: elections that do not fall under the above four categories ...
[ "Determines", "whether", "the", "list", "of", "Preference", "objects", "represents", "complete", "strict", "orderings", "over", "the", "candidates", "(", "soc", ")", "incomplete", "strict", "orderings", "(", "soi", ")", "complete", "orderings", "with", "ties", "...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L34-L62
train
Determines whether the list of Preferences objects represents complete strict orderings over the given entry point.
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
Returns a list of the number of times each preference is given.
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
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.
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
Returns a list of dictionaries one for each preference that associates each position in that the ranking with a list of integer representations of the candidates ranked at that ArcGIS position.
PrefPy/prefpy
prefpy/profile.py
Profile.getOrderVectors
def getOrderVectors(self): """ Returns a list of lists, one for each preference, of candidates ordered from most preferred to least. Note that ties are not indicated in the returned lists. Also returns a list of the number of times each preference is given. """ orderVect...
python
def getOrderVectors(self): """ Returns a list of lists, one for each preference, of candidates ordered from most preferred to least. Note that ties are not indicated in the returned lists. Also returns a list of the number of times each preference is given. """ orderVect...
[ "def", "getOrderVectors", "(", "self", ")", ":", "orderVectors", "=", "[", "]", "for", "preference", "in", "self", ".", "preferences", ":", "orderVectors", ".", "append", "(", "preference", ".", "getOrderVector", "(", ")", ")", "return", "orderVectors" ]
Returns a list of lists, one for each preference, of candidates ordered from most preferred to least. Note that ties are not indicated in the returned lists. Also returns a list of the number of times each preference is given.
[ "Returns", "a", "list", "of", "lists", "one", "for", "each", "preference", "of", "candidates", "ordered", "from", "most", "preferred", "to", "least", ".", "Note", "that", "ties", "are", "not", "indicated", "in", "the", "returned", "lists", ".", "Also", "re...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L97-L107
train
Returns a list of lists one for each preference of candidates ordered from most preferred to least preferred .
PrefPy/prefpy
prefpy/profile.py
Profile.getOrderVectorsEGMM
def getOrderVectorsEGMM(self): """ Returns a list of lists, one for each preference, of candidates ordered from most preferred to least. Note that ties are not indicated in the returned lists. Also returns a list of the number of times each preference is given. """ order...
python
def getOrderVectorsEGMM(self): """ Returns a list of lists, one for each preference, of candidates ordered from most preferred to least. Note that ties are not indicated in the returned lists. Also returns a list of the number of times each preference is given. """ order...
[ "def", "getOrderVectorsEGMM", "(", "self", ")", ":", "orderVectors", "=", "[", "]", "for", "preference", "in", "self", ".", "preferences", ":", "orderVectors", ".", "append", "(", "preference", ".", "getOrderVectorEGMM", "(", ")", ")", "return", "orderVectors"...
Returns a list of lists, one for each preference, of candidates ordered from most preferred to least. Note that ties are not indicated in the returned lists. Also returns a list of the number of times each preference is given.
[ "Returns", "a", "list", "of", "lists", "one", "for", "each", "preference", "of", "candidates", "ordered", "from", "most", "preferred", "to", "least", ".", "Note", "that", "ties", "are", "not", "indicated", "in", "the", "returned", "lists", ".", "Also", "re...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L109-L119
train
Returns a list of lists one for each preference of the ties ordered from most preferred to least preferred .
PrefPy/prefpy
prefpy/profile.py
Profile.getWmg
def getWmg(self, normalize = False): """ Generate a weighted majority graph that represents the whole profile. The function will return a two-dimensional dictionary that associates integer representations of each pair of candidates, cand1 and cand2, with the number of times cand1 is rank...
python
def getWmg(self, normalize = False): """ Generate a weighted majority graph that represents the whole profile. The function will return a two-dimensional dictionary that associates integer representations of each pair of candidates, cand1 and cand2, with the number of times cand1 is rank...
[ "def", "getWmg", "(", "self", ",", "normalize", "=", "False", ")", ":", "# Initialize a new dictionary for our final weighted majority graph.", "wmgMap", "=", "dict", "(", ")", "for", "cand", "in", "self", ".", "candMap", ".", "keys", "(", ")", ":", "wmgMap", ...
Generate a weighted majority graph that represents the whole profile. The function will return a two-dimensional dictionary that associates integer representations of each pair of candidates, cand1 and cand2, with the number of times cand1 is ranked above cand2 minus the number of times cand2 is...
[ "Generate", "a", "weighted", "majority", "graph", "that", "represents", "the", "whole", "profile", ".", "The", "function", "will", "return", "a", "two", "-", "dimensional", "dictionary", "that", "associates", "integer", "representations", "of", "each", "pair", "...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/profile.py#L121-L161
train
Generates a weighted majority graph that represents the whole profile.
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
Exports a preflib format file that contains all the information of the current Profile.
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", ")", ":", "# Use the functionality found in io to read the file.", "elecFileObj", "=", "open", "(", "fileName", ",", "'r'", ")", "self", ".", "candMap", ",", "rankMaps", ",", "wmgMapsCounts", ",", "self", "...
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
Imports a preflib format file that contains all the information of a Profile. This function will automatically create the Profile object for each member of the current Profile object.
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", ")", ":", "# Because our Profile class is not directly JSON serializable, we exporrt the underlying ", "# dictionary. ", "data", "=", "dict", "(", ")", "for", "key", "in", "self", ".", "__dict__", ".", "keys", "(", ...
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
Exports a json file that contains all the information of the current Profile.
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
Imports a json file that contains all the information of a Profile and creates a list of all the members of the current Profile object. This function will import all the information of a Profile and all the members of the Profile object.
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", "(", ")", ":", "# test example below taken from GMMRA by Azari, Chen, Parkes, & Xia\r", "cand_set", "=", "[", "0", ",", "1", ",", "2", "]", "votes", "=", "[", "[", "0", ",", "1", ",", "2", "]", ",", "[", "1", ",", "2", ",", "0", "]", "...
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
Driver function for the MM algorithm
PrefPy/prefpy
prefpy/mmgbtl.py
MMPLAggregator.aggregate
def aggregate(self, rankings, epsilon, max_iters): """ Description: Minorization-Maximization algorithm which returns an estimate of the ground-truth parameters, gamma for the given data. Parameters: rankings: set of rankings to aggregate ...
python
def aggregate(self, rankings, epsilon, max_iters): """ Description: Minorization-Maximization algorithm which returns an estimate of the ground-truth parameters, gamma for the given data. Parameters: rankings: set of rankings to aggregate ...
[ "def", "aggregate", "(", "self", ",", "rankings", ",", "epsilon", ",", "max_iters", ")", ":", "# compute the matrix w, the numbers of pairwise wins:\r", "w", "=", "np", ".", "zeros", "(", "(", "self", ".", "m", ",", "self", ".", "m", ")", ")", "for", "rank...
Description: Minorization-Maximization algorithm which returns an estimate of the ground-truth parameters, gamma for the given data. Parameters: rankings: set of rankings to aggregate epsilon: convergence condition value, set to None for itera...
[ "Description", ":", "Minorization", "-", "Maximization", "algorithm", "which", "returns", "an", "estimate", "of", "the", "ground", "-", "truth", "parameters", "gamma", "for", "the", "given", "data", ".", "Parameters", ":", "rankings", ":", "set", "of", "rankin...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mmgbtl.py#L17-L70
train
Returns an aggregate of the ground - truth parameters and the gamma for each entry in the given data.
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
Generates and returns URL for redirecting to the RunKeeper Login Page of Health Graph API.
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
Return URL for image used for RunKeeper Login button.
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
Returns the Access Token retrieved from the Health Graph API Token Endpoint following the login to RunKeeper.
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
Revokes the Access Token by accessing the De - authorization Endpoint of Health Graph API.
IRC-SPHERE/HyperStream
hyperstream/time_interval.py
parse_time_tuple
def parse_time_tuple(start, end): """ Parse a time tuple. These can be: relative in seconds, e.g. (-4, 0) relative in timedelta, e.g. (timedelta(seconds=-4), timedelta(0)) absolute in date/datetime, e.g. (datetime(2016, 4, 28, 20, 0, 0, 0, UTC), datetime(2016, 4, 28, 21, 0, 0, 0, UTC...
python
def parse_time_tuple(start, end): """ Parse a time tuple. These can be: relative in seconds, e.g. (-4, 0) relative in timedelta, e.g. (timedelta(seconds=-4), timedelta(0)) absolute in date/datetime, e.g. (datetime(2016, 4, 28, 20, 0, 0, 0, UTC), datetime(2016, 4, 28, 21, 0, 0, 0, UTC...
[ "def", "parse_time_tuple", "(", "start", ",", "end", ")", ":", "if", "isinstance", "(", "start", ",", "int", ")", ":", "start_time", "=", "timedelta", "(", "seconds", "=", "start", ")", "elif", "isinstance", "(", "start", ",", "timedelta", ")", ":", "s...
Parse a time tuple. These can be: relative in seconds, e.g. (-4, 0) relative in timedelta, e.g. (timedelta(seconds=-4), timedelta(0)) absolute in date/datetime, e.g. (datetime(2016, 4, 28, 20, 0, 0, 0, UTC), datetime(2016, 4, 28, 21, 0, 0, 0, UTC)) absolute in iso strings, e.g. ("201...
[ "Parse", "a", "time", "tuple", ".", "These", "can", "be", ":", "relative", "in", "seconds", "e", ".", "g", ".", "(", "-", "4", "0", ")", "relative", "in", "timedelta", "e", ".", "g", ".", "(", "timedelta", "(", "seconds", "=", "-", "4", ")", "t...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/time_interval.py#L450-L495
train
Parse a time tuple into a TimeInterval or RelativeTimeInterval object.
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
Splits the list of time intervals in the specified points into two lists of time intervals.
cloudmesh-cmd3/cmd3
cmd3/plugins/clear.py
clear.do_clear
def do_clear(self, arg, arguments): """ Usage: clear Clears the screen.""" sys.stdout.write(os.popen('clear').read())
python
def do_clear(self, arg, arguments): """ Usage: clear Clears the screen.""" sys.stdout.write(os.popen('clear').read())
[ "def", "do_clear", "(", "self", ",", "arg", ",", "arguments", ")", ":", "sys", ".", "stdout", ".", "write", "(", "os", ".", "popen", "(", "'clear'", ")", ".", "read", "(", ")", ")" ]
Usage: clear Clears the screen.
[ "Usage", ":", "clear" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/clear.py#L19-L26
train
Clear the current color screen.
cloudmesh-cmd3/cmd3
cmd3/plugins/clear.py
clear.do_banner
def do_banner(self, arg, arguments): """ :: Usage: banner [-c CHAR] [-n WIDTH] [-i INDENT] [-r COLOR] TEXT Arguments: TEXT The text message from which to create the banner CHAR The character for the frame. WID...
python
def do_banner(self, arg, arguments): """ :: Usage: banner [-c CHAR] [-n WIDTH] [-i INDENT] [-r COLOR] TEXT Arguments: TEXT The text message from which to create the banner CHAR The character for the frame. WID...
[ "def", "do_banner", "(", "self", ",", "arg", ",", "arguments", ")", ":", "print", "arguments", "n", "=", "int", "(", "arguments", "[", "'-n'", "]", ")", "c", "=", "arguments", "[", "'-c'", "]", "i", "=", "int", "(", "arguments", "[", "'-i'", "]", ...
:: Usage: banner [-c CHAR] [-n WIDTH] [-i INDENT] [-r COLOR] TEXT Arguments: TEXT The text message from which to create the banner CHAR The character for the frame. WIDTH Width of the banner INDENT indentatio...
[ "::" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/clear.py#L29-L60
train
\ n A banner for the current locale
inveniosoftware-contrib/invenio-workflows
invenio_workflows/api.py
WorkflowObject.save
def save(self, status=None, callback_pos=None, id_workflow=None): """Save object to persistent storage.""" if self.model is None: raise WorkflowsMissingModel() with db.session.begin_nested(): workflow_object_before_save.send(self) self.model.modified = datet...
python
def save(self, status=None, callback_pos=None, id_workflow=None): """Save object to persistent storage.""" if self.model is None: raise WorkflowsMissingModel() with db.session.begin_nested(): workflow_object_before_save.send(self) self.model.modified = datet...
[ "def", "save", "(", "self", ",", "status", "=", "None", ",", "callback_pos", "=", "None", ",", "id_workflow", "=", "None", ")", ":", "if", "self", ".", "model", "is", "None", ":", "raise", "WorkflowsMissingModel", "(", ")", "with", "db", ".", "session"...
Save object to persistent storage.
[ "Save", "object", "to", "persistent", "storage", "." ]
9c09fd29509a3db975ac2aba337e6760d8cfd3c2
https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L98-L136
train
Save object to persistent storage.
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", ...
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
Create a new Workflow Object with given content.
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
Return a workflow object from id.
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", "[", "cl...
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
Wrap sqlalchemy query methods of sqlalchemy. BaseQuery.
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
Delete a workflow object.
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
Assign an action to this object and a message to the user.
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", ".", "com...
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
Start the workflow specified on the object.
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", ".", "...
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
Continue the workflow for this object.
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
Return dictionary of current task function info for this object.
rsgalloway/grit
grit/server/git_http_backend.py
assemble_WSGI_git_app
def assemble_WSGI_git_app(*args, **kw): ''' Assembles basic WSGI-compatible application providing functionality of git-http-backend. content_path (Defaults to '.' = "current" directory) The path to the folder that will be the root of served files. Accepts relative paths. uri_marker (Def...
python
def assemble_WSGI_git_app(*args, **kw): ''' Assembles basic WSGI-compatible application providing functionality of git-http-backend. content_path (Defaults to '.' = "current" directory) The path to the folder that will be the root of served files. Accepts relative paths. uri_marker (Def...
[ "def", "assemble_WSGI_git_app", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "default_options", "=", "[", "[", "'content_path'", ",", "'.'", "]", ",", "[", "'uri_marker'", ",", "''", "]", "]", "args", "=", "list", "(", "args", ")", "options", "="...
Assembles basic WSGI-compatible application providing functionality of git-http-backend. content_path (Defaults to '.' = "current" directory) The path to the folder that will be the root of served files. Accepts relative paths. uri_marker (Defaults to '') Acts as a "virtual folder" separ...
[ "Assembles", "basic", "WSGI", "-", "compatible", "application", "providing", "functionality", "of", "git", "-", "http", "-", "backend", ".", "content_path", "(", "Defaults", "to", ".", "=", "current", "directory", ")", "The", "path", "to", "the", "folder", "...
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/git_http_backend.py#L629-L692
train
Assembles a basic WSGI - compatible application providing functionality of git - http - backend.
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
A list of handlers that can be used to handle the error code.
rsgalloway/grit
grit/server/git_http_backend.py
WSGIHandlerSelector.add
def add(self, path, default_handler = None, **http_methods): """ Add a selector mapping. add(path, default_handler, **named_handlers) Adding order is important. Firt added = first matched. If you want to hand special case URI handled by one app and shorter versi...
python
def add(self, path, default_handler = None, **http_methods): """ Add a selector mapping. add(path, default_handler, **named_handlers) Adding order is important. Firt added = first matched. If you want to hand special case URI handled by one app and shorter versi...
[ "def", "add", "(", "self", ",", "path", ",", "default_handler", "=", "None", ",", "*", "*", "http_methods", ")", ":", "if", "default_handler", ":", "methods", "=", "defaultdict", "(", "lambda", ":", "default_handler", ",", "http_methods", ".", "copy", "(",...
Add a selector mapping. add(path, default_handler, **named_handlers) Adding order is important. Firt added = first matched. If you want to hand special case URI handled by one app and shorter version of the same regex string by anoter app, .add() special case first. ...
[ "Add", "a", "selector", "mapping", ".", "add", "(", "path", "default_handler", "**", "named_handlers", ")", "Adding", "order", "is", "important", ".", "Firt", "added", "=", "first", "matched", ".", "If", "you", "want", "to", "hand", "special", "case", "URI...
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/git_http_backend.py#L162-L212
train
Add a new selector mapping.
rsgalloway/grit
grit/server/git_http_backend.py
GitHTTPBackendBase.basic_checks
def basic_checks(self, dataObj, environ, start_response): ''' This function is shared by GitInfoRefs and SmartHTTPRPCHandler WSGI classes. It does the same basic steps - figure out working path, git command etc. dataObj - dictionary Because the dataObj passed in is mutable...
python
def basic_checks(self, dataObj, environ, start_response): ''' This function is shared by GitInfoRefs and SmartHTTPRPCHandler WSGI classes. It does the same basic steps - figure out working path, git command etc. dataObj - dictionary Because the dataObj passed in is mutable...
[ "def", "basic_checks", "(", "self", ",", "dataObj", ",", "environ", ",", "start_response", ")", ":", "selector_matches", "=", "(", "environ", ".", "get", "(", "'wsgiorg.routing_args'", ")", "or", "(", "[", "]", ",", "{", "}", ")", ")", "[", "1", "]", ...
This function is shared by GitInfoRefs and SmartHTTPRPCHandler WSGI classes. It does the same basic steps - figure out working path, git command etc. dataObj - dictionary Because the dataObj passed in is mutable, it's a pointer. Once this function returns, this object, as created b...
[ "This", "function", "is", "shared", "by", "GitInfoRefs", "and", "SmartHTTPRPCHandler", "WSGI", "classes", ".", "It", "does", "the", "same", "basic", "steps", "-", "figure", "out", "working", "path", "git", "command", "etc", ".", "dataObj", "-", "dictionary", ...
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/git_http_backend.py#L359-L432
train
This function is used by the HTTPServer to check if the given dataObj is mutable and if so checks if the given dataObj has access to the given git command. Returns non - None if the request was not made.
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
prints some information about the shell scope
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
activates the shell scope
cloudmesh-cmd3/cmd3
cmd3/plugins/shell_scope.py
shell_scope.do_use
def do_use(self, arg): """ :: USAGE: use list lists the available scopes use add SCOPE adds a scope <scope> use delete SCOPE removes the <scope> use without parameters allows an ...
python
def do_use(self, arg): """ :: USAGE: use list lists the available scopes use add SCOPE adds a scope <scope> use delete SCOPE removes the <scope> use without parameters allows an ...
[ "def", "do_use", "(", "self", ",", "arg", ")", ":", "if", "arg", "==", "'list'", ":", "self", ".", "_list_scope", "(", ")", "return", "elif", "arg", ".", "startswith", "(", "'add'", ")", ":", "new_scope", "=", "arg", ".", "split", "(", "' '", ")", ...
:: USAGE: use list lists the available scopes use add SCOPE adds a scope <scope> use delete SCOPE removes the <scope> use without parameters allows an interactive s...
[ "::", "USAGE", ":" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/shell_scope.py#L82-L134
train
This function is called by the user to enter a new use command.
cloudmesh-cmd3/cmd3
cmd3/plugins/shell_scope.py
shell_scope.do_debug
def do_debug(self, args, arguments): """ :: Usage: debug on debug off Turns the debug log level on and off. """ filename = path_expand("~/.cloudmesh/cmd3.yaml") config = ConfigDict(filename=filename) if arguments['on']:...
python
def do_debug(self, args, arguments): """ :: Usage: debug on debug off Turns the debug log level on and off. """ filename = path_expand("~/.cloudmesh/cmd3.yaml") config = ConfigDict(filename=filename) if arguments['on']:...
[ "def", "do_debug", "(", "self", ",", "args", ",", "arguments", ")", ":", "filename", "=", "path_expand", "(", "\"~/.cloudmesh/cmd3.yaml\"", ")", "config", "=", "ConfigDict", "(", "filename", "=", "filename", ")", "if", "arguments", "[", "'on'", "]", ":", "...
:: Usage: debug on debug off Turns the debug log level on and off.
[ "::" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/shell_scope.py#L260-L276
train
Set the debug level on or off.
cloudmesh-cmd3/cmd3
cmd3/plugins/shell_scope.py
shell_scope.do_loglevel
def do_loglevel(self, args, arguments): """ :: Usage: loglevel loglevel critical loglevel error loglevel warning loglevel info loglevel debug Shows current log level or changes it. ...
python
def do_loglevel(self, args, arguments): """ :: Usage: loglevel loglevel critical loglevel error loglevel warning loglevel info loglevel debug Shows current log level or changes it. ...
[ "def", "do_loglevel", "(", "self", ",", "args", ",", "arguments", ")", ":", "if", "arguments", "[", "'debug'", "]", ":", "self", ".", "loglevel", "=", "\"DEBUG\"", "elif", "arguments", "[", "'error'", "]", ":", "self", ".", "loglevel", "=", "\"ERROR\"", ...
:: Usage: loglevel loglevel critical loglevel error loglevel warning loglevel info loglevel debug Shows current log level or changes it. loglevel - shows current log level critical ...
[ "::" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/shell_scope.py#L279-L319
train
Set the log level of the current application.
cloudmesh-cmd3/cmd3
cmd3/plugins/shell_scope.py
shell_scope.do_verbose
def do_verbose(self, args, arguments): """ Usage: verbose (True | False) verbose If it sets to True, a command will be printed before execution. In the interactive mode, you may want to set it to False. When you use scripts, we recommend to set it to True...
python
def do_verbose(self, args, arguments): """ Usage: verbose (True | False) verbose If it sets to True, a command will be printed before execution. In the interactive mode, you may want to set it to False. When you use scripts, we recommend to set it to True...
[ "def", "do_verbose", "(", "self", ",", "args", ",", "arguments", ")", ":", "if", "args", "==", "''", ":", "self", ".", "echo", "=", "not", "self", ".", "echo", "else", ":", "self", ".", "echo", "=", "arguments", "[", "'True'", "]" ]
Usage: verbose (True | False) verbose If it sets to True, a command will be printed before execution. In the interactive mode, you may want to set it to False. When you use scripts, we recommend to set it to True. The default is set to False If verbose ...
[ "Usage", ":", "verbose", "(", "True", "|", "False", ")", "verbose" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/shell_scope.py#L323-L342
train
Set verbose flag
cloudmesh-cmd3/cmd3
cmd3/plugins/shell_scope.py
shell_scope.do_var
def do_var(self, arg, arguments): """ Usage: var list var delete NAMES var NAME=VALUE var NAME Arguments: NAME Name of the variable NAMES Names of the variable separated by spaces VALUE VALUE to be assig...
python
def do_var(self, arg, arguments): """ Usage: var list var delete NAMES var NAME=VALUE var NAME Arguments: NAME Name of the variable NAMES Names of the variable separated by spaces VALUE VALUE to be assig...
[ "def", "do_var", "(", "self", ",", "arg", ",", "arguments", ")", ":", "if", "arguments", "[", "'list'", "]", "or", "arg", "==", "''", "or", "arg", "is", "None", ":", "self", ".", "_list_variables", "(", ")", "return", "elif", "arguments", "[", "'NAME...
Usage: var list var delete NAMES var NAME=VALUE var NAME Arguments: NAME Name of the variable NAMES Names of the variable separated by spaces VALUE VALUE to be assigned special vars date and time are defined
[ "Usage", ":", "var", "list", "var", "delete", "NAMES", "var", "NAME", "=", "VALUE", "var", "NAME" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/shell_scope.py#L375-L412
train
This function is called by the command line to set the variable in the internal state of the object.
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
Generates the stack of functions to call.
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
Returns a unique MiddlewareManager instance.
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
Checks that the configuration makes sense.
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", ":", "# noinspection PyTypeChecker", "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
Get the function to call which will run all middlewares.
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", ")", "# if args.neighbor_offsets:",...
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
Load a loci from the command line arguments.
pyQode/pyqode.cobol
pyqode/cobol/widgets/code_edit.py
CobolCodeEdit._do_home_key
def _do_home_key(self, event=None, select=False): """ Performs home key action """ # get nb char to first significative char min_column = self.indenter_mode.min_column text = api.TextHelper(self).current_line_text()[min_column:] indent = len(text) - len(text.lstrip()) del...
python
def _do_home_key(self, event=None, select=False): """ Performs home key action """ # get nb char to first significative char min_column = self.indenter_mode.min_column text = api.TextHelper(self).current_line_text()[min_column:] indent = len(text) - len(text.lstrip()) del...
[ "def", "_do_home_key", "(", "self", ",", "event", "=", "None", ",", "select", "=", "False", ")", ":", "# get nb char to first significative char", "min_column", "=", "self", ".", "indenter_mode", ".", "min_column", "text", "=", "api", ".", "TextHelper", "(", "...
Performs home key action
[ "Performs", "home", "key", "action" ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/widgets/code_edit.py#L206-L224
train
Handles the home key presses.
cloudmesh-cmd3/cmd3
cmd3/plugins/py.py
py.do_py
def do_py(self, arg): """ :: Usage: py py COMMAND Arguments: COMMAND the command to be executed Description: The command without a parameter will be executed and the interactive pyth...
python
def do_py(self, arg): """ :: Usage: py py COMMAND Arguments: COMMAND the command to be executed Description: The command without a parameter will be executed and the interactive pyth...
[ "def", "do_py", "(", "self", ",", "arg", ")", ":", "self", ".", "pystate", "[", "'self'", "]", "=", "self", "arg", "=", "arg", ".", "strip", "(", ")", "localvars", "=", "(", "self", ".", "locals_in_py", "and", "self", ".", "pystate", ")", "or", "...
:: Usage: py py COMMAND Arguments: COMMAND the command to be executed Description: The command without a parameter will be executed and the interactive python mode is entered. The python mode can be...
[ "::" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/py.py#L39-L98
train
A function that executes a python command.
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
Formats the date information provided by the given a datetime object.
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
Formats the date and time information provided by the given timestamp object.
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
Tries to extract a datetime object from the given string expecting date information only. Raises a DateTimeFormatterException if the extraction fails.
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
Tries to extract a datetime object from the given string including time information.
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
Tries to extract a datetime object from the given string including only hours.
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
Tries to extract a datetime object from the given string.
inveniosoftware-contrib/invenio-workflows
invenio_workflows/tasks.py
start
def start(workflow_name, data=None, object_id=None, **kwargs): """Start a workflow by given name for specified data. The name of the workflow to start is considered unique and it is equal to the name of a file containing the workflow definition. The data passed could be a list of Python standard data ...
python
def start(workflow_name, data=None, object_id=None, **kwargs): """Start a workflow by given name for specified data. The name of the workflow to start is considered unique and it is equal to the name of a file containing the workflow definition. The data passed could be a list of Python standard data ...
[ "def", "start", "(", "workflow_name", ",", "data", "=", "None", ",", "object_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", ".", "proxies", "import", "workflow_object_class", "from", ".", "worker_engine", "import", "run_worker", "if", "data", ...
Start a workflow by given name for specified data. The name of the workflow to start is considered unique and it is equal to the name of a file containing the workflow definition. The data passed could be a list of Python standard data types such as strings, dict, integers etc. to run through the work...
[ "Start", "a", "workflow", "by", "given", "name", "for", "specified", "data", "." ]
9c09fd29509a3db975ac2aba337e6760d8cfd3c2
https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/tasks.py#L31-L77
train
Start a new workflow by given name for specified data.
inveniosoftware-contrib/invenio-workflows
invenio_workflows/tasks.py
resume
def resume(oid, restart_point="continue_next", **kwargs): """Continue workflow for given WorkflowObject id (oid). Depending on `start_point` it may start from previous, current or next task. Special custom keyword arguments can be given to the workflow engine in order to pass certain variables to ...
python
def resume(oid, restart_point="continue_next", **kwargs): """Continue workflow for given WorkflowObject id (oid). Depending on `start_point` it may start from previous, current or next task. Special custom keyword arguments can be given to the workflow engine in order to pass certain variables to ...
[ "def", "resume", "(", "oid", ",", "restart_point", "=", "\"continue_next\"", ",", "*", "*", "kwargs", ")", ":", "from", ".", "worker_engine", "import", "continue_worker", "return", "text_type", "(", "continue_worker", "(", "oid", ",", "restart_point", ",", "*"...
Continue workflow for given WorkflowObject id (oid). Depending on `start_point` it may start from previous, current or next task. Special custom keyword arguments can be given to the workflow engine in order to pass certain variables to the tasks in the workflow execution, such as a task-id from B...
[ "Continue", "workflow", "for", "given", "WorkflowObject", "id", "(", "oid", ")", "." ]
9c09fd29509a3db975ac2aba337e6760d8cfd3c2
https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/tasks.py#L81-L103
train
Continue the workflow for given WorkflowObject id.
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
Restart the workflow from a given workflow engine UUID.
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", "+", "'.'", ")", ":", "# this causes a Runtime error with m...
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
Import all submodules and register them in the context namespace.
cloudmesh-cmd3/cmd3
cmd3/shell.py
DynamicCmd
def DynamicCmd(name, plugins): """ Returns a cmd with the added plugins, :param name: TODO: :param plugins: list of plugins """ exec('class %s(cmd.Cmd):\n prompt="cm> "' % name) plugin_objects = [] for plugin in plugins: classprefix = plugin['class'] plugin_list =...
python
def DynamicCmd(name, plugins): """ Returns a cmd with the added plugins, :param name: TODO: :param plugins: list of plugins """ exec('class %s(cmd.Cmd):\n prompt="cm> "' % name) plugin_objects = [] for plugin in plugins: classprefix = plugin['class'] plugin_list =...
[ "def", "DynamicCmd", "(", "name", ",", "plugins", ")", ":", "exec", "(", "'class %s(cmd.Cmd):\\n prompt=\"cm> \"'", "%", "name", ")", "plugin_objects", "=", "[", "]", "for", "plugin", "in", "plugins", ":", "classprefix", "=", "plugin", "[", "'class'", "]", ...
Returns a cmd with the added plugins, :param name: TODO: :param plugins: list of plugins
[ "Returns", "a", "cmd", "with", "the", "added", "plugins", ":", "param", "name", ":", "TODO", ":", ":", "param", "plugins", ":", "list", "of", "plugins" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/shell.py#L135-L151
train
Dynamic command factory.
cloudmesh-cmd3/cmd3
cmd3/shell.py
get_plugins
def get_plugins(directory): """ returns the list of plugins from the specified directory :param directory: directory that contains the plugins. Files starting with _ will be ignored. """ # not just plugin_*.py plugins = [] files = glob.glob(directory + "/*.py") for p in files: p ...
python
def get_plugins(directory): """ returns the list of plugins from the specified directory :param directory: directory that contains the plugins. Files starting with _ will be ignored. """ # not just plugin_*.py plugins = [] files = glob.glob(directory + "/*.py") for p in files: p ...
[ "def", "get_plugins", "(", "directory", ")", ":", "# not just plugin_*.py", "plugins", "=", "[", "]", "files", "=", "glob", ".", "glob", "(", "directory", "+", "\"/*.py\"", ")", "for", "p", "in", "files", ":", "p", "=", "p", ".", "replace", "(", "direc...
returns the list of plugins from the specified directory :param directory: directory that contains the plugins. Files starting with _ will be ignored.
[ "returns", "the", "list", "of", "plugins", "from", "the", "specified", "directory", ":", "param", "directory", ":", "directory", "that", "contains", "the", "plugins", ".", "Files", "starting", "with", "_", "will", "be", "ignored", "." ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/shell.py#L158-L172
train
returns the list of plugins from the specified directory
cloudmesh-cmd3/cmd3
cmd3/shell.py
load_plugins
def load_plugins(classprefix, plugin_list): """ loads the plugins specified in the list :param classprefix: the class prefix :param plugin_list: the list of plugins """ # classprefix "cmd3.plugins." plugins = [] import_object = {} # log.info(str(list)) for plugin in plugin_list: ...
python
def load_plugins(classprefix, plugin_list): """ loads the plugins specified in the list :param classprefix: the class prefix :param plugin_list: the list of plugins """ # classprefix "cmd3.plugins." plugins = [] import_object = {} # log.info(str(list)) for plugin in plugin_list: ...
[ "def", "load_plugins", "(", "classprefix", ",", "plugin_list", ")", ":", "# classprefix \"cmd3.plugins.\"", "plugins", "=", "[", "]", "import_object", "=", "{", "}", "# log.info(str(list))", "for", "plugin", "in", "plugin_list", ":", "if", "cygwin", ":", "plugin",...
loads the plugins specified in the list :param classprefix: the class prefix :param plugin_list: the list of plugins
[ "loads", "the", "plugins", "specified", "in", "the", "list", ":", "param", "classprefix", ":", "the", "class", "prefix", ":", "param", "plugin_list", ":", "the", "list", "of", "plugins" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/shell.py#L183-L217
train
loads the plugins specified in the list of plugins in the classprefix
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
A command decorator to create a function with docopt arguments. It also generates a help function.
cloudmesh-cmd3/cmd3
cmd3/shell.py
create_file
def create_file(filename): """ Creates a new file if the file name does not exists :param filename: the name of the file """ expanded_filename = os.path.expanduser(os.path.expandvars(filename)) if not os.path.exists(expanded_filename): open(expanded_filename, "a").close()
python
def create_file(filename): """ Creates a new file if the file name does not exists :param filename: the name of the file """ expanded_filename = os.path.expanduser(os.path.expandvars(filename)) if not os.path.exists(expanded_filename): open(expanded_filename, "a").close()
[ "def", "create_file", "(", "filename", ")", ":", "expanded_filename", "=", "os", ".", "path", ".", "expanduser", "(", "os", ".", "path", ".", "expandvars", "(", "filename", ")", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "expanded_filename"...
Creates a new file if the file name does not exists :param filename: the name of the file
[ "Creates", "a", "new", "file", "if", "the", "file", "name", "does", "not", "exists", ":", "param", "filename", ":", "the", "name", "of", "the", "file" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/shell.py#L312-L320
train
Creates a new file if the file name does not exists
cloudmesh-cmd3/cmd3
cmd3/shell.py
get_plugins_from_dir
def get_plugins_from_dir(dir_path, classbase): """dir_path/classbase/plugins""" if dir_path == "sys": dir_path = os.path.abspath( os.path.join(os.path.dirname(__file__), 'plugins')) dir_plugins = get_plugins(dir_path) return {"dir": dir_path, "plugins": dir_plugins, "class":...
python
def get_plugins_from_dir(dir_path, classbase): """dir_path/classbase/plugins""" if dir_path == "sys": dir_path = os.path.abspath( os.path.join(os.path.dirname(__file__), 'plugins')) dir_plugins = get_plugins(dir_path) return {"dir": dir_path, "plugins": dir_plugins, "class":...
[ "def", "get_plugins_from_dir", "(", "dir_path", ",", "classbase", ")", ":", "if", "dir_path", "==", "\"sys\"", ":", "dir_path", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", ...
dir_path/classbase/plugins
[ "dir_path", "/", "classbase", "/", "plugins" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/shell.py#L332-L359
train
Get the list of plugins from a directory.
cloudmesh-cmd3/cmd3
cmd3/shell.py
main
def main(): """cm. Usage: cm [-q] help cm [-v] [-b] [--file=SCRIPT] [-i] [COMMAND ...] Arguments: COMMAND A command to be executed Options: --file=SCRIPT -f SCRIPT Executes the script -i After start keep the shell interactive, ...
python
def main(): """cm. Usage: cm [-q] help cm [-v] [-b] [--file=SCRIPT] [-i] [COMMAND ...] Arguments: COMMAND A command to be executed Options: --file=SCRIPT -f SCRIPT Executes the script -i After start keep the shell interactive, ...
[ "def", "main", "(", ")", ":", "echo", "=", "False", "try", ":", "arguments", "=", "docopt", "(", "main", ".", "__doc__", ",", "help", "=", "True", ")", "# fixing the help parameter parsing", "if", "arguments", "[", "'help'", "]", ":", "arguments", "[", "...
cm. Usage: cm [-q] help cm [-v] [-b] [--file=SCRIPT] [-i] [COMMAND ...] Arguments: COMMAND A command to be executed Options: --file=SCRIPT -f SCRIPT Executes the script -i After start keep the shell interactive, ot...
[ "cm", "." ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/shell.py#L380-L503
train
Command line interface for the CM.
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
Adds a file to the version
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
Adds an item to the tree if the tree is mutable
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
Removes an item from the tree.
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
Generator that yields Items
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
Returns set of items.
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
read blob on access only because get_object is slow
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", ")", "#FIXME: hack, there has to be a better way", "return", "It...
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
Create a new Item instance from a file path.
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
Create a new Item from a string.
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
Modify item data and commit to repo.
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
Check out the data of the item to the given path.