repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
zhanglab/psamm
psamm/findprimarypairs.py
_jaccard_similarity
def _jaccard_similarity(f1, f2, weight_func): """Calculate generalized Jaccard similarity of formulas. Returns the weighted similarity value or None if there is no overlap at all. If the union of the formulas has a weight of zero (i.e. the denominator in the Jaccard similarity is zero), a value of zero...
python
def _jaccard_similarity(f1, f2, weight_func): """Calculate generalized Jaccard similarity of formulas. Returns the weighted similarity value or None if there is no overlap at all. If the union of the formulas has a weight of zero (i.e. the denominator in the Jaccard similarity is zero), a value of zero...
[ "def", "_jaccard_similarity", "(", "f1", ",", "f2", ",", "weight_func", ")", ":", "elements", "=", "set", "(", "f1", ")", "elements", ".", "update", "(", "f2", ")", "count", ",", "w_count", ",", "w_total", "=", "0", ",", "0", ",", "0", "for", "elem...
Calculate generalized Jaccard similarity of formulas. Returns the weighted similarity value or None if there is no overlap at all. If the union of the formulas has a weight of zero (i.e. the denominator in the Jaccard similarity is zero), a value of zero is returned.
[ "Calculate", "generalized", "Jaccard", "similarity", "of", "formulas", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/findprimarypairs.py#L49-L72
train
65,400
zhanglab/psamm
psamm/findprimarypairs.py
predict_compound_pairs_iterated
def predict_compound_pairs_iterated( reactions, formulas, prior=(1, 43), max_iterations=None, element_weight=element_weight): """Predict reaction pairs using iterated method. Returns a tuple containing a dictionary of predictions keyed by the reaction IDs, and the final number of iterations...
python
def predict_compound_pairs_iterated( reactions, formulas, prior=(1, 43), max_iterations=None, element_weight=element_weight): """Predict reaction pairs using iterated method. Returns a tuple containing a dictionary of predictions keyed by the reaction IDs, and the final number of iterations...
[ "def", "predict_compound_pairs_iterated", "(", "reactions", ",", "formulas", ",", "prior", "=", "(", "1", ",", "43", ")", ",", "max_iterations", "=", "None", ",", "element_weight", "=", "element_weight", ")", ":", "prior_alpha", ",", "prior_beta", "=", "prior"...
Predict reaction pairs using iterated method. Returns a tuple containing a dictionary of predictions keyed by the reaction IDs, and the final number of iterations. Each reaction prediction entry contains a tuple with a dictionary of transfers and a dictionary of unbalanced compounds. The dictionary of ...
[ "Predict", "reaction", "pairs", "using", "iterated", "method", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/findprimarypairs.py#L156-L247
train
65,401
zhanglab/psamm
psamm/findprimarypairs.py
predict_compound_pairs
def predict_compound_pairs(reaction, compound_formula, pair_weights={}, weight_func=element_weight): """Predict compound pairs for a single reaction. Performs greedy matching on reaction compounds using a scoring function that uses generalized Jaccard similarity corrected by the ...
python
def predict_compound_pairs(reaction, compound_formula, pair_weights={}, weight_func=element_weight): """Predict compound pairs for a single reaction. Performs greedy matching on reaction compounds using a scoring function that uses generalized Jaccard similarity corrected by the ...
[ "def", "predict_compound_pairs", "(", "reaction", ",", "compound_formula", ",", "pair_weights", "=", "{", "}", ",", "weight_func", "=", "element_weight", ")", ":", "def", "score_func", "(", "inst1", ",", "inst2", ")", ":", "score", "=", "_jaccard_similarity", ...
Predict compound pairs for a single reaction. Performs greedy matching on reaction compounds using a scoring function that uses generalized Jaccard similarity corrected by the weights in the given dictionary. Returns a tuple of a transfer dictionary and a dictionary of unbalanced compounds. The diction...
[ "Predict", "compound", "pairs", "for", "a", "single", "reaction", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/findprimarypairs.py#L366-L400
train
65,402
juju-solutions/jujuresources
jujuresources/__init__.py
config_get
def config_get(option_name): """ Helper to access a Juju config option when charmhelpers is not available. :param str option_name: Name of the config option to get the value of """ try: raw = subprocess.check_output(['config-get', option_name, '--format=yaml']) return yaml.load(raw....
python
def config_get(option_name): """ Helper to access a Juju config option when charmhelpers is not available. :param str option_name: Name of the config option to get the value of """ try: raw = subprocess.check_output(['config-get', option_name, '--format=yaml']) return yaml.load(raw....
[ "def", "config_get", "(", "option_name", ")", ":", "try", ":", "raw", "=", "subprocess", ".", "check_output", "(", "[", "'config-get'", ",", "option_name", ",", "'--format=yaml'", "]", ")", "return", "yaml", ".", "load", "(", "raw", ".", "decode", "(", "...
Helper to access a Juju config option when charmhelpers is not available. :param str option_name: Name of the config option to get the value of
[ "Helper", "to", "access", "a", "Juju", "config", "option", "when", "charmhelpers", "is", "not", "available", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/__init__.py#L24-L34
train
65,403
juju-solutions/jujuresources
jujuresources/__init__.py
fetch
def fetch(which=None, mirror_url=None, resources_yaml='resources.yaml', force=False, reporthook=None): """ Attempt to fetch all resources for a charm. :param list which: A name, or a list of one or more resource names, to fetch. If ommitted, all non-optional resources are fetched. ...
python
def fetch(which=None, mirror_url=None, resources_yaml='resources.yaml', force=False, reporthook=None): """ Attempt to fetch all resources for a charm. :param list which: A name, or a list of one or more resource names, to fetch. If ommitted, all non-optional resources are fetched. ...
[ "def", "fetch", "(", "which", "=", "None", ",", "mirror_url", "=", "None", ",", "resources_yaml", "=", "'resources.yaml'", ",", "force", "=", "False", ",", "reporthook", "=", "None", ")", ":", "resources", "=", "_load", "(", "resources_yaml", ",", "None", ...
Attempt to fetch all resources for a charm. :param list which: A name, or a list of one or more resource names, to fetch. If ommitted, all non-optional resources are fetched. You can also pass ``jujuresources.ALL`` to fetch all optional *and* required resources. :param str mirror_url: ...
[ "Attempt", "to", "fetch", "all", "resources", "for", "a", "charm", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/__init__.py#L135-L167
train
65,404
happyleavesaoc/python-limitlessled
limitlessled/group/__init__.py
rate
def rate(wait=MIN_WAIT, reps=REPS): """ Rate limit a command function. :param wait: How long to wait between commands. :param reps: How many times to send a command. :returns: Decorator. """ def decorator(function): """ Decorator function. :returns: Wrapper. """ ...
python
def rate(wait=MIN_WAIT, reps=REPS): """ Rate limit a command function. :param wait: How long to wait between commands. :param reps: How many times to send a command. :returns: Decorator. """ def decorator(function): """ Decorator function. :returns: Wrapper. """ ...
[ "def", "rate", "(", "wait", "=", "MIN_WAIT", ",", "reps", "=", "REPS", ")", ":", "def", "decorator", "(", "function", ")", ":", "\"\"\" Decorator function.\n\n :returns: Wrapper.\n \"\"\"", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*",...
Rate limit a command function. :param wait: How long to wait between commands. :param reps: How many times to send a command. :returns: Decorator.
[ "Rate", "limit", "a", "command", "function", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L13-L39
train
65,405
happyleavesaoc/python-limitlessled
limitlessled/group/__init__.py
Group.on
def on(self, state): """ Turn on or off. :param state: True (on) or False (off). """ self._on = state cmd = self.command_set.off() if state: cmd = self.command_set.on() self.send(cmd)
python
def on(self, state): """ Turn on or off. :param state: True (on) or False (off). """ self._on = state cmd = self.command_set.off() if state: cmd = self.command_set.on() self.send(cmd)
[ "def", "on", "(", "self", ",", "state", ")", ":", "self", ".", "_on", "=", "state", "cmd", "=", "self", ".", "command_set", ".", "off", "(", ")", "if", "state", ":", "cmd", "=", "self", ".", "command_set", ".", "on", "(", ")", "self", ".", "sen...
Turn on or off. :param state: True (on) or False (off).
[ "Turn", "on", "or", "off", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L77-L86
train
65,406
happyleavesaoc/python-limitlessled
limitlessled/group/__init__.py
Group.flash
def flash(self, duration=0.0): """ Flash a group. :param duration: How quickly to flash (in seconds). """ for _ in range(2): self.on = not self.on time.sleep(duration)
python
def flash(self, duration=0.0): """ Flash a group. :param duration: How quickly to flash (in seconds). """ for _ in range(2): self.on = not self.on time.sleep(duration)
[ "def", "flash", "(", "self", ",", "duration", "=", "0.0", ")", ":", "for", "_", "in", "range", "(", "2", ")", ":", "self", ".", "on", "=", "not", "self", ".", "on", "time", ".", "sleep", "(", "duration", ")" ]
Flash a group. :param duration: How quickly to flash (in seconds).
[ "Flash", "a", "group", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L98-L105
train
65,407
happyleavesaoc/python-limitlessled
limitlessled/group/__init__.py
Group.send
def send(self, cmd): """ Send a command to the bridge. :param cmd: List of command bytes. """ self._bridge.send(cmd, wait=self.wait, reps=self.reps)
python
def send(self, cmd): """ Send a command to the bridge. :param cmd: List of command bytes. """ self._bridge.send(cmd, wait=self.wait, reps=self.reps)
[ "def", "send", "(", "self", ",", "cmd", ")", ":", "self", ".", "_bridge", ".", "send", "(", "cmd", ",", "wait", "=", "self", ".", "wait", ",", "reps", "=", "self", ".", "reps", ")" ]
Send a command to the bridge. :param cmd: List of command bytes.
[ "Send", "a", "command", "to", "the", "bridge", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L107-L112
train
65,408
happyleavesaoc/python-limitlessled
limitlessled/group/__init__.py
Group.enqueue
def enqueue(self, pipeline): """ Start a pipeline. :param pipeline: Start this pipeline. """ copied = Pipeline().append(pipeline) copied.group = self self._queue.put(copied)
python
def enqueue(self, pipeline): """ Start a pipeline. :param pipeline: Start this pipeline. """ copied = Pipeline().append(pipeline) copied.group = self self._queue.put(copied)
[ "def", "enqueue", "(", "self", ",", "pipeline", ")", ":", "copied", "=", "Pipeline", "(", ")", ".", "append", "(", "pipeline", ")", "copied", ".", "group", "=", "self", "self", ".", "_queue", ".", "put", "(", "copied", ")" ]
Start a pipeline. :param pipeline: Start this pipeline.
[ "Start", "a", "pipeline", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L114-L121
train
65,409
happyleavesaoc/python-limitlessled
limitlessled/group/__init__.py
Group._wait
def _wait(self, duration, steps, commands): """ Compute wait time. :param duration: Total time (in seconds). :param steps: Number of steps. :param commands: Number of commands. :returns: Wait in seconds. """ wait = ((duration - self.wait * self.reps * commands) /...
python
def _wait(self, duration, steps, commands): """ Compute wait time. :param duration: Total time (in seconds). :param steps: Number of steps. :param commands: Number of commands. :returns: Wait in seconds. """ wait = ((duration - self.wait * self.reps * commands) /...
[ "def", "_wait", "(", "self", ",", "duration", ",", "steps", ",", "commands", ")", ":", "wait", "=", "(", "(", "duration", "-", "self", ".", "wait", "*", "self", ".", "reps", "*", "commands", ")", "/", "steps", ")", "-", "(", "self", ".", "wait", ...
Compute wait time. :param duration: Total time (in seconds). :param steps: Number of steps. :param commands: Number of commands. :returns: Wait in seconds.
[ "Compute", "wait", "time", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L127-L137
train
65,410
juju-solutions/jujuresources
jujuresources/backend.py
Resource.get
def get(cls, name, definition, output_dir): """ Dispatch to the right subclass based on the definition. """ if 'url' in definition: return URLResource(name, definition, output_dir) elif 'pypi' in definition: return PyPIResource(name, definition, output_dir...
python
def get(cls, name, definition, output_dir): """ Dispatch to the right subclass based on the definition. """ if 'url' in definition: return URLResource(name, definition, output_dir) elif 'pypi' in definition: return PyPIResource(name, definition, output_dir...
[ "def", "get", "(", "cls", ",", "name", ",", "definition", ",", "output_dir", ")", ":", "if", "'url'", "in", "definition", ":", "return", "URLResource", "(", "name", ",", "definition", ",", "output_dir", ")", "elif", "'pypi'", "in", "definition", ":", "re...
Dispatch to the right subclass based on the definition.
[ "Dispatch", "to", "the", "right", "subclass", "based", "on", "the", "definition", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/backend.py#L65-L74
train
65,411
happyleavesaoc/python-limitlessled
limitlessled/pipeline.py
PipelineQueue.run
def run(self): """ Run the pipeline queue. The pipeline queue will run forever. """ while True: self._event.clear() self._queue.get().run(self._event)
python
def run(self): """ Run the pipeline queue. The pipeline queue will run forever. """ while True: self._event.clear() self._queue.get().run(self._event)
[ "def", "run", "(", "self", ")", ":", "while", "True", ":", "self", ".", "_event", ".", "clear", "(", ")", "self", ".", "_queue", ".", "get", "(", ")", ".", "run", "(", "self", ".", "_event", ")" ]
Run the pipeline queue. The pipeline queue will run forever.
[ "Run", "the", "pipeline", "queue", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L25-L32
train
65,412
happyleavesaoc/python-limitlessled
limitlessled/pipeline.py
Pipeline.run
def run(self, stop): """ Run the pipeline. :param stop: Stop event """ _LOGGER.info("Starting a new pipeline on group %s", self._group) self._group.bridge.incr_active() for i, stage in enumerate(self._pipe): self._execute_stage(i, stage, stop) _LOGGER...
python
def run(self, stop): """ Run the pipeline. :param stop: Stop event """ _LOGGER.info("Starting a new pipeline on group %s", self._group) self._group.bridge.incr_active() for i, stage in enumerate(self._pipe): self._execute_stage(i, stage, stop) _LOGGER...
[ "def", "run", "(", "self", ",", "stop", ")", ":", "_LOGGER", ".", "info", "(", "\"Starting a new pipeline on group %s\"", ",", "self", ".", "_group", ")", "self", ".", "_group", ".", "bridge", ".", "incr_active", "(", ")", "for", "i", ",", "stage", "in",...
Run the pipeline. :param stop: Stop event
[ "Run", "the", "pipeline", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L104-L114
train
65,413
happyleavesaoc/python-limitlessled
limitlessled/pipeline.py
Pipeline.append
def append(self, pipeline): """ Append a pipeline to this pipeline. :param pipeline: Pipeline to append. :returns: This pipeline. """ for stage in pipeline.pipe: self._pipe.append(stage) return self
python
def append(self, pipeline): """ Append a pipeline to this pipeline. :param pipeline: Pipeline to append. :returns: This pipeline. """ for stage in pipeline.pipe: self._pipe.append(stage) return self
[ "def", "append", "(", "self", ",", "pipeline", ")", ":", "for", "stage", "in", "pipeline", ".", "pipe", ":", "self", ".", "_pipe", ".", "append", "(", "stage", ")", "return", "self" ]
Append a pipeline to this pipeline. :param pipeline: Pipeline to append. :returns: This pipeline.
[ "Append", "a", "pipeline", "to", "this", "pipeline", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L116-L124
train
65,414
happyleavesaoc/python-limitlessled
limitlessled/pipeline.py
Pipeline._add_stage
def _add_stage(self, name): """ Add stage methods at runtime. Stage methods all follow the same pattern. :param name: Stage name. """ def stage_func(self, *args, **kwargs): """ Stage function. :param args: Positional arguments. :param kwargs...
python
def _add_stage(self, name): """ Add stage methods at runtime. Stage methods all follow the same pattern. :param name: Stage name. """ def stage_func(self, *args, **kwargs): """ Stage function. :param args: Positional arguments. :param kwargs...
[ "def", "_add_stage", "(", "self", ",", "name", ")", ":", "def", "stage_func", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\" Stage function.\n\n :param args: Positional arguments.\n :param kwargs: Keyword arguments.\n ...
Add stage methods at runtime. Stage methods all follow the same pattern. :param name: Stage name.
[ "Add", "stage", "methods", "at", "runtime", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L126-L143
train
65,415
happyleavesaoc/python-limitlessled
limitlessled/pipeline.py
Pipeline._execute_stage
def _execute_stage(self, index, stage, stop): """ Execute a pipeline stage. :param index: Stage index. :param stage: Stage object. """ if stop.is_set(): _LOGGER.info("Stopped pipeline on group %s", self._group) return _LOGGER.info(" -> Running sta...
python
def _execute_stage(self, index, stage, stop): """ Execute a pipeline stage. :param index: Stage index. :param stage: Stage object. """ if stop.is_set(): _LOGGER.info("Stopped pipeline on group %s", self._group) return _LOGGER.info(" -> Running sta...
[ "def", "_execute_stage", "(", "self", ",", "index", ",", "stage", ",", "stop", ")", ":", "if", "stop", ".", "is_set", "(", ")", ":", "_LOGGER", ".", "info", "(", "\"Stopped pipeline on group %s\"", ",", "self", ".", "_group", ")", "return", "_LOGGER", "....
Execute a pipeline stage. :param index: Stage index. :param stage: Stage object.
[ "Execute", "a", "pipeline", "stage", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L145-L198
train
65,416
happyleavesaoc/python-limitlessled
limitlessled/pipeline.py
Pipeline._repeat
def _repeat(self, index, stage, stop): """ Repeat a stage. :param index: Stage index. :param stage: Stage object to repeat. :param iterations: Number of iterations (default infinite). :param stages: Stages back to repeat (default 1). """ times = None if '...
python
def _repeat(self, index, stage, stop): """ Repeat a stage. :param index: Stage index. :param stage: Stage object to repeat. :param iterations: Number of iterations (default infinite). :param stages: Stages back to repeat (default 1). """ times = None if '...
[ "def", "_repeat", "(", "self", ",", "index", ",", "stage", ",", "stop", ")", ":", "times", "=", "None", "if", "'iterations'", "in", "stage", ".", "kwargs", ":", "times", "=", "stage", ".", "kwargs", "[", "'iterations'", "]", "-", "1", "stages_back", ...
Repeat a stage. :param index: Stage index. :param stage: Stage object to repeat. :param iterations: Number of iterations (default infinite). :param stages: Stages back to repeat (default 1).
[ "Repeat", "a", "stage", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L200-L223
train
65,417
happyleavesaoc/python-limitlessled
limitlessled/group/dimmer.py
DimmerGroup.brightness
def brightness(self, brightness): """ Set the brightness. :param brightness: Value to set (0.0-1.0). """ try: cmd = self.command_set.brightness(brightness) self.send(cmd) self._brightness = brightness except AttributeError: self._s...
python
def brightness(self, brightness): """ Set the brightness. :param brightness: Value to set (0.0-1.0). """ try: cmd = self.command_set.brightness(brightness) self.send(cmd) self._brightness = brightness except AttributeError: self._s...
[ "def", "brightness", "(", "self", ",", "brightness", ")", ":", "try", ":", "cmd", "=", "self", ".", "command_set", ".", "brightness", "(", "brightness", ")", "self", ".", "send", "(", "cmd", ")", "self", ".", "_brightness", "=", "brightness", "except", ...
Set the brightness. :param brightness: Value to set (0.0-1.0).
[ "Set", "the", "brightness", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/dimmer.py#L36-L48
train
65,418
happyleavesaoc/python-limitlessled
limitlessled/group/dimmer.py
DimmerGroup._to_brightness
def _to_brightness(self, brightness): """ Step to a given brightness. :param brightness: Get to this brightness. """ self._to_value(self._brightness, brightness, self.command_set.brightness_steps, self._dimmer, self._brighter)
python
def _to_brightness(self, brightness): """ Step to a given brightness. :param brightness: Get to this brightness. """ self._to_value(self._brightness, brightness, self.command_set.brightness_steps, self._dimmer, self._brighter)
[ "def", "_to_brightness", "(", "self", ",", "brightness", ")", ":", "self", ".", "_to_value", "(", "self", ".", "_brightness", ",", "brightness", ",", "self", ".", "command_set", ".", "brightness_steps", ",", "self", ".", "_dimmer", ",", "self", ".", "_brig...
Step to a given brightness. :param brightness: Get to this brightness.
[ "Step", "to", "a", "given", "brightness", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/dimmer.py#L113-L120
train
65,419
happyleavesaoc/python-limitlessled
limitlessled/group/dimmer.py
DimmerGroup._to_value
def _to_value(self, current, target, max_steps, step_down, step_up): """ Step to a value :param current: Current value. :param target: Target value. :param max_steps: Maximum number of steps. :param step_down: Down function. :param step_up: Up function. """ ...
python
def _to_value(self, current, target, max_steps, step_down, step_up): """ Step to a value :param current: Current value. :param target: Target value. :param max_steps: Maximum number of steps. :param step_down: Down function. :param step_up: Up function. """ ...
[ "def", "_to_value", "(", "self", ",", "current", ",", "target", ",", "max_steps", ",", "step_down", ",", "step_up", ")", ":", "for", "_", "in", "range", "(", "steps", "(", "current", ",", "target", ",", "max_steps", ")", ")", ":", "if", "(", "current...
Step to a value :param current: Current value. :param target: Target value. :param max_steps: Maximum number of steps. :param step_down: Down function. :param step_up: Up function.
[ "Step", "to", "a", "value" ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/dimmer.py#L123-L136
train
65,420
happyleavesaoc/python-limitlessled
limitlessled/group/dimmer.py
DimmerGroup._dimmest
def _dimmest(self): """ Group brightness as dim as possible. """ for _ in range(steps(self.brightness, 0.0, self.command_set.brightness_steps)): self._dimmer()
python
def _dimmest(self): """ Group brightness as dim as possible. """ for _ in range(steps(self.brightness, 0.0, self.command_set.brightness_steps)): self._dimmer()
[ "def", "_dimmest", "(", "self", ")", ":", "for", "_", "in", "range", "(", "steps", "(", "self", ".", "brightness", ",", "0.0", ",", "self", ".", "command_set", ".", "brightness_steps", ")", ")", ":", "self", ".", "_dimmer", "(", ")" ]
Group brightness as dim as possible.
[ "Group", "brightness", "as", "dim", "as", "possible", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/dimmer.py#L146-L150
train
65,421
juicer/juicer
juicer/common/Cart.py
Cart.add_repo
def add_repo(self, repo_name, items): """ Build up repos `name` - Name of this repo. `items` - List of paths to rpm. """ juicer.utils.Log.log_debug("[CART:%s] Adding %s items to repo '%s'" % \ (self.cart_name, len(items), repo_name)...
python
def add_repo(self, repo_name, items): """ Build up repos `name` - Name of this repo. `items` - List of paths to rpm. """ juicer.utils.Log.log_debug("[CART:%s] Adding %s items to repo '%s'" % \ (self.cart_name, len(items), repo_name)...
[ "def", "add_repo", "(", "self", ",", "repo_name", ",", "items", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"[CART:%s] Adding %s items to repo '%s'\"", "%", "(", "self", ".", "cart_name", ",", "len", "(", "items", ")", ",", "repo...
Build up repos `name` - Name of this repo. `items` - List of paths to rpm.
[ "Build", "up", "repos" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L72-L91
train
65,422
juicer/juicer
juicer/common/Cart.py
Cart.load
def load(self, json_file): """ Build a cart from a json file """ cart_file = os.path.join(CART_LOCATION, json_file) try: cart_body = juicer.utils.read_json_document(cart_file) except IOError as e: juicer.utils.Log.log_error('an error occured while ...
python
def load(self, json_file): """ Build a cart from a json file """ cart_file = os.path.join(CART_LOCATION, json_file) try: cart_body = juicer.utils.read_json_document(cart_file) except IOError as e: juicer.utils.Log.log_error('an error occured while ...
[ "def", "load", "(", "self", ",", "json_file", ")", ":", "cart_file", "=", "os", ".", "path", ".", "join", "(", "CART_LOCATION", ",", "json_file", ")", "try", ":", "cart_body", "=", "juicer", ".", "utils", ".", "read_json_document", "(", "cart_file", ")",...
Build a cart from a json file
[ "Build", "a", "cart", "from", "a", "json", "file" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L99-L119
train
65,423
juicer/juicer
juicer/common/Cart.py
Cart.sign_items
def sign_items(self, sign_with): """ Sign the items in the cart with a GPG key. After everything is collected and signed all the cart items are issued a refresh() to sync their is_signed attributes. `sign_with` is a reference to the method that implements juicer.common....
python
def sign_items(self, sign_with): """ Sign the items in the cart with a GPG key. After everything is collected and signed all the cart items are issued a refresh() to sync their is_signed attributes. `sign_with` is a reference to the method that implements juicer.common....
[ "def", "sign_items", "(", "self", ",", "sign_with", ")", ":", "cart_items", "=", "self", ".", "items", "(", ")", "item_paths", "=", "[", "item", ".", "path", "for", "item", "in", "cart_items", "]", "sign_with", "(", "item_paths", ")", "for", "item", "i...
Sign the items in the cart with a GPG key. After everything is collected and signed all the cart items are issued a refresh() to sync their is_signed attributes. `sign_with` is a reference to the method that implements juicer.common.RpmSignPlugin.
[ "Sign", "the", "items", "in", "the", "cart", "with", "a", "GPG", "key", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L138-L153
train
65,424
juicer/juicer
juicer/common/Cart.py
Cart.sync_remotes
def sync_remotes(self, force=False): """ Pull down all non-local items and save them into remotes_storage. """ connectors = juicer.utils.get_login_info()[0] for repo, items in self.iterrepos(): repoid = "%s-%s" % (repo, self.current_env) for rpm in items: ...
python
def sync_remotes(self, force=False): """ Pull down all non-local items and save them into remotes_storage. """ connectors = juicer.utils.get_login_info()[0] for repo, items in self.iterrepos(): repoid = "%s-%s" % (repo, self.current_env) for rpm in items: ...
[ "def", "sync_remotes", "(", "self", ",", "force", "=", "False", ")", ":", "connectors", "=", "juicer", ".", "utils", ".", "get_login_info", "(", ")", "[", "0", "]", "for", "repo", ",", "items", "in", "self", ".", "iterrepos", "(", ")", ":", "repoid",...
Pull down all non-local items and save them into remotes_storage.
[ "Pull", "down", "all", "non", "-", "local", "items", "and", "save", "them", "into", "remotes_storage", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L155-L167
train
65,425
juicer/juicer
juicer/common/Cart.py
Cart.items
def items(self): """ Build and return a list of all items in this cart """ cart_items = [] for repo, items in self.iterrepos(): cart_items.extend(items) return cart_items
python
def items(self): """ Build and return a list of all items in this cart """ cart_items = [] for repo, items in self.iterrepos(): cart_items.extend(items) return cart_items
[ "def", "items", "(", "self", ")", ":", "cart_items", "=", "[", "]", "for", "repo", ",", "items", "in", "self", ".", "iterrepos", "(", ")", ":", "cart_items", ".", "extend", "(", "items", ")", "return", "cart_items" ]
Build and return a list of all items in this cart
[ "Build", "and", "return", "a", "list", "of", "all", "items", "in", "this", "cart" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L184-L189
train
65,426
juju-solutions/jujuresources
jujuresources/cli.py
arg
def arg(*args, **kwargs): """ Decorator to add args to subcommands. """ def _arg(f): if not hasattr(f, '_subcommand_args'): f._subcommand_args = [] f._subcommand_args.append((args, kwargs)) return f return _arg
python
def arg(*args, **kwargs): """ Decorator to add args to subcommands. """ def _arg(f): if not hasattr(f, '_subcommand_args'): f._subcommand_args = [] f._subcommand_args.append((args, kwargs)) return f return _arg
[ "def", "arg", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "_arg", "(", "f", ")", ":", "if", "not", "hasattr", "(", "f", ",", "'_subcommand_args'", ")", ":", "f", ".", "_subcommand_args", "=", "[", "]", "f", ".", "_subcommand_args", ...
Decorator to add args to subcommands.
[ "Decorator", "to", "add", "args", "to", "subcommands", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L26-L35
train
65,427
juju-solutions/jujuresources
jujuresources/cli.py
argset
def argset(name, *args, **kwargs): """ Decorator to add sets of required mutually exclusive args to subcommands. """ def _arg(f): if not hasattr(f, '_subcommand_argsets'): f._subcommand_argsets = {} f._subcommand_argsets.setdefault(name, []).append((args, kwargs)) ret...
python
def argset(name, *args, **kwargs): """ Decorator to add sets of required mutually exclusive args to subcommands. """ def _arg(f): if not hasattr(f, '_subcommand_argsets'): f._subcommand_argsets = {} f._subcommand_argsets.setdefault(name, []).append((args, kwargs)) ret...
[ "def", "argset", "(", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "_arg", "(", "f", ")", ":", "if", "not", "hasattr", "(", "f", ",", "'_subcommand_argsets'", ")", ":", "f", ".", "_subcommand_argsets", "=", "{", "}", "f", "...
Decorator to add sets of required mutually exclusive args to subcommands.
[ "Decorator", "to", "add", "sets", "of", "required", "mutually", "exclusive", "args", "to", "subcommands", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L38-L47
train
65,428
juju-solutions/jujuresources
jujuresources/cli.py
resources
def resources(argv=sys.argv[1:]): """ Juju CLI subcommand for dispatching resources subcommands. """ eps = iter_entry_points('jujuresources.subcommands') ep_map = {ep.name: ep.load() for ep in eps} parser = argparse.ArgumentParser() if '--description' in argv: print('Manage and mirr...
python
def resources(argv=sys.argv[1:]): """ Juju CLI subcommand for dispatching resources subcommands. """ eps = iter_entry_points('jujuresources.subcommands') ep_map = {ep.name: ep.load() for ep in eps} parser = argparse.ArgumentParser() if '--description' in argv: print('Manage and mirr...
[ "def", "resources", "(", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", ")", ":", "eps", "=", "iter_entry_points", "(", "'jujuresources.subcommands'", ")", "ep_map", "=", "{", "ep", ".", "name", ":", "ep", ".", "load", "(", ")", "for", "ep", ...
Juju CLI subcommand for dispatching resources subcommands.
[ "Juju", "CLI", "subcommand", "for", "dispatching", "resources", "subcommands", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L54-L87
train
65,429
juju-solutions/jujuresources
jujuresources/cli.py
fetch
def fetch(opts): """ Create a local mirror of one or more resources. """ resources = _load(opts.resources, opts.output_dir) if opts.all: opts.resource_names = ALL reporthook = None if opts.quiet else lambda name: print('Fetching {}...'.format(name)) if opts.verbose: backend.V...
python
def fetch(opts): """ Create a local mirror of one or more resources. """ resources = _load(opts.resources, opts.output_dir) if opts.all: opts.resource_names = ALL reporthook = None if opts.quiet else lambda name: print('Fetching {}...'.format(name)) if opts.verbose: backend.V...
[ "def", "fetch", "(", "opts", ")", ":", "resources", "=", "_load", "(", "opts", ".", "resources", ",", "opts", ".", "output_dir", ")", "if", "opts", ".", "all", ":", "opts", ".", "resource_names", "=", "ALL", "reporthook", "=", "None", "if", "opts", "...
Create a local mirror of one or more resources.
[ "Create", "a", "local", "mirror", "of", "one", "or", "more", "resources", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L107-L118
train
65,430
juju-solutions/jujuresources
jujuresources/cli.py
verify
def verify(opts): """ Verify that one or more resources were downloaded successfully. """ resources = _load(opts.resources, opts.output_dir) if opts.all: opts.resource_names = ALL invalid = _invalid(resources, opts.resource_names) if not invalid: if not opts.quiet: ...
python
def verify(opts): """ Verify that one or more resources were downloaded successfully. """ resources = _load(opts.resources, opts.output_dir) if opts.all: opts.resource_names = ALL invalid = _invalid(resources, opts.resource_names) if not invalid: if not opts.quiet: ...
[ "def", "verify", "(", "opts", ")", ":", "resources", "=", "_load", "(", "opts", ".", "resources", ",", "opts", ".", "output_dir", ")", "if", "opts", ".", "all", ":", "opts", ".", "resource_names", "=", "ALL", "invalid", "=", "_invalid", "(", "resources...
Verify that one or more resources were downloaded successfully.
[ "Verify", "that", "one", "or", "more", "resources", "were", "downloaded", "successfully", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L132-L147
train
65,431
juju-solutions/jujuresources
jujuresources/cli.py
resource_path
def resource_path(opts): """ Return the full path to a named resource. """ resources = _load(opts.resources, opts.output_dir) if opts.resource_name not in resources: sys.stderr.write('Invalid resource name: {}\n'.format(opts.resource_name)) return 1 print(resources[opts.resource_...
python
def resource_path(opts): """ Return the full path to a named resource. """ resources = _load(opts.resources, opts.output_dir) if opts.resource_name not in resources: sys.stderr.write('Invalid resource name: {}\n'.format(opts.resource_name)) return 1 print(resources[opts.resource_...
[ "def", "resource_path", "(", "opts", ")", ":", "resources", "=", "_load", "(", "opts", ".", "resources", ",", "opts", ".", "output_dir", ")", "if", "opts", ".", "resource_name", "not", "in", "resources", ":", "sys", ".", "stderr", ".", "write", "(", "'...
Return the full path to a named resource.
[ "Return", "the", "full", "path", "to", "a", "named", "resource", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L192-L200
train
65,432
juju-solutions/jujuresources
jujuresources/cli.py
serve
def serve(opts): """ Run a light-weight HTTP server hosting previously mirrored resources """ resources = _load(opts.resources, opts.output_dir) opts.output_dir = resources.output_dir # allow resources.yaml to set default output_dir if not os.path.exists(opts.output_dir): sys.stderr.wri...
python
def serve(opts): """ Run a light-weight HTTP server hosting previously mirrored resources """ resources = _load(opts.resources, opts.output_dir) opts.output_dir = resources.output_dir # allow resources.yaml to set default output_dir if not os.path.exists(opts.output_dir): sys.stderr.wri...
[ "def", "serve", "(", "opts", ")", ":", "resources", "=", "_load", "(", "opts", ".", "resources", ",", "opts", ".", "output_dir", ")", "opts", ".", "output_dir", "=", "resources", ".", "output_dir", "# allow resources.yaml to set default output_dir", "if", "not",...
Run a light-weight HTTP server hosting previously mirrored resources
[ "Run", "a", "light", "-", "weight", "HTTP", "server", "hosting", "previously", "mirrored", "resources" ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L229-L249
train
65,433
happyleavesaoc/python-limitlessled
limitlessled/group/white.py
WhiteGroup._to_temperature
def _to_temperature(self, temperature): """ Step to a given temperature. :param temperature: Get to this temperature. """ self._to_value(self._temperature, temperature, self.command_set.temperature_steps, self._warmer, self._cooler)
python
def _to_temperature(self, temperature): """ Step to a given temperature. :param temperature: Get to this temperature. """ self._to_value(self._temperature, temperature, self.command_set.temperature_steps, self._warmer, self._cooler)
[ "def", "_to_temperature", "(", "self", ",", "temperature", ")", ":", "self", ".", "_to_value", "(", "self", ".", "_temperature", ",", "temperature", ",", "self", ".", "command_set", ".", "temperature_steps", ",", "self", ".", "_warmer", ",", "self", ".", "...
Step to a given temperature. :param temperature: Get to this temperature.
[ "Step", "to", "a", "given", "temperature", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/white.py#L169-L176
train
65,434
happyleavesaoc/python-limitlessled
limitlessled/group/white.py
WhiteGroup._warmest
def _warmest(self): """ Group temperature as warm as possible. """ for _ in range(steps(self.temperature, 0.0, self.command_set.temperature_steps)): self._warmer()
python
def _warmest(self): """ Group temperature as warm as possible. """ for _ in range(steps(self.temperature, 0.0, self.command_set.temperature_steps)): self._warmer()
[ "def", "_warmest", "(", "self", ")", ":", "for", "_", "in", "range", "(", "steps", "(", "self", ".", "temperature", ",", "0.0", ",", "self", ".", "command_set", ".", "temperature_steps", ")", ")", ":", "self", ".", "_warmer", "(", ")" ]
Group temperature as warm as possible.
[ "Group", "temperature", "as", "warm", "as", "possible", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/white.py#L209-L213
train
65,435
happyleavesaoc/python-limitlessled
limitlessled/group/white.py
WhiteGroup._coolest
def _coolest(self): """ Group temperature as cool as possible. """ for _ in range(steps(self.temperature, 1.0, self.command_set.temperature_steps)): self._cooler()
python
def _coolest(self): """ Group temperature as cool as possible. """ for _ in range(steps(self.temperature, 1.0, self.command_set.temperature_steps)): self._cooler()
[ "def", "_coolest", "(", "self", ")", ":", "for", "_", "in", "range", "(", "steps", "(", "self", ".", "temperature", ",", "1.0", ",", "self", ".", "command_set", ".", "temperature_steps", ")", ")", ":", "self", ".", "_cooler", "(", ")" ]
Group temperature as cool as possible.
[ "Group", "temperature", "as", "cool", "as", "possible", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/white.py#L216-L220
train
65,436
open-homeautomation/pknx
knxip/helper.py
ip_to_array
def ip_to_array(ipaddress): """Convert a string representing an IPv4 address to 4 bytes.""" res = [] for i in ipaddress.split("."): res.append(int(i)) assert len(res) == 4 return res
python
def ip_to_array(ipaddress): """Convert a string representing an IPv4 address to 4 bytes.""" res = [] for i in ipaddress.split("."): res.append(int(i)) assert len(res) == 4 return res
[ "def", "ip_to_array", "(", "ipaddress", ")", ":", "res", "=", "[", "]", "for", "i", "in", "ipaddress", ".", "split", "(", "\".\"", ")", ":", "res", ".", "append", "(", "int", "(", "i", ")", ")", "assert", "len", "(", "res", ")", "==", "4", "ret...
Convert a string representing an IPv4 address to 4 bytes.
[ "Convert", "a", "string", "representing", "an", "IPv4", "address", "to", "4", "bytes", "." ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/helper.py#L8-L15
train
65,437
open-homeautomation/pknx
knxip/helper.py
int_to_array
def int_to_array(i, length=2): """Convert an length byte integer to an array of bytes.""" res = [] for dummy in range(0, length): res.append(i & 0xff) i = i >> 8 return reversed(res)
python
def int_to_array(i, length=2): """Convert an length byte integer to an array of bytes.""" res = [] for dummy in range(0, length): res.append(i & 0xff) i = i >> 8 return reversed(res)
[ "def", "int_to_array", "(", "i", ",", "length", "=", "2", ")", ":", "res", "=", "[", "]", "for", "dummy", "in", "range", "(", "0", ",", "length", ")", ":", "res", ".", "append", "(", "i", "&", "0xff", ")", "i", "=", "i", ">>", "8", "return", ...
Convert an length byte integer to an array of bytes.
[ "Convert", "an", "length", "byte", "integer", "to", "an", "array", "of", "bytes", "." ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/helper.py#L18-L24
train
65,438
todbot/blink1-python
blink1/blink1.py
Blink1.stop
def stop(self): """Stop internal color pattern playing """ if ( self.dev == None ): return '' buf = [REPORT_ID, ord('p'), 0, 0, 0, 0, 0, 0, 0] return self.write(buf);
python
def stop(self): """Stop internal color pattern playing """ if ( self.dev == None ): return '' buf = [REPORT_ID, ord('p'), 0, 0, 0, 0, 0, 0, 0] return self.write(buf);
[ "def", "stop", "(", "self", ")", ":", "if", "(", "self", ".", "dev", "==", "None", ")", ":", "return", "''", "buf", "=", "[", "REPORT_ID", ",", "ord", "(", "'p'", ")", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ...
Stop internal color pattern playing
[ "Stop", "internal", "color", "pattern", "playing" ]
7a5183becd9662f88da3c29afd3447403f4ef82f
https://github.com/todbot/blink1-python/blob/7a5183becd9662f88da3c29afd3447403f4ef82f/blink1/blink1.py#L222-L227
train
65,439
todbot/blink1-python
blink1/blink1.py
Blink1.savePattern
def savePattern(self): """Save internal RAM pattern to flash """ if ( self.dev == None ): return '' buf = [REPORT_ID, ord('W'), 0xBE, 0xEF, 0xCA, 0xFE, 0, 0, 0] return self.write(buf);
python
def savePattern(self): """Save internal RAM pattern to flash """ if ( self.dev == None ): return '' buf = [REPORT_ID, ord('W'), 0xBE, 0xEF, 0xCA, 0xFE, 0, 0, 0] return self.write(buf);
[ "def", "savePattern", "(", "self", ")", ":", "if", "(", "self", ".", "dev", "==", "None", ")", ":", "return", "''", "buf", "=", "[", "REPORT_ID", ",", "ord", "(", "'W'", ")", ",", "0xBE", ",", "0xEF", ",", "0xCA", ",", "0xFE", ",", "0", ",", ...
Save internal RAM pattern to flash
[ "Save", "internal", "RAM", "pattern", "to", "flash" ]
7a5183becd9662f88da3c29afd3447403f4ef82f
https://github.com/todbot/blink1-python/blob/7a5183becd9662f88da3c29afd3447403f4ef82f/blink1/blink1.py#L229-L234
train
65,440
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.create_repo
def create_repo(self, repo_name=None, feed=None, envs=[], checksum_type="sha256", query='/repositories/'): """ `repo_name` - Name of repository to create `feed` - Repo URL to feed from `checksum_type` - Used for generating meta-data Create repository in specified environments, a...
python
def create_repo(self, repo_name=None, feed=None, envs=[], checksum_type="sha256", query='/repositories/'): """ `repo_name` - Name of repository to create `feed` - Repo URL to feed from `checksum_type` - Used for generating meta-data Create repository in specified environments, a...
[ "def", "create_repo", "(", "self", ",", "repo_name", "=", "None", ",", "feed", "=", "None", ",", "envs", "=", "[", "]", ",", "checksum_type", "=", "\"sha256\"", ",", "query", "=", "'/repositories/'", ")", ":", "data", "=", "{", "'display_name'", ":", "...
`repo_name` - Name of repository to create `feed` - Repo URL to feed from `checksum_type` - Used for generating meta-data Create repository in specified environments, associate the yum_distributor with it and publish the repo
[ "repo_name", "-", "Name", "of", "repository", "to", "create", "feed", "-", "Repo", "URL", "to", "feed", "from", "checksum_type", "-", "Used", "for", "generating", "meta", "-", "data" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L47-L115
train
65,441
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.create_user
def create_user(self, login=None, password=None, user_name=None, envs=[], query='/users/'): """ `login` - Login or username for user `password` - Plain text password for user `user_name` - Full name of user Create user in specified environments """ login = login....
python
def create_user(self, login=None, password=None, user_name=None, envs=[], query='/users/'): """ `login` - Login or username for user `password` - Plain text password for user `user_name` - Full name of user Create user in specified environments """ login = login....
[ "def", "create_user", "(", "self", ",", "login", "=", "None", ",", "password", "=", "None", ",", "user_name", "=", "None", ",", "envs", "=", "[", "]", ",", "query", "=", "'/users/'", ")", ":", "login", "=", "login", ".", "lower", "(", ")", "data", ...
`login` - Login or username for user `password` - Plain text password for user `user_name` - Full name of user Create user in specified environments
[ "login", "-", "Login", "or", "username", "for", "user", "password", "-", "Plain", "text", "password", "for", "user", "user_name", "-", "Full", "name", "of", "user" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L342-L374
train
65,442
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.delete_repo
def delete_repo(self, repo_name=None, envs=[], query='/repositories/'): """ `repo_name` - Name of repository to delete Delete repo in specified environments """ orphan_query = '/content/orphans/rpm/' juicer.utils.Log.log_debug("Delete Repo: %s", repo_name) for e...
python
def delete_repo(self, repo_name=None, envs=[], query='/repositories/'): """ `repo_name` - Name of repository to delete Delete repo in specified environments """ orphan_query = '/content/orphans/rpm/' juicer.utils.Log.log_debug("Delete Repo: %s", repo_name) for e...
[ "def", "delete_repo", "(", "self", ",", "repo_name", "=", "None", ",", "envs", "=", "[", "]", ",", "query", "=", "'/repositories/'", ")", ":", "orphan_query", "=", "'/content/orphans/rpm/'", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"Del...
`repo_name` - Name of repository to delete Delete repo in specified environments
[ "repo_name", "-", "Name", "of", "repository", "to", "delete" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L376-L410
train
65,443
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.delete_user
def delete_user(self, login=None, envs=[], query='/users/'): """ `login` - Login or username of user to delete Delete user in specified environments """ juicer.utils.Log.log_debug("Delete User: %s", login) for env in envs: if envs.index(env) != 0 and juicer....
python
def delete_user(self, login=None, envs=[], query='/users/'): """ `login` - Login or username of user to delete Delete user in specified environments """ juicer.utils.Log.log_debug("Delete User: %s", login) for env in envs: if envs.index(env) != 0 and juicer....
[ "def", "delete_user", "(", "self", ",", "login", "=", "None", ",", "envs", "=", "[", "]", ",", "query", "=", "'/users/'", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"Delete User: %s\"", ",", "login", ")", "for", "env", "in...
`login` - Login or username of user to delete Delete user in specified environments
[ "login", "-", "Login", "or", "username", "of", "user", "to", "delete" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L412-L437
train
65,444
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.sync_repo
def sync_repo(self, repo_name=None, envs=[], query='/repositories/'): """ Sync repository in specified environments """ juicer.utils.Log.log_debug( "Sync Repo %s In: %s" % (repo_name, ",".join(envs))) data = { 'override_config': { 'verify_...
python
def sync_repo(self, repo_name=None, envs=[], query='/repositories/'): """ Sync repository in specified environments """ juicer.utils.Log.log_debug( "Sync Repo %s In: %s" % (repo_name, ",".join(envs))) data = { 'override_config': { 'verify_...
[ "def", "sync_repo", "(", "self", ",", "repo_name", "=", "None", ",", "envs", "=", "[", "]", ",", "query", "=", "'/repositories/'", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"Sync Repo %s In: %s\"", "%", "(", "repo_name", ",",...
Sync repository in specified environments
[ "Sync", "repository", "in", "specified", "environments" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L439-L461
train
65,445
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.list_repos
def list_repos(self, envs=[], query='/repositories/'): """ List repositories in specified environments """ juicer.utils.Log.log_debug( "List Repos In: %s", ", ".join(envs)) repo_lists = {} for env in envs: repo_lists[env] = [] for env...
python
def list_repos(self, envs=[], query='/repositories/'): """ List repositories in specified environments """ juicer.utils.Log.log_debug( "List Repos In: %s", ", ".join(envs)) repo_lists = {} for env in envs: repo_lists[env] = [] for env...
[ "def", "list_repos", "(", "self", ",", "envs", "=", "[", "]", ",", "query", "=", "'/repositories/'", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"List Repos In: %s\"", ",", "\", \"", ".", "join", "(", "envs", ")", ")", "repo_...
List repositories in specified environments
[ "List", "repositories", "in", "specified", "environments" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L463-L482
train
65,446
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.list_users
def list_users(self, envs=[], query="/users/"): """ List users in specified environments """ juicer.utils.Log.log_debug( "List Users In: %s", ", ".join(envs)) for env in envs: juicer.utils.Log.log_info("%s:" % (env)) _r = self.connectors[en...
python
def list_users(self, envs=[], query="/users/"): """ List users in specified environments """ juicer.utils.Log.log_debug( "List Users In: %s", ", ".join(envs)) for env in envs: juicer.utils.Log.log_info("%s:" % (env)) _r = self.connectors[en...
[ "def", "list_users", "(", "self", ",", "envs", "=", "[", "]", ",", "query", "=", "\"/users/\"", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"List Users In: %s\"", ",", "\", \"", ".", "join", "(", "envs", ")", ")", "for", "e...
List users in specified environments
[ "List", "users", "in", "specified", "environments" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L484-L503
train
65,447
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.role_add
def role_add(self, role=None, login=None, envs=[], query='/roles/'): """ `login` - Login or username of user to add to `role` `role` - Role to add user to Add user to role """ data = {'login': self.args.login} juicer.utils.Log.log_debug( "Add Role...
python
def role_add(self, role=None, login=None, envs=[], query='/roles/'): """ `login` - Login or username of user to add to `role` `role` - Role to add user to Add user to role """ data = {'login': self.args.login} juicer.utils.Log.log_debug( "Add Role...
[ "def", "role_add", "(", "self", ",", "role", "=", "None", ",", "login", "=", "None", ",", "envs", "=", "[", "]", ",", "query", "=", "'/roles/'", ")", ":", "data", "=", "{", "'login'", ":", "self", ".", "args", ".", "login", "}", "juicer", ".", ...
`login` - Login or username of user to add to `role` `role` - Role to add user to Add user to role
[ "login", "-", "Login", "or", "username", "of", "user", "to", "add", "to", "role", "role", "-", "Role", "to", "add", "user", "to" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L505-L532
train
65,448
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.show_user
def show_user(self, login=None, envs=[], query='/users/'): """ `login` - Login or username of user Show user in specified environments """ juicer.utils.Log.log_debug("Show User: %s", login) # keep track of which iteration of environment we're in count = 0 ...
python
def show_user(self, login=None, envs=[], query='/users/'): """ `login` - Login or username of user Show user in specified environments """ juicer.utils.Log.log_debug("Show User: %s", login) # keep track of which iteration of environment we're in count = 0 ...
[ "def", "show_user", "(", "self", ",", "login", "=", "None", ",", "envs", "=", "[", "]", ",", "query", "=", "'/users/'", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"Show User: %s\"", ",", "login", ")", "# keep track of which it...
`login` - Login or username of user Show user in specified environments
[ "login", "-", "Login", "or", "username", "of", "user" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L566-L600
train
65,449
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.list_roles
def list_roles(self, envs=[], query='/roles/'): """ List roles in specified environments """ juicer.utils.Log.log_debug("List Roles %s", ", ".join(envs)) count = 0 for env in envs: count += 1 rcount = 0 juicer.utils.Log.log_info("%s:...
python
def list_roles(self, envs=[], query='/roles/'): """ List roles in specified environments """ juicer.utils.Log.log_debug("List Roles %s", ", ".join(envs)) count = 0 for env in envs: count += 1 rcount = 0 juicer.utils.Log.log_info("%s:...
[ "def", "list_roles", "(", "self", ",", "envs", "=", "[", "]", ",", "query", "=", "'/roles/'", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"List Roles %s\"", ",", "\", \"", ".", "join", "(", "envs", ")", ")", "count", "=", ...
List roles in specified environments
[ "List", "roles", "in", "specified", "environments" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L602-L636
train
65,450
juicer/juicer
juicer/admin/JuicerAdmin.py
JuicerAdmin.update_user
def update_user(self, login=None, user_name=None, password=None, envs=[], query='/users/'): """ `login` - Login or username of user to update `user_name` - Updated full name of user `password` - Updated plain text password for user Update user information """ jui...
python
def update_user(self, login=None, user_name=None, password=None, envs=[], query='/users/'): """ `login` - Login or username of user to update `user_name` - Updated full name of user `password` - Updated plain text password for user Update user information """ jui...
[ "def", "update_user", "(", "self", ",", "login", "=", "None", ",", "user_name", "=", "None", ",", "password", "=", "None", ",", "envs", "=", "[", "]", ",", "query", "=", "'/users/'", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "...
`login` - Login or username of user to update `user_name` - Updated full name of user `password` - Updated plain text password for user Update user information
[ "login", "-", "Login", "or", "username", "of", "user", "to", "update", "user_name", "-", "Updated", "full", "name", "of", "user", "password", "-", "Updated", "plain", "text", "password", "for", "user" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L638-L676
train
65,451
juicer/juicer
juicer/common/Repo.py
RepoDiff._diff
def _diff(self): """Calculates what you need to do to make a pulp repo match a juicer repo def""" j_cs = self.j['checksum_type'] j_feed = self.j['feed'] p_cs = self.p['checksum_type'] p_feed = self.p['feed'] # checksum is a distributor property # Is the pulp che...
python
def _diff(self): """Calculates what you need to do to make a pulp repo match a juicer repo def""" j_cs = self.j['checksum_type'] j_feed = self.j['feed'] p_cs = self.p['checksum_type'] p_feed = self.p['feed'] # checksum is a distributor property # Is the pulp che...
[ "def", "_diff", "(", "self", ")", ":", "j_cs", "=", "self", ".", "j", "[", "'checksum_type'", "]", "j_feed", "=", "self", ".", "j", "[", "'feed'", "]", "p_cs", "=", "self", ".", "p", "[", "'checksum_type'", "]", "p_feed", "=", "self", ".", "p", "...
Calculates what you need to do to make a pulp repo match a juicer repo def
[ "Calculates", "what", "you", "need", "to", "do", "to", "make", "a", "pulp", "repo", "match", "a", "juicer", "repo", "def" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Repo.py#L156-L175
train
65,452
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer._set_prefixes
def _set_prefixes(self, conf): """Set the graphite key prefixes :param dict conf: The configuration data """ if conf.get('legacy_namespace', 'y') in self.TRUE_VALUES: self.count_prefix = 'stats_counts' self.count_suffix = '' self.gauge_prefix = 'stat...
python
def _set_prefixes(self, conf): """Set the graphite key prefixes :param dict conf: The configuration data """ if conf.get('legacy_namespace', 'y') in self.TRUE_VALUES: self.count_prefix = 'stats_counts' self.count_suffix = '' self.gauge_prefix = 'stat...
[ "def", "_set_prefixes", "(", "self", ",", "conf", ")", ":", "if", "conf", ".", "get", "(", "'legacy_namespace'", ",", "'y'", ")", "in", "self", ".", "TRUE_VALUES", ":", "self", ".", "count_prefix", "=", "'stats_counts'", "self", ".", "count_suffix", "=", ...
Set the graphite key prefixes :param dict conf: The configuration data
[ "Set", "the", "graphite", "key", "prefixes" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L57-L81
train
65,453
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer._get_batches
def _get_batches(self, items): """given a list yield list at most self.max_batch_size in size""" for i in xrange(0, len(items), self.max_batch_size): yield items[i:i + self.max_batch_size]
python
def _get_batches(self, items): """given a list yield list at most self.max_batch_size in size""" for i in xrange(0, len(items), self.max_batch_size): yield items[i:i + self.max_batch_size]
[ "def", "_get_batches", "(", "self", ",", "items", ")", ":", "for", "i", "in", "xrange", "(", "0", ",", "len", "(", "items", ")", ",", "self", ".", "max_batch_size", ")", ":", "yield", "items", "[", "i", ":", "i", "+", "self", ".", "max_batch_size",...
given a list yield list at most self.max_batch_size in size
[ "given", "a", "list", "yield", "list", "at", "most", "self", ".", "max_batch_size", "in", "size" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L83-L86
train
65,454
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer.report_stats
def report_stats(self, payload, is_retry=False): """ Send data to graphite host :param payload: Data to send to graphite """ if self.debug: if self.pickle_proto: print "reporting pickled stats" else: print "reporting stats ...
python
def report_stats(self, payload, is_retry=False): """ Send data to graphite host :param payload: Data to send to graphite """ if self.debug: if self.pickle_proto: print "reporting pickled stats" else: print "reporting stats ...
[ "def", "report_stats", "(", "self", ",", "payload", ",", "is_retry", "=", "False", ")", ":", "if", "self", ".", "debug", ":", "if", "self", ".", "pickle_proto", ":", "print", "\"reporting pickled stats\"", "else", ":", "print", "\"reporting stats -> {\\n%s}\"", ...
Send data to graphite host :param payload: Data to send to graphite
[ "Send", "data", "to", "graphite", "host" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L88-L122
train
65,455
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer.stats_flush
def stats_flush(self): """ Periodically flush stats to graphite """ while True: try: eventlet.sleep(self.flush_interval) if self.debug: print "seen %d stats so far." % self.stats_seen print "current count...
python
def stats_flush(self): """ Periodically flush stats to graphite """ while True: try: eventlet.sleep(self.flush_interval) if self.debug: print "seen %d stats so far." % self.stats_seen print "current count...
[ "def", "stats_flush", "(", "self", ")", ":", "while", "True", ":", "try", ":", "eventlet", ".", "sleep", "(", "self", ".", "flush_interval", ")", "if", "self", ".", "debug", ":", "print", "\"seen %d stats so far.\"", "%", "self", ".", "stats_seen", "print"...
Periodically flush stats to graphite
[ "Periodically", "flush", "stats", "to", "graphite" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L124-L144
train
65,456
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer.pickle_payload
def pickle_payload(self): """obtain stats payload in batches of pickle format""" tstamp = int(time.time()) payload = [] for item in self.counters: payload.append(("%s.%s%s" % (self.rate_prefix, item, self.rate_suffix), ...
python
def pickle_payload(self): """obtain stats payload in batches of pickle format""" tstamp = int(time.time()) payload = [] for item in self.counters: payload.append(("%s.%s%s" % (self.rate_prefix, item, self.rate_suffix), ...
[ "def", "pickle_payload", "(", "self", ")", ":", "tstamp", "=", "int", "(", "time", ".", "time", "(", ")", ")", "payload", "=", "[", "]", "for", "item", "in", "self", ".", "counters", ":", "payload", ".", "append", "(", "(", "\"%s.%s%s\"", "%", "(",...
obtain stats payload in batches of pickle format
[ "obtain", "stats", "payload", "in", "batches", "of", "pickle", "format" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L146-L180
train
65,457
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer.plain_payload
def plain_payload(self): """obtain stats payload in plaintext format""" tstamp = int(time.time()) payload = [] for item in self.counters: payload.append('%s.%s%s %s %s\n' % (self.rate_prefix, item, ...
python
def plain_payload(self): """obtain stats payload in plaintext format""" tstamp = int(time.time()) payload = [] for item in self.counters: payload.append('%s.%s%s %s %s\n' % (self.rate_prefix, item, ...
[ "def", "plain_payload", "(", "self", ")", ":", "tstamp", "=", "int", "(", "time", ".", "time", "(", ")", ")", "payload", "=", "[", "]", "for", "item", "in", "self", ".", "counters", ":", "payload", ".", "append", "(", "'%s.%s%s %s %s\\n'", "%", "(", ...
obtain stats payload in plaintext format
[ "obtain", "stats", "payload", "in", "plaintext", "format" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L182-L216
train
65,458
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer.process_gauge
def process_gauge(self, key, fields): """ Process a received gauge event :param key: Key of timer :param fields: Received fields """ try: self.gauges[key] = float(fields[0]) if self.stats_seen >= maxint: self.logger.info("hit maxin...
python
def process_gauge(self, key, fields): """ Process a received gauge event :param key: Key of timer :param fields: Received fields """ try: self.gauges[key] = float(fields[0]) if self.stats_seen >= maxint: self.logger.info("hit maxin...
[ "def", "process_gauge", "(", "self", ",", "key", ",", "fields", ")", ":", "try", ":", "self", ".", "gauges", "[", "key", "]", "=", "float", "(", "fields", "[", "0", "]", ")", "if", "self", ".", "stats_seen", ">=", "maxint", ":", "self", ".", "log...
Process a received gauge event :param key: Key of timer :param fields: Received fields
[ "Process", "a", "received", "gauge", "event" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L218-L234
train
65,459
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer.process_timer
def process_timer(self, key, fields): """ Process a received timer event :param key: Key of timer :param fields: Received fields """ try: if key not in self.timers: self.timers[key] = [] self.timers[key].append(float(fields[0])) ...
python
def process_timer(self, key, fields): """ Process a received timer event :param key: Key of timer :param fields: Received fields """ try: if key not in self.timers: self.timers[key] = [] self.timers[key].append(float(fields[0])) ...
[ "def", "process_timer", "(", "self", ",", "key", ",", "fields", ")", ":", "try", ":", "if", "key", "not", "in", "self", ".", "timers", ":", "self", ".", "timers", "[", "key", "]", "=", "[", "]", "self", ".", "timers", "[", "key", "]", ".", "app...
Process a received timer event :param key: Key of timer :param fields: Received fields
[ "Process", "a", "received", "timer", "event" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L236-L254
train
65,460
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer.process_counter
def process_counter(self, key, fields): """ Process a received counter event :param key: Key of counter :param fields: Received fields """ sample_rate = 1.0 try: if len(fields) is 3: if self.ratecheck.match(fields[2]): ...
python
def process_counter(self, key, fields): """ Process a received counter event :param key: Key of counter :param fields: Received fields """ sample_rate = 1.0 try: if len(fields) is 3: if self.ratecheck.match(fields[2]): ...
[ "def", "process_counter", "(", "self", ",", "key", ",", "fields", ")", ":", "sample_rate", "=", "1.0", "try", ":", "if", "len", "(", "fields", ")", "is", "3", ":", "if", "self", ".", "ratecheck", ".", "match", "(", "fields", "[", "2", "]", ")", "...
Process a received counter event :param key: Key of counter :param fields: Received fields
[ "Process", "a", "received", "counter", "event" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L256-L281
train
65,461
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer.process_timer_key
def process_timer_key(self, key, tstamp, stack, pickled=False): """Append the plain text graphite :param str key: The timer key to process :param int tstamp: The timestamp for the data point :param list stack: The stack of metrics to append the output to """ self.timers...
python
def process_timer_key(self, key, tstamp, stack, pickled=False): """Append the plain text graphite :param str key: The timer key to process :param int tstamp: The timestamp for the data point :param list stack: The stack of metrics to append the output to """ self.timers...
[ "def", "process_timer_key", "(", "self", ",", "key", ",", "tstamp", ",", "stack", ",", "pickled", "=", "False", ")", ":", "self", ".", "timers", "[", "key", "]", ".", "sort", "(", ")", "values", "=", "{", "'count'", ":", "len", "(", "self", ".", ...
Append the plain text graphite :param str key: The timer key to process :param int tstamp: The timestamp for the data point :param list stack: The stack of metrics to append the output to
[ "Append", "the", "plain", "text", "graphite" ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L283-L314
train
65,462
pandemicsyn/statsdpy
statsdpy/statsd.py
StatsdServer.decode_recvd
def decode_recvd(self, data): """ Decode and process the data from a received event. :param data: Data to decode and process. """ bits = data.split(':') if len(bits) == 2: key = self.keycheck.sub('_', bits[0]) fields = bits[1].split("|") ...
python
def decode_recvd(self, data): """ Decode and process the data from a received event. :param data: Data to decode and process. """ bits = data.split(':') if len(bits) == 2: key = self.keycheck.sub('_', bits[0]) fields = bits[1].split("|") ...
[ "def", "decode_recvd", "(", "self", ",", "data", ")", ":", "bits", "=", "data", ".", "split", "(", "':'", ")", "if", "len", "(", "bits", ")", "==", "2", ":", "key", "=", "self", ".", "keycheck", ".", "sub", "(", "'_'", ",", "bits", "[", "0", ...
Decode and process the data from a received event. :param data: Data to decode and process.
[ "Decode", "and", "process", "the", "data", "from", "a", "received", "event", "." ]
9cfccf89121fd6a12df20f17fa3eb8f618a36455
https://github.com/pandemicsyn/statsdpy/blob/9cfccf89121fd6a12df20f17fa3eb8f618a36455/statsdpy/statsd.py#L316-L339
train
65,463
juju-solutions/jujuresources
docs/exts/clidoc.py
CLIDoc._get_usage
def _get_usage(self): """ Build usage string from argparser args. """ parser = argparse.ArgumentParser() parser.prog = 'juju-resources {}'.format(self.object_name) for set_name, set_args in getattr(self.object, '_subcommand_argsets', {}).items(): for ap_args, ...
python
def _get_usage(self): """ Build usage string from argparser args. """ parser = argparse.ArgumentParser() parser.prog = 'juju-resources {}'.format(self.object_name) for set_name, set_args in getattr(self.object, '_subcommand_argsets', {}).items(): for ap_args, ...
[ "def", "_get_usage", "(", "self", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "prog", "=", "'juju-resources {}'", ".", "format", "(", "self", ".", "object_name", ")", "for", "set_name", ",", "set_args", "in", "getat...
Build usage string from argparser args.
[ "Build", "usage", "string", "from", "argparser", "args", "." ]
7d2c5f50981784cc4b5cde216b930f6d59c951a4
https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/docs/exts/clidoc.py#L15-L28
train
65,464
open-homeautomation/pknx
knxip/core.py
parse_group_address
def parse_group_address(addr): """Parse KNX group addresses and return the address as an integer. This allows to convert x/x/x and x/x address syntax to a numeric KNX group address """ if addr is None: raise KNXException("No address given") res = None if re.match('[0-9]+$', addr)...
python
def parse_group_address(addr): """Parse KNX group addresses and return the address as an integer. This allows to convert x/x/x and x/x address syntax to a numeric KNX group address """ if addr is None: raise KNXException("No address given") res = None if re.match('[0-9]+$', addr)...
[ "def", "parse_group_address", "(", "addr", ")", ":", "if", "addr", "is", "None", ":", "raise", "KNXException", "(", "\"No address given\"", ")", "res", "=", "None", "if", "re", ".", "match", "(", "'[0-9]+$'", ",", "addr", ")", ":", "res", "=", "int", "...
Parse KNX group addresses and return the address as an integer. This allows to convert x/x/x and x/x address syntax to a numeric KNX group address
[ "Parse", "KNX", "group", "addresses", "and", "return", "the", "address", "as", "an", "integer", "." ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/core.py#L21-L53
train
65,465
open-homeautomation/pknx
knxip/core.py
ValueCache.set
def set(self, name, value): """Set the cached value for the given name""" old_val = self.values.get(name) if old_val != value: self.values[name] = value return True else: return False
python
def set(self, name, value): """Set the cached value for the given name""" old_val = self.values.get(name) if old_val != value: self.values[name] = value return True else: return False
[ "def", "set", "(", "self", ",", "name", ",", "value", ")", ":", "old_val", "=", "self", ".", "values", ".", "get", "(", "name", ")", "if", "old_val", "!=", "value", ":", "self", ".", "values", "[", "name", "]", "=", "value", "return", "True", "el...
Set the cached value for the given name
[ "Set", "the", "cached", "value", "for", "the", "given", "name" ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/core.py#L67-L74
train
65,466
open-homeautomation/pknx
knxip/core.py
KNXMessage.sanitize
def sanitize(self): """Sanitize all fields of the KNX message.""" self.repeat = self.repeat % 2 self.priority = self.priority % 4 self.src_addr = self.src_addr % 0x10000 self.dst_addr = self.dst_addr % 0x10000 self.multicast = self.multicast % 2 self.routing = sel...
python
def sanitize(self): """Sanitize all fields of the KNX message.""" self.repeat = self.repeat % 2 self.priority = self.priority % 4 self.src_addr = self.src_addr % 0x10000 self.dst_addr = self.dst_addr % 0x10000 self.multicast = self.multicast % 2 self.routing = sel...
[ "def", "sanitize", "(", "self", ")", ":", "self", ".", "repeat", "=", "self", ".", "repeat", "%", "2", "self", ".", "priority", "=", "self", ".", "priority", "%", "4", "self", ".", "src_addr", "=", "self", ".", "src_addr", "%", "0x10000", "self", "...
Sanitize all fields of the KNX message.
[ "Sanitize", "all", "fields", "of", "the", "KNX", "message", "." ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/core.py#L129-L139
train
65,467
open-homeautomation/pknx
knxip/core.py
KNXMessage.to_frame
def to_frame(self): """Convert the object to its frame format.""" self.sanitize() res = [] res.append((1 << 7) + (1 << 4) + (self.repeat << 5) + (self.priority << 2)) res.append(self.src_addr >> 8) res.append(self.src_addr % 0x100) res.append(se...
python
def to_frame(self): """Convert the object to its frame format.""" self.sanitize() res = [] res.append((1 << 7) + (1 << 4) + (self.repeat << 5) + (self.priority << 2)) res.append(self.src_addr >> 8) res.append(self.src_addr % 0x100) res.append(se...
[ "def", "to_frame", "(", "self", ")", ":", "self", ".", "sanitize", "(", ")", "res", "=", "[", "]", "res", ".", "append", "(", "(", "1", "<<", "7", ")", "+", "(", "1", "<<", "4", ")", "+", "(", "self", ".", "repeat", "<<", "5", ")", "+", "...
Convert the object to its frame format.
[ "Convert", "the", "object", "to", "its", "frame", "format", "." ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/core.py#L141-L162
train
65,468
open-homeautomation/pknx
knxip/core.py
KNXMessage.from_frame
def from_frame(cls, frame): """Create a KNXMessage object from the frame format.""" message = cls() # Check checksum first checksum = 0 for i in range(0, len(frame) - 1): checksum += frame[i] if (checksum % 0x100) != frame[len(frame) - 1]: raise ...
python
def from_frame(cls, frame): """Create a KNXMessage object from the frame format.""" message = cls() # Check checksum first checksum = 0 for i in range(0, len(frame) - 1): checksum += frame[i] if (checksum % 0x100) != frame[len(frame) - 1]: raise ...
[ "def", "from_frame", "(", "cls", ",", "frame", ")", ":", "message", "=", "cls", "(", ")", "# Check checksum first", "checksum", "=", "0", "for", "i", "in", "range", "(", "0", ",", "len", "(", "frame", ")", "-", "1", ")", ":", "checksum", "+=", "fra...
Create a KNXMessage object from the frame format.
[ "Create", "a", "KNXMessage", "object", "from", "the", "frame", "format", "." ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/core.py#L165-L193
train
65,469
juicer/juicer
juicer/utils/Remotes.py
assemble_remotes
def assemble_remotes(resource): """ Using the specified input resource, assemble a list of rpm URLS. This function will, when given a remote package url, directory index, or a combination of the two in a local input file, do all the work required to turn that input into a list of only remote pa...
python
def assemble_remotes(resource): """ Using the specified input resource, assemble a list of rpm URLS. This function will, when given a remote package url, directory index, or a combination of the two in a local input file, do all the work required to turn that input into a list of only remote pa...
[ "def", "assemble_remotes", "(", "resource", ")", ":", "resource_type", "=", "classify_resource_type", "(", "resource", ")", "if", "resource_type", "is", "None", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"Could not classify or find the input r...
Using the specified input resource, assemble a list of rpm URLS. This function will, when given a remote package url, directory index, or a combination of the two in a local input file, do all the work required to turn that input into a list of only remote package URLs.
[ "Using", "the", "specified", "input", "resource", "assemble", "a", "list", "of", "rpm", "URLS", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/Remotes.py#L32-L54
train
65,470
juicer/juicer
juicer/utils/Remotes.py
classify_resource_type
def classify_resource_type(resource): """ Determine if the specified resource is remote or local. We can handle three remote resource types from the command line, remote RPMs, directory indexes, and input files. They're classified by matching the following patterns: - Remote RPMS start with ht...
python
def classify_resource_type(resource): """ Determine if the specified resource is remote or local. We can handle three remote resource types from the command line, remote RPMs, directory indexes, and input files. They're classified by matching the following patterns: - Remote RPMS start with ht...
[ "def", "classify_resource_type", "(", "resource", ")", ":", "if", "is_remote_package", "(", "resource", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"Classified %s as a remote package\"", "%", "resource", ")", "return", "REMOTE_PKG_TYPE", ...
Determine if the specified resource is remote or local. We can handle three remote resource types from the command line, remote RPMs, directory indexes, and input files. They're classified by matching the following patterns: - Remote RPMS start with http[s] and end with .RPM - Directory indexes st...
[ "Determine", "if", "the", "specified", "resource", "is", "remote", "or", "local", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/Remotes.py#L57-L80
train
65,471
juicer/juicer
juicer/utils/Remotes.py
is_remote_package
def is_remote_package(resource): """ Classify the input resource as a remote RPM or not. """ remote_regexp = re.compile(r"^https?://(.+).rpm$", re.I) result = remote_regexp.match(resource) if result is not None: juicer.utils.Log.log_debug("%s matches remote package regexp" % resource) ...
python
def is_remote_package(resource): """ Classify the input resource as a remote RPM or not. """ remote_regexp = re.compile(r"^https?://(.+).rpm$", re.I) result = remote_regexp.match(resource) if result is not None: juicer.utils.Log.log_debug("%s matches remote package regexp" % resource) ...
[ "def", "is_remote_package", "(", "resource", ")", ":", "remote_regexp", "=", "re", ".", "compile", "(", "r\"^https?://(.+).rpm$\"", ",", "re", ".", "I", ")", "result", "=", "remote_regexp", ".", "match", "(", "resource", ")", "if", "result", "is", "not", "...
Classify the input resource as a remote RPM or not.
[ "Classify", "the", "input", "resource", "as", "a", "remote", "RPM", "or", "not", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/Remotes.py#L83-L95
train
65,472
juicer/juicer
juicer/utils/Remotes.py
is_directory_index
def is_directory_index(resource): """ Classify the input resource as a directory index or not. """ remote_regexp = re.compile(r"^https?://(.+)/?$", re.I) result = remote_regexp.match(resource) if result is not None: juicer.utils.Log.log_debug("%s matches directory index regexp" % resour...
python
def is_directory_index(resource): """ Classify the input resource as a directory index or not. """ remote_regexp = re.compile(r"^https?://(.+)/?$", re.I) result = remote_regexp.match(resource) if result is not None: juicer.utils.Log.log_debug("%s matches directory index regexp" % resour...
[ "def", "is_directory_index", "(", "resource", ")", ":", "remote_regexp", "=", "re", ".", "compile", "(", "r\"^https?://(.+)/?$\"", ",", "re", ".", "I", ")", "result", "=", "remote_regexp", ".", "match", "(", "resource", ")", "if", "result", "is", "not", "N...
Classify the input resource as a directory index or not.
[ "Classify", "the", "input", "resource", "as", "a", "directory", "index", "or", "not", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/Remotes.py#L98-L110
train
65,473
juicer/juicer
juicer/utils/Remotes.py
parse_input_file
def parse_input_file(resource): """ Parse input file into remote packages and excluded data. In addition to garbage, excluded data includes directory indexes for the time being. This will be revisited after basic functionality has been fully implemented. """ input_resource = open(resource, ...
python
def parse_input_file(resource): """ Parse input file into remote packages and excluded data. In addition to garbage, excluded data includes directory indexes for the time being. This will be revisited after basic functionality has been fully implemented. """ input_resource = open(resource, ...
[ "def", "parse_input_file", "(", "resource", ")", ":", "input_resource", "=", "open", "(", "resource", ",", "'r'", ")", ".", "read", "(", ")", "remotes_list", "=", "[", "url", "for", "url", "in", "input_resource", ".", "split", "(", ")", "]", "juicer", ...
Parse input file into remote packages and excluded data. In addition to garbage, excluded data includes directory indexes for the time being. This will be revisited after basic functionality has been fully implemented.
[ "Parse", "input", "file", "into", "remote", "packages", "and", "excluded", "data", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/Remotes.py#L113-L135
train
65,474
juicer/juicer
juicer/utils/Remotes.py
parse_directory_index
def parse_directory_index(directory_index): """ Retrieve a directory index and make a list of the RPMs listed. """ # Normalize our URL style if not directory_index.endswith('/'): directory_index = directory_index + '/' site_index = urllib2.urlopen(directory_index) parsed_site_index ...
python
def parse_directory_index(directory_index): """ Retrieve a directory index and make a list of the RPMs listed. """ # Normalize our URL style if not directory_index.endswith('/'): directory_index = directory_index + '/' site_index = urllib2.urlopen(directory_index) parsed_site_index ...
[ "def", "parse_directory_index", "(", "directory_index", ")", ":", "# Normalize our URL style", "if", "not", "directory_index", ".", "endswith", "(", "'/'", ")", ":", "directory_index", "=", "directory_index", "+", "'/'", "site_index", "=", "urllib2", ".", "urlopen",...
Retrieve a directory index and make a list of the RPMs listed.
[ "Retrieve", "a", "directory", "index", "and", "make", "a", "list", "of", "the", "RPMs", "listed", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/Remotes.py#L138-L156
train
65,475
todbot/blink1-python
blink1/kelvin.py
kelvin_to_rgb
def kelvin_to_rgb(kelvin): """ Convert a color temperature given in kelvin to an approximate RGB value. :param kelvin: Color temp in K :return: Tuple of (r, g, b), equivalent color for the temperature """ temp = kelvin / 100.0 # Calculate Red: if temp <= 66: red = 255 else:...
python
def kelvin_to_rgb(kelvin): """ Convert a color temperature given in kelvin to an approximate RGB value. :param kelvin: Color temp in K :return: Tuple of (r, g, b), equivalent color for the temperature """ temp = kelvin / 100.0 # Calculate Red: if temp <= 66: red = 255 else:...
[ "def", "kelvin_to_rgb", "(", "kelvin", ")", ":", "temp", "=", "kelvin", "/", "100.0", "# Calculate Red:", "if", "temp", "<=", "66", ":", "red", "=", "255", "else", ":", "red", "=", "329.698727446", "*", "(", "(", "temp", "-", "60", ")", "**", "-", ...
Convert a color temperature given in kelvin to an approximate RGB value. :param kelvin: Color temp in K :return: Tuple of (r, g, b), equivalent color for the temperature
[ "Convert", "a", "color", "temperature", "given", "in", "kelvin", "to", "an", "approximate", "RGB", "value", "." ]
7a5183becd9662f88da3c29afd3447403f4ef82f
https://github.com/todbot/blink1-python/blob/7a5183becd9662f88da3c29afd3447403f4ef82f/blink1/kelvin.py#L37-L67
train
65,476
happyleavesaoc/python-limitlessled
limitlessled/group/rgbw.py
RgbwGroup.white
def white(self): """ Set color to white. """ self._color = RGB_WHITE cmd = self.command_set.white() self.send(cmd)
python
def white(self): """ Set color to white. """ self._color = RGB_WHITE cmd = self.command_set.white() self.send(cmd)
[ "def", "white", "(", "self", ")", ":", "self", ".", "_color", "=", "RGB_WHITE", "cmd", "=", "self", ".", "command_set", ".", "white", "(", ")", "self", ".", "send", "(", "cmd", ")" ]
Set color to white.
[ "Set", "color", "to", "white", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/rgbw.py#L53-L57
train
65,477
happyleavesaoc/python-limitlessled
limitlessled/group/rgbw.py
RgbwGroup.brightness
def brightness(self, brightness): """ Set the group brightness. :param brightness: Brightness in decimal percent (0.0-1.0). """ if brightness < 0 or brightness > 1: raise ValueError("Brightness must be a percentage " "represented as decimal 0-1.0...
python
def brightness(self, brightness): """ Set the group brightness. :param brightness: Brightness in decimal percent (0.0-1.0). """ if brightness < 0 or brightness > 1: raise ValueError("Brightness must be a percentage " "represented as decimal 0-1.0...
[ "def", "brightness", "(", "self", ",", "brightness", ")", ":", "if", "brightness", "<", "0", "or", "brightness", ">", "1", ":", "raise", "ValueError", "(", "\"Brightness must be a percentage \"", "\"represented as decimal 0-1.0\"", ")", "self", ".", "_brightness", ...
Set the group brightness. :param brightness: Brightness in decimal percent (0.0-1.0).
[ "Set", "the", "group", "brightness", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/rgbw.py#L73-L83
train
65,478
happyleavesaoc/python-limitlessled
limitlessled/group/rgbw.py
RgbwGroup.hue
def hue(self, hue): """ Set the group hue. :param hue: Hue in decimal percent (0.0-1.0). """ if hue < 0 or hue > 1: raise ValueError("Hue must be a percentage " "represented as decimal 0-1.0") self._hue = hue cmd = self.command_se...
python
def hue(self, hue): """ Set the group hue. :param hue: Hue in decimal percent (0.0-1.0). """ if hue < 0 or hue > 1: raise ValueError("Hue must be a percentage " "represented as decimal 0-1.0") self._hue = hue cmd = self.command_se...
[ "def", "hue", "(", "self", ",", "hue", ")", ":", "if", "hue", "<", "0", "or", "hue", ">", "1", ":", "raise", "ValueError", "(", "\"Hue must be a percentage \"", "\"represented as decimal 0-1.0\"", ")", "self", ".", "_hue", "=", "hue", "cmd", "=", "self", ...
Set the group hue. :param hue: Hue in decimal percent (0.0-1.0).
[ "Set", "the", "group", "hue", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/rgbw.py#L94-L104
train
65,479
open-homeautomation/pknx
knxip/timeupdater.py
KNXDateTimeUpdater.send_updates
def send_updates(self): """ Send updated to the KNX bus. """ d = datetime.now() if self.timeaddr: self.tunnel.group_write(self.timeaddr, time_to_knx(d)) if self.dateaddr: self.tunnel.group_write(self.dateaddr, ...
python
def send_updates(self): """ Send updated to the KNX bus. """ d = datetime.now() if self.timeaddr: self.tunnel.group_write(self.timeaddr, time_to_knx(d)) if self.dateaddr: self.tunnel.group_write(self.dateaddr, ...
[ "def", "send_updates", "(", "self", ")", ":", "d", "=", "datetime", ".", "now", "(", ")", "if", "self", ".", "timeaddr", ":", "self", ".", "tunnel", ".", "group_write", "(", "self", ".", "timeaddr", ",", "time_to_knx", "(", "d", ")", ")", "if", "se...
Send updated to the KNX bus.
[ "Send", "updated", "to", "the", "KNX", "bus", "." ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/timeupdater.py#L60-L81
train
65,480
open-homeautomation/pknx
knxip/timeupdater.py
KNXDateTimeUpdater.updater_loop
def updater_loop(self): """ Main loop that should run in the background. """ self.updater_running = True while (self.updater_running): self.send_updates() sleep(self.updateinterval)
python
def updater_loop(self): """ Main loop that should run in the background. """ self.updater_running = True while (self.updater_running): self.send_updates() sleep(self.updateinterval)
[ "def", "updater_loop", "(", "self", ")", ":", "self", ".", "updater_running", "=", "True", "while", "(", "self", ".", "updater_running", ")", ":", "self", ".", "send_updates", "(", ")", "sleep", "(", "self", ".", "updateinterval", ")" ]
Main loop that should run in the background.
[ "Main", "loop", "that", "should", "run", "in", "the", "background", "." ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/timeupdater.py#L83-L88
train
65,481
open-homeautomation/pknx
knxip/timeupdater.py
KNXDateTimeUpdater.run_updater_in_background
def run_updater_in_background(self): """ Starts a thread that runs the updater in the background. """ thread = threading.Thread(target=self.updater_loop()) thread.daemon = True thread.start()
python
def run_updater_in_background(self): """ Starts a thread that runs the updater in the background. """ thread = threading.Thread(target=self.updater_loop()) thread.daemon = True thread.start()
[ "def", "run_updater_in_background", "(", "self", ")", ":", "thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "updater_loop", "(", ")", ")", "thread", ".", "daemon", "=", "True", "thread", ".", "start", "(", ")" ]
Starts a thread that runs the updater in the background.
[ "Starts", "a", "thread", "that", "runs", "the", "updater", "in", "the", "background", "." ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/timeupdater.py#L90-L94
train
65,482
kdheepak/zip
zip/app/settings.py
parent_dir
def parent_dir(path): '''Return the parent of a directory.''' return os.path.abspath(os.path.join(path, os.pardir, os.pardir, '_build'))
python
def parent_dir(path): '''Return the parent of a directory.''' return os.path.abspath(os.path.join(path, os.pardir, os.pardir, '_build'))
[ "def", "parent_dir", "(", "path", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "path", ",", "os", ".", "pardir", ",", "os", ".", "pardir", ",", "'_build'", ")", ")" ]
Return the parent of a directory.
[ "Return", "the", "parent", "of", "a", "directory", "." ]
5c7f2400045d6ae2b3b4994577c73209562604a9
https://github.com/kdheepak/zip/blob/5c7f2400045d6ae2b3b4994577c73209562604a9/zip/app/settings.py#L11-L13
train
65,483
juicer/juicer
juicer/common/CartItem.py
CartItem.update
def update(self, path): """ Update the attributes of this CartItem. """ self._reset() self.path = path self._refresh_synced() if self.is_synced: self._refresh_path() self._refresh_signed() self._refresh_nvr()
python
def update(self, path): """ Update the attributes of this CartItem. """ self._reset() self.path = path self._refresh_synced() if self.is_synced: self._refresh_path() self._refresh_signed() self._refresh_nvr()
[ "def", "update", "(", "self", ",", "path", ")", ":", "self", ".", "_reset", "(", ")", "self", ".", "path", "=", "path", "self", ".", "_refresh_synced", "(", ")", "if", "self", ".", "is_synced", ":", "self", ".", "_refresh_path", "(", ")", "self", "...
Update the attributes of this CartItem.
[ "Update", "the", "attributes", "of", "this", "CartItem", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/CartItem.py#L44-L54
train
65,484
juicer/juicer
juicer/common/CartItem.py
CartItem.sync_to
def sync_to(self, destination): """ Sync an RPM from a REMOTE to a LOCAL path. Returns True if the item required a sync, False if it already existed locally. TODO: Remove dupe code in Cart.py:sync_remotes() """ rpm = RPM(self.path) rpm.sync(destination) ...
python
def sync_to(self, destination): """ Sync an RPM from a REMOTE to a LOCAL path. Returns True if the item required a sync, False if it already existed locally. TODO: Remove dupe code in Cart.py:sync_remotes() """ rpm = RPM(self.path) rpm.sync(destination) ...
[ "def", "sync_to", "(", "self", ",", "destination", ")", ":", "rpm", "=", "RPM", "(", "self", ".", "path", ")", "rpm", ".", "sync", "(", "destination", ")", "if", "rpm", ".", "modified", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "("...
Sync an RPM from a REMOTE to a LOCAL path. Returns True if the item required a sync, False if it already existed locally. TODO: Remove dupe code in Cart.py:sync_remotes()
[ "Sync", "an", "RPM", "from", "a", "REMOTE", "to", "a", "LOCAL", "path", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/CartItem.py#L63-L78
train
65,485
juicer/juicer
juicer/common/CartItem.py
CartItem._refresh_synced
def _refresh_synced(self): """ Update our is_synced attribute accordingly. """ if self.path.startswith('http'): juicer.utils.Log.log_debug("%s is not synced" % self.path) self.is_synced = False else: juicer.utils.Log.log_debug("%s is synced" % ...
python
def _refresh_synced(self): """ Update our is_synced attribute accordingly. """ if self.path.startswith('http'): juicer.utils.Log.log_debug("%s is not synced" % self.path) self.is_synced = False else: juicer.utils.Log.log_debug("%s is synced" % ...
[ "def", "_refresh_synced", "(", "self", ")", ":", "if", "self", ".", "path", ".", "startswith", "(", "'http'", ")", ":", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"%s is not synced\"", "%", "self", ".", "path", ")", "self", ".", "is_s...
Update our is_synced attribute accordingly.
[ "Update", "our", "is_synced", "attribute", "accordingly", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/CartItem.py#L80-L89
train
65,486
juicer/juicer
juicer/common/CartItem.py
CartItem._refresh_path
def _refresh_path(self): """ Does it exist? Can we read it? Is it an RPM? """ # Unsynced items are remote so we can't check some of their # properties yet if os.path.exists(self.path): try: i = open(self.path, 'r') i.close() jui...
python
def _refresh_path(self): """ Does it exist? Can we read it? Is it an RPM? """ # Unsynced items are remote so we can't check some of their # properties yet if os.path.exists(self.path): try: i = open(self.path, 'r') i.close() jui...
[ "def", "_refresh_path", "(", "self", ")", ":", "# Unsynced items are remote so we can't check some of their", "# properties yet", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "path", ")", ":", "try", ":", "i", "=", "open", "(", "self", ".", "path"...
Does it exist? Can we read it? Is it an RPM?
[ "Does", "it", "exist?", "Can", "we", "read", "it?", "Is", "it", "an", "RPM?" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/CartItem.py#L91-L103
train
65,487
juicer/juicer
juicer/common/CartItem.py
CartItem._refresh_nvr
def _refresh_nvr(self): """ Refresh our name-version-release attributes. """ rpm_info = juicer.utils.rpm_info(self.path) self.name = rpm_info['name'] self.version = rpm_info['version'] self.release = rpm_info['release']
python
def _refresh_nvr(self): """ Refresh our name-version-release attributes. """ rpm_info = juicer.utils.rpm_info(self.path) self.name = rpm_info['name'] self.version = rpm_info['version'] self.release = rpm_info['release']
[ "def", "_refresh_nvr", "(", "self", ")", ":", "rpm_info", "=", "juicer", ".", "utils", ".", "rpm_info", "(", "self", ".", "path", ")", "self", ".", "name", "=", "rpm_info", "[", "'name'", "]", "self", ".", "version", "=", "rpm_info", "[", "'version'", ...
Refresh our name-version-release attributes.
[ "Refresh", "our", "name", "-", "version", "-", "release", "attributes", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/CartItem.py#L105-L110
train
65,488
juicer/juicer
juicer/common/CartItem.py
CartItem._reset
def _reset(self): """ Used during update operations and when initialized. """ self.path = '' self.version = '' self.release = '' self.is_signed = False self.is_synced = False self.rpm = False
python
def _reset(self): """ Used during update operations and when initialized. """ self.path = '' self.version = '' self.release = '' self.is_signed = False self.is_synced = False self.rpm = False
[ "def", "_reset", "(", "self", ")", ":", "self", ".", "path", "=", "''", "self", ".", "version", "=", "''", "self", ".", "release", "=", "''", "self", ".", "is_signed", "=", "False", "self", ".", "is_synced", "=", "False", "self", ".", "rpm", "=", ...
Used during update operations and when initialized.
[ "Used", "during", "update", "operations", "and", "when", "initialized", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/CartItem.py#L119-L126
train
65,489
happyleavesaoc/python-limitlessled
limitlessled/__init__.py
LimitlessLED.add_bridge
def add_bridge(self, bridge): """ Add bridge groups. :param bridge: Add groups from this bridge. """ for group in bridge.groups: self._groups[group.name] = group
python
def add_bridge(self, bridge): """ Add bridge groups. :param bridge: Add groups from this bridge. """ for group in bridge.groups: self._groups[group.name] = group
[ "def", "add_bridge", "(", "self", ",", "bridge", ")", ":", "for", "group", "in", "bridge", ".", "groups", ":", "self", ".", "_groups", "[", "group", ".", "name", "]", "=", "group" ]
Add bridge groups. :param bridge: Add groups from this bridge.
[ "Add", "bridge", "groups", "." ]
70307c2bf8c91430a99579d2ad18b228ec7a8488
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/__init__.py#L36-L42
train
65,490
JustusW/harparser
harparser.py
HAREncodable.json
def json(self, json_string=None): """ Convenience method allowing easy dumping to and loading from json. """ if json_string is not None: return self.__init__(loads(json_string)) dump = self if isinstance(self, HAR.log): dump = {"log": dump} ...
python
def json(self, json_string=None): """ Convenience method allowing easy dumping to and loading from json. """ if json_string is not None: return self.__init__(loads(json_string)) dump = self if isinstance(self, HAR.log): dump = {"log": dump} ...
[ "def", "json", "(", "self", ",", "json_string", "=", "None", ")", ":", "if", "json_string", "is", "not", "None", ":", "return", "self", ".", "__init__", "(", "loads", "(", "json_string", ")", ")", "dump", "=", "self", "if", "isinstance", "(", "self", ...
Convenience method allowing easy dumping to and loading from json.
[ "Convenience", "method", "allowing", "easy", "dumping", "to", "and", "loading", "from", "json", "." ]
89f06b9e556ecfbab5202551fdcb13f1e1c69cfc
https://github.com/JustusW/harparser/blob/89f06b9e556ecfbab5202551fdcb13f1e1c69cfc/harparser.py#L97-L106
train
65,491
open-homeautomation/pknx
knxip/gatewayscanner.py
GatewayScanner.start_search
def start_search(self): """ Start the Gateway Search Request and return the address information :rtype: (string,int) :return: a tuple(string(IP),int(Port) when found or None when timeout occurs """ self._asyncio_loop = asyncio.get_event_loop() # Cre...
python
def start_search(self): """ Start the Gateway Search Request and return the address information :rtype: (string,int) :return: a tuple(string(IP),int(Port) when found or None when timeout occurs """ self._asyncio_loop = asyncio.get_event_loop() # Cre...
[ "def", "start_search", "(", "self", ")", ":", "self", ".", "_asyncio_loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "# Creating Broadcast Receiver", "coroutine_listen", "=", "self", ".", "_asyncio_loop", ".", "create_datagram_endpoint", "(", "lambda", ":", ...
Start the Gateway Search Request and return the address information :rtype: (string,int) :return: a tuple(string(IP),int(Port) when found or None when timeout occurs
[ "Start", "the", "Gateway", "Search", "Request", "and", "return", "the", "address", "information" ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/gatewayscanner.py#L69-L116
train
65,492
open-homeautomation/pknx
knxip/gatewayscanner.py
GatewayScanner._process_response
def _process_response(self, received_data): """ Processing the incoming UDP Datagram from the Broadcast Socket :param received_data: UDP Datagram Package to Process :type received_data: Byte """ resp = bytearray(received_data) self._resolved_gateway_ip_address = ...
python
def _process_response(self, received_data): """ Processing the incoming UDP Datagram from the Broadcast Socket :param received_data: UDP Datagram Package to Process :type received_data: Byte """ resp = bytearray(received_data) self._resolved_gateway_ip_address = ...
[ "def", "_process_response", "(", "self", ",", "received_data", ")", ":", "resp", "=", "bytearray", "(", "received_data", ")", "self", ".", "_resolved_gateway_ip_address", "=", "str", ".", "format", "(", "\"{}.{}.{}.{}\"", ",", "resp", "[", "8", "]", ",", "re...
Processing the incoming UDP Datagram from the Broadcast Socket :param received_data: UDP Datagram Package to Process :type received_data: Byte
[ "Processing", "the", "incoming", "UDP", "Datagram", "from", "the", "Broadcast", "Socket" ]
a8aed8271563923c447aa330ba7c1c2927286f7a
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/gatewayscanner.py#L126-L137
train
65,493
juicer/juicer
juicer/utils/Upload.py
Upload.append
def append(self, fdata, offset, query='/content/uploads'): """ append binary data to an upload `fdata` - binary data to send to pulp `offset` - the amount of previously-uploaded data """ query = '%s/%s/%s/' % (query, self.uid, offset) _r = self.connector.put(query...
python
def append(self, fdata, offset, query='/content/uploads'): """ append binary data to an upload `fdata` - binary data to send to pulp `offset` - the amount of previously-uploaded data """ query = '%s/%s/%s/' % (query, self.uid, offset) _r = self.connector.put(query...
[ "def", "append", "(", "self", ",", "fdata", ",", "offset", ",", "query", "=", "'/content/uploads'", ")", ":", "query", "=", "'%s/%s/%s/'", "%", "(", "query", ",", "self", ".", "uid", ",", "offset", ")", "_r", "=", "self", ".", "connector", ".", "put"...
append binary data to an upload `fdata` - binary data to send to pulp `offset` - the amount of previously-uploaded data
[ "append", "binary", "data", "to", "an", "upload", "fdata", "-", "binary", "data", "to", "send", "to", "pulp", "offset", "-", "the", "amount", "of", "previously", "-", "uploaded", "data" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/Upload.py#L47-L59
train
65,494
juicer/juicer
juicer/utils/Upload.py
Upload.import_upload
def import_upload(self, nvrea, ftype='rpm', rpm_name='', desc=None, htype='md5', lic=None, group=None, vendor=None, req=None): """ import the completed upload into pulp `ftype` - the type of the upload `rpm_name` - the name of the uploaded rpm `desc` - description of the rpm ...
python
def import_upload(self, nvrea, ftype='rpm', rpm_name='', desc=None, htype='md5', lic=None, group=None, vendor=None, req=None): """ import the completed upload into pulp `ftype` - the type of the upload `rpm_name` - the name of the uploaded rpm `desc` - description of the rpm ...
[ "def", "import_upload", "(", "self", ",", "nvrea", ",", "ftype", "=", "'rpm'", ",", "rpm_name", "=", "''", ",", "desc", "=", "None", ",", "htype", "=", "'md5'", ",", "lic", "=", "None", ",", "group", "=", "None", ",", "vendor", "=", "None", ",", ...
import the completed upload into pulp `ftype` - the type of the upload `rpm_name` - the name of the uploaded rpm `desc` - description of the rpm `htype` - checksum type `lic` - license used in the packaged software `group` - package group `vendor` - software vendo...
[ "import", "the", "completed", "upload", "into", "pulp", "ftype", "-", "the", "type", "of", "the", "upload", "rpm_name", "-", "the", "name", "of", "the", "uploaded", "rpm", "desc", "-", "description", "of", "the", "rpm", "htype", "-", "checksum", "type", ...
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/Upload.py#L61-L104
train
65,495
juicer/juicer
juicer/utils/Upload.py
Upload.clean_upload
def clean_upload(self, query='/content/uploads/'): """ pulp leaves droppings if you don't specifically tell it to clean up after itself. use this to do so. """ query = query + self.uid + '/' _r = self.connector.delete(query) if _r.status_code == Constants.PULP_DE...
python
def clean_upload(self, query='/content/uploads/'): """ pulp leaves droppings if you don't specifically tell it to clean up after itself. use this to do so. """ query = query + self.uid + '/' _r = self.connector.delete(query) if _r.status_code == Constants.PULP_DE...
[ "def", "clean_upload", "(", "self", ",", "query", "=", "'/content/uploads/'", ")", ":", "query", "=", "query", "+", "self", ".", "uid", "+", "'/'", "_r", "=", "self", ".", "connector", ".", "delete", "(", "query", ")", "if", "_r", ".", "status_code", ...
pulp leaves droppings if you don't specifically tell it to clean up after itself. use this to do so.
[ "pulp", "leaves", "droppings", "if", "you", "don", "t", "specifically", "tell", "it", "to", "clean", "up", "after", "itself", ".", "use", "this", "to", "do", "so", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/Upload.py#L106-L117
train
65,496
juicer/juicer
juicer/utils/__init__.py
_user_config_file
def _user_config_file(): """ Check that the config file is present and readable. If not, copy a template in place. """ config_file = Constants.USER_CONFIG if os.path.exists(config_file) and os.access(config_file, os.R_OK): return config_file elif os.path.exists(config_file) and not o...
python
def _user_config_file(): """ Check that the config file is present and readable. If not, copy a template in place. """ config_file = Constants.USER_CONFIG if os.path.exists(config_file) and os.access(config_file, os.R_OK): return config_file elif os.path.exists(config_file) and not o...
[ "def", "_user_config_file", "(", ")", ":", "config_file", "=", "Constants", ".", "USER_CONFIG", "if", "os", ".", "path", ".", "exists", "(", "config_file", ")", "and", "os", ".", "access", "(", "config_file", ",", "os", ".", "R_OK", ")", ":", "return", ...
Check that the config file is present and readable. If not, copy a template in place.
[ "Check", "that", "the", "config", "file", "is", "present", "and", "readable", ".", "If", "not", "copy", "a", "template", "in", "place", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/__init__.py#L70-L83
train
65,497
juicer/juicer
juicer/utils/__init__.py
cart_db
def cart_db(): """ return a pymongo db connection for interacting with cart objects """ config = _config_file() _config_test(config) juicer.utils.Log.log_debug("Establishing cart connection:") cart_con = MongoClient(dict(config.items(config.sections()[0]))['cart_host']) cart_db = cart_c...
python
def cart_db(): """ return a pymongo db connection for interacting with cart objects """ config = _config_file() _config_test(config) juicer.utils.Log.log_debug("Establishing cart connection:") cart_con = MongoClient(dict(config.items(config.sections()[0]))['cart_host']) cart_db = cart_c...
[ "def", "cart_db", "(", ")", ":", "config", "=", "_config_file", "(", ")", "_config_test", "(", "config", ")", "juicer", ".", "utils", ".", "Log", ".", "log_debug", "(", "\"Establishing cart connection:\"", ")", "cart_con", "=", "MongoClient", "(", "dict", "(...
return a pymongo db connection for interacting with cart objects
[ "return", "a", "pymongo", "db", "connection", "for", "interacting", "with", "cart", "objects" ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/__init__.py#L123-L134
train
65,498
juicer/juicer
juicer/utils/__init__.py
upload_cart
def upload_cart(cart, collection): """ Connect to mongo and store your cart in the specified collection. """ cart_cols = cart_db() cart_json = read_json_document(cart.cart_file()) try: cart_id = cart_cols[collection].save(cart_json) except MongoErrors.AutoReconnect: raise Ju...
python
def upload_cart(cart, collection): """ Connect to mongo and store your cart in the specified collection. """ cart_cols = cart_db() cart_json = read_json_document(cart.cart_file()) try: cart_id = cart_cols[collection].save(cart_json) except MongoErrors.AutoReconnect: raise Ju...
[ "def", "upload_cart", "(", "cart", ",", "collection", ")", ":", "cart_cols", "=", "cart_db", "(", ")", "cart_json", "=", "read_json_document", "(", "cart", ".", "cart_file", "(", ")", ")", "try", ":", "cart_id", "=", "cart_cols", "[", "collection", "]", ...
Connect to mongo and store your cart in the specified collection.
[ "Connect", "to", "mongo", "and", "store", "your", "cart", "in", "the", "specified", "collection", "." ]
0c9f0fd59e293d45df6b46e81f675d33221c600d
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/__init__.py#L137-L148
train
65,499