id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
11,600
pklaus/brother_ql
brother_ql/backends/helpers.py
send
def send(instructions, printer_identifier=None, backend_identifier=None, blocking=True): """ Send instruction bytes to a printer. :param bytes instructions: The instructions to be sent to the printer. :param str printer_identifier: Identifier for the printer. :param str backend_identifier: Can enfo...
python
def send(instructions, printer_identifier=None, backend_identifier=None, blocking=True): """ Send instruction bytes to a printer. :param bytes instructions: The instructions to be sent to the printer. :param str printer_identifier: Identifier for the printer. :param str backend_identifier: Can enfo...
[ "def", "send", "(", "instructions", ",", "printer_identifier", "=", "None", ",", "backend_identifier", "=", "None", ",", "blocking", "=", "True", ")", ":", "status", "=", "{", "'instructions_sent'", ":", "True", ",", "# The instructions were sent to the printer.", ...
Send instruction bytes to a printer. :param bytes instructions: The instructions to be sent to the printer. :param str printer_identifier: Identifier for the printer. :param str backend_identifier: Can enforce the use of a specific backend. :param bool blocking: Indicates whether the function call shou...
[ "Send", "instruction", "bytes", "to", "a", "printer", "." ]
b551b1fc944873f3a2ead7032d144dfd81011e79
https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/backends/helpers.py#L26-L103
11,601
pklaus/brother_ql
brother_ql/reader.py
merge_specific_instructions
def merge_specific_instructions(chunks, join_preamble=True, join_raster=True): """ Process a list of instructions by merging subsequent instuctions with identical opcodes into "large instructions". """ new_instructions = [] last_opcode = None instruction_buffer = b'' for instruction in c...
python
def merge_specific_instructions(chunks, join_preamble=True, join_raster=True): """ Process a list of instructions by merging subsequent instuctions with identical opcodes into "large instructions". """ new_instructions = [] last_opcode = None instruction_buffer = b'' for instruction in c...
[ "def", "merge_specific_instructions", "(", "chunks", ",", "join_preamble", "=", "True", ",", "join_raster", "=", "True", ")", ":", "new_instructions", "=", "[", "]", "last_opcode", "=", "None", "instruction_buffer", "=", "b''", "for", "instruction", "in", "chunk...
Process a list of instructions by merging subsequent instuctions with identical opcodes into "large instructions".
[ "Process", "a", "list", "of", "instructions", "by", "merging", "subsequent", "instuctions", "with", "identical", "opcodes", "into", "large", "instructions", "." ]
b551b1fc944873f3a2ead7032d144dfd81011e79
https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/reader.py#L209-L230
11,602
pklaus/brother_ql
brother_ql/cli.py
cli
def cli(ctx, *args, **kwargs): """ Command line interface for the brother_ql Python package. """ backend = kwargs.get('backend', None) model = kwargs.get('model', None) printer = kwargs.get('printer', None) debug = kwargs.get('debug') # Store the general CLI options in the context meta diction...
python
def cli(ctx, *args, **kwargs): """ Command line interface for the brother_ql Python package. """ backend = kwargs.get('backend', None) model = kwargs.get('model', None) printer = kwargs.get('printer', None) debug = kwargs.get('debug') # Store the general CLI options in the context meta diction...
[ "def", "cli", "(", "ctx", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "backend", "=", "kwargs", ".", "get", "(", "'backend'", ",", "None", ")", "model", "=", "kwargs", ".", "get", "(", "'model'", ",", "None", ")", "printer", "=", "kwargs...
Command line interface for the brother_ql Python package.
[ "Command", "line", "interface", "for", "the", "brother_ql", "Python", "package", "." ]
b551b1fc944873f3a2ead7032d144dfd81011e79
https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/cli.py#L26-L40
11,603
pklaus/brother_ql
brother_ql/cli.py
env
def env(ctx, *args, **kwargs): """ print debug info about running environment """ import sys, platform, os, shutil from pkg_resources import get_distribution, working_set print("\n##################\n") print("Information about the running environment of brother_ql.") print("(Please prov...
python
def env(ctx, *args, **kwargs): """ print debug info about running environment """ import sys, platform, os, shutil from pkg_resources import get_distribution, working_set print("\n##################\n") print("Information about the running environment of brother_ql.") print("(Please prov...
[ "def", "env", "(", "ctx", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "sys", ",", "platform", ",", "os", ",", "shutil", "from", "pkg_resources", "import", "get_distribution", ",", "working_set", "print", "(", "\"\\n##################\\n\""...
print debug info about running environment
[ "print", "debug", "info", "about", "running", "environment" ]
b551b1fc944873f3a2ead7032d144dfd81011e79
https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/cli.py#L81-L120
11,604
pklaus/brother_ql
brother_ql/cli.py
print_cmd
def print_cmd(ctx, *args, **kwargs): """ Print a label of the provided IMAGE. """ backend = ctx.meta.get('BACKEND', 'pyusb') model = ctx.meta.get('MODEL') printer = ctx.meta.get('PRINTER') from brother_ql.conversion import convert from brother_ql.backends.helpers import send from brother_ql....
python
def print_cmd(ctx, *args, **kwargs): """ Print a label of the provided IMAGE. """ backend = ctx.meta.get('BACKEND', 'pyusb') model = ctx.meta.get('MODEL') printer = ctx.meta.get('PRINTER') from brother_ql.conversion import convert from brother_ql.backends.helpers import send from brother_ql....
[ "def", "print_cmd", "(", "ctx", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "backend", "=", "ctx", ".", "meta", ".", "get", "(", "'BACKEND'", ",", "'pyusb'", ")", "model", "=", "ctx", ".", "meta", ".", "get", "(", "'MODEL'", ")", "printe...
Print a label of the provided IMAGE.
[ "Print", "a", "label", "of", "the", "provided", "IMAGE", "." ]
b551b1fc944873f3a2ead7032d144dfd81011e79
https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/cli.py#L134-L147
11,605
pklaus/brother_ql
brother_ql/backends/pyusb.py
list_available_devices
def list_available_devices(): """ List all available devices for the respective backend returns: devices: a list of dictionaries with the keys 'identifier' and 'instance': \ [ {'identifier': 'usb://0x04f9:0x2015/C5Z315686', 'instance': pyusb.core.Device()}, ] The 'identifier' is of the form...
python
def list_available_devices(): """ List all available devices for the respective backend returns: devices: a list of dictionaries with the keys 'identifier' and 'instance': \ [ {'identifier': 'usb://0x04f9:0x2015/C5Z315686', 'instance': pyusb.core.Device()}, ] The 'identifier' is of the form...
[ "def", "list_available_devices", "(", ")", ":", "class", "find_class", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "class_", ")", ":", "self", ".", "_class", "=", "class_", "def", "__call__", "(", "self", ",", "device", ")", ":", "# f...
List all available devices for the respective backend returns: devices: a list of dictionaries with the keys 'identifier' and 'instance': \ [ {'identifier': 'usb://0x04f9:0x2015/C5Z315686', 'instance': pyusb.core.Device()}, ] The 'identifier' is of the format idVendor:idProduct_iSerialNumber.
[ "List", "all", "available", "devices", "for", "the", "respective", "backend" ]
b551b1fc944873f3a2ead7032d144dfd81011e79
https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/backends/pyusb.py#L21-L55
11,606
pklaus/brother_ql
brother_ql/devicedependent.py
_populate_label_legacy_structures
def _populate_label_legacy_structures(): """ We contain this code inside a function so that the imports we do in here are not visible at the module level. """ global DIE_CUT_LABEL, ENDLESS_LABEL, ROUND_DIE_CUT_LABEL global label_sizes, label_type_specs from brother_ql.labels import FormFact...
python
def _populate_label_legacy_structures(): """ We contain this code inside a function so that the imports we do in here are not visible at the module level. """ global DIE_CUT_LABEL, ENDLESS_LABEL, ROUND_DIE_CUT_LABEL global label_sizes, label_type_specs from brother_ql.labels import FormFact...
[ "def", "_populate_label_legacy_structures", "(", ")", ":", "global", "DIE_CUT_LABEL", ",", "ENDLESS_LABEL", ",", "ROUND_DIE_CUT_LABEL", "global", "label_sizes", ",", "label_type_specs", "from", "brother_ql", ".", "labels", "import", "FormFactor", "DIE_CUT_LABEL", "=", "...
We contain this code inside a function so that the imports we do in here are not visible at the module level.
[ "We", "contain", "this", "code", "inside", "a", "function", "so", "that", "the", "imports", "we", "do", "in", "here", "are", "not", "visible", "at", "the", "module", "level", "." ]
b551b1fc944873f3a2ead7032d144dfd81011e79
https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/devicedependent.py#L59-L86
11,607
pklaus/brother_ql
brother_ql/backends/__init__.py
guess_backend
def guess_backend(identifier): """ guess the backend from a given identifier string for the device """ if identifier.startswith('usb://') or identifier.startswith('0x'): return 'pyusb' elif identifier.startswith('file://') or identifier.startswith('/dev/usb/') or identifier.startswith('lp'): ...
python
def guess_backend(identifier): """ guess the backend from a given identifier string for the device """ if identifier.startswith('usb://') or identifier.startswith('0x'): return 'pyusb' elif identifier.startswith('file://') or identifier.startswith('/dev/usb/') or identifier.startswith('lp'): ...
[ "def", "guess_backend", "(", "identifier", ")", ":", "if", "identifier", ".", "startswith", "(", "'usb://'", ")", "or", "identifier", ".", "startswith", "(", "'0x'", ")", ":", "return", "'pyusb'", "elif", "identifier", ".", "startswith", "(", "'file://'", ")...
guess the backend from a given identifier string for the device
[ "guess", "the", "backend", "from", "a", "given", "identifier", "string", "for", "the", "device" ]
b551b1fc944873f3a2ead7032d144dfd81011e79
https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/backends/__init__.py#L11-L20
11,608
gfairchild/yelpapi
yelpapi/yelpapi.py
YelpAPI.featured_event_query
def featured_event_query(self, **kwargs): """ Query the Yelp Featured Event API. documentation: https://www.yelp.com/developers/documentation/v3/featured_event required parameters: * one of either: * location - text specifying a location ...
python
def featured_event_query(self, **kwargs): """ Query the Yelp Featured Event API. documentation: https://www.yelp.com/developers/documentation/v3/featured_event required parameters: * one of either: * location - text specifying a location ...
[ "def", "featured_event_query", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "kwargs", ".", "get", "(", "'location'", ")", "and", "(", "not", "kwargs", ".", "get", "(", "'latitude'", ")", "or", "not", "kwargs", ".", "get", "(", "'longi...
Query the Yelp Featured Event API. documentation: https://www.yelp.com/developers/documentation/v3/featured_event required parameters: * one of either: * location - text specifying a location to search for * latitude and longitude
[ "Query", "the", "Yelp", "Featured", "Event", "API", "." ]
51e35fbe44ac131630ce5e2f1b6f53711846e2a7
https://github.com/gfairchild/yelpapi/blob/51e35fbe44ac131630ce5e2f1b6f53711846e2a7/yelpapi/yelpapi.py#L174-L189
11,609
gfairchild/yelpapi
yelpapi/yelpapi.py
YelpAPI._get_clean_parameters
def _get_clean_parameters(kwargs): """ Clean the parameters by filtering out any parameters that have a None value. """ return dict((k, v) for k, v in kwargs.items() if v is not None)
python
def _get_clean_parameters(kwargs): """ Clean the parameters by filtering out any parameters that have a None value. """ return dict((k, v) for k, v in kwargs.items() if v is not None)
[ "def", "_get_clean_parameters", "(", "kwargs", ")", ":", "return", "dict", "(", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", "if", "v", "is", "not", "None", ")" ]
Clean the parameters by filtering out any parameters that have a None value.
[ "Clean", "the", "parameters", "by", "filtering", "out", "any", "parameters", "that", "have", "a", "None", "value", "." ]
51e35fbe44ac131630ce5e2f1b6f53711846e2a7
https://github.com/gfairchild/yelpapi/blob/51e35fbe44ac131630ce5e2f1b6f53711846e2a7/yelpapi/yelpapi.py#L258-L262
11,610
gfairchild/yelpapi
yelpapi/yelpapi.py
YelpAPI._query
def _query(self, url, **kwargs): """ All query methods have the same logic, so don't repeat it! Query the URL, parse the response as JSON, and check for errors. If all goes well, return the parsed JSON. """ parameters = YelpAPI._get_clean_parameters(kwargs) respon...
python
def _query(self, url, **kwargs): """ All query methods have the same logic, so don't repeat it! Query the URL, parse the response as JSON, and check for errors. If all goes well, return the parsed JSON. """ parameters = YelpAPI._get_clean_parameters(kwargs) respon...
[ "def", "_query", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "parameters", "=", "YelpAPI", ".", "_get_clean_parameters", "(", "kwargs", ")", "response", "=", "self", ".", "_yelp_session", ".", "get", "(", "url", ",", "headers", "=", "se...
All query methods have the same logic, so don't repeat it! Query the URL, parse the response as JSON, and check for errors. If all goes well, return the parsed JSON.
[ "All", "query", "methods", "have", "the", "same", "logic", "so", "don", "t", "repeat", "it!", "Query", "the", "URL", "parse", "the", "response", "as", "JSON", "and", "check", "for", "errors", ".", "If", "all", "goes", "well", "return", "the", "parsed", ...
51e35fbe44ac131630ce5e2f1b6f53711846e2a7
https://github.com/gfairchild/yelpapi/blob/51e35fbe44ac131630ce5e2f1b6f53711846e2a7/yelpapi/yelpapi.py#L264-L286
11,611
samgiles/slumber
slumber/utils.py
url_join
def url_join(base, *args): """ Helper function to join an arbitrary number of url segments together. """ scheme, netloc, path, query, fragment = urlsplit(base) path = path if len(path) else "/" path = posixpath.join(path, *[('%s' % x) for x in args]) return urlunsplit([scheme, netloc, path, ...
python
def url_join(base, *args): """ Helper function to join an arbitrary number of url segments together. """ scheme, netloc, path, query, fragment = urlsplit(base) path = path if len(path) else "/" path = posixpath.join(path, *[('%s' % x) for x in args]) return urlunsplit([scheme, netloc, path, ...
[ "def", "url_join", "(", "base", ",", "*", "args", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "fragment", "=", "urlsplit", "(", "base", ")", "path", "=", "path", "if", "len", "(", "path", ")", "else", "\"/\"", "path", "=", ...
Helper function to join an arbitrary number of url segments together.
[ "Helper", "function", "to", "join", "an", "arbitrary", "number", "of", "url", "segments", "together", "." ]
af0f9ef7bd8df8bde6b47088630786c737869bce
https://github.com/samgiles/slumber/blob/af0f9ef7bd8df8bde6b47088630786c737869bce/slumber/utils.py#L9-L16
11,612
20c/vaping
vaping/plugins/vodka.py
probe_to_graphsrv
def probe_to_graphsrv(probe): """ takes a probe instance and generates a graphsrv data group for it using the probe's config """ config = probe.config # manual group set up via `group` config key if "group" in config: source, group = config["group"].split(".") group_fi...
python
def probe_to_graphsrv(probe): """ takes a probe instance and generates a graphsrv data group for it using the probe's config """ config = probe.config # manual group set up via `group` config key if "group" in config: source, group = config["group"].split(".") group_fi...
[ "def", "probe_to_graphsrv", "(", "probe", ")", ":", "config", "=", "probe", ".", "config", "# manual group set up via `group` config key", "if", "\"group\"", "in", "config", ":", "source", ",", "group", "=", "config", "[", "\"group\"", "]", ".", "split", "(", ...
takes a probe instance and generates a graphsrv data group for it using the probe's config
[ "takes", "a", "probe", "instance", "and", "generates", "a", "graphsrv", "data", "group", "for", "it", "using", "the", "probe", "s", "config" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/vodka.py#L20-L49
11,613
20c/vaping
vaping/plugins/__init__.py
PluginBase.new_message
def new_message(self): """ creates a new message, setting `type`, `source`, `ts`, `data` - `data` is initialized to an empty array """ msg = {} msg['data'] = [] msg['type'] = self.plugin_type msg['source'] = self.name msg['ts'] = (datetime.datetime...
python
def new_message(self): """ creates a new message, setting `type`, `source`, `ts`, `data` - `data` is initialized to an empty array """ msg = {} msg['data'] = [] msg['type'] = self.plugin_type msg['source'] = self.name msg['ts'] = (datetime.datetime...
[ "def", "new_message", "(", "self", ")", ":", "msg", "=", "{", "}", "msg", "[", "'data'", "]", "=", "[", "]", "msg", "[", "'type'", "]", "=", "self", ".", "plugin_type", "msg", "[", "'source'", "]", "=", "self", ".", "name", "msg", "[", "'ts'", ...
creates a new message, setting `type`, `source`, `ts`, `data` - `data` is initialized to an empty array
[ "creates", "a", "new", "message", "setting", "type", "source", "ts", "data", "-", "data", "is", "initialized", "to", "an", "empty", "array" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L51-L61
11,614
20c/vaping
vaping/plugins/__init__.py
PluginBase.popen
def popen(self, args, **kwargs): """ creates a subprocess with passed args """ self.log.debug("popen %s", ' '.join(args)) return vaping.io.subprocess.Popen(args, **kwargs)
python
def popen(self, args, **kwargs): """ creates a subprocess with passed args """ self.log.debug("popen %s", ' '.join(args)) return vaping.io.subprocess.Popen(args, **kwargs)
[ "def", "popen", "(", "self", ",", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "log", ".", "debug", "(", "\"popen %s\"", ",", "' '", ".", "join", "(", "args", ")", ")", "return", "vaping", ".", "io", ".", "subprocess", ".", "Popen", "(...
creates a subprocess with passed args
[ "creates", "a", "subprocess", "with", "passed", "args" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L63-L68
11,615
20c/vaping
vaping/plugins/__init__.py
ProbeBase.queue_emission
def queue_emission(self, msg): """ queue an emission of a message for all output plugins """ if not msg: return for _emitter in self._emit: if not hasattr(_emitter, 'emit'): continue def emit(emitter=_emitter): s...
python
def queue_emission(self, msg): """ queue an emission of a message for all output plugins """ if not msg: return for _emitter in self._emit: if not hasattr(_emitter, 'emit'): continue def emit(emitter=_emitter): s...
[ "def", "queue_emission", "(", "self", ",", "msg", ")", ":", "if", "not", "msg", ":", "return", "for", "_emitter", "in", "self", ".", "_emit", ":", "if", "not", "hasattr", "(", "_emitter", ",", "'emit'", ")", ":", "continue", "def", "emit", "(", "emit...
queue an emission of a message for all output plugins
[ "queue", "an", "emission", "of", "a", "message", "for", "all", "output", "plugins" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L131-L145
11,616
20c/vaping
vaping/plugins/__init__.py
ProbeBase.send_emission
def send_emission(self): """ emit and remove the first emission in the queue """ if self._emit_queue.empty(): return emit = self._emit_queue.get() emit()
python
def send_emission(self): """ emit and remove the first emission in the queue """ if self._emit_queue.empty(): return emit = self._emit_queue.get() emit()
[ "def", "send_emission", "(", "self", ")", ":", "if", "self", ".", "_emit_queue", ".", "empty", "(", ")", ":", "return", "emit", "=", "self", ".", "_emit_queue", ".", "get", "(", ")", "emit", "(", ")" ]
emit and remove the first emission in the queue
[ "emit", "and", "remove", "the", "first", "emission", "in", "the", "queue" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L147-L154
11,617
20c/vaping
vaping/plugins/__init__.py
FileProbe.validate_file_handler
def validate_file_handler(self): """ Here we validate that our filehandler is pointing to an existing file. If it doesnt, because file has been deleted, we close the filehander and try to reopen """ if self.fh.closed: try: self.fh = op...
python
def validate_file_handler(self): """ Here we validate that our filehandler is pointing to an existing file. If it doesnt, because file has been deleted, we close the filehander and try to reopen """ if self.fh.closed: try: self.fh = op...
[ "def", "validate_file_handler", "(", "self", ")", ":", "if", "self", ".", "fh", ".", "closed", ":", "try", ":", "self", ".", "fh", "=", "open", "(", "self", ".", "path", ",", "\"r\"", ")", "self", ".", "fh", ".", "seek", "(", "0", ",", "2", ")"...
Here we validate that our filehandler is pointing to an existing file. If it doesnt, because file has been deleted, we close the filehander and try to reopen
[ "Here", "we", "validate", "that", "our", "filehandler", "is", "pointing", "to", "an", "existing", "file", "." ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L245-L273
11,618
20c/vaping
vaping/plugins/__init__.py
FileProbe.probe
def probe(self): """ Probe the file for new lines """ # make sure the filehandler is still valid # (e.g. file stat hasnt changed, file exists etc.) if not self.validate_file_handler(): return [] messages = [] # read any new lines and push th...
python
def probe(self): """ Probe the file for new lines """ # make sure the filehandler is still valid # (e.g. file stat hasnt changed, file exists etc.) if not self.validate_file_handler(): return [] messages = [] # read any new lines and push th...
[ "def", "probe", "(", "self", ")", ":", "# make sure the filehandler is still valid", "# (e.g. file stat hasnt changed, file exists etc.)", "if", "not", "self", ".", "validate_file_handler", "(", ")", ":", "return", "[", "]", "messages", "=", "[", "]", "# read any new li...
Probe the file for new lines
[ "Probe", "the", "file", "for", "new", "lines" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L276-L310
11,619
20c/vaping
vaping/plugins/__init__.py
TimeSeriesDB.filename_formatters
def filename_formatters(self, data, row): """ Returns a dict containing the various filename formatter values Values are gotten from the vaping data message as well as the currently processed row in the message - `data`: vaping message - `row`: vaping message data row ...
python
def filename_formatters(self, data, row): """ Returns a dict containing the various filename formatter values Values are gotten from the vaping data message as well as the currently processed row in the message - `data`: vaping message - `row`: vaping message data row ...
[ "def", "filename_formatters", "(", "self", ",", "data", ",", "row", ")", ":", "r", "=", "{", "\"source\"", ":", "data", ".", "get", "(", "\"source\"", ")", ",", "\"field\"", ":", "self", ".", "field", ",", "\"type\"", ":", "data", ".", "get", "(", ...
Returns a dict containing the various filename formatter values Values are gotten from the vaping data message as well as the currently processed row in the message - `data`: vaping message - `row`: vaping message data row
[ "Returns", "a", "dict", "containing", "the", "various", "filename", "formatter", "values" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L394-L411
11,620
20c/vaping
vaping/plugins/__init__.py
TimeSeriesDB.format_filename
def format_filename(self, data, row): """ Returns a formatted filename using the template stored in self.filename - `data`: vaping message - `row`: vaping message data row """ return self.filename.format(**self.filename_formatters(data, row))
python
def format_filename(self, data, row): """ Returns a formatted filename using the template stored in self.filename - `data`: vaping message - `row`: vaping message data row """ return self.filename.format(**self.filename_formatters(data, row))
[ "def", "format_filename", "(", "self", ",", "data", ",", "row", ")", ":", "return", "self", ".", "filename", ".", "format", "(", "*", "*", "self", ".", "filename_formatters", "(", "data", ",", "row", ")", ")" ]
Returns a formatted filename using the template stored in self.filename - `data`: vaping message - `row`: vaping message data row
[ "Returns", "a", "formatted", "filename", "using", "the", "template", "stored", "in", "self", ".", "filename" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L413-L421
11,621
20c/vaping
vaping/plugins/__init__.py
TimeSeriesDB.emit
def emit(self, message): """ emit to database """ # handle vaping data that arrives in a list if isinstance(message.get("data"), list): for row in message.get("data"): # format filename from data filename = self.format_filename(messag...
python
def emit(self, message): """ emit to database """ # handle vaping data that arrives in a list if isinstance(message.get("data"), list): for row in message.get("data"): # format filename from data filename = self.format_filename(messag...
[ "def", "emit", "(", "self", ",", "message", ")", ":", "# handle vaping data that arrives in a list", "if", "isinstance", "(", "message", ".", "get", "(", "\"data\"", ")", ",", "list", ")", ":", "for", "row", "in", "message", ".", "get", "(", "\"data\"", ")...
emit to database
[ "emit", "to", "database" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L423-L442
11,622
20c/vaping
vaping/config.py
parse_interval
def parse_interval(val): """ converts a string to float of seconds .5 = 500ms 90 = 1m30s """ re_intv = re.compile(r"([\d\.]+)([a-zA-Z]+)") val = val.strip() total = 0.0 for match in re_intv.findall(val): unit = match[1] count = float(match[0]) if unit...
python
def parse_interval(val): """ converts a string to float of seconds .5 = 500ms 90 = 1m30s """ re_intv = re.compile(r"([\d\.]+)([a-zA-Z]+)") val = val.strip() total = 0.0 for match in re_intv.findall(val): unit = match[1] count = float(match[0]) if unit...
[ "def", "parse_interval", "(", "val", ")", ":", "re_intv", "=", "re", ".", "compile", "(", "r\"([\\d\\.]+)([a-zA-Z]+)\"", ")", "val", "=", "val", ".", "strip", "(", ")", "total", "=", "0.0", "for", "match", "in", "re_intv", ".", "findall", "(", "val", "...
converts a string to float of seconds .5 = 500ms 90 = 1m30s
[ "converts", "a", "string", "to", "float", "of", "seconds", ".", "5", "=", "500ms", "90", "=", "1m30s" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/config.py#L8-L33
11,623
20c/vaping
vaping/plugins/fping.py
FPingBase.hosts_args
def hosts_args(self): """ hosts list can contain strings specifying a host directly or dicts containing a "host" key to specify the host this way we can allow passing further config details (color, name etc.) with each host as well as simply dropping in addresses for quick ...
python
def hosts_args(self): """ hosts list can contain strings specifying a host directly or dicts containing a "host" key to specify the host this way we can allow passing further config details (color, name etc.) with each host as well as simply dropping in addresses for quick ...
[ "def", "hosts_args", "(", "self", ")", ":", "host_args", "=", "[", "]", "for", "row", "in", "self", ".", "hosts", ":", "if", "isinstance", "(", "row", ",", "dict", ")", ":", "host_args", ".", "append", "(", "row", "[", "\"host\"", "]", ")", "else",...
hosts list can contain strings specifying a host directly or dicts containing a "host" key to specify the host this way we can allow passing further config details (color, name etc.) with each host as well as simply dropping in addresses for quick setup depending on the user's needs
[ "hosts", "list", "can", "contain", "strings", "specifying", "a", "host", "directly", "or", "dicts", "containing", "a", "host", "key", "to", "specify", "the", "host" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/fping.py#L39-L61
11,624
20c/vaping
vaping/plugins/fping.py
FPingBase.parse_verbose
def parse_verbose(self, line): """ parse output from verbose format """ try: logging.debug(line) (host, pings) = line.split(' : ') cnt = 0 lost = 0 times = [] pings = pings.strip().split(' ') cnt = len(pi...
python
def parse_verbose(self, line): """ parse output from verbose format """ try: logging.debug(line) (host, pings) = line.split(' : ') cnt = 0 lost = 0 times = [] pings = pings.strip().split(' ') cnt = len(pi...
[ "def", "parse_verbose", "(", "self", ",", "line", ")", ":", "try", ":", "logging", ".", "debug", "(", "line", ")", "(", "host", ",", "pings", ")", "=", "line", ".", "split", "(", "' : '", ")", "cnt", "=", "0", "lost", "=", "0", "times", "=", "[...
parse output from verbose format
[ "parse", "output", "from", "verbose", "format" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/fping.py#L63-L100
11,625
20c/vaping
vaping/cli.py
start
def start(ctx, **kwargs): """ start a vaping process """ update_context(ctx, kwargs) daemon = mk_daemon(ctx) if ctx.debug or kwargs['no_fork']: daemon.run() else: daemon.start()
python
def start(ctx, **kwargs): """ start a vaping process """ update_context(ctx, kwargs) daemon = mk_daemon(ctx) if ctx.debug or kwargs['no_fork']: daemon.run() else: daemon.start()
[ "def", "start", "(", "ctx", ",", "*", "*", "kwargs", ")", ":", "update_context", "(", "ctx", ",", "kwargs", ")", "daemon", "=", "mk_daemon", "(", "ctx", ")", "if", "ctx", ".", "debug", "or", "kwargs", "[", "'no_fork'", "]", ":", "daemon", ".", "run...
start a vaping process
[ "start", "a", "vaping", "process" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/cli.py#L52-L63
11,626
20c/vaping
vaping/cli.py
stop
def stop(ctx, **kwargs): """ stop a vaping process """ update_context(ctx, kwargs) daemon = mk_daemon(ctx) daemon.stop()
python
def stop(ctx, **kwargs): """ stop a vaping process """ update_context(ctx, kwargs) daemon = mk_daemon(ctx) daemon.stop()
[ "def", "stop", "(", "ctx", ",", "*", "*", "kwargs", ")", ":", "update_context", "(", "ctx", ",", "kwargs", ")", "daemon", "=", "mk_daemon", "(", "ctx", ")", "daemon", ".", "stop", "(", ")" ]
stop a vaping process
[ "stop", "a", "vaping", "process" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/cli.py#L70-L77
11,627
20c/vaping
vaping/cli.py
restart
def restart(ctx, **kwargs): """ restart a vaping process """ update_context(ctx, kwargs) daemon = mk_daemon(ctx) daemon.stop() daemon.start()
python
def restart(ctx, **kwargs): """ restart a vaping process """ update_context(ctx, kwargs) daemon = mk_daemon(ctx) daemon.stop() daemon.start()
[ "def", "restart", "(", "ctx", ",", "*", "*", "kwargs", ")", ":", "update_context", "(", "ctx", ",", "kwargs", ")", "daemon", "=", "mk_daemon", "(", "ctx", ")", "daemon", ".", "stop", "(", ")", "daemon", ".", "start", "(", ")" ]
restart a vaping process
[ "restart", "a", "vaping", "process" ]
c51f00586c99edb3d51e4abdbdfe3174755533ee
https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/cli.py#L84-L92
11,628
aio-libs/aiohttp-debugtoolbar
aiohttp_debugtoolbar/panels/base.py
DebugPanel.render_content
def render_content(self, request): """Return a string containing the HTML to be rendered for the panel. By default this will render the template defined by the :attr:`.template` attribute with a rendering context defined by :attr:`.data` combined with the ``dict`` returned from ...
python
def render_content(self, request): """Return a string containing the HTML to be rendered for the panel. By default this will render the template defined by the :attr:`.template` attribute with a rendering context defined by :attr:`.data` combined with the ``dict`` returned from ...
[ "def", "render_content", "(", "self", ",", "request", ")", ":", "context", "=", "self", ".", "data", ".", "copy", "(", ")", "context", ".", "update", "(", "self", ".", "render_vars", "(", "request", ")", ")", "return", "render", "(", "self", ".", "te...
Return a string containing the HTML to be rendered for the panel. By default this will render the template defined by the :attr:`.template` attribute with a rendering context defined by :attr:`.data` combined with the ``dict`` returned from :meth:`.render_vars`. The ``request``...
[ "Return", "a", "string", "containing", "the", "HTML", "to", "be", "rendered", "for", "the", "panel", "." ]
a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322
https://github.com/aio-libs/aiohttp-debugtoolbar/blob/a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322/aiohttp_debugtoolbar/panels/base.py#L82-L95
11,629
aio-libs/aiohttp-debugtoolbar
aiohttp_debugtoolbar/toolbar.py
DebugToolbar.inject
def inject(self, request, response): """ Inject the debug toolbar iframe into an HTML response. """ # called in host app if not isinstance(response, Response): return settings = request.app[APP_KEY]['settings'] response_html = response.body rou...
python
def inject(self, request, response): """ Inject the debug toolbar iframe into an HTML response. """ # called in host app if not isinstance(response, Response): return settings = request.app[APP_KEY]['settings'] response_html = response.body rou...
[ "def", "inject", "(", "self", ",", "request", ",", "response", ")", ":", "# called in host app", "if", "not", "isinstance", "(", "response", ",", "Response", ")", ":", "return", "settings", "=", "request", ".", "app", "[", "APP_KEY", "]", "[", "'settings'"...
Inject the debug toolbar iframe into an HTML response.
[ "Inject", "the", "debug", "toolbar", "iframe", "into", "an", "HTML", "response", "." ]
a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322
https://github.com/aio-libs/aiohttp-debugtoolbar/blob/a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322/aiohttp_debugtoolbar/toolbar.py#L52-L81
11,630
aio-libs/aiohttp-debugtoolbar
aiohttp_debugtoolbar/utils.py
common_segment_count
def common_segment_count(path, value): """Return the number of path segments common to both""" i = 0 if len(path) <= len(value): for x1, x2 in zip(path, value): if x1 == x2: i += 1 else: return 0 return i
python
def common_segment_count(path, value): """Return the number of path segments common to both""" i = 0 if len(path) <= len(value): for x1, x2 in zip(path, value): if x1 == x2: i += 1 else: return 0 return i
[ "def", "common_segment_count", "(", "path", ",", "value", ")", ":", "i", "=", "0", "if", "len", "(", "path", ")", "<=", "len", "(", "value", ")", ":", "for", "x1", ",", "x2", "in", "zip", "(", "path", ",", "value", ")", ":", "if", "x1", "==", ...
Return the number of path segments common to both
[ "Return", "the", "number", "of", "path", "segments", "common", "to", "both" ]
a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322
https://github.com/aio-libs/aiohttp-debugtoolbar/blob/a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322/aiohttp_debugtoolbar/utils.py#L83-L92
11,631
jsocol/pystatsd
statsd/client/base.py
StatsClientBase.timing
def timing(self, stat, delta, rate=1): """ Send new timing information. `delta` can be either a number of milliseconds or a timedelta. """ if isinstance(delta, timedelta): # Convert timedelta to number of milliseconds. delta = delta.total_seconds() * 1000...
python
def timing(self, stat, delta, rate=1): """ Send new timing information. `delta` can be either a number of milliseconds or a timedelta. """ if isinstance(delta, timedelta): # Convert timedelta to number of milliseconds. delta = delta.total_seconds() * 1000...
[ "def", "timing", "(", "self", ",", "stat", ",", "delta", ",", "rate", "=", "1", ")", ":", "if", "isinstance", "(", "delta", ",", "timedelta", ")", ":", "# Convert timedelta to number of milliseconds.", "delta", "=", "delta", ".", "total_seconds", "(", ")", ...
Send new timing information. `delta` can be either a number of milliseconds or a timedelta.
[ "Send", "new", "timing", "information", "." ]
006a86394c44ff71e6e8e52529daa3c0fdcc93fb
https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/base.py#L22-L31
11,632
jsocol/pystatsd
statsd/client/base.py
StatsClientBase.decr
def decr(self, stat, count=1, rate=1): """Decrement a stat by `count`.""" self.incr(stat, -count, rate)
python
def decr(self, stat, count=1, rate=1): """Decrement a stat by `count`.""" self.incr(stat, -count, rate)
[ "def", "decr", "(", "self", ",", "stat", ",", "count", "=", "1", ",", "rate", "=", "1", ")", ":", "self", ".", "incr", "(", "stat", ",", "-", "count", ",", "rate", ")" ]
Decrement a stat by `count`.
[ "Decrement", "a", "stat", "by", "count", "." ]
006a86394c44ff71e6e8e52529daa3c0fdcc93fb
https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/base.py#L37-L39
11,633
jsocol/pystatsd
statsd/client/base.py
StatsClientBase.gauge
def gauge(self, stat, value, rate=1, delta=False): """Set a gauge value.""" if value < 0 and not delta: if rate < 1: if random.random() > rate: return with self.pipeline() as pipe: pipe._send_stat(stat, '0|g', 1) ...
python
def gauge(self, stat, value, rate=1, delta=False): """Set a gauge value.""" if value < 0 and not delta: if rate < 1: if random.random() > rate: return with self.pipeline() as pipe: pipe._send_stat(stat, '0|g', 1) ...
[ "def", "gauge", "(", "self", ",", "stat", ",", "value", ",", "rate", "=", "1", ",", "delta", "=", "False", ")", ":", "if", "value", "<", "0", "and", "not", "delta", ":", "if", "rate", "<", "1", ":", "if", "random", ".", "random", "(", ")", ">...
Set a gauge value.
[ "Set", "a", "gauge", "value", "." ]
006a86394c44ff71e6e8e52529daa3c0fdcc93fb
https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/base.py#L41-L52
11,634
jsocol/pystatsd
statsd/client/base.py
StatsClientBase.set
def set(self, stat, value, rate=1): """Set a set value.""" self._send_stat(stat, '%s|s' % value, rate)
python
def set(self, stat, value, rate=1): """Set a set value.""" self._send_stat(stat, '%s|s' % value, rate)
[ "def", "set", "(", "self", ",", "stat", ",", "value", ",", "rate", "=", "1", ")", ":", "self", ".", "_send_stat", "(", "stat", ",", "'%s|s'", "%", "value", ",", "rate", ")" ]
Set a set value.
[ "Set", "a", "set", "value", "." ]
006a86394c44ff71e6e8e52529daa3c0fdcc93fb
https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/base.py#L54-L56
11,635
jsocol/pystatsd
statsd/client/timer.py
safe_wraps
def safe_wraps(wrapper, *args, **kwargs): """Safely wraps partial functions.""" while isinstance(wrapper, functools.partial): wrapper = wrapper.func return functools.wraps(wrapper, *args, **kwargs)
python
def safe_wraps(wrapper, *args, **kwargs): """Safely wraps partial functions.""" while isinstance(wrapper, functools.partial): wrapper = wrapper.func return functools.wraps(wrapper, *args, **kwargs)
[ "def", "safe_wraps", "(", "wrapper", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "while", "isinstance", "(", "wrapper", ",", "functools", ".", "partial", ")", ":", "wrapper", "=", "wrapper", ".", "func", "return", "functools", ".", "wraps", "(...
Safely wraps partial functions.
[ "Safely", "wraps", "partial", "functions", "." ]
006a86394c44ff71e6e8e52529daa3c0fdcc93fb
https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/timer.py#L14-L18
11,636
jorisroovers/gitlint
gitlint/user_rules.py
find_rule_classes
def find_rule_classes(extra_path): """ Searches a given directory or python module for rule classes. This is done by adding the directory path to the python path, importing the modules and then finding any Rule class in those modules. :param extra_path: absolute directory or file path to search for...
python
def find_rule_classes(extra_path): """ Searches a given directory or python module for rule classes. This is done by adding the directory path to the python path, importing the modules and then finding any Rule class in those modules. :param extra_path: absolute directory or file path to search for...
[ "def", "find_rule_classes", "(", "extra_path", ")", ":", "files", "=", "[", "]", "modules", "=", "[", "]", "if", "os", ".", "path", ".", "isfile", "(", "extra_path", ")", ":", "files", "=", "[", "os", ".", "path", ".", "basename", "(", "extra_path", ...
Searches a given directory or python module for rule classes. This is done by adding the directory path to the python path, importing the modules and then finding any Rule class in those modules. :param extra_path: absolute directory or file path to search for rule classes :return: The list of rule cla...
[ "Searches", "a", "given", "directory", "or", "python", "module", "for", "rule", "classes", ".", "This", "is", "done", "by", "adding", "the", "directory", "path", "to", "the", "python", "path", "importing", "the", "modules", "and", "then", "finding", "any", ...
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/user_rules.py#L16-L73
11,637
jorisroovers/gitlint
qa/base.py
ustr
def ustr(obj): """ Python 2 and 3 utility method that converts an obj to unicode in python 2 and to a str object in python 3""" if sys.version_info[0] == 2: # If we are getting a string, then do an explicit decode # else, just call the unicode method of the object if type(obj) in [str, b...
python
def ustr(obj): """ Python 2 and 3 utility method that converts an obj to unicode in python 2 and to a str object in python 3""" if sys.version_info[0] == 2: # If we are getting a string, then do an explicit decode # else, just call the unicode method of the object if type(obj) in [str, b...
[ "def", "ustr", "(", "obj", ")", ":", "if", "sys", ".", "version_info", "[", "0", "]", "==", "2", ":", "# If we are getting a string, then do an explicit decode", "# else, just call the unicode method of the object", "if", "type", "(", "obj", ")", "in", "[", "str", ...
Python 2 and 3 utility method that converts an obj to unicode in python 2 and to a str object in python 3
[ "Python", "2", "and", "3", "utility", "method", "that", "converts", "an", "obj", "to", "unicode", "in", "python", "2", "and", "to", "a", "str", "object", "in", "python", "3" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/qa/base.py#L21-L34
11,638
jorisroovers/gitlint
gitlint/config.py
LintConfig.get_rule_option
def get_rule_option(self, rule_name_or_id, option_name): """ Returns the value of a given option for a given rule. LintConfigErrors will be raised if the rule or option don't exist. """ option = self._get_option(rule_name_or_id, option_name) return option.value
python
def get_rule_option(self, rule_name_or_id, option_name): """ Returns the value of a given option for a given rule. LintConfigErrors will be raised if the rule or option don't exist. """ option = self._get_option(rule_name_or_id, option_name) return option.value
[ "def", "get_rule_option", "(", "self", ",", "rule_name_or_id", ",", "option_name", ")", ":", "option", "=", "self", ".", "_get_option", "(", "rule_name_or_id", ",", "option_name", ")", "return", "option", ".", "value" ]
Returns the value of a given option for a given rule. LintConfigErrors will be raised if the rule or option don't exist.
[ "Returns", "the", "value", "of", "a", "given", "option", "for", "a", "given", "rule", ".", "LintConfigErrors", "will", "be", "raised", "if", "the", "rule", "or", "option", "don", "t", "exist", "." ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/config.py#L207-L211
11,639
jorisroovers/gitlint
gitlint/config.py
LintConfig.set_rule_option
def set_rule_option(self, rule_name_or_id, option_name, option_value): """ Attempts to set a given value for a given option for a given rule. LintConfigErrors will be raised if the rule or option don't exist or if the value is invalid. """ option = self._get_option(rule_name_or_id, option_na...
python
def set_rule_option(self, rule_name_or_id, option_name, option_value): """ Attempts to set a given value for a given option for a given rule. LintConfigErrors will be raised if the rule or option don't exist or if the value is invalid. """ option = self._get_option(rule_name_or_id, option_na...
[ "def", "set_rule_option", "(", "self", ",", "rule_name_or_id", ",", "option_name", ",", "option_value", ")", ":", "option", "=", "self", ".", "_get_option", "(", "rule_name_or_id", ",", "option_name", ")", "try", ":", "option", ".", "set", "(", "option_value",...
Attempts to set a given value for a given option for a given rule. LintConfigErrors will be raised if the rule or option don't exist or if the value is invalid.
[ "Attempts", "to", "set", "a", "given", "value", "for", "a", "given", "option", "for", "a", "given", "rule", ".", "LintConfigErrors", "will", "be", "raised", "if", "the", "rule", "or", "option", "don", "t", "exist", "or", "if", "the", "value", "is", "in...
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/config.py#L213-L221
11,640
jorisroovers/gitlint
gitlint/config.py
LintConfigBuilder.set_from_config_file
def set_from_config_file(self, filename): """ Loads lint config from a ini-style config file """ if not os.path.exists(filename): raise LintConfigError(u"Invalid file path: {0}".format(filename)) self._config_path = os.path.abspath(filename) try: parser = ConfigPa...
python
def set_from_config_file(self, filename): """ Loads lint config from a ini-style config file """ if not os.path.exists(filename): raise LintConfigError(u"Invalid file path: {0}".format(filename)) self._config_path = os.path.abspath(filename) try: parser = ConfigPa...
[ "def", "set_from_config_file", "(", "self", ",", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "raise", "LintConfigError", "(", "u\"Invalid file path: {0}\"", ".", "format", "(", "filename", ")", ")", "self",...
Loads lint config from a ini-style config file
[ "Loads", "lint", "config", "from", "a", "ini", "-", "style", "config", "file" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/config.py#L310-L324
11,641
jorisroovers/gitlint
gitlint/config.py
LintConfigBuilder.build
def build(self, config=None): """ Build a real LintConfig object by normalizing and validating the options that were previously set on this factory. """ # If we are passed a config object, then rebuild that object instead of building a new lintconfig object from # scratch if not...
python
def build(self, config=None): """ Build a real LintConfig object by normalizing and validating the options that were previously set on this factory. """ # If we are passed a config object, then rebuild that object instead of building a new lintconfig object from # scratch if not...
[ "def", "build", "(", "self", ",", "config", "=", "None", ")", ":", "# If we are passed a config object, then rebuild that object instead of building a new lintconfig object from", "# scratch", "if", "not", "config", ":", "config", "=", "LintConfig", "(", ")", "config", "....
Build a real LintConfig object by normalizing and validating the options that were previously set on this factory.
[ "Build", "a", "real", "LintConfig", "object", "by", "normalizing", "and", "validating", "the", "options", "that", "were", "previously", "set", "on", "this", "factory", "." ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/config.py#L326-L349
11,642
jorisroovers/gitlint
gitlint/config.py
LintConfigBuilder.clone
def clone(self): """ Creates an exact copy of a LintConfigBuilder. """ builder = LintConfigBuilder() builder._config_blueprint = copy.deepcopy(self._config_blueprint) builder._config_path = self._config_path return builder
python
def clone(self): """ Creates an exact copy of a LintConfigBuilder. """ builder = LintConfigBuilder() builder._config_blueprint = copy.deepcopy(self._config_blueprint) builder._config_path = self._config_path return builder
[ "def", "clone", "(", "self", ")", ":", "builder", "=", "LintConfigBuilder", "(", ")", "builder", ".", "_config_blueprint", "=", "copy", ".", "deepcopy", "(", "self", ".", "_config_blueprint", ")", "builder", ".", "_config_path", "=", "self", ".", "_config_pa...
Creates an exact copy of a LintConfigBuilder.
[ "Creates", "an", "exact", "copy", "of", "a", "LintConfigBuilder", "." ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/config.py#L351-L356
11,643
jorisroovers/gitlint
gitlint/git.py
_git
def _git(*command_parts, **kwargs): """ Convenience function for running git commands. Automatically deals with exceptions and unicode. """ # Special arguments passed to sh: http://amoffat.github.io/sh/special_arguments.html git_kwargs = {'_tty_out': False} git_kwargs.update(kwargs) try: res...
python
def _git(*command_parts, **kwargs): """ Convenience function for running git commands. Automatically deals with exceptions and unicode. """ # Special arguments passed to sh: http://amoffat.github.io/sh/special_arguments.html git_kwargs = {'_tty_out': False} git_kwargs.update(kwargs) try: res...
[ "def", "_git", "(", "*", "command_parts", ",", "*", "*", "kwargs", ")", ":", "# Special arguments passed to sh: http://amoffat.github.io/sh/special_arguments.html", "git_kwargs", "=", "{", "'_tty_out'", ":", "False", "}", "git_kwargs", ".", "update", "(", "kwargs", ")...
Convenience function for running git commands. Automatically deals with exceptions and unicode.
[ "Convenience", "function", "for", "running", "git", "commands", ".", "Automatically", "deals", "with", "exceptions", "and", "unicode", "." ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/git.py#L21-L42
11,644
jorisroovers/gitlint
gitlint/git.py
git_commentchar
def git_commentchar(): """ Shortcut for retrieving comment char from git config """ commentchar = _git("config", "--get", "core.commentchar", _ok_code=[1]) # git will return an exit code of 1 if it can't find a config value, in this case we fall-back to # as commentchar if hasattr(commentchar, 'exit_cod...
python
def git_commentchar(): """ Shortcut for retrieving comment char from git config """ commentchar = _git("config", "--get", "core.commentchar", _ok_code=[1]) # git will return an exit code of 1 if it can't find a config value, in this case we fall-back to # as commentchar if hasattr(commentchar, 'exit_cod...
[ "def", "git_commentchar", "(", ")", ":", "commentchar", "=", "_git", "(", "\"config\"", ",", "\"--get\"", ",", "\"core.commentchar\"", ",", "_ok_code", "=", "[", "1", "]", ")", "# git will return an exit code of 1 if it can't find a config value, in this case we fall-back t...
Shortcut for retrieving comment char from git config
[ "Shortcut", "for", "retrieving", "comment", "char", "from", "git", "config" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/git.py#L50-L56
11,645
jorisroovers/gitlint
gitlint/git.py
GitCommitMessage.from_full_message
def from_full_message(commit_msg_str): """ Parses a full git commit message by parsing a given string into the different parts of a commit message """ all_lines = commit_msg_str.splitlines() try: cutline_index = all_lines.index(GitCommitMessage.CUTLINE) except ValueError: ...
python
def from_full_message(commit_msg_str): """ Parses a full git commit message by parsing a given string into the different parts of a commit message """ all_lines = commit_msg_str.splitlines() try: cutline_index = all_lines.index(GitCommitMessage.CUTLINE) except ValueError: ...
[ "def", "from_full_message", "(", "commit_msg_str", ")", ":", "all_lines", "=", "commit_msg_str", ".", "splitlines", "(", ")", "try", ":", "cutline_index", "=", "all_lines", ".", "index", "(", "GitCommitMessage", ".", "CUTLINE", ")", "except", "ValueError", ":", ...
Parses a full git commit message by parsing a given string into the different parts of a commit message
[ "Parses", "a", "full", "git", "commit", "message", "by", "parsing", "a", "given", "string", "into", "the", "different", "parts", "of", "a", "commit", "message" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/git.py#L76-L87
11,646
jorisroovers/gitlint
gitlint/lint.py
GitLinter.should_ignore_rule
def should_ignore_rule(self, rule): """ Determines whether a rule should be ignored based on the general list of commits to ignore """ return rule.id in self.config.ignore or rule.name in self.config.ignore
python
def should_ignore_rule(self, rule): """ Determines whether a rule should be ignored based on the general list of commits to ignore """ return rule.id in self.config.ignore or rule.name in self.config.ignore
[ "def", "should_ignore_rule", "(", "self", ",", "rule", ")", ":", "return", "rule", ".", "id", "in", "self", ".", "config", ".", "ignore", "or", "rule", ".", "name", "in", "self", ".", "config", ".", "ignore" ]
Determines whether a rule should be ignored based on the general list of commits to ignore
[ "Determines", "whether", "a", "rule", "should", "be", "ignored", "based", "on", "the", "general", "list", "of", "commits", "to", "ignore" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/lint.py#L19-L21
11,647
jorisroovers/gitlint
gitlint/lint.py
GitLinter._apply_line_rules
def _apply_line_rules(lines, commit, rules, line_nr_start): """ Iterates over the lines in a given list of lines and validates a given list of rules against each line """ all_violations = [] line_nr = line_nr_start for line in lines: for rule in rules: violati...
python
def _apply_line_rules(lines, commit, rules, line_nr_start): """ Iterates over the lines in a given list of lines and validates a given list of rules against each line """ all_violations = [] line_nr = line_nr_start for line in lines: for rule in rules: violati...
[ "def", "_apply_line_rules", "(", "lines", ",", "commit", ",", "rules", ",", "line_nr_start", ")", ":", "all_violations", "=", "[", "]", "line_nr", "=", "line_nr_start", "for", "line", "in", "lines", ":", "for", "rule", "in", "rules", ":", "violations", "="...
Iterates over the lines in a given list of lines and validates a given list of rules against each line
[ "Iterates", "over", "the", "lines", "in", "a", "given", "list", "of", "lines", "and", "validates", "a", "given", "list", "of", "rules", "against", "each", "line" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/lint.py#L46-L58
11,648
jorisroovers/gitlint
gitlint/lint.py
GitLinter._apply_commit_rules
def _apply_commit_rules(rules, commit): """ Applies a set of rules against a given commit and gitcontext """ all_violations = [] for rule in rules: violations = rule.validate(commit) if violations: all_violations.extend(violations) return all_viola...
python
def _apply_commit_rules(rules, commit): """ Applies a set of rules against a given commit and gitcontext """ all_violations = [] for rule in rules: violations = rule.validate(commit) if violations: all_violations.extend(violations) return all_viola...
[ "def", "_apply_commit_rules", "(", "rules", ",", "commit", ")", ":", "all_violations", "=", "[", "]", "for", "rule", "in", "rules", ":", "violations", "=", "rule", ".", "validate", "(", "commit", ")", "if", "violations", ":", "all_violations", ".", "extend...
Applies a set of rules against a given commit and gitcontext
[ "Applies", "a", "set", "of", "rules", "against", "a", "given", "commit", "and", "gitcontext" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/lint.py#L61-L68
11,649
jorisroovers/gitlint
gitlint/lint.py
GitLinter.lint
def lint(self, commit): """ Lint the last commit in a given git context by applying all ignore, title, body and commit rules. """ LOG.debug("Linting commit %s", commit.sha or "[SHA UNKNOWN]") LOG.debug("Commit Object\n" + ustr(commit)) # Apply config rules for rule in self.confi...
python
def lint(self, commit): """ Lint the last commit in a given git context by applying all ignore, title, body and commit rules. """ LOG.debug("Linting commit %s", commit.sha or "[SHA UNKNOWN]") LOG.debug("Commit Object\n" + ustr(commit)) # Apply config rules for rule in self.confi...
[ "def", "lint", "(", "self", ",", "commit", ")", ":", "LOG", ".", "debug", "(", "\"Linting commit %s\"", ",", "commit", ".", "sha", "or", "\"[SHA UNKNOWN]\"", ")", "LOG", ".", "debug", "(", "\"Commit Object\\n\"", "+", "ustr", "(", "commit", ")", ")", "# ...
Lint the last commit in a given git context by applying all ignore, title, body and commit rules.
[ "Lint", "the", "last", "commit", "in", "a", "given", "git", "context", "by", "applying", "all", "ignore", "title", "body", "and", "commit", "rules", "." ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/lint.py#L70-L96
11,650
jorisroovers/gitlint
gitlint/lint.py
GitLinter.print_violations
def print_violations(self, violations): """ Print a given set of violations to the standard error output """ for v in violations: line_nr = v.line_nr if v.line_nr else "-" self.display.e(u"{0}: {1}".format(line_nr, v.rule_id), exact=True) self.display.ee(u"{0}: {1} {2...
python
def print_violations(self, violations): """ Print a given set of violations to the standard error output """ for v in violations: line_nr = v.line_nr if v.line_nr else "-" self.display.e(u"{0}: {1}".format(line_nr, v.rule_id), exact=True) self.display.ee(u"{0}: {1} {2...
[ "def", "print_violations", "(", "self", ",", "violations", ")", ":", "for", "v", "in", "violations", ":", "line_nr", "=", "v", ".", "line_nr", "if", "v", ".", "line_nr", "else", "\"-\"", "self", ".", "display", ".", "e", "(", "u\"{0}: {1}\"", ".", "for...
Print a given set of violations to the standard error output
[ "Print", "a", "given", "set", "of", "violations", "to", "the", "standard", "error", "output" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/lint.py#L98-L108
11,651
jorisroovers/gitlint
gitlint/display.py
Display._output
def _output(self, message, verbosity, exact, stream): """ Output a message if the config's verbosity is >= to the given verbosity. If exact == True, the message will only be outputted if the given verbosity exactly matches the config's verbosity. """ if exact: if self.config.verbosit...
python
def _output(self, message, verbosity, exact, stream): """ Output a message if the config's verbosity is >= to the given verbosity. If exact == True, the message will only be outputted if the given verbosity exactly matches the config's verbosity. """ if exact: if self.config.verbosit...
[ "def", "_output", "(", "self", ",", "message", ",", "verbosity", ",", "exact", ",", "stream", ")", ":", "if", "exact", ":", "if", "self", ".", "config", ".", "verbosity", "==", "verbosity", ":", "stream", ".", "write", "(", "message", "+", "\"\\n\"", ...
Output a message if the config's verbosity is >= to the given verbosity. If exact == True, the message will only be outputted if the given verbosity exactly matches the config's verbosity.
[ "Output", "a", "message", "if", "the", "config", "s", "verbosity", "is", ">", "=", "to", "the", "given", "verbosity", ".", "If", "exact", "==", "True", "the", "message", "will", "only", "be", "outputted", "if", "the", "given", "verbosity", "exactly", "ma...
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/display.py#L20-L28
11,652
jorisroovers/gitlint
gitlint/cli.py
setup_logging
def setup_logging(): """ Setup gitlint logging """ root_log = logging.getLogger("gitlint") root_log.propagate = False # Don't propagate to child loggers, the gitlint root logger handles everything handler = logging.StreamHandler() formatter = logging.Formatter(LOG_FORMAT) handler.setFormatter(f...
python
def setup_logging(): """ Setup gitlint logging """ root_log = logging.getLogger("gitlint") root_log.propagate = False # Don't propagate to child loggers, the gitlint root logger handles everything handler = logging.StreamHandler() formatter = logging.Formatter(LOG_FORMAT) handler.setFormatter(f...
[ "def", "setup_logging", "(", ")", ":", "root_log", "=", "logging", ".", "getLogger", "(", "\"gitlint\"", ")", "root_log", ".", "propagate", "=", "False", "# Don't propagate to child loggers, the gitlint root logger handles everything", "handler", "=", "logging", ".", "S...
Setup gitlint logging
[ "Setup", "gitlint", "logging" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/cli.py#L39-L47
11,653
jorisroovers/gitlint
gitlint/cli.py
build_config
def build_config(ctx, target, config_path, c, extra_path, ignore, verbose, silent, debug): """ Creates a LintConfig object based on a set of commandline parameters. """ config_builder = LintConfigBuilder() try: # Config precedence: # First, load default config or config from configfile ...
python
def build_config(ctx, target, config_path, c, extra_path, ignore, verbose, silent, debug): """ Creates a LintConfig object based on a set of commandline parameters. """ config_builder = LintConfigBuilder() try: # Config precedence: # First, load default config or config from configfile ...
[ "def", "build_config", "(", "ctx", ",", "target", ",", "config_path", ",", "c", ",", "extra_path", ",", "ignore", ",", "verbose", ",", "silent", ",", "debug", ")", ":", "config_builder", "=", "LintConfigBuilder", "(", ")", "try", ":", "# Config precedence:",...
Creates a LintConfig object based on a set of commandline parameters.
[ "Creates", "a", "LintConfig", "object", "based", "on", "a", "set", "of", "commandline", "parameters", "." ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/cli.py#L57-L93
11,654
jorisroovers/gitlint
gitlint/cli.py
get_stdin_data
def get_stdin_data(): """ Helper function that returns data send to stdin or False if nothing is send """ # STDIN can only be 3 different types of things ("modes") # 1. An interactive terminal device (i.e. a TTY -> sys.stdin.isatty() or stat.S_ISCHR) # 2. A (named) pipe (stat.S_ISFIFO) # 3. A reg...
python
def get_stdin_data(): """ Helper function that returns data send to stdin or False if nothing is send """ # STDIN can only be 3 different types of things ("modes") # 1. An interactive terminal device (i.e. a TTY -> sys.stdin.isatty() or stat.S_ISCHR) # 2. A (named) pipe (stat.S_ISFIFO) # 3. A reg...
[ "def", "get_stdin_data", "(", ")", ":", "# STDIN can only be 3 different types of things (\"modes\")", "# 1. An interactive terminal device (i.e. a TTY -> sys.stdin.isatty() or stat.S_ISCHR)", "# 2. A (named) pipe (stat.S_ISFIFO)", "# 3. A regular file (stat.S_ISREG)", "# Technically, STDIN can...
Helper function that returns data send to stdin or False if nothing is send
[ "Helper", "function", "that", "returns", "data", "send", "to", "stdin", "or", "False", "if", "nothing", "is", "send" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/cli.py#L96-L125
11,655
jorisroovers/gitlint
gitlint/cli.py
cli
def cli( # pylint: disable=too-many-arguments ctx, target, config, c, commits, extra_path, ignore, msg_filename, verbose, silent, debug, ): """ Git lint tool, checks your git commit messages for styling issues """ try: if debug: logging.getLogger("gitlint").setLevel(logging...
python
def cli( # pylint: disable=too-many-arguments ctx, target, config, c, commits, extra_path, ignore, msg_filename, verbose, silent, debug, ): """ Git lint tool, checks your git commit messages for styling issues """ try: if debug: logging.getLogger("gitlint").setLevel(logging...
[ "def", "cli", "(", "# pylint: disable=too-many-arguments", "ctx", ",", "target", ",", "config", ",", "c", ",", "commits", ",", "extra_path", ",", "ignore", ",", "msg_filename", ",", "verbose", ",", "silent", ",", "debug", ",", ")", ":", "try", ":", "if", ...
Git lint tool, checks your git commit messages for styling issues
[ "Git", "lint", "tool", "checks", "your", "git", "commit", "messages", "for", "styling", "issues" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/cli.py#L147-L173
11,656
jorisroovers/gitlint
gitlint/cli.py
install_hook
def install_hook(ctx): """ Install gitlint as a git commit-msg hook. """ try: lint_config = ctx.obj[0] hooks.GitHookInstaller.install_commit_msg_hook(lint_config) # declare victory :-) hook_path = hooks.GitHookInstaller.commit_msg_hook_path(lint_config) click.echo(u"Succe...
python
def install_hook(ctx): """ Install gitlint as a git commit-msg hook. """ try: lint_config = ctx.obj[0] hooks.GitHookInstaller.install_commit_msg_hook(lint_config) # declare victory :-) hook_path = hooks.GitHookInstaller.commit_msg_hook_path(lint_config) click.echo(u"Succe...
[ "def", "install_hook", "(", "ctx", ")", ":", "try", ":", "lint_config", "=", "ctx", ".", "obj", "[", "0", "]", "hooks", ".", "GitHookInstaller", ".", "install_commit_msg_hook", "(", "lint_config", ")", "# declare victory :-)", "hook_path", "=", "hooks", ".", ...
Install gitlint as a git commit-msg hook.
[ "Install", "gitlint", "as", "a", "git", "commit", "-", "msg", "hook", "." ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/cli.py#L246-L257
11,657
jorisroovers/gitlint
gitlint/cli.py
uninstall_hook
def uninstall_hook(ctx): """ Uninstall gitlint commit-msg hook. """ try: lint_config = ctx.obj[0] hooks.GitHookInstaller.uninstall_commit_msg_hook(lint_config) # declare victory :-) hook_path = hooks.GitHookInstaller.commit_msg_hook_path(lint_config) click.echo(u"Successf...
python
def uninstall_hook(ctx): """ Uninstall gitlint commit-msg hook. """ try: lint_config = ctx.obj[0] hooks.GitHookInstaller.uninstall_commit_msg_hook(lint_config) # declare victory :-) hook_path = hooks.GitHookInstaller.commit_msg_hook_path(lint_config) click.echo(u"Successf...
[ "def", "uninstall_hook", "(", "ctx", ")", ":", "try", ":", "lint_config", "=", "ctx", ".", "obj", "[", "0", "]", "hooks", ".", "GitHookInstaller", ".", "uninstall_commit_msg_hook", "(", "lint_config", ")", "# declare victory :-)", "hook_path", "=", "hooks", "....
Uninstall gitlint commit-msg hook.
[ "Uninstall", "gitlint", "commit", "-", "msg", "hook", "." ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/cli.py#L262-L273
11,658
jorisroovers/gitlint
gitlint/cli.py
generate_config
def generate_config(ctx): """ Generates a sample gitlint config file. """ path = click.prompt('Please specify a location for the sample gitlint config file', default=DEFAULT_CONFIG_FILE) path = os.path.abspath(path) dir_name = os.path.dirname(path) if not os.path.exists(dir_name): click.echo...
python
def generate_config(ctx): """ Generates a sample gitlint config file. """ path = click.prompt('Please specify a location for the sample gitlint config file', default=DEFAULT_CONFIG_FILE) path = os.path.abspath(path) dir_name = os.path.dirname(path) if not os.path.exists(dir_name): click.echo...
[ "def", "generate_config", "(", "ctx", ")", ":", "path", "=", "click", ".", "prompt", "(", "'Please specify a location for the sample gitlint config file'", ",", "default", "=", "DEFAULT_CONFIG_FILE", ")", "path", "=", "os", ".", "path", ".", "abspath", "(", "path"...
Generates a sample gitlint config file.
[ "Generates", "a", "sample", "gitlint", "config", "file", "." ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/cli.py#L278-L292
11,659
jorisroovers/gitlint
gitlint/hooks.py
GitHookInstaller._assert_git_repo
def _assert_git_repo(target): """ Asserts that a given target directory is a git repository """ hooks_dir = os.path.abspath(os.path.join(target, HOOKS_DIR_PATH)) if not os.path.isdir(hooks_dir): raise GitHookInstallerError(u"{0} is not a git repository.".format(target))
python
def _assert_git_repo(target): """ Asserts that a given target directory is a git repository """ hooks_dir = os.path.abspath(os.path.join(target, HOOKS_DIR_PATH)) if not os.path.isdir(hooks_dir): raise GitHookInstallerError(u"{0} is not a git repository.".format(target))
[ "def", "_assert_git_repo", "(", "target", ")", ":", "hooks_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "target", ",", "HOOKS_DIR_PATH", ")", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "hooks_di...
Asserts that a given target directory is a git repository
[ "Asserts", "that", "a", "given", "target", "directory", "is", "a", "git", "repository" ]
6248bd6cbc20c1be3bb6d196a5ec0425af99733b
https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/hooks.py#L23-L27
11,660
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
get_job_url
def get_job_url(config, hub, group, project): """ Util method to get job url """ if ((config is not None) and ('hub' in config) and (hub is None)): hub = config["hub"] if ((config is not None) and ('group' in config) and (group is None)): group = config["group"] if ((config is no...
python
def get_job_url(config, hub, group, project): """ Util method to get job url """ if ((config is not None) and ('hub' in config) and (hub is None)): hub = config["hub"] if ((config is not None) and ('group' in config) and (group is None)): group = config["group"] if ((config is no...
[ "def", "get_job_url", "(", "config", ",", "hub", ",", "group", ",", "project", ")", ":", "if", "(", "(", "config", "is", "not", "None", ")", "and", "(", "'hub'", "in", "config", ")", "and", "(", "hub", "is", "None", ")", ")", ":", "hub", "=", "...
Util method to get job url
[ "Util", "method", "to", "get", "job", "url" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L22-L34
11,661
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
get_backend_stats_url
def get_backend_stats_url(config, hub, backend_type): """ Util method to get backend stats url """ if ((config is not None) and ('hub' in config) and (hub is None)): hub = config["hub"] if (hub is not None): return '/Network/{}/devices/{}'.format(hub, backend_type) return '/Backe...
python
def get_backend_stats_url(config, hub, backend_type): """ Util method to get backend stats url """ if ((config is not None) and ('hub' in config) and (hub is None)): hub = config["hub"] if (hub is not None): return '/Network/{}/devices/{}'.format(hub, backend_type) return '/Backe...
[ "def", "get_backend_stats_url", "(", "config", ",", "hub", ",", "backend_type", ")", ":", "if", "(", "(", "config", "is", "not", "None", ")", "and", "(", "'hub'", "in", "config", ")", "and", "(", "hub", "is", "None", ")", ")", ":", "hub", "=", "con...
Util method to get backend stats url
[ "Util", "method", "to", "get", "backend", "stats", "url" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L36-L44
11,662
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
get_backend_url
def get_backend_url(config, hub, group, project): """ Util method to get backend url """ if ((config is not None) and ('hub' in config) and (hub is None)): hub = config["hub"] if ((config is not None) and ('group' in config) and (group is None)): group = config["group"] if ((conf...
python
def get_backend_url(config, hub, group, project): """ Util method to get backend url """ if ((config is not None) and ('hub' in config) and (hub is None)): hub = config["hub"] if ((config is not None) and ('group' in config) and (group is None)): group = config["group"] if ((conf...
[ "def", "get_backend_url", "(", "config", ",", "hub", ",", "group", ",", "project", ")", ":", "if", "(", "(", "config", "is", "not", "None", ")", "and", "(", "'hub'", "in", "config", ")", "and", "(", "hub", "is", "None", ")", ")", ":", "hub", "=",...
Util method to get backend url
[ "Util", "method", "to", "get", "backend", "url" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L47-L59
11,663
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
_Credentials.obtain_token
def obtain_token(self, config=None): """Obtain the token to access to QX Platform. Raises: CredentialsError: when token is invalid or the user has not accepted the license. ApiError: when the response from the server couldn't be parsed. """ client...
python
def obtain_token(self, config=None): """Obtain the token to access to QX Platform. Raises: CredentialsError: when token is invalid or the user has not accepted the license. ApiError: when the response from the server couldn't be parsed. """ client...
[ "def", "obtain_token", "(", "self", ",", "config", "=", "None", ")", ":", "client_application", "=", "CLIENT_APPLICATION", "if", "self", ".", "config", "and", "(", "\"client_application\"", "in", "self", ".", "config", ")", ":", "client_application", "+=", "':...
Obtain the token to access to QX Platform. Raises: CredentialsError: when token is invalid or the user has not accepted the license. ApiError: when the response from the server couldn't be parsed.
[ "Obtain", "the", "token", "to", "access", "to", "QX", "Platform", "." ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L107-L169
11,664
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
_Request.check_token
def check_token(self, respond): """ Check is the user's token is valid """ if respond.status_code == 401: self.credential.obtain_token(config=self.config) return False return True
python
def check_token(self, respond): """ Check is the user's token is valid """ if respond.status_code == 401: self.credential.obtain_token(config=self.config) return False return True
[ "def", "check_token", "(", "self", ",", "respond", ")", ":", "if", "respond", ".", "status_code", "==", "401", ":", "self", ".", "credential", ".", "obtain_token", "(", "config", "=", "self", ".", "config", ")", "return", "False", "return", "True" ]
Check is the user's token is valid
[ "Check", "is", "the", "user", "s", "token", "is", "valid" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L264-L271
11,665
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
_Request.post
def post(self, path, params='', data=None): """ POST Method Wrapper of the REST API """ self.result = None data = data or {} headers = {'Content-Type': 'application/json', 'x-qx-client-application': self.client_application} url = str(self.creden...
python
def post(self, path, params='', data=None): """ POST Method Wrapper of the REST API """ self.result = None data = data or {} headers = {'Content-Type': 'application/json', 'x-qx-client-application': self.client_application} url = str(self.creden...
[ "def", "post", "(", "self", ",", "path", ",", "params", "=", "''", ",", "data", "=", "None", ")", ":", "self", ".", "result", "=", "None", "data", "=", "data", "or", "{", "}", "headers", "=", "{", "'Content-Type'", ":", "'application/json'", ",", "...
POST Method Wrapper of the REST API
[ "POST", "Method", "Wrapper", "of", "the", "REST", "API" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L273-L305
11,666
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
_Request._parse_response
def _parse_response(self, respond): """parse text of response for HTTP errors This parses the text of the response to decide whether to retry request or raise exception. At the moment this only detects an exception condition. Args: respond (Response): requests.Respo...
python
def _parse_response(self, respond): """parse text of response for HTTP errors This parses the text of the response to decide whether to retry request or raise exception. At the moment this only detects an exception condition. Args: respond (Response): requests.Respo...
[ "def", "_parse_response", "(", "self", ",", "respond", ")", ":", "# convert error messages into exceptions", "mobj", "=", "self", ".", "_max_qubit_error_re", ".", "match", "(", "respond", ".", "text", ")", "if", "mobj", ":", "raise", "RegisterSizeError", "(", "'...
parse text of response for HTTP errors This parses the text of the response to decide whether to retry request or raise exception. At the moment this only detects an exception condition. Args: respond (Response): requests.Response object Returns: bool: ...
[ "parse", "text", "of", "response", "for", "HTTP", "errors" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L421-L443
11,667
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience._check_backend
def _check_backend(self, backend, endpoint): """ Check if the name of a backend is valid to run in QX Platform """ # First check against hacks for old backend names original_backend = backend backend = backend.lower() if endpoint == 'experiment': if ba...
python
def _check_backend(self, backend, endpoint): """ Check if the name of a backend is valid to run in QX Platform """ # First check against hacks for old backend names original_backend = backend backend = backend.lower() if endpoint == 'experiment': if ba...
[ "def", "_check_backend", "(", "self", ",", "backend", ",", "endpoint", ")", ":", "# First check against hacks for old backend names", "original_backend", "=", "backend", "backend", "=", "backend", ".", "lower", "(", ")", "if", "endpoint", "==", "'experiment'", ":", ...
Check if the name of a backend is valid to run in QX Platform
[ "Check", "if", "the", "name", "of", "a", "backend", "is", "valid", "to", "run", "in", "QX", "Platform" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L480-L501
11,668
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.get_execution
def get_execution(self, id_execution, access_token=None, user_id=None): """ Get a execution, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check_credentia...
python
def get_execution(self, id_execution, access_token=None, user_id=None): """ Get a execution, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check_credentia...
[ "def", "get_execution", "(", "self", ",", "id_execution", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "credential", ".", "set_token", "(", "access_token", ")", "if", "user_id"...
Get a execution, by its id
[ "Get", "a", "execution", "by", "its", "id" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L509-L522
11,669
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.get_result_from_execution
def get_result_from_execution(self, id_execution, access_token=None, user_id=None): """ Get the result of a execution, by the execution id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id)...
python
def get_result_from_execution(self, id_execution, access_token=None, user_id=None): """ Get the result of a execution, by the execution id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id)...
[ "def", "get_result_from_execution", "(", "self", ",", "id_execution", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "credential", ".", "set_token", "(", "access_token", ")", "if",...
Get the result of a execution, by the execution id
[ "Get", "the", "result", "of", "a", "execution", "by", "the", "execution", "id" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L524-L551
11,670
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.get_code
def get_code(self, id_code, access_token=None, user_id=None): """ Get a code, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check_credentials(): ...
python
def get_code(self, id_code, access_token=None, user_id=None): """ Get a code, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check_credentials(): ...
[ "def", "get_code", "(", "self", ",", "id_code", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "credential", ".", "set_token", "(", "access_token", ")", "if", "user_id", ":", ...
Get a code, by its id
[ "Get", "a", "code", "by", "its", "id" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L553-L568
11,671
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.get_image_code
def get_image_code(self, id_code, access_token=None, user_id=None): """ Get the image of a code, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check_crede...
python
def get_image_code(self, id_code, access_token=None, user_id=None): """ Get the image of a code, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check_crede...
[ "def", "get_image_code", "(", "self", ",", "id_code", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "credential", ".", "set_token", "(", "access_token", ")", "if", "user_id", ...
Get the image of a code, by its id
[ "Get", "the", "image", "of", "a", "code", "by", "its", "id" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L570-L580
11,672
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.get_last_codes
def get_last_codes(self, access_token=None, user_id=None): """ Get the last codes of the user """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check_credentials(): ...
python
def get_last_codes(self, access_token=None, user_id=None): """ Get the last codes of the user """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check_credentials(): ...
[ "def", "get_last_codes", "(", "self", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "credential", ".", "set_token", "(", "access_token", ")", "if", "user_id", ":", "self", "."...
Get the last codes of the user
[ "Get", "the", "last", "codes", "of", "the", "user" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L582-L593
11,673
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.run_job
def run_job(self, job, backend='simulator', shots=1, max_credits=None, seed=None, hub=None, group=None, project=None, hpc=None, access_token=None, user_id=None): """ Execute a job """ if access_token: self.req.credential.set_token(access_token)...
python
def run_job(self, job, backend='simulator', shots=1, max_credits=None, seed=None, hub=None, group=None, project=None, hpc=None, access_token=None, user_id=None): """ Execute a job """ if access_token: self.req.credential.set_token(access_token)...
[ "def", "run_job", "(", "self", ",", "job", ",", "backend", "=", "'simulator'", ",", "shots", "=", "1", ",", "max_credits", "=", "None", ",", "seed", "=", "None", ",", "hub", "=", "None", ",", "group", "=", "None", ",", "project", "=", "None", ",", ...
Execute a job
[ "Execute", "a", "job" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L679-L732
11,674
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.get_job
def get_job(self, id_job, hub=None, group=None, project=None, access_token=None, user_id=None): """ Get the information about a job, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential....
python
def get_job(self, id_job, hub=None, group=None, project=None, access_token=None, user_id=None): """ Get the information about a job, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential....
[ "def", "get_job", "(", "self", ",", "id_job", ",", "hub", "=", "None", ",", "group", "=", "None", ",", "project", "=", "None", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", "...
Get the information about a job, by its id
[ "Get", "the", "information", "about", "a", "job", "by", "its", "id" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L734-L769
11,675
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.get_jobs
def get_jobs(self, limit=10, skip=0, backend=None, only_completed=False, filter=None, hub=None, group=None, project=None, access_token=None, user_id=None): """ Get the information about the user jobs """ if access_token: self.req.credential.set_token(access_token) if ...
python
def get_jobs(self, limit=10, skip=0, backend=None, only_completed=False, filter=None, hub=None, group=None, project=None, access_token=None, user_id=None): """ Get the information about the user jobs """ if access_token: self.req.credential.set_token(access_token) if ...
[ "def", "get_jobs", "(", "self", ",", "limit", "=", "10", ",", "skip", "=", "0", ",", "backend", "=", "None", ",", "only_completed", "=", "False", ",", "filter", "=", "None", ",", "hub", "=", "None", ",", "group", "=", "None", ",", "project", "=", ...
Get the information about the user jobs
[ "Get", "the", "information", "about", "the", "user", "jobs" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L771-L800
11,676
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.get_status_job
def get_status_job(self, id_job, hub=None, group=None, project=None, access_token=None, user_id=None): """ Get the status about a job, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.cr...
python
def get_status_job(self, id_job, hub=None, group=None, project=None, access_token=None, user_id=None): """ Get the status about a job, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.cr...
[ "def", "get_status_job", "(", "self", ",", "id_job", ",", "hub", "=", "None", ",", "group", "=", "None", ",", "project", "=", "None", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "re...
Get the status about a job, by its id
[ "Get", "the", "status", "about", "a", "job", "by", "its", "id" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L802-L828
11,677
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.cancel_job
def cancel_job(self, id_job, hub=None, group=None, project=None, access_token=None, user_id=None): """ Cancel the information about a job, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.cr...
python
def cancel_job(self, id_job, hub=None, group=None, project=None, access_token=None, user_id=None): """ Cancel the information about a job, by its id """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.cr...
[ "def", "cancel_job", "(", "self", ",", "id_job", ",", "hub", "=", "None", ",", "group", "=", "None", ",", "project", "=", "None", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ...
Cancel the information about a job, by its id
[ "Cancel", "the", "information", "about", "a", "job", "by", "its", "id" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L863-L889
11,678
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.backend_status
def backend_status(self, backend='ibmqx4', access_token=None, user_id=None): """ Get the status of a chip """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) backend_type = self._che...
python
def backend_status(self, backend='ibmqx4', access_token=None, user_id=None): """ Get the status of a chip """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) backend_type = self._che...
[ "def", "backend_status", "(", "self", ",", "backend", "=", "'ibmqx4'", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "credential", ".", "set_token", "(", "access_token", ")", ...
Get the status of a chip
[ "Get", "the", "status", "of", "a", "chip" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L891-L916
11,679
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.backend_calibration
def backend_calibration(self, backend='ibmqx4', hub=None, access_token=None, user_id=None): """ Get the calibration of a real chip """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) ...
python
def backend_calibration(self, backend='ibmqx4', hub=None, access_token=None, user_id=None): """ Get the calibration of a real chip """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) ...
[ "def", "backend_calibration", "(", "self", ",", "backend", "=", "'ibmqx4'", ",", "hub", "=", "None", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "credential", ".", "set_toke...
Get the calibration of a real chip
[ "Get", "the", "calibration", "of", "a", "real", "chip" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L918-L945
11,680
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.available_backends
def available_backends(self, hub=None, group=None, project=None, access_token=None, user_id=None): """ Get the backends available to use in the QX Platform """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set...
python
def available_backends(self, hub=None, group=None, project=None, access_token=None, user_id=None): """ Get the backends available to use in the QX Platform """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set...
[ "def", "available_backends", "(", "self", ",", "hub", "=", "None", ",", "group", "=", "None", ",", "project", "=", "None", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "c...
Get the backends available to use in the QX Platform
[ "Get", "the", "backends", "available", "to", "use", "in", "the", "QX", "Platform" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L976-L994
11,681
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.available_backend_simulators
def available_backend_simulators(self, access_token=None, user_id=None): """ Get the backend simulators available to use in the QX Platform """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id...
python
def available_backend_simulators(self, access_token=None, user_id=None): """ Get the backend simulators available to use in the QX Platform """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id...
[ "def", "available_backend_simulators", "(", "self", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "credential", ".", "set_token", "(", "access_token", ")", "if", "user_id", ":", ...
Get the backend simulators available to use in the QX Platform
[ "Get", "the", "backend", "simulators", "available", "to", "use", "in", "the", "QX", "Platform" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L996-L1012
11,682
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
IBMQuantumExperience.get_my_credits
def get_my_credits(self, access_token=None, user_id=None): """ Get the credits by user to use in the QX Platform """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check...
python
def get_my_credits(self, access_token=None, user_id=None): """ Get the credits by user to use in the QX Platform """ if access_token: self.req.credential.set_token(access_token) if user_id: self.req.credential.set_user_id(user_id) if not self.check...
[ "def", "get_my_credits", "(", "self", ",", "access_token", "=", "None", ",", "user_id", "=", "None", ")", ":", "if", "access_token", ":", "self", ".", "req", ".", "credential", ".", "set_token", "(", "access_token", ")", "if", "user_id", ":", "self", "."...
Get the credits by user to use in the QX Platform
[ "Get", "the", "credits", "by", "user", "to", "use", "in", "the", "QX", "Platform" ]
2ab240110fb7e653254e44c4833f3643e8ae7f0f
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L1014-L1033
11,683
ionelmc/python-hunter
src/hunter/tracer.py
Tracer.trace
def trace(self, predicate): """ Starts tracing with the given callable. Args: predicate (callable that accepts a single :obj:`hunter.Event` argument): Return: self """ self._handler = predicate if self.threading_support is None or self.thr...
python
def trace(self, predicate): """ Starts tracing with the given callable. Args: predicate (callable that accepts a single :obj:`hunter.Event` argument): Return: self """ self._handler = predicate if self.threading_support is None or self.thr...
[ "def", "trace", "(", "self", ",", "predicate", ")", ":", "self", ".", "_handler", "=", "predicate", "if", "self", ".", "threading_support", "is", "None", "or", "self", ".", "threading_support", ":", "self", ".", "_threading_previous", "=", "getattr", "(", ...
Starts tracing with the given callable. Args: predicate (callable that accepts a single :obj:`hunter.Event` argument): Return: self
[ "Starts", "tracing", "with", "the", "given", "callable", "." ]
b3a1310b0593d2c6b6ef430883843896e17d6a81
https://github.com/ionelmc/python-hunter/blob/b3a1310b0593d2c6b6ef430883843896e17d6a81/src/hunter/tracer.py#L81-L96
11,684
ionelmc/python-hunter
src/hunter/__init__.py
And
def And(*predicates, **kwargs): """ `And` predicate. Returns ``False`` at the first sub-predicate that returns ``False``. """ if kwargs: predicates += Query(**kwargs), return _flatten(_And, *predicates)
python
def And(*predicates, **kwargs): """ `And` predicate. Returns ``False`` at the first sub-predicate that returns ``False``. """ if kwargs: predicates += Query(**kwargs), return _flatten(_And, *predicates)
[ "def", "And", "(", "*", "predicates", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "predicates", "+=", "Query", "(", "*", "*", "kwargs", ")", ",", "return", "_flatten", "(", "_And", ",", "*", "predicates", ")" ]
`And` predicate. Returns ``False`` at the first sub-predicate that returns ``False``.
[ "And", "predicate", ".", "Returns", "False", "at", "the", "first", "sub", "-", "predicate", "that", "returns", "False", "." ]
b3a1310b0593d2c6b6ef430883843896e17d6a81
https://github.com/ionelmc/python-hunter/blob/b3a1310b0593d2c6b6ef430883843896e17d6a81/src/hunter/__init__.py#L120-L126
11,685
ionelmc/python-hunter
src/hunter/__init__.py
Or
def Or(*predicates, **kwargs): """ `Or` predicate. Returns ``True`` at the first sub-predicate that returns ``True``. """ if kwargs: predicates += tuple(Query(**{k: v}) for k, v in kwargs.items()) return _flatten(_Or, *predicates)
python
def Or(*predicates, **kwargs): """ `Or` predicate. Returns ``True`` at the first sub-predicate that returns ``True``. """ if kwargs: predicates += tuple(Query(**{k: v}) for k, v in kwargs.items()) return _flatten(_Or, *predicates)
[ "def", "Or", "(", "*", "predicates", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "predicates", "+=", "tuple", "(", "Query", "(", "*", "*", "{", "k", ":", "v", "}", ")", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")",...
`Or` predicate. Returns ``True`` at the first sub-predicate that returns ``True``.
[ "Or", "predicate", ".", "Returns", "True", "at", "the", "first", "sub", "-", "predicate", "that", "returns", "True", "." ]
b3a1310b0593d2c6b6ef430883843896e17d6a81
https://github.com/ionelmc/python-hunter/blob/b3a1310b0593d2c6b6ef430883843896e17d6a81/src/hunter/__init__.py#L129-L135
11,686
ionelmc/python-hunter
src/hunter/__init__.py
wrap
def wrap(function_to_trace=None, **trace_options): """ Functions decorated with this will be traced. Use ``local=True`` to only trace local code, eg:: @hunter.wrap(local=True) def my_function(): ... Keyword arguments are allowed, eg:: @hunter.wrap(action=hunter.Ca...
python
def wrap(function_to_trace=None, **trace_options): """ Functions decorated with this will be traced. Use ``local=True`` to only trace local code, eg:: @hunter.wrap(local=True) def my_function(): ... Keyword arguments are allowed, eg:: @hunter.wrap(action=hunter.Ca...
[ "def", "wrap", "(", "function_to_trace", "=", "None", ",", "*", "*", "trace_options", ")", ":", "def", "tracing_decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "tracing_wrapper", "(", "*", "args", ",", "*", "...
Functions decorated with this will be traced. Use ``local=True`` to only trace local code, eg:: @hunter.wrap(local=True) def my_function(): ... Keyword arguments are allowed, eg:: @hunter.wrap(action=hunter.CallPrinter) def my_function(): ... Or, ...
[ "Functions", "decorated", "with", "this", "will", "be", "traced", "." ]
b3a1310b0593d2c6b6ef430883843896e17d6a81
https://github.com/ionelmc/python-hunter/blob/b3a1310b0593d2c6b6ef430883843896e17d6a81/src/hunter/__init__.py#L210-L250
11,687
ionelmc/python-hunter
src/hunter/event.py
Event.threadid
def threadid(self): """ Current thread ident. If current thread is main thread then it returns ``None``. :type: int or None """ current = self.thread.ident main = get_main_thread() if main is None: return current else: return curre...
python
def threadid(self): """ Current thread ident. If current thread is main thread then it returns ``None``. :type: int or None """ current = self.thread.ident main = get_main_thread() if main is None: return current else: return curre...
[ "def", "threadid", "(", "self", ")", ":", "current", "=", "self", ".", "thread", ".", "ident", "main", "=", "get_main_thread", "(", ")", "if", "main", "is", "None", ":", "return", "current", "else", ":", "return", "current", "if", "current", "!=", "mai...
Current thread ident. If current thread is main thread then it returns ``None``. :type: int or None
[ "Current", "thread", "ident", ".", "If", "current", "thread", "is", "main", "thread", "then", "it", "returns", "None", "." ]
b3a1310b0593d2c6b6ef430883843896e17d6a81
https://github.com/ionelmc/python-hunter/blob/b3a1310b0593d2c6b6ef430883843896e17d6a81/src/hunter/event.py#L101-L112
11,688
ionelmc/python-hunter
src/hunter/event.py
Event.filename
def filename(self, exists=os.path.exists, cython_suffix_re=CYTHON_SUFFIX_RE): """ A string with absolute path to file. :type: str """ filename = self.frame.f_globals.get('__file__', '') if filename is None: filename = '' if filename.endswith(('.pyc',...
python
def filename(self, exists=os.path.exists, cython_suffix_re=CYTHON_SUFFIX_RE): """ A string with absolute path to file. :type: str """ filename = self.frame.f_globals.get('__file__', '') if filename is None: filename = '' if filename.endswith(('.pyc',...
[ "def", "filename", "(", "self", ",", "exists", "=", "os", ".", "path", ".", "exists", ",", "cython_suffix_re", "=", "CYTHON_SUFFIX_RE", ")", ":", "filename", "=", "self", ".", "frame", ".", "f_globals", ".", "get", "(", "'__file__'", ",", "''", ")", "i...
A string with absolute path to file. :type: str
[ "A", "string", "with", "absolute", "path", "to", "file", "." ]
b3a1310b0593d2c6b6ef430883843896e17d6a81
https://github.com/ionelmc/python-hunter/blob/b3a1310b0593d2c6b6ef430883843896e17d6a81/src/hunter/event.py#L176-L197
11,689
ionelmc/python-hunter
src/hunter/event.py
Event.stdlib
def stdlib(self): """ A boolean flag. ``True`` if frame is in stdlib. :type: bool """ if self.module == 'pkg_resources' or self.module.startswith('pkg_resources.'): return False elif self.filename.startswith(SITE_PACKAGES_PATHS): # if it's in site...
python
def stdlib(self): """ A boolean flag. ``True`` if frame is in stdlib. :type: bool """ if self.module == 'pkg_resources' or self.module.startswith('pkg_resources.'): return False elif self.filename.startswith(SITE_PACKAGES_PATHS): # if it's in site...
[ "def", "stdlib", "(", "self", ")", ":", "if", "self", ".", "module", "==", "'pkg_resources'", "or", "self", ".", "module", ".", "startswith", "(", "'pkg_resources.'", ")", ":", "return", "False", "elif", "self", ".", "filename", ".", "startswith", "(", "...
A boolean flag. ``True`` if frame is in stdlib. :type: bool
[ "A", "boolean", "flag", ".", "True", "if", "frame", "is", "in", "stdlib", "." ]
b3a1310b0593d2c6b6ef430883843896e17d6a81
https://github.com/ionelmc/python-hunter/blob/b3a1310b0593d2c6b6ef430883843896e17d6a81/src/hunter/event.py#L216-L230
11,690
ionelmc/python-hunter
src/hunter/actions.py
VarsPrinter._iter_symbols
def _iter_symbols(code): """ Iterate all the variable names in the given expression. Example: * ``self.foobar`` yields ``self`` * ``self[foobar]`` yields `self`` and ``foobar`` """ for node in ast.walk(ast.parse(code)): if isinstance(node, ast.Name):...
python
def _iter_symbols(code): """ Iterate all the variable names in the given expression. Example: * ``self.foobar`` yields ``self`` * ``self[foobar]`` yields `self`` and ``foobar`` """ for node in ast.walk(ast.parse(code)): if isinstance(node, ast.Name):...
[ "def", "_iter_symbols", "(", "code", ")", ":", "for", "node", "in", "ast", ".", "walk", "(", "ast", ".", "parse", "(", "code", ")", ")", ":", "if", "isinstance", "(", "node", ",", "ast", ".", "Name", ")", ":", "yield", "node", ".", "id" ]
Iterate all the variable names in the given expression. Example: * ``self.foobar`` yields ``self`` * ``self[foobar]`` yields `self`` and ``foobar``
[ "Iterate", "all", "the", "variable", "names", "in", "the", "given", "expression", "." ]
b3a1310b0593d2c6b6ef430883843896e17d6a81
https://github.com/ionelmc/python-hunter/blob/b3a1310b0593d2c6b6ef430883843896e17d6a81/src/hunter/actions.py#L437-L448
11,691
HttpRunner/har2case
har2case/core.py
HarParser.__make_request_url
def __make_request_url(self, teststep_dict, entry_json): """ parse HAR entry request url and queryString, and make teststep url and params Args: entry_json (dict): { "request": { "url": "https://httprunner.top/home?v=1&w=2", ...
python
def __make_request_url(self, teststep_dict, entry_json): """ parse HAR entry request url and queryString, and make teststep url and params Args: entry_json (dict): { "request": { "url": "https://httprunner.top/home?v=1&w=2", ...
[ "def", "__make_request_url", "(", "self", ",", "teststep_dict", ",", "entry_json", ")", ":", "request_params", "=", "utils", ".", "convert_list_to_dict", "(", "entry_json", "[", "\"request\"", "]", ".", "get", "(", "\"queryString\"", ",", "[", "]", ")", ")", ...
parse HAR entry request url and queryString, and make teststep url and params Args: entry_json (dict): { "request": { "url": "https://httprunner.top/home?v=1&w=2", "queryString": [ {"name...
[ "parse", "HAR", "entry", "request", "url", "and", "queryString", "and", "make", "teststep", "url", "and", "params" ]
369e576b24b3521832c35344b104828e30742170
https://github.com/HttpRunner/har2case/blob/369e576b24b3521832c35344b104828e30742170/har2case/core.py#L43-L86
11,692
HttpRunner/har2case
har2case/core.py
HarParser.__make_request_method
def __make_request_method(self, teststep_dict, entry_json): """ parse HAR entry request method, and make teststep method. """ method = entry_json["request"].get("method") if not method: logging.exception("method missed in request.") sys.exit(1) teststep_d...
python
def __make_request_method(self, teststep_dict, entry_json): """ parse HAR entry request method, and make teststep method. """ method = entry_json["request"].get("method") if not method: logging.exception("method missed in request.") sys.exit(1) teststep_d...
[ "def", "__make_request_method", "(", "self", ",", "teststep_dict", ",", "entry_json", ")", ":", "method", "=", "entry_json", "[", "\"request\"", "]", ".", "get", "(", "\"method\"", ")", "if", "not", "method", ":", "logging", ".", "exception", "(", "\"method ...
parse HAR entry request method, and make teststep method.
[ "parse", "HAR", "entry", "request", "method", "and", "make", "teststep", "method", "." ]
369e576b24b3521832c35344b104828e30742170
https://github.com/HttpRunner/har2case/blob/369e576b24b3521832c35344b104828e30742170/har2case/core.py#L88-L96
11,693
HttpRunner/har2case
har2case/core.py
HarParser.__make_request_headers
def __make_request_headers(self, teststep_dict, entry_json): """ parse HAR entry request headers, and make teststep headers. header in IGNORE_REQUEST_HEADERS will be ignored. Args: entry_json (dict): { "request": { "hea...
python
def __make_request_headers(self, teststep_dict, entry_json): """ parse HAR entry request headers, and make teststep headers. header in IGNORE_REQUEST_HEADERS will be ignored. Args: entry_json (dict): { "request": { "hea...
[ "def", "__make_request_headers", "(", "self", ",", "teststep_dict", ",", "entry_json", ")", ":", "teststep_headers", "=", "{", "}", "for", "header", "in", "entry_json", "[", "\"request\"", "]", ".", "get", "(", "\"headers\"", ",", "[", "]", ")", ":", "if",...
parse HAR entry request headers, and make teststep headers. header in IGNORE_REQUEST_HEADERS will be ignored. Args: entry_json (dict): { "request": { "headers": [ {"name": "Host", "value": "httprunne...
[ "parse", "HAR", "entry", "request", "headers", "and", "make", "teststep", "headers", ".", "header", "in", "IGNORE_REQUEST_HEADERS", "will", "be", "ignored", "." ]
369e576b24b3521832c35344b104828e30742170
https://github.com/HttpRunner/har2case/blob/369e576b24b3521832c35344b104828e30742170/har2case/core.py#L98-L130
11,694
HttpRunner/har2case
har2case/core.py
HarParser._make_request_data
def _make_request_data(self, teststep_dict, entry_json): """ parse HAR entry request data, and make teststep request data Args: entry_json (dict): { "request": { "method": "POST", "postData": { ...
python
def _make_request_data(self, teststep_dict, entry_json): """ parse HAR entry request data, and make teststep request data Args: entry_json (dict): { "request": { "method": "POST", "postData": { ...
[ "def", "_make_request_data", "(", "self", ",", "teststep_dict", ",", "entry_json", ")", ":", "method", "=", "entry_json", "[", "\"request\"", "]", ".", "get", "(", "\"method\"", ")", "if", "method", "in", "[", "\"POST\"", ",", "\"PUT\"", ",", "\"PATCH\"", ...
parse HAR entry request data, and make teststep request data Args: entry_json (dict): { "request": { "method": "POST", "postData": { "mimeType": "application/x-www-form-urlencoded; charse...
[ "parse", "HAR", "entry", "request", "data", "and", "make", "teststep", "request", "data" ]
369e576b24b3521832c35344b104828e30742170
https://github.com/HttpRunner/har2case/blob/369e576b24b3521832c35344b104828e30742170/har2case/core.py#L132-L188
11,695
HttpRunner/har2case
har2case/core.py
HarParser._make_validate
def _make_validate(self, teststep_dict, entry_json): """ parse HAR entry response and make teststep validate. Args: entry_json (dict): { "request": {}, "response": { "status": 200, "heade...
python
def _make_validate(self, teststep_dict, entry_json): """ parse HAR entry response and make teststep validate. Args: entry_json (dict): { "request": {}, "response": { "status": 200, "heade...
[ "def", "_make_validate", "(", "self", ",", "teststep_dict", ",", "entry_json", ")", ":", "teststep_dict", "[", "\"validate\"", "]", ".", "append", "(", "{", "\"eq\"", ":", "[", "\"status_code\"", ",", "entry_json", "[", "\"response\"", "]", ".", "get", "(", ...
parse HAR entry response and make teststep validate. Args: entry_json (dict): { "request": {}, "response": { "status": 200, "headers": [ { ...
[ "parse", "HAR", "entry", "response", "and", "make", "teststep", "validate", "." ]
369e576b24b3521832c35344b104828e30742170
https://github.com/HttpRunner/har2case/blob/369e576b24b3521832c35344b104828e30742170/har2case/core.py#L190-L266
11,696
HttpRunner/har2case
har2case/utils.py
load_har_log_entries
def load_har_log_entries(file_path): """ load HAR file and return log entries list Args: file_path (str) Returns: list: entries [ { "request": {}, "response": {} }, { "re...
python
def load_har_log_entries(file_path): """ load HAR file and return log entries list Args: file_path (str) Returns: list: entries [ { "request": {}, "response": {} }, { "re...
[ "def", "load_har_log_entries", "(", "file_path", ")", ":", "with", "io", ".", "open", "(", "file_path", ",", "\"r+\"", ",", "encoding", "=", "\"utf-8-sig\"", ")", "as", "f", ":", "try", ":", "content_json", "=", "json", ".", "loads", "(", "f", ".", "re...
load HAR file and return log entries list Args: file_path (str) Returns: list: entries [ { "request": {}, "response": {} }, { "request": {}, "response": {...
[ "load", "HAR", "file", "and", "return", "log", "entries", "list" ]
369e576b24b3521832c35344b104828e30742170
https://github.com/HttpRunner/har2case/blob/369e576b24b3521832c35344b104828e30742170/har2case/utils.py#L10-L36
11,697
HttpRunner/har2case
har2case/utils.py
x_www_form_urlencoded
def x_www_form_urlencoded(post_data): """ convert origin dict to x-www-form-urlencoded Args: post_data (dict): {"a": 1, "b":2} Returns: str: a=1&b=2 """ if isinstance(post_data, dict): return "&".join([ u"{}={}".format(key, value) ...
python
def x_www_form_urlencoded(post_data): """ convert origin dict to x-www-form-urlencoded Args: post_data (dict): {"a": 1, "b":2} Returns: str: a=1&b=2 """ if isinstance(post_data, dict): return "&".join([ u"{}={}".format(key, value) ...
[ "def", "x_www_form_urlencoded", "(", "post_data", ")", ":", "if", "isinstance", "(", "post_data", ",", "dict", ")", ":", "return", "\"&\"", ".", "join", "(", "[", "u\"{}={}\"", ".", "format", "(", "key", ",", "value", ")", "for", "key", ",", "value", "...
convert origin dict to x-www-form-urlencoded Args: post_data (dict): {"a": 1, "b":2} Returns: str: a=1&b=2
[ "convert", "origin", "dict", "to", "x", "-", "www", "-", "form", "-", "urlencoded" ]
369e576b24b3521832c35344b104828e30742170
https://github.com/HttpRunner/har2case/blob/369e576b24b3521832c35344b104828e30742170/har2case/utils.py#L39-L57
11,698
HttpRunner/har2case
har2case/utils.py
convert_x_www_form_urlencoded_to_dict
def convert_x_www_form_urlencoded_to_dict(post_data): """ convert x_www_form_urlencoded data to dict Args: post_data (str): a=1&b=2 Returns: dict: {"a":1, "b":2} """ if isinstance(post_data, str): converted_dict = {} for k_v in post_data.split("&"): try...
python
def convert_x_www_form_urlencoded_to_dict(post_data): """ convert x_www_form_urlencoded data to dict Args: post_data (str): a=1&b=2 Returns: dict: {"a":1, "b":2} """ if isinstance(post_data, str): converted_dict = {} for k_v in post_data.split("&"): try...
[ "def", "convert_x_www_form_urlencoded_to_dict", "(", "post_data", ")", ":", "if", "isinstance", "(", "post_data", ",", "str", ")", ":", "converted_dict", "=", "{", "}", "for", "k_v", "in", "post_data", ".", "split", "(", "\"&\"", ")", ":", "try", ":", "key...
convert x_www_form_urlencoded data to dict Args: post_data (str): a=1&b=2 Returns: dict: {"a":1, "b":2}
[ "convert", "x_www_form_urlencoded", "data", "to", "dict" ]
369e576b24b3521832c35344b104828e30742170
https://github.com/HttpRunner/har2case/blob/369e576b24b3521832c35344b104828e30742170/har2case/utils.py#L60-L82
11,699
HttpRunner/har2case
har2case/utils.py
dump_yaml
def dump_yaml(testcase, yaml_file): """ dump HAR entries to yaml testcase """ logging.info("dump testcase to YAML format.") with io.open(yaml_file, 'w', encoding="utf-8") as outfile: yaml.dump(testcase, outfile, allow_unicode=True, default_flow_style=False, indent=4) logging.info("Generate...
python
def dump_yaml(testcase, yaml_file): """ dump HAR entries to yaml testcase """ logging.info("dump testcase to YAML format.") with io.open(yaml_file, 'w', encoding="utf-8") as outfile: yaml.dump(testcase, outfile, allow_unicode=True, default_flow_style=False, indent=4) logging.info("Generate...
[ "def", "dump_yaml", "(", "testcase", ",", "yaml_file", ")", ":", "logging", ".", "info", "(", "\"dump testcase to YAML format.\"", ")", "with", "io", ".", "open", "(", "yaml_file", ",", "'w'", ",", "encoding", "=", "\"utf-8\"", ")", "as", "outfile", ":", "...
dump HAR entries to yaml testcase
[ "dump", "HAR", "entries", "to", "yaml", "testcase" ]
369e576b24b3521832c35344b104828e30742170
https://github.com/HttpRunner/har2case/blob/369e576b24b3521832c35344b104828e30742170/har2case/utils.py#L106-L114