repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
mjirik/io3d
io3d/dcmreaddata.py
DicomDirectory.print_series_info
def print_series_info(self, series_info, minimal_series_number=1): """ Print series_info from dcmdirstats """ strinfo = '' if len(series_info) > minimal_series_number: for serie_number in series_info.keys(): strl = get_one_serie_info(series_info, serie...
python
def print_series_info(self, series_info, minimal_series_number=1): """ Print series_info from dcmdirstats """ strinfo = '' if len(series_info) > minimal_series_number: for serie_number in series_info.keys(): strl = get_one_serie_info(series_info, serie...
[ "def", "print_series_info", "(", "self", ",", "series_info", ",", "minimal_series_number", "=", "1", ")", ":", "strinfo", "=", "''", "if", "len", "(", "series_info", ")", ">", "minimal_series_number", ":", "for", "serie_number", "in", "series_info", ".", "keys...
Print series_info from dcmdirstats
[ "Print", "series_info", "from", "dcmdirstats" ]
train
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmreaddata.py#L645-L656
mjirik/io3d
io3d/dcmreaddata.py
DicomDirectory.__prepare_info_from_dicomdir_file
def __prepare_info_from_dicomdir_file(self, writedicomdirfile=True): """ Check if exists dicomdir file and load it or cerate it dcmdir = get_dir(dirpath) dcmdir: list with filenames, SeriesNumber and SliceLocation """ createdcmdir = True dicomdirfile = os.path....
python
def __prepare_info_from_dicomdir_file(self, writedicomdirfile=True): """ Check if exists dicomdir file and load it or cerate it dcmdir = get_dir(dirpath) dcmdir: list with filenames, SeriesNumber and SliceLocation """ createdcmdir = True dicomdirfile = os.path....
[ "def", "__prepare_info_from_dicomdir_file", "(", "self", ",", "writedicomdirfile", "=", "True", ")", ":", "createdcmdir", "=", "True", "dicomdirfile", "=", "os", ".", "path", ".", "join", "(", "self", ".", "dirpath", ",", "self", ".", "dicomdir_filename", ")",...
Check if exists dicomdir file and load it or cerate it dcmdir = get_dir(dirpath) dcmdir: list with filenames, SeriesNumber and SliceLocation
[ "Check", "if", "exists", "dicomdir", "file", "and", "load", "it", "or", "cerate", "it" ]
train
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmreaddata.py#L679-L718
mjirik/io3d
io3d/dcmreaddata.py
DicomDirectory.series_in_dir
def series_in_dir(self): """input is dcmdir, not dirpath """ # none_count = 0 countsd = {} # dcmdirseries = [] for line in self.files_with_info: if "SeriesNumber" in line: sn = line['SeriesNumber'] else: sn = None ...
python
def series_in_dir(self): """input is dcmdir, not dirpath """ # none_count = 0 countsd = {} # dcmdirseries = [] for line in self.files_with_info: if "SeriesNumber" in line: sn = line['SeriesNumber'] else: sn = None ...
[ "def", "series_in_dir", "(", "self", ")", ":", "# none_count = 0", "countsd", "=", "{", "}", "# dcmdirseries = []", "for", "line", "in", "self", ".", "files_with_info", ":", "if", "\"SeriesNumber\"", "in", "line", ":", "sn", "=", "line", "[", "'SeriesNumber'",...
input is dcmdir, not dirpath
[ "input", "is", "dcmdir", "not", "dirpath" ]
train
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmreaddata.py#L720-L765
mjirik/io3d
io3d/dcmreaddata.py
DicomDirectory.get_sorted_series_files
def get_sorted_series_files(self, startpath="", series_number=None, return_files_with_info=False, sort_keys="SliceLocation", return_files=True, remove_doubled_slice_locations=True): """ Function returns sorted list of dicom files. File paths are organized by Serie...
python
def get_sorted_series_files(self, startpath="", series_number=None, return_files_with_info=False, sort_keys="SliceLocation", return_files=True, remove_doubled_slice_locations=True): """ Function returns sorted list of dicom files. File paths are organized by Serie...
[ "def", "get_sorted_series_files", "(", "self", ",", "startpath", "=", "\"\"", ",", "series_number", "=", "None", ",", "return_files_with_info", "=", "False", ",", "sort_keys", "=", "\"SliceLocation\"", ",", "return_files", "=", "True", ",", "remove_doubled_slice_loc...
Function returns sorted list of dicom files. File paths are organized by SeriesUID, StudyUID and FrameUID :param startpath: path prefix. E.g. "~/data" :param series_number: ID of series used for filtering the data :param return_files_with_info: return more complex information about sor...
[ "Function", "returns", "sorted", "list", "of", "dicom", "files", ".", "File", "paths", "are", "organized", "by", "SeriesUID", "StudyUID", "and", "FrameUID" ]
train
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmreaddata.py#L767-L815
mjirik/io3d
io3d/dcmreaddata.py
DicomDirectory._create_dicomdir_info
def _create_dicomdir_info(self): """ Function crates list of all files in dicom dir with all IDs """ filelist = files_in_dir(self.dirpath) files = [] metadataline = {} for filepath in filelist: head, teil = os.path.split(filepath) dcmdata...
python
def _create_dicomdir_info(self): """ Function crates list of all files in dicom dir with all IDs """ filelist = files_in_dir(self.dirpath) files = [] metadataline = {} for filepath in filelist: head, teil = os.path.split(filepath) dcmdata...
[ "def", "_create_dicomdir_info", "(", "self", ")", ":", "filelist", "=", "files_in_dir", "(", "self", ".", "dirpath", ")", "files", "=", "[", "]", "metadataline", "=", "{", "}", "for", "filepath", "in", "filelist", ":", "head", ",", "teil", "=", "os", "...
Function crates list of all files in dicom dir with all IDs
[ "Function", "crates", "list", "of", "all", "files", "in", "dicom", "dir", "with", "all", "IDs" ]
train
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmreaddata.py#L828-L874
ClericPy/torequests
torequests/parsers.py
get_one
def get_one(seq, default=None, skip_string_iter=True): """ Return one item from seq or None(by default). """ if skip_string_iter and isinstance(seq, (str, unicode, bytes, bytearray)): return seq if not seq: return '' try: return next(iter(seq)) except TypeError: ...
python
def get_one(seq, default=None, skip_string_iter=True): """ Return one item from seq or None(by default). """ if skip_string_iter and isinstance(seq, (str, unicode, bytes, bytearray)): return seq if not seq: return '' try: return next(iter(seq)) except TypeError: ...
[ "def", "get_one", "(", "seq", ",", "default", "=", "None", ",", "skip_string_iter", "=", "True", ")", ":", "if", "skip_string_iter", "and", "isinstance", "(", "seq", ",", "(", "str", ",", "unicode", ",", "bytes", ",", "bytearray", ")", ")", ":", "retur...
Return one item from seq or None(by default).
[ "Return", "one", "item", "from", "seq", "or", "None", "(", "by", "default", ")", "." ]
train
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/parsers.py#L15-L27
ClericPy/torequests
torequests/parsers.py
SimpleParser.ensure_list
def ensure_list(obj): """ null obj -> return []; str, unicode, bytes, bytearray -> [obj]; else -> list(obj) """ if not obj: return [] elif isinstance(obj, (str, unicode, bytes, bytearray)): return [obj] elif hasattr(obj, '__iter_...
python
def ensure_list(obj): """ null obj -> return []; str, unicode, bytes, bytearray -> [obj]; else -> list(obj) """ if not obj: return [] elif isinstance(obj, (str, unicode, bytes, bytearray)): return [obj] elif hasattr(obj, '__iter_...
[ "def", "ensure_list", "(", "obj", ")", ":", "if", "not", "obj", ":", "return", "[", "]", "elif", "isinstance", "(", "obj", ",", "(", "str", ",", "unicode", ",", "bytes", ",", "bytearray", ")", ")", ":", "return", "[", "obj", "]", "elif", "hasattr",...
null obj -> return []; str, unicode, bytes, bytearray -> [obj]; else -> list(obj)
[ "null", "obj", "-", ">", "return", "[]", ";" ]
train
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/parsers.py#L167-L182
ClericPy/torequests
torequests/parsers.py
SimpleParser.python_parser
def python_parser(self, obj, *args): """operate a python obj""" attr, args = args[0], args[1:] item = getattr(obj, attr) if callable(item): item = item(*args) return [item]
python
def python_parser(self, obj, *args): """operate a python obj""" attr, args = args[0], args[1:] item = getattr(obj, attr) if callable(item): item = item(*args) return [item]
[ "def", "python_parser", "(", "self", ",", "obj", ",", "*", "args", ")", ":", "attr", ",", "args", "=", "args", "[", "0", "]", ",", "args", "[", "1", ":", "]", "item", "=", "getattr", "(", "obj", ",", "attr", ")", "if", "callable", "(", "item", ...
operate a python obj
[ "operate", "a", "python", "obj" ]
train
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/parsers.py#L194-L200
ClericPy/torequests
torequests/parsers.py
SimpleParser.re_parser
def re_parser(self, scode, *args): """ args: [arg1, arg2] arg[0] = a valid regex pattern arg[1] : if startswith('@') call sub; if startswith('$') call finditer, $0, $1 means group index. return an ensure_list """ def gen_match(matches, num): ...
python
def re_parser(self, scode, *args): """ args: [arg1, arg2] arg[0] = a valid regex pattern arg[1] : if startswith('@') call sub; if startswith('$') call finditer, $0, $1 means group index. return an ensure_list """ def gen_match(matches, num): ...
[ "def", "re_parser", "(", "self", ",", "scode", ",", "*", "args", ")", ":", "def", "gen_match", "(", "matches", ",", "num", ")", ":", "for", "match", "in", "matches", ":", "yield", "match", ".", "group", "(", "num", ")", "scode", "=", "self", ".", ...
args: [arg1, arg2] arg[0] = a valid regex pattern arg[1] : if startswith('@') call sub; if startswith('$') call finditer, $0, $1 means group index. return an ensure_list
[ "args", ":", "[", "arg1", "arg2", "]" ]
train
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/parsers.py#L202-L228
ClericPy/torequests
torequests/parsers.py
SimpleParser.html_parser
def html_parser(self, scode, *args): """ args[0] = cssselector args[1] = text / html / xml / @attribute_name """ allow_method = ('text', 'html', 'xml') css_path, method = args assert method in allow_method or method.startswith( '@'), 'method allow: %s...
python
def html_parser(self, scode, *args): """ args[0] = cssselector args[1] = text / html / xml / @attribute_name """ allow_method = ('text', 'html', 'xml') css_path, method = args assert method in allow_method or method.startswith( '@'), 'method allow: %s...
[ "def", "html_parser", "(", "self", ",", "scode", ",", "*", "args", ")", ":", "allow_method", "=", "(", "'text'", ",", "'html'", ",", "'xml'", ")", "css_path", ",", "method", "=", "args", "assert", "method", "in", "allow_method", "or", "method", ".", "s...
args[0] = cssselector args[1] = text / html / xml / @attribute_name
[ "args", "[", "0", "]", "=", "cssselector" ]
train
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/parsers.py#L230-L251
ClericPy/torequests
torequests/parsers.py
SimpleParser.xml_parser
def xml_parser(self, scode, *args): """ args[0]: xpath args[1]: text / html / xml """ allow_method = ('text', 'html', 'xml') xpath_string, method = args assert method in allow_method, 'method allow: %s' % allow_method result = self.ensure_list( ...
python
def xml_parser(self, scode, *args): """ args[0]: xpath args[1]: text / html / xml """ allow_method = ('text', 'html', 'xml') xpath_string, method = args assert method in allow_method, 'method allow: %s' % allow_method result = self.ensure_list( ...
[ "def", "xml_parser", "(", "self", ",", "scode", ",", "*", "args", ")", ":", "allow_method", "=", "(", "'text'", ",", "'html'", ",", "'xml'", ")", "xpath_string", ",", "method", "=", "args", "assert", "method", "in", "allow_method", ",", "'method allow: %s'...
args[0]: xpath args[1]: text / html / xml
[ "args", "[", "0", "]", ":", "xpath" ]
train
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/parsers.py#L253-L270
ClericPy/torequests
torequests/parsers.py
SimpleParser.parse
def parse(self, scode, args_chain=None, join_with=None, default=''): """ single arg: [one_to_many, parser_name, *args] args_chain: [['1-n', 're', 'search', '(<.*?>)', '\\1']] [['1-n', 'html', 'p', 'html'], ['n-n', 'html', 'p', 'text']] """ ass...
python
def parse(self, scode, args_chain=None, join_with=None, default=''): """ single arg: [one_to_many, parser_name, *args] args_chain: [['1-n', 're', 'search', '(<.*?>)', '\\1']] [['1-n', 'html', 'p', 'html'], ['n-n', 'html', 'p', 'text']] """ ass...
[ "def", "parse", "(", "self", ",", "scode", ",", "args_chain", "=", "None", ",", "join_with", "=", "None", ",", "default", "=", "''", ")", ":", "assert", "args_chain", "and", "isinstance", "(", "args_chain", ",", "(", "list", ",", "tuple", ")", ")", "...
single arg: [one_to_many, parser_name, *args] args_chain: [['1-n', 're', 'search', '(<.*?>)', '\\1']] [['1-n', 'html', 'p', 'html'], ['n-n', 'html', 'p', 'text']]
[ "single", "arg", ":", "[", "one_to_many", "parser_name", "*", "args", "]", "args_chain", ":", "[[", "1", "-", "n", "re", "search", "(", "<", ".", "*", "?", ">", ")", "\\\\", "1", "]]", "[[", "1", "-", "n", "html", "p", "html", "]", "[", "n", ...
train
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/parsers.py#L291-L336
jurismarches/chopper
chopper/css/extractor.py
CSSExtractor.parse
def parse(self): """ Parses the CSS contents and returns the cleaned CSS as a string :returns: The cleaned CSS :rtype: str """ # Build the HTML tree self.tree = self._build_tree(self.html_contents) # Parse the CSS contents self.stylesheet = self....
python
def parse(self): """ Parses the CSS contents and returns the cleaned CSS as a string :returns: The cleaned CSS :rtype: str """ # Build the HTML tree self.tree = self._build_tree(self.html_contents) # Parse the CSS contents self.stylesheet = self....
[ "def", "parse", "(", "self", ")", ":", "# Build the HTML tree", "self", ".", "tree", "=", "self", ".", "_build_tree", "(", "self", ".", "html_contents", ")", "# Parse the CSS contents", "self", ".", "stylesheet", "=", "self", ".", "parser", ".", "parse_stylesh...
Parses the CSS contents and returns the cleaned CSS as a string :returns: The cleaned CSS :rtype: str
[ "Parses", "the", "CSS", "contents", "and", "returns", "the", "cleaned", "CSS", "as", "a", "string" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/css/extractor.py#L42-L56
jurismarches/chopper
chopper/css/extractor.py
CSSExtractor.rel_to_abs
def rel_to_abs(self, base_url): """ Converts relative links from css contents to absolute links :param base_url: The base page url to use for building absolute links :type base_url: str :param css_contents: The CSS contents to parse :type css_contents: str """ ...
python
def rel_to_abs(self, base_url): """ Converts relative links from css contents to absolute links :param base_url: The base page url to use for building absolute links :type base_url: str :param css_contents: The CSS contents to parse :type css_contents: str """ ...
[ "def", "rel_to_abs", "(", "self", ",", "base_url", ")", ":", "self", ".", "cleaned_css", "=", "self", ".", "rel_to_abs_re", ".", "sub", "(", "lambda", "match", ":", "\"url('%s')\"", "%", "urljoin", "(", "base_url", ",", "match", ".", "group", "(", "'path...
Converts relative links from css contents to absolute links :param base_url: The base page url to use for building absolute links :type base_url: str :param css_contents: The CSS contents to parse :type css_contents: str
[ "Converts", "relative", "links", "from", "css", "contents", "to", "absolute", "links" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/css/extractor.py#L58-L70
jurismarches/chopper
chopper/css/extractor.py
CSSExtractor._clean_css
def _clean_css(self): """ Returns the cleaned CSS :param stylesheet: The Stylesheet object to parse :type stylesheet: tinycss.css21.Stylesheet """ # Init the cleaned CSS rules and contents string css_rules = [] # For every rule in the CSS for rul...
python
def _clean_css(self): """ Returns the cleaned CSS :param stylesheet: The Stylesheet object to parse :type stylesheet: tinycss.css21.Stylesheet """ # Init the cleaned CSS rules and contents string css_rules = [] # For every rule in the CSS for rul...
[ "def", "_clean_css", "(", "self", ")", ":", "# Init the cleaned CSS rules and contents string", "css_rules", "=", "[", "]", "# For every rule in the CSS", "for", "rule", "in", "self", ".", "stylesheet", ".", "rules", ":", "try", ":", "# Clean the CSS rule", "cleaned_r...
Returns the cleaned CSS :param stylesheet: The Stylesheet object to parse :type stylesheet: tinycss.css21.Stylesheet
[ "Returns", "the", "cleaned", "CSS" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/css/extractor.py#L85-L110
jurismarches/chopper
chopper/css/extractor.py
CSSExtractor._clean_rule
def _clean_rule(self, rule): """ Cleans a css Rule by removing Selectors without matches on the tree Returns None if the whole rule do not match :param rule: CSS Rule to check :type rule: A tinycss Rule object :returns: A cleaned tinycss Rule with only Selectors matching...
python
def _clean_rule(self, rule): """ Cleans a css Rule by removing Selectors without matches on the tree Returns None if the whole rule do not match :param rule: CSS Rule to check :type rule: A tinycss Rule object :returns: A cleaned tinycss Rule with only Selectors matching...
[ "def", "_clean_rule", "(", "self", ",", "rule", ")", ":", "# Always match @ rules", "if", "rule", ".", "at_keyword", "is", "not", "None", ":", "return", "rule", "# Clean selectors", "cleaned_token_list", "=", "[", "]", "for", "token_list", "in", "split_on_comma"...
Cleans a css Rule by removing Selectors without matches on the tree Returns None if the whole rule do not match :param rule: CSS Rule to check :type rule: A tinycss Rule object :returns: A cleaned tinycss Rule with only Selectors matching the tree or None :rtype: tinycss Rule or...
[ "Cleans", "a", "css", "Rule", "by", "removing", "Selectors", "without", "matches", "on", "the", "tree", "Returns", "None", "if", "the", "whole", "rule", "do", "not", "match" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/css/extractor.py#L112-L150
jurismarches/chopper
chopper/css/extractor.py
CSSExtractor._token_list_matches_tree
def _token_list_matches_tree(self, token_list): """ Returns whether the token list matches the HTML tree :param selector: A Token list to check :type selector: list of Token objects :returns: True if the token list has matches in self.tree :rtype: bool """ ...
python
def _token_list_matches_tree(self, token_list): """ Returns whether the token list matches the HTML tree :param selector: A Token list to check :type selector: list of Token objects :returns: True if the token list has matches in self.tree :rtype: bool """ ...
[ "def", "_token_list_matches_tree", "(", "self", ",", "token_list", ")", ":", "try", ":", "parsed_selector", "=", "cssselect", ".", "parse", "(", "''", ".", "join", "(", "token", ".", "as_css", "(", ")", "for", "token", "in", "token_list", ")", ")", "[", ...
Returns whether the token list matches the HTML tree :param selector: A Token list to check :type selector: list of Token objects :returns: True if the token list has matches in self.tree :rtype: bool
[ "Returns", "whether", "the", "token", "list", "matches", "the", "HTML", "tree" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/css/extractor.py#L152-L170
jurismarches/chopper
chopper/css/extractor.py
CSSExtractor._rule_as_string
def _rule_as_string(self, rule): """ Converts a tinycss rule to a formatted CSS string :param rule: The rule to format :type rule: tinycss Rule object :returns: The Rule as a CSS string :rtype: str """ if isinstance(rule, RuleSet): # Simple CS...
python
def _rule_as_string(self, rule): """ Converts a tinycss rule to a formatted CSS string :param rule: The rule to format :type rule: tinycss Rule object :returns: The Rule as a CSS string :rtype: str """ if isinstance(rule, RuleSet): # Simple CS...
[ "def", "_rule_as_string", "(", "self", ",", "rule", ")", ":", "if", "isinstance", "(", "rule", ",", "RuleSet", ")", ":", "# Simple CSS rule : a { color: red; }", "return", "'%s{%s}'", "%", "(", "self", ".", "_selector_as_string", "(", "rule", ".", "selector", ...
Converts a tinycss rule to a formatted CSS string :param rule: The rule to format :type rule: tinycss Rule object :returns: The Rule as a CSS string :rtype: str
[ "Converts", "a", "tinycss", "rule", "to", "a", "formatted", "CSS", "string" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/css/extractor.py#L184-L223
jurismarches/chopper
chopper/css/extractor.py
CSSExtractor._selector_as_string
def _selector_as_string(self, selector): """ Returns a selector as a CSS string :param selector: A list of tinycss Tokens :type selector: list :returns: The CSS string for the selector :rtype: str """ return ','.join( ''.join(token.as_css() fo...
python
def _selector_as_string(self, selector): """ Returns a selector as a CSS string :param selector: A list of tinycss Tokens :type selector: list :returns: The CSS string for the selector :rtype: str """ return ','.join( ''.join(token.as_css() fo...
[ "def", "_selector_as_string", "(", "self", ",", "selector", ")", ":", "return", "','", ".", "join", "(", "''", ".", "join", "(", "token", ".", "as_css", "(", ")", "for", "token", "in", "strip_whitespace", "(", "token_list", ")", ")", "for", "token_list",...
Returns a selector as a CSS string :param selector: A list of tinycss Tokens :type selector: list :returns: The CSS string for the selector :rtype: str
[ "Returns", "a", "selector", "as", "a", "CSS", "string" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/css/extractor.py#L225-L236
jurismarches/chopper
chopper/css/extractor.py
CSSExtractor._declarations_as_string
def _declarations_as_string(self, declarations): """ Returns a list of declarations as a formatted CSS string :param declarations: The list of tinycss Declarations to format :type declarations: list of tinycss.css21.Declaration :returns: The CSS string for the declarations list ...
python
def _declarations_as_string(self, declarations): """ Returns a list of declarations as a formatted CSS string :param declarations: The list of tinycss Declarations to format :type declarations: list of tinycss.css21.Declaration :returns: The CSS string for the declarations list ...
[ "def", "_declarations_as_string", "(", "self", ",", "declarations", ")", ":", "return", "''", ".", "join", "(", "'%s:%s%s;'", "%", "(", "d", ".", "name", ",", "d", ".", "value", ".", "as_css", "(", ")", ",", "' !'", "+", "d", ".", "priority", "if", ...
Returns a list of declarations as a formatted CSS string :param declarations: The list of tinycss Declarations to format :type declarations: list of tinycss.css21.Declaration :returns: The CSS string for the declarations list :rtype: str
[ "Returns", "a", "list", "of", "declarations", "as", "a", "formatted", "CSS", "string" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/css/extractor.py#L238-L250
vsoch/helpme
helpme/utils/format.py
envars_to_markdown
def envars_to_markdown(envars, title = "Environment"): '''generate a markdown list of a list of environment variable tuples Parameters ========== title: A title for the section (defaults to "Environment" envars: a list of tuples for the environment, e.g.: [('TERM', 'xterm-2...
python
def envars_to_markdown(envars, title = "Environment"): '''generate a markdown list of a list of environment variable tuples Parameters ========== title: A title for the section (defaults to "Environment" envars: a list of tuples for the environment, e.g.: [('TERM', 'xterm-2...
[ "def", "envars_to_markdown", "(", "envars", ",", "title", "=", "\"Environment\"", ")", ":", "markdown", "=", "''", "if", "envars", "not", "in", "[", "None", ",", "''", ",", "[", "]", "]", ":", "markdown", "+=", "'\\n## %s\\n'", "%", "title", "for", "en...
generate a markdown list of a list of environment variable tuples Parameters ========== title: A title for the section (defaults to "Environment" envars: a list of tuples for the environment, e.g.: [('TERM', 'xterm-256color'), ('SHELL', '/bin/bash'), (...
[ "generate", "a", "markdown", "list", "of", "a", "list", "of", "environment", "variable", "tuples" ]
train
https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/utils/format.py#L29-L48
DreamLab/VmShepherd
src/vmshepherd/iaas/abstract.py
AbstractIaasDriver.create_vm
async def create_vm(self, preset_name: str, image: str, flavor: str, security_groups: List=None, userdata: Dict=None, key_name: str=None, availability_zone: str=None, subnets: List=None) -> Any: """ Create (boot) a new server. :arg string preset_n...
python
async def create_vm(self, preset_name: str, image: str, flavor: str, security_groups: List=None, userdata: Dict=None, key_name: str=None, availability_zone: str=None, subnets: List=None) -> Any: """ Create (boot) a new server. :arg string preset_n...
[ "async", "def", "create_vm", "(", "self", ",", "preset_name", ":", "str", ",", "image", ":", "str", ",", "flavor", ":", "str", ",", "security_groups", ":", "List", "=", "None", ",", "userdata", ":", "Dict", "=", "None", ",", "key_name", ":", "str", "...
Create (boot) a new server. :arg string preset_name: Name of vm group where vm is created. :arg string image: Image name. :arg string flavor: Flavor (or instance_type in AWS) name. :arg list security_groups: A list of security group names. :arg dict userdata: A dict of arbitrary...
[ "Create", "(", "boot", ")", "a", "new", "server", "." ]
train
https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/iaas/abstract.py#L26-L46
SetBased/py-stratum
pystratum/application/PyStratumApplication.py
PyStratumApplication.get_default_commands
def get_default_commands(self): """ Returns the default commands of this application. :rtype: list[cleo.Command] """ commands = Application.get_default_commands(self) self.add(ConstantsCommand()) self.add(LoaderCommand()) self.add(PyStratumCommand()) ...
python
def get_default_commands(self): """ Returns the default commands of this application. :rtype: list[cleo.Command] """ commands = Application.get_default_commands(self) self.add(ConstantsCommand()) self.add(LoaderCommand()) self.add(PyStratumCommand()) ...
[ "def", "get_default_commands", "(", "self", ")", ":", "commands", "=", "Application", ".", "get_default_commands", "(", "self", ")", "self", ".", "add", "(", "ConstantsCommand", "(", ")", ")", "self", ".", "add", "(", "LoaderCommand", "(", ")", ")", "self"...
Returns the default commands of this application. :rtype: list[cleo.Command]
[ "Returns", "the", "default", "commands", "of", "this", "application", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/application/PyStratumApplication.py#L25-L38
bpannier/simpletr64
simpletr64/discover.py
Discover.discover
def discover(service="ssdp:all", timeout=1, retries=2, ipAddress="239.255.255.250", port=1900): """Discovers UPnP devices in the local network. Try to discover all devices in the local network which do support UPnP. The discovery process can fail for various reasons and it is recommended to do ...
python
def discover(service="ssdp:all", timeout=1, retries=2, ipAddress="239.255.255.250", port=1900): """Discovers UPnP devices in the local network. Try to discover all devices in the local network which do support UPnP. The discovery process can fail for various reasons and it is recommended to do ...
[ "def", "discover", "(", "service", "=", "\"ssdp:all\"", ",", "timeout", "=", "1", ",", "retries", "=", "2", ",", "ipAddress", "=", "\"239.255.255.250\"", ",", "port", "=", "1900", ")", ":", "socket", ".", "setdefaulttimeout", "(", "timeout", ")", "messages...
Discovers UPnP devices in the local network. Try to discover all devices in the local network which do support UPnP. The discovery process can fail for various reasons and it is recommended to do at least two discoveries, which you can specify with the ``retries`` parameter. The defaul...
[ "Discovers", "UPnP", "devices", "in", "the", "local", "network", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/discover.py#L34-L111
bpannier/simpletr64
simpletr64/discover.py
Discover.discoverParticularHost
def discoverParticularHost(host, service="ssdp:all", deviceDefinitionURL=None, timeout=1, retries=2, ipAddress="239.255.255.250", port=1900, proxies=None): """Discover a particular host and find the best response. This tries to find the most specific discovery result for ...
python
def discoverParticularHost(host, service="ssdp:all", deviceDefinitionURL=None, timeout=1, retries=2, ipAddress="239.255.255.250", port=1900, proxies=None): """Discover a particular host and find the best response. This tries to find the most specific discovery result for ...
[ "def", "discoverParticularHost", "(", "host", ",", "service", "=", "\"ssdp:all\"", ",", "deviceDefinitionURL", "=", "None", ",", "timeout", "=", "1", ",", "retries", "=", "2", ",", "ipAddress", "=", "\"239.255.255.250\"", ",", "port", "=", "1900", ",", "prox...
Discover a particular host and find the best response. This tries to find the most specific discovery result for the given host. Only the discovery result contains the URL to the XML tree which initializes the device definition. If an URL is already known it should be provided to avoid addition...
[ "Discover", "a", "particular", "host", "and", "find", "the", "best", "response", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/discover.py#L114-L265
bpannier/simpletr64
simpletr64/discover.py
Discover.rateServiceTypeInResult
def rateServiceTypeInResult(discoveryResponse): """Gives a quality rating for a given service type in a result, higher is better. Several UpnP devices reply to a discovery request with multiple responses with different service type announcements. To find the most specific one we need to be able...
python
def rateServiceTypeInResult(discoveryResponse): """Gives a quality rating for a given service type in a result, higher is better. Several UpnP devices reply to a discovery request with multiple responses with different service type announcements. To find the most specific one we need to be able...
[ "def", "rateServiceTypeInResult", "(", "discoveryResponse", ")", ":", "if", "discoveryResponse", "is", "None", ":", "return", "0", "serviceType", "=", "discoveryResponse", ".", "service", "if", "serviceType", ".", "startswith", "(", "\"urn:dslforum-org:device\"", ")",...
Gives a quality rating for a given service type in a result, higher is better. Several UpnP devices reply to a discovery request with multiple responses with different service type announcements. To find the most specific one we need to be able rate the service types against each other. Usually...
[ "Gives", "a", "quality", "rating", "for", "a", "given", "service", "type", "in", "a", "result", "higher", "is", "better", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/discover.py#L268-L304
vsoch/helpme
helpme/main/base/http.py
download
def download(self, url, file_name, headers=None, show_progress=True): '''stream to a temporary file, rename on successful completion Parameters ========== file_name: the file name to stream to url: the url to stream from ...
python
def download(self, url, file_name, headers=None, show_progress=True): '''stream to a temporary file, rename on successful completion Parameters ========== file_name: the file name to stream to url: the url to stream from ...
[ "def", "download", "(", "self", ",", "url", ",", "file_name", ",", "headers", "=", "None", ",", "show_progress", "=", "True", ")", ":", "fd", ",", "tmp_file", "=", "tempfile", ".", "mkstemp", "(", "prefix", "=", "(", "\"%s.tmp.\"", "%", "file_name", ")...
stream to a temporary file, rename on successful completion Parameters ========== file_name: the file name to stream to url: the url to stream from headers: additional headers to add force: If the final image exists, don't overwrite
[ "stream", "to", "a", "temporary", "file", "rename", "on", "successful", "completion" ]
train
https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/base/http.py#L172-L204
vsoch/helpme
helpme/main/base/http.py
stream_response
def stream_response(self, response, stream_to=None): ''' stream response is one level higher up than stream, starting with a response object and then performing the stream without making the requests.get. The expectation is that the request was successful (status code 20*). Par...
python
def stream_response(self, response, stream_to=None): ''' stream response is one level higher up than stream, starting with a response object and then performing the stream without making the requests.get. The expectation is that the request was successful (status code 20*). Par...
[ "def", "stream_response", "(", "self", ",", "response", ",", "stream_to", "=", "None", ")", ":", "if", "response", ".", "status_code", "==", "200", ":", "# Keep user updated with Progress Bar", "content_size", "=", "None", "if", "'Content-Length'", "in", "response...
stream response is one level higher up than stream, starting with a response object and then performing the stream without making the requests.get. The expectation is that the request was successful (status code 20*). Parameters ========== response: a response that is ready ...
[ "stream", "response", "is", "one", "level", "higher", "up", "than", "stream", "starting", "with", "a", "response", "object", "and", "then", "performing", "the", "stream", "without", "making", "the", "requests", ".", "get", ".", "The", "expectation", "is", "t...
train
https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/base/http.py#L255-L297
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64.getSCDPURL
def getSCDPURL(self, serviceType, default=None): """Returns the SCDP (Service Control Protocol Document) URL for a given service type. When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this method returns for a given service type/namespace th...
python
def getSCDPURL(self, serviceType, default=None): """Returns the SCDP (Service Control Protocol Document) URL for a given service type. When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this method returns for a given service type/namespace th...
[ "def", "getSCDPURL", "(", "self", ",", "serviceType", ",", "default", "=", "None", ")", ":", "if", "serviceType", "in", "self", ".", "__deviceServiceDefinitions", ".", "keys", "(", ")", ":", "return", "self", ".", "__deviceServiceDefinitions", "[", "serviceTyp...
Returns the SCDP (Service Control Protocol Document) URL for a given service type. When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this method returns for a given service type/namespace the associated URL to the SCDP. If the device definitions ...
[ "Returns", "the", "SCDP", "(", "Service", "Control", "Protocol", "Document", ")", "URL", "for", "a", "given", "service", "type", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L270-L297
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64.getControlURL
def getControlURL(self, serviceType, default=None): """Returns the control URL for a given service type. When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this method returns for a given service type/namespace the associated control URL. If t...
python
def getControlURL(self, serviceType, default=None): """Returns the control URL for a given service type. When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this method returns for a given service type/namespace the associated control URL. If t...
[ "def", "getControlURL", "(", "self", ",", "serviceType", ",", "default", "=", "None", ")", ":", "if", "serviceType", "in", "self", ".", "__deviceServiceDefinitions", ".", "keys", "(", ")", ":", "return", "self", ".", "__deviceServiceDefinitions", "[", "service...
Returns the control URL for a given service type. When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this method returns for a given service type/namespace the associated control URL. If the device definitions have not been loaded a default va...
[ "Returns", "the", "control", "URL", "for", "a", "given", "service", "type", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L299-L326
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64.getEventSubURL
def getEventSubURL(self, serviceType, default=None): """Returns the event URL for a given service type. When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this method returns for a given service type/namespace the associated event URL. If the ...
python
def getEventSubURL(self, serviceType, default=None): """Returns the event URL for a given service type. When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this method returns for a given service type/namespace the associated event URL. If the ...
[ "def", "getEventSubURL", "(", "self", ",", "serviceType", ",", "default", "=", "None", ")", ":", "if", "serviceType", "in", "self", ".", "__deviceServiceDefinitions", ".", "keys", "(", ")", ":", "return", "self", ".", "__deviceServiceDefinitions", "[", "servic...
Returns the event URL for a given service type. When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this method returns for a given service type/namespace the associated event URL. If the device definitions have not been loaded a default value ...
[ "Returns", "the", "event", "URL", "for", "a", "given", "service", "type", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L328-L354
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64.execute
def execute(self, uri, namespace, action, timeout=2, **kwargs): """Executes a given action with optional arguments. The execution of an action of an UPnP/TR64 device needs more than just the name of an action. It needs the control URI which is called to place the action and also the namespace a...
python
def execute(self, uri, namespace, action, timeout=2, **kwargs): """Executes a given action with optional arguments. The execution of an action of an UPnP/TR64 device needs more than just the name of an action. It needs the control URI which is called to place the action and also the namespace a...
[ "def", "execute", "(", "self", ",", "uri", ",", "namespace", ",", "action", ",", "timeout", "=", "2", ",", "*", "*", "kwargs", ")", ":", "if", "not", "uri", ":", "raise", "ValueError", "(", "\"No action URI has been defined.\"", ")", "if", "not", "namesp...
Executes a given action with optional arguments. The execution of an action of an UPnP/TR64 device needs more than just the name of an action. It needs the control URI which is called to place the action and also the namespace aka service type is needed. The namespace defines the scope or servi...
[ "Executes", "a", "given", "action", "with", "optional", "arguments", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L356-L483
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64._extractErrorString
def _extractErrorString(request): """Extract error string from a failed UPnP call. :param request: the failed request result :type request: requests.Response :return: an extracted error text or empty str :rtype: str """ errorStr = "" tag = None ...
python
def _extractErrorString(request): """Extract error string from a failed UPnP call. :param request: the failed request result :type request: requests.Response :return: an extracted error text or empty str :rtype: str """ errorStr = "" tag = None ...
[ "def", "_extractErrorString", "(", "request", ")", ":", "errorStr", "=", "\"\"", "tag", "=", "None", "# noinspection PyBroadException", "try", ":", "# parse XML return", "root", "=", "ET", ".", "fromstring", "(", "request", ".", "text", ".", "encode", "(", "'u...
Extract error string from a failed UPnP call. :param request: the failed request result :type request: requests.Response :return: an extracted error text or empty str :rtype: str
[ "Extract", "error", "string", "from", "a", "failed", "UPnP", "call", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L486-L515
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64.setupTR64Device
def setupTR64Device(self, deviceType): """Setup actions for known devices. For convenience reasons for some devices there is no need to discover/load device definitions before the pre defined :doc:`tr64` can be used. The following devices are currently supported (please help to extend)...
python
def setupTR64Device(self, deviceType): """Setup actions for known devices. For convenience reasons for some devices there is no need to discover/load device definitions before the pre defined :doc:`tr64` can be used. The following devices are currently supported (please help to extend)...
[ "def", "setupTR64Device", "(", "self", ",", "deviceType", ")", ":", "if", "deviceType", ".", "lower", "(", ")", "!=", "\"fritz.box\"", ":", "raise", "ValueError", "(", "\"Unknown device type given.\"", ")", "self", ".", "__deviceServiceDefinitions", "=", "{", "}...
Setup actions for known devices. For convenience reasons for some devices there is no need to discover/load device definitions before the pre defined :doc:`tr64` can be used. The following devices are currently supported (please help to extend): * fritz.box - Any AVM Fritz Box with th...
[ "Setup", "actions", "for", "known", "devices", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L517-L589
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64.loadDeviceDefinitions
def loadDeviceDefinitions(self, urlOfXMLDefinition, timeout=3): """Loads the device definitions from a given URL which points to the root XML in the device. This loads the device definitions which is needed in case you like to: * get additional information's about the device like manufacture, ...
python
def loadDeviceDefinitions(self, urlOfXMLDefinition, timeout=3): """Loads the device definitions from a given URL which points to the root XML in the device. This loads the device definitions which is needed in case you like to: * get additional information's about the device like manufacture, ...
[ "def", "loadDeviceDefinitions", "(", "self", ",", "urlOfXMLDefinition", ",", "timeout", "=", "3", ")", ":", "# setup proxies", "proxies", "=", "{", "}", "if", "self", ".", "__httpsProxy", ":", "proxies", "=", "{", "\"https\"", ":", "self", ".", "__httpsProxy...
Loads the device definitions from a given URL which points to the root XML in the device. This loads the device definitions which is needed in case you like to: * get additional information's about the device like manufacture, device type, etc * get all support service types of this device ...
[ "Loads", "the", "device", "definitions", "from", "a", "given", "URL", "which", "points", "to", "the", "root", "XML", "in", "the", "device", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L591-L642
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64._loadDeviceDefinitions
def _loadDeviceDefinitions(self, urlOfXMLDefinition, xml): """Internal call to parse the XML of the device definition. :param urlOfXMLDefinition: the URL to the XML device defintions :param xml: the XML content to parse """ # extract the base path of the given XML to make sure ...
python
def _loadDeviceDefinitions(self, urlOfXMLDefinition, xml): """Internal call to parse the XML of the device definition. :param urlOfXMLDefinition: the URL to the XML device defintions :param xml: the XML content to parse """ # extract the base path of the given XML to make sure ...
[ "def", "_loadDeviceDefinitions", "(", "self", ",", "urlOfXMLDefinition", ",", "xml", ")", ":", "# extract the base path of the given XML to make sure any relative URL later will be created correctly", "url", "=", "urlparse", "(", "urlOfXMLDefinition", ")", "baseURIPath", "=", "...
Internal call to parse the XML of the device definition. :param urlOfXMLDefinition: the URL to the XML device defintions :param xml: the XML content to parse
[ "Internal", "call", "to", "parse", "the", "XML", "of", "the", "device", "definition", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L644-L668
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64._iterateToFindSCPDElements
def _iterateToFindSCPDElements(self, element, baseURIPath): """Internal method to iterate through device definition XML tree. :param element: the XML root node of the device definitions :type element: xml.etree.ElementTree.Element :param str baseURIPath: the base URL """ ...
python
def _iterateToFindSCPDElements(self, element, baseURIPath): """Internal method to iterate through device definition XML tree. :param element: the XML root node of the device definitions :type element: xml.etree.ElementTree.Element :param str baseURIPath: the base URL """ ...
[ "def", "_iterateToFindSCPDElements", "(", "self", ",", "element", ",", "baseURIPath", ")", ":", "for", "child", "in", "element", ".", "getchildren", "(", ")", ":", "tagName", "=", "child", ".", "tag", ".", "lower", "(", ")", "if", "tagName", ".", "endswi...
Internal method to iterate through device definition XML tree. :param element: the XML root node of the device definitions :type element: xml.etree.ElementTree.Element :param str baseURIPath: the base URL
[ "Internal", "method", "to", "iterate", "through", "device", "definition", "XML", "tree", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L670-L725
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64._processServiceList
def _processServiceList(self, serviceList, baseURIPath): """Internal method to iterate in the device definition XML tree through the service list. :param serviceList: the XML root node of a service list :type serviceList: xml.etree.ElementTree.Element """ # iterate through all ...
python
def _processServiceList(self, serviceList, baseURIPath): """Internal method to iterate in the device definition XML tree through the service list. :param serviceList: the XML root node of a service list :type serviceList: xml.etree.ElementTree.Element """ # iterate through all ...
[ "def", "_processServiceList", "(", "self", ",", "serviceList", ",", "baseURIPath", ")", ":", "# iterate through all children in serviceList XML tag", "for", "service", "in", "serviceList", ".", "getchildren", "(", ")", ":", "# has to be a service", "if", "not", "service...
Internal method to iterate in the device definition XML tree through the service list. :param serviceList: the XML root node of a service list :type serviceList: xml.etree.ElementTree.Element
[ "Internal", "method", "to", "iterate", "in", "the", "device", "definition", "XML", "tree", "through", "the", "service", "list", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L727-L792
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64.loadSCPD
def loadSCPD(self, serviceType=None, timeout=3, ignoreFailures=False): """Load action definition(s) (Service Control Protocol Document). If the device definitions have been loaded via loadDeviceDefinitions() this method loads actions definitions. The action definitions are needed if you like to...
python
def loadSCPD(self, serviceType=None, timeout=3, ignoreFailures=False): """Load action definition(s) (Service Control Protocol Document). If the device definitions have been loaded via loadDeviceDefinitions() this method loads actions definitions. The action definitions are needed if you like to...
[ "def", "loadSCPD", "(", "self", ",", "serviceType", "=", "None", ",", "timeout", "=", "3", ",", "ignoreFailures", "=", "False", ")", ":", "if", "serviceType", "is", "not", "None", ":", "self", ".", "_loadSCPD", "(", "serviceType", ",", "float", "(", "t...
Load action definition(s) (Service Control Protocol Document). If the device definitions have been loaded via loadDeviceDefinitions() this method loads actions definitions. The action definitions are needed if you like to execute an action on a UPnP device. The actions definition contains the n...
[ "Load", "action", "definition", "(", "s", ")", "(", "Service", "Control", "Protocol", "Document", ")", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L794-L834
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64._loadSCPD
def _loadSCPD(self, serviceType, timeout): """Internal method to load the action definitions. :param str serviceType: the service type to load :param int timeout: the timeout for downloading """ if serviceType not in self.__deviceServiceDefinitions.keys(): raise Val...
python
def _loadSCPD(self, serviceType, timeout): """Internal method to load the action definitions. :param str serviceType: the service type to load :param int timeout: the timeout for downloading """ if serviceType not in self.__deviceServiceDefinitions.keys(): raise Val...
[ "def", "_loadSCPD", "(", "self", ",", "serviceType", ",", "timeout", ")", ":", "if", "serviceType", "not", "in", "self", ".", "__deviceServiceDefinitions", ".", "keys", "(", ")", ":", "raise", "ValueError", "(", "\"Can not load SCPD, no service type defined for: \""...
Internal method to load the action definitions. :param str serviceType: the service type to load :param int timeout: the timeout for downloading
[ "Internal", "method", "to", "load", "the", "action", "definitions", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L836-L923
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64._parseSCPDActions
def _parseSCPDActions(self, actionListElement, actions, variableParameterDict): """Internal method to parse the SCPD definitions. :param actionListElement: the action xml element :type actionListElement: xml.etree.ElementTree.Element :param dict actions: a container to store all actions...
python
def _parseSCPDActions(self, actionListElement, actions, variableParameterDict): """Internal method to parse the SCPD definitions. :param actionListElement: the action xml element :type actionListElement: xml.etree.ElementTree.Element :param dict actions: a container to store all actions...
[ "def", "_parseSCPDActions", "(", "self", ",", "actionListElement", ",", "actions", ",", "variableParameterDict", ")", ":", "# go through all action elements in this list", "for", "actionElement", "in", "actionListElement", ".", "getchildren", "(", ")", ":", "action", "=...
Internal method to parse the SCPD definitions. :param actionListElement: the action xml element :type actionListElement: xml.etree.ElementTree.Element :param dict actions: a container to store all actions :param dict variableParameterDict: remember where a variable gets referenced
[ "Internal", "method", "to", "parse", "the", "SCPD", "definitions", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L925-L1000
bpannier/simpletr64
simpletr64/devicetr64.py
DeviceTR64._parseSCPDVariableTypes
def _parseSCPDVariableTypes(self, variableListElement, variableTypes): """Internal method to parse the SCPD definitions. :param variableListElement: the xml root node of the variable list :type variableListElement: xml.etree.ElementTree.Element :param dict variableTypes: a container to ...
python
def _parseSCPDVariableTypes(self, variableListElement, variableTypes): """Internal method to parse the SCPD definitions. :param variableListElement: the xml root node of the variable list :type variableListElement: xml.etree.ElementTree.Element :param dict variableTypes: a container to ...
[ "def", "_parseSCPDVariableTypes", "(", "self", ",", "variableListElement", ",", "variableTypes", ")", ":", "# iterate through all variables", "for", "variableElement", "in", "variableListElement", ".", "getchildren", "(", ")", ":", "variable", "=", "{", "}", "# iterat...
Internal method to parse the SCPD definitions. :param variableListElement: the xml root node of the variable list :type variableListElement: xml.etree.ElementTree.Element :param dict variableTypes: a container to store the variables
[ "Internal", "method", "to", "parse", "the", "SCPD", "definitions", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L1002-L1035
bpannier/simpletr64
simpletr64/actions/wifi.py
Wifi.createFromURL
def createFromURL(urlOfXMLDefinition): """Factory method to create a DeviceTR64 from an URL to the XML device definitions. :param str urlOfXMLDefinition: :return: the new object :rtype: Wifi """ url = urlparse(urlOfXMLDefinition) if not url.port: if ...
python
def createFromURL(urlOfXMLDefinition): """Factory method to create a DeviceTR64 from an URL to the XML device definitions. :param str urlOfXMLDefinition: :return: the new object :rtype: Wifi """ url = urlparse(urlOfXMLDefinition) if not url.port: if ...
[ "def", "createFromURL", "(", "urlOfXMLDefinition", ")", ":", "url", "=", "urlparse", "(", "urlOfXMLDefinition", ")", "if", "not", "url", ".", "port", ":", "if", "url", ".", "scheme", ".", "lower", "(", ")", "==", "\"https\"", ":", "port", "=", "443", "...
Factory method to create a DeviceTR64 from an URL to the XML device definitions. :param str urlOfXMLDefinition: :return: the new object :rtype: Wifi
[ "Factory", "method", "to", "create", "a", "DeviceTR64", "from", "an", "URL", "to", "the", "XML", "device", "definitions", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/wifi.py#L62-L79
bpannier/simpletr64
simpletr64/actions/wifi.py
Wifi.getWifiInfo
def getWifiInfo(self, wifiInterfaceId=1, timeout=1): """Execute GetInfo action to get Wifi basic information's. :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed :return: the basic informations :rtype...
python
def getWifiInfo(self, wifiInterfaceId=1, timeout=1): """Execute GetInfo action to get Wifi basic information's. :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed :return: the basic informations :rtype...
[ "def", "getWifiInfo", "(", "self", ",", "wifiInterfaceId", "=", "1", ",", "timeout", "=", "1", ")", ":", "namespace", "=", "Wifi", ".", "getServiceType", "(", "\"getWifiInfo\"", ")", "+", "str", "(", "wifiInterfaceId", ")", "uri", "=", "self", ".", "getC...
Execute GetInfo action to get Wifi basic information's. :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed :return: the basic informations :rtype: WifiBasicInfo
[ "Execute", "GetInfo", "action", "to", "get", "Wifi", "basic", "information", "s", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/wifi.py#L93-L106
bpannier/simpletr64
simpletr64/actions/wifi.py
Wifi.getTotalAssociations
def getTotalAssociations(self, wifiInterfaceId=1, timeout=1): """Execute GetTotalAssociations action to get the amount of associated Wifi clients. :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed :return: th...
python
def getTotalAssociations(self, wifiInterfaceId=1, timeout=1): """Execute GetTotalAssociations action to get the amount of associated Wifi clients. :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed :return: th...
[ "def", "getTotalAssociations", "(", "self", ",", "wifiInterfaceId", "=", "1", ",", "timeout", "=", "1", ")", ":", "namespace", "=", "Wifi", ".", "getServiceType", "(", "\"getTotalAssociations\"", ")", "+", "str", "(", "wifiInterfaceId", ")", "uri", "=", "sel...
Execute GetTotalAssociations action to get the amount of associated Wifi clients. :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed :return: the amount of Wifi clients :rtype: int .. seealso:: :meth:...
[ "Execute", "GetTotalAssociations", "action", "to", "get", "the", "amount", "of", "associated", "Wifi", "clients", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/wifi.py#L138-L153
bpannier/simpletr64
simpletr64/actions/wifi.py
Wifi.getGenericAssociatedDeviceInfo
def getGenericAssociatedDeviceInfo(self, index, wifiInterfaceId=1, timeout=1): """Execute GetGenericAssociatedDeviceInfo action to get detailed information about a Wifi client. :param int index: the number of the client :param int wifiInterfaceId: the id of the Wifi interface :param flo...
python
def getGenericAssociatedDeviceInfo(self, index, wifiInterfaceId=1, timeout=1): """Execute GetGenericAssociatedDeviceInfo action to get detailed information about a Wifi client. :param int index: the number of the client :param int wifiInterfaceId: the id of the Wifi interface :param flo...
[ "def", "getGenericAssociatedDeviceInfo", "(", "self", ",", "index", ",", "wifiInterfaceId", "=", "1", ",", "timeout", "=", "1", ")", ":", "namespace", "=", "Wifi", ".", "getServiceType", "(", "\"getGenericAssociatedDeviceInfo\"", ")", "+", "str", "(", "wifiInter...
Execute GetGenericAssociatedDeviceInfo action to get detailed information about a Wifi client. :param int index: the number of the client :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed :return: the detaile...
[ "Execute", "GetGenericAssociatedDeviceInfo", "action", "to", "get", "detailed", "information", "about", "a", "Wifi", "client", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/wifi.py#L155-L172
bpannier/simpletr64
simpletr64/actions/wifi.py
Wifi.getSpecificAssociatedDeviceInfo
def getSpecificAssociatedDeviceInfo(self, macAddress, wifiInterfaceId=1, timeout=1): """Execute GetSpecificAssociatedDeviceInfo action to get detailed information about a Wifi client. :param str macAddress: MAC address in the form ``38:C9:86:26:7E:38``; be aware that the MAC address might b...
python
def getSpecificAssociatedDeviceInfo(self, macAddress, wifiInterfaceId=1, timeout=1): """Execute GetSpecificAssociatedDeviceInfo action to get detailed information about a Wifi client. :param str macAddress: MAC address in the form ``38:C9:86:26:7E:38``; be aware that the MAC address might b...
[ "def", "getSpecificAssociatedDeviceInfo", "(", "self", ",", "macAddress", ",", "wifiInterfaceId", "=", "1", ",", "timeout", "=", "1", ")", ":", "namespace", "=", "Wifi", ".", "getServiceType", "(", "\"getSpecificAssociatedDeviceInfo\"", ")", "+", "str", "(", "wi...
Execute GetSpecificAssociatedDeviceInfo action to get detailed information about a Wifi client. :param str macAddress: MAC address in the form ``38:C9:86:26:7E:38``; be aware that the MAC address might be case sensitive, depending on the router :param int wifiInterfaceId: the id of the Wifi...
[ "Execute", "GetSpecificAssociatedDeviceInfo", "action", "to", "get", "detailed", "information", "about", "a", "Wifi", "client", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/wifi.py#L174-L192
bpannier/simpletr64
simpletr64/actions/wifi.py
Wifi.setEnable
def setEnable(self, status, wifiInterfaceId=1, timeout=1): """Set enable status for a Wifi interface, be careful you don't cut yourself off. :param bool status: enable or disable the interface :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to ...
python
def setEnable(self, status, wifiInterfaceId=1, timeout=1): """Set enable status for a Wifi interface, be careful you don't cut yourself off. :param bool status: enable or disable the interface :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to ...
[ "def", "setEnable", "(", "self", ",", "status", ",", "wifiInterfaceId", "=", "1", ",", "timeout", "=", "1", ")", ":", "namespace", "=", "Wifi", ".", "getServiceType", "(", "\"setEnable\"", ")", "+", "str", "(", "wifiInterfaceId", ")", "uri", "=", "self",...
Set enable status for a Wifi interface, be careful you don't cut yourself off. :param bool status: enable or disable the interface :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed
[ "Set", "enable", "status", "for", "a", "Wifi", "interface", "be", "careful", "you", "don", "t", "cut", "yourself", "off", "." ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/wifi.py#L194-L209
bpannier/simpletr64
simpletr64/actions/wifi.py
Wifi.setChannel
def setChannel(self, channel, wifiInterfaceId=1, timeout=1): """Set the channel of this Wifi interface :param int channel: the channel number :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed """ ...
python
def setChannel(self, channel, wifiInterfaceId=1, timeout=1): """Set the channel of this Wifi interface :param int channel: the channel number :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed """ ...
[ "def", "setChannel", "(", "self", ",", "channel", ",", "wifiInterfaceId", "=", "1", ",", "timeout", "=", "1", ")", ":", "namespace", "=", "Wifi", ".", "getServiceType", "(", "\"setChannel\"", ")", "+", "str", "(", "wifiInterfaceId", ")", "uri", "=", "sel...
Set the channel of this Wifi interface :param int channel: the channel number :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed
[ "Set", "the", "channel", "of", "this", "Wifi", "interface" ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/wifi.py#L211-L221
bpannier/simpletr64
simpletr64/actions/wifi.py
Wifi.setSSID
def setSSID(self, ssid, wifiInterfaceId=1, timeout=1): """Set the SSID (name of the Wifi network) :param str ssid: the SSID/wifi network name :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed """ ...
python
def setSSID(self, ssid, wifiInterfaceId=1, timeout=1): """Set the SSID (name of the Wifi network) :param str ssid: the SSID/wifi network name :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed """ ...
[ "def", "setSSID", "(", "self", ",", "ssid", ",", "wifiInterfaceId", "=", "1", ",", "timeout", "=", "1", ")", ":", "namespace", "=", "Wifi", ".", "getServiceType", "(", "\"setChannel\"", ")", "+", "str", "(", "wifiInterfaceId", ")", "uri", "=", "self", ...
Set the SSID (name of the Wifi network) :param str ssid: the SSID/wifi network name :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed
[ "Set", "the", "SSID", "(", "name", "of", "the", "Wifi", "network", ")" ]
train
https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/wifi.py#L223-L233
DreamLab/VmShepherd
src/vmshepherd/http/rpc_api.py
RpcApi.enabled_checker
def enabled_checker(func): """ Access decorator which checks if a RPC method is enabled by our configuration """ @wraps(func) def wrap(self, *args, **kwargs): if self.allowed_methods and isinstance(self.allowed_methods, list) and func.__name__ not in self.allowed_methods: ...
python
def enabled_checker(func): """ Access decorator which checks if a RPC method is enabled by our configuration """ @wraps(func) def wrap(self, *args, **kwargs): if self.allowed_methods and isinstance(self.allowed_methods, list) and func.__name__ not in self.allowed_methods: ...
[ "def", "enabled_checker", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrap", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "allowed_methods", "and", "isinstance", "(", "self", ".", "allowed_me...
Access decorator which checks if a RPC method is enabled by our configuration
[ "Access", "decorator", "which", "checks", "if", "a", "RPC", "method", "is", "enabled", "by", "our", "configuration" ]
train
https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/http/rpc_api.py#L18-L26
DreamLab/VmShepherd
src/vmshepherd/http/rpc_api.py
RpcApi.list_presets
async def list_presets(self): """ Listing presets :return: (list of presets) :rtype: list Sample response: ``["preset1", "preset2"]`` """ presets = await self.request.app.vmshepherd.preset_manager.list_presets() return list(presets.keys())
python
async def list_presets(self): """ Listing presets :return: (list of presets) :rtype: list Sample response: ``["preset1", "preset2"]`` """ presets = await self.request.app.vmshepherd.preset_manager.list_presets() return list(presets.keys())
[ "async", "def", "list_presets", "(", "self", ")", ":", "presets", "=", "await", "self", ".", "request", ".", "app", ".", "vmshepherd", ".", "preset_manager", ".", "list_presets", "(", ")", "return", "list", "(", "presets", ".", "keys", "(", ")", ")" ]
Listing presets :return: (list of presets) :rtype: list Sample response: ``["preset1", "preset2"]``
[ "Listing", "presets" ]
train
https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/http/rpc_api.py#L29-L41
DreamLab/VmShepherd
src/vmshepherd/http/rpc_api.py
RpcApi.list_vms
async def list_vms(self, preset): """ Listing virtual machines in a given preset :arg string preset: preset name :return: (Size of a preset, list of virtual machines) - first element of a tuple is a size of virtual machines in a preset - second element is a dic...
python
async def list_vms(self, preset): """ Listing virtual machines in a given preset :arg string preset: preset name :return: (Size of a preset, list of virtual machines) - first element of a tuple is a size of virtual machines in a preset - second element is a dic...
[ "async", "def", "list_vms", "(", "self", ",", "preset", ")", ":", "vmshepherd", "=", "self", ".", "request", ".", "app", ".", "vmshepherd", "preset", "=", "vmshepherd", ".", "preset_manager", ".", "get_preset", "(", "preset", ")", "result_vms", "=", "{", ...
Listing virtual machines in a given preset :arg string preset: preset name :return: (Size of a preset, list of virtual machines) - first element of a tuple is a size of virtual machines in a preset - second element is a dict which contains all Virtual Machines, where every ele...
[ "Listing", "virtual", "machines", "in", "a", "given", "preset" ]
train
https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/http/rpc_api.py#L44-L64
DreamLab/VmShepherd
src/vmshepherd/http/rpc_api.py
RpcApi.terminate_vm
async def terminate_vm(self, preset, vm_id): """ Discard vm in specified preset :arg string preset: preset name :arg int vm_id: Virtual Machine id :return: 'OK' Sample response: ``OK`` """ vmshepherd = self.request.app.vmshepherd preset = vmsh...
python
async def terminate_vm(self, preset, vm_id): """ Discard vm in specified preset :arg string preset: preset name :arg int vm_id: Virtual Machine id :return: 'OK' Sample response: ``OK`` """ vmshepherd = self.request.app.vmshepherd preset = vmsh...
[ "async", "def", "terminate_vm", "(", "self", ",", "preset", ",", "vm_id", ")", ":", "vmshepherd", "=", "self", ".", "request", ".", "app", ".", "vmshepherd", "preset", "=", "vmshepherd", ".", "preset_manager", ".", "get_preset", "(", "preset", ")", "await"...
Discard vm in specified preset :arg string preset: preset name :arg int vm_id: Virtual Machine id :return: 'OK' Sample response: ``OK``
[ "Discard", "vm", "in", "specified", "preset" ]
train
https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/http/rpc_api.py#L67-L80
DreamLab/VmShepherd
src/vmshepherd/http/rpc_api.py
RpcApi.get_vm_metadata
async def get_vm_metadata(self, preset, vm_id): """ Get vm metadata :arg string preset: preset name :arg int vm_id: Virtual Machine id :return: Metadata for Virtual Machine :rtype: dict Sample response: ``{ 'time_shutdown' : "12312312321' }`` """ ...
python
async def get_vm_metadata(self, preset, vm_id): """ Get vm metadata :arg string preset: preset name :arg int vm_id: Virtual Machine id :return: Metadata for Virtual Machine :rtype: dict Sample response: ``{ 'time_shutdown' : "12312312321' }`` """ ...
[ "async", "def", "get_vm_metadata", "(", "self", ",", "preset", ",", "vm_id", ")", ":", "vmshepherd", "=", "self", ".", "request", ".", "app", ".", "vmshepherd", "preset", "=", "vmshepherd", ".", "preset_manager", ".", "get_preset", "(", "preset", ")", "vm_...
Get vm metadata :arg string preset: preset name :arg int vm_id: Virtual Machine id :return: Metadata for Virtual Machine :rtype: dict Sample response: ``{ 'time_shutdown' : "12312312321' }``
[ "Get", "vm", "metadata" ]
train
https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/http/rpc_api.py#L83-L100
Suor/autolink
autolink.py
linkify
def linkify(text, attrs={}): """ Convert URL-like and email-like strings into links. """ def separate_parentheses(s): start = re_find(r'^\(*', s) end = re_find(r'\)*$', s) n = min(len(start), len(end)) if n: return s[:n], s[n:-n], s[-n:] else: ...
python
def linkify(text, attrs={}): """ Convert URL-like and email-like strings into links. """ def separate_parentheses(s): start = re_find(r'^\(*', s) end = re_find(r'\)*$', s) n = min(len(start), len(end)) if n: return s[:n], s[n:-n], s[-n:] else: ...
[ "def", "linkify", "(", "text", ",", "attrs", "=", "{", "}", ")", ":", "def", "separate_parentheses", "(", "s", ")", ":", "start", "=", "re_find", "(", "r'^\\(*'", ",", "s", ")", "end", "=", "re_find", "(", "r'\\)*$'", ",", "s", ")", "n", "=", "mi...
Convert URL-like and email-like strings into links.
[ "Convert", "URL", "-", "like", "and", "email", "-", "like", "strings", "into", "links", "." ]
train
https://github.com/Suor/autolink/blob/0a101e6fb6359ae18fce1b9f8907ff9113a6086f/autolink.py#L53-L96
Suor/autolink
autolink.py
force_unicode
def force_unicode(s, encoding='utf-8', errors='strict'): """ Similar to smart_text, except that lazy instances are resolved to strings, rather than kept as lazy objects. """ # Handle the common case first, saves 30-40% when s is an instance of # six.text_type. This function gets called often in ...
python
def force_unicode(s, encoding='utf-8', errors='strict'): """ Similar to smart_text, except that lazy instances are resolved to strings, rather than kept as lazy objects. """ # Handle the common case first, saves 30-40% when s is an instance of # six.text_type. This function gets called often in ...
[ "def", "force_unicode", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "# Handle the common case first, saves 30-40% when s is an instance of", "# six.text_type. This function gets called often in that setting.", "if", "isinstance", "(", "s...
Similar to smart_text, except that lazy instances are resolved to strings, rather than kept as lazy objects.
[ "Similar", "to", "smart_text", "except", "that", "lazy", "instances", "are", "resolved", "to", "strings", "rather", "than", "kept", "as", "lazy", "objects", "." ]
train
https://github.com/Suor/autolink/blob/0a101e6fb6359ae18fce1b9f8907ff9113a6086f/autolink.py#L103-L125
mjirik/io3d
io3d/hdf5_io.py
save_dict_to_hdf5
def save_dict_to_hdf5(dic, filename): """ .... """ with h5py.File(filename, 'w') as h5file: rf = recursively_save_dict_contents_to_group(h5file, '/', dic) h5_rf = h5file.create_group("_reconstruction_flags") # h5_rf = h5file.create_group("_reconstruction_key_flags") for k...
python
def save_dict_to_hdf5(dic, filename): """ .... """ with h5py.File(filename, 'w') as h5file: rf = recursively_save_dict_contents_to_group(h5file, '/', dic) h5_rf = h5file.create_group("_reconstruction_flags") # h5_rf = h5file.create_group("_reconstruction_key_flags") for k...
[ "def", "save_dict_to_hdf5", "(", "dic", ",", "filename", ")", ":", "with", "h5py", ".", "File", "(", "filename", ",", "'w'", ")", "as", "h5file", ":", "rf", "=", "recursively_save_dict_contents_to_group", "(", "h5file", ",", "'/'", ",", "dic", ")", "h5_rf"...
....
[ "...." ]
train
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/hdf5_io.py#L16-L25
mjirik/io3d
io3d/hdf5_io.py
recursively_save_dict_contents_to_group
def recursively_save_dict_contents_to_group(h5file, path, dic): """ .... """ reconstruction_flags = {} # reconstruction_key_flags = {} for key, item in dic.items(): if type(key) is not str: # import pickle # key = pickle.dumps(key).decode("ascii") impo...
python
def recursively_save_dict_contents_to_group(h5file, path, dic): """ .... """ reconstruction_flags = {} # reconstruction_key_flags = {} for key, item in dic.items(): if type(key) is not str: # import pickle # key = pickle.dumps(key).decode("ascii") impo...
[ "def", "recursively_save_dict_contents_to_group", "(", "h5file", ",", "path", ",", "dic", ")", ":", "reconstruction_flags", "=", "{", "}", "# reconstruction_key_flags = {}", "for", "key", ",", "item", "in", "dic", ".", "items", "(", ")", ":", "if", "type", "("...
....
[ "...." ]
train
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/hdf5_io.py#L30-L83
mjirik/io3d
io3d/hdf5_io.py
recursively_load_dict_contents_from_group
def recursively_load_dict_contents_from_group(h5file, path): """ .... """ rf = h5file["_reconstruction_flags"] # rkf = h5file["_reconstruction_key_flags"] ans = {} for key, item in h5file[path].items(): dest_key = key # if key in ("_reconstruction_flags", "_reconstruction_key...
python
def recursively_load_dict_contents_from_group(h5file, path): """ .... """ rf = h5file["_reconstruction_flags"] # rkf = h5file["_reconstruction_key_flags"] ans = {} for key, item in h5file[path].items(): dest_key = key # if key in ("_reconstruction_flags", "_reconstruction_key...
[ "def", "recursively_load_dict_contents_from_group", "(", "h5file", ",", "path", ")", ":", "rf", "=", "h5file", "[", "\"_reconstruction_flags\"", "]", "# rkf = h5file[\"_reconstruction_key_flags\"]", "ans", "=", "{", "}", "for", "key", ",", "item", "in", "h5file", "[...
....
[ "...." ]
train
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/hdf5_io.py#L92-L140
PlaidWeb/Pushl
pushl/__main__.py
parse_args
def parse_args(*args): """ Parse the arguments for the command """ parser = argparse.ArgumentParser( description="Send push notifications for a feed") parser.add_argument('--version', action='version', version="%(prog)s " + __version__.__version__) parser.add_argument('...
python
def parse_args(*args): """ Parse the arguments for the command """ parser = argparse.ArgumentParser( description="Send push notifications for a feed") parser.add_argument('--version', action='version', version="%(prog)s " + __version__.__version__) parser.add_argument('...
[ "def", "parse_args", "(", "*", "args", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Send push notifications for a feed\"", ")", "parser", ".", "add_argument", "(", "'--version'", ",", "action", "=", "'version'", ",", "v...
Parse the arguments for the command
[ "Parse", "the", "arguments", "for", "the", "command" ]
train
https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/__main__.py#L17-L89
PlaidWeb/Pushl
pushl/__main__.py
main
def main(): """ main entry point """ args = parse_args() logging.basicConfig(level=LOG_LEVELS[min( args.verbosity, len(LOG_LEVELS) - 1)]) loop = asyncio.get_event_loop() loop.run_until_complete(_run(args))
python
def main(): """ main entry point """ args = parse_args() logging.basicConfig(level=LOG_LEVELS[min( args.verbosity, len(LOG_LEVELS) - 1)]) loop = asyncio.get_event_loop() loop.run_until_complete(_run(args))
[ "def", "main", "(", ")", ":", "args", "=", "parse_args", "(", ")", "logging", ".", "basicConfig", "(", "level", "=", "LOG_LEVELS", "[", "min", "(", "args", ".", "verbosity", ",", "len", "(", "LOG_LEVELS", ")", "-", "1", ")", "]", ")", "loop", "=", ...
main entry point
[ "main", "entry", "point" ]
train
https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/__main__.py#L92-L99
launchdarkly/relayCommander
relay_commander/ld.py
LaunchDarklyApi.get_environments
def get_environments(self, project_key: str) -> dict: """ Retrieve all environments for a given project. Includes name, key, and mobile key. :param project_key: Key for project. :returns: dictionary of environments. """ try: resp = self.client.get_p...
python
def get_environments(self, project_key: str) -> dict: """ Retrieve all environments for a given project. Includes name, key, and mobile key. :param project_key: Key for project. :returns: dictionary of environments. """ try: resp = self.client.get_p...
[ "def", "get_environments", "(", "self", ",", "project_key", ":", "str", ")", "->", "dict", ":", "try", ":", "resp", "=", "self", ".", "client", ".", "get_project", "(", "project_key", ")", "except", "launchdarkly_api", ".", "rest", ".", "ApiException", "as...
Retrieve all environments for a given project. Includes name, key, and mobile key. :param project_key: Key for project. :returns: dictionary of environments.
[ "Retrieve", "all", "environments", "for", "a", "given", "project", "." ]
train
https://github.com/launchdarkly/relayCommander/blob/eee7fa22f04edc3854dd53c3ec2db8c599ad1e89/relay_commander/ld.py#L50-L78
launchdarkly/relayCommander
relay_commander/ld.py
LaunchDarklyApi.update_flag
def update_flag(self, state: str, feature_key: str) \ -> launchdarkly_api.FeatureFlag: """ Update the flag status for the specified feature flag. :param state: New feature flag state :param featureKey: Feature flag key :returns: FeatureFlag object. """ b...
python
def update_flag(self, state: str, feature_key: str) \ -> launchdarkly_api.FeatureFlag: """ Update the flag status for the specified feature flag. :param state: New feature flag state :param featureKey: Feature flag key :returns: FeatureFlag object. """ b...
[ "def", "update_flag", "(", "self", ",", "state", ":", "str", ",", "feature_key", ":", "str", ")", "->", "launchdarkly_api", ".", "FeatureFlag", ":", "build_env", "=", "\"/environments/\"", "+", "self", ".", "environment_key", "+", "\"/on\"", "patch_comment", "...
Update the flag status for the specified feature flag. :param state: New feature flag state :param featureKey: Feature flag key :returns: FeatureFlag object.
[ "Update", "the", "flag", "status", "for", "the", "specified", "feature", "flag", "." ]
train
https://github.com/launchdarkly/relayCommander/blob/eee7fa22f04edc3854dd53c3ec2db8c599ad1e89/relay_commander/ld.py#L80-L102
SetBased/py-stratum
pystratum/wrapper/RowsWithKeyWrapper.py
RowsWithKeyWrapper._write_result_handler
def _write_result_handler(self, routine): """ Generates code for calling the stored routine in the wrapper method. """ self._write_line('ret = {}') self._write_execute_rows(routine) self._write_line('for row in rows:') num_of_dict = len(routine['columns']) ...
python
def _write_result_handler(self, routine): """ Generates code for calling the stored routine in the wrapper method. """ self._write_line('ret = {}') self._write_execute_rows(routine) self._write_line('for row in rows:') num_of_dict = len(routine['columns']) ...
[ "def", "_write_result_handler", "(", "self", ",", "routine", ")", ":", "self", ".", "_write_line", "(", "'ret = {}'", ")", "self", ".", "_write_execute_rows", "(", "routine", ")", "self", ".", "_write_line", "(", "'for row in rows:'", ")", "num_of_dict", "=", ...
Generates code for calling the stored routine in the wrapper method.
[ "Generates", "code", "for", "calling", "the", "stored", "routine", "in", "the", "wrapper", "method", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/wrapper/RowsWithKeyWrapper.py#L30-L86
SetBased/py-stratum
pystratum/MetadataDataLayer.py
MetadataDataLayer._log_query
def _log_query(query): """ Logs the query on the console. :param str query: The query. """ query = query.strip() if os.linesep in query: # Query is a multi line query MetadataDataLayer.io.log_very_verbose('Executing query:') MetadataD...
python
def _log_query(query): """ Logs the query on the console. :param str query: The query. """ query = query.strip() if os.linesep in query: # Query is a multi line query MetadataDataLayer.io.log_very_verbose('Executing query:') MetadataD...
[ "def", "_log_query", "(", "query", ")", ":", "query", "=", "query", ".", "strip", "(", ")", "if", "os", ".", "linesep", "in", "query", ":", "# Query is a multi line query", "MetadataDataLayer", ".", "io", ".", "log_very_verbose", "(", "'Executing query:'", ")"...
Logs the query on the console. :param str query: The query.
[ "Logs", "the", "query", "on", "the", "console", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/MetadataDataLayer.py#L20-L34
vsoch/helpme
helpme/main/discourse/utils.py
request_token
def request_token(self, board): '''send a public key to request a token. When we call this function, we already have an RSA key at self.key board: the discourse board to post to ''' nonce = str(uuid.uuid4()) data = {'scopes': 'write', 'client_id': self.client_id, ...
python
def request_token(self, board): '''send a public key to request a token. When we call this function, we already have an RSA key at self.key board: the discourse board to post to ''' nonce = str(uuid.uuid4()) data = {'scopes': 'write', 'client_id': self.client_id, ...
[ "def", "request_token", "(", "self", ",", "board", ")", ":", "nonce", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "data", "=", "{", "'scopes'", ":", "'write'", ",", "'client_id'", ":", "self", ".", "client_id", ",", "'application_name'", ":",...
send a public key to request a token. When we call this function, we already have an RSA key at self.key board: the discourse board to post to
[ "send", "a", "public", "key", "to", "request", "a", "token", ".", "When", "we", "call", "this", "function", "we", "already", "have", "an", "RSA", "key", "at", "self", ".", "key" ]
train
https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/discourse/utils.py#L32-L93
vsoch/helpme
helpme/main/discourse/utils.py
create_post
def create_post(self, title, body, board, category, username): '''create a Discourse post, given a title, body, board, and token. Parameters ========== title: the issue title body: the issue body board: the discourse board to post to ''' category_url = "%s/categories.js...
python
def create_post(self, title, body, board, category, username): '''create a Discourse post, given a title, body, board, and token. Parameters ========== title: the issue title body: the issue body board: the discourse board to post to ''' category_url = "%s/categories.js...
[ "def", "create_post", "(", "self", ",", "title", ",", "body", ",", "board", ",", "category", ",", "username", ")", ":", "category_url", "=", "\"%s/categories.json\"", "%", "board", "response", "=", "requests", ".", "get", "(", "category_url", ")", "if", "r...
create a Discourse post, given a title, body, board, and token. Parameters ========== title: the issue title body: the issue body board: the discourse board to post to
[ "create", "a", "Discourse", "post", "given", "a", "title", "body", "board", "and", "token", "." ]
train
https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/discourse/utils.py#L97-L152
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.main
def main(self, config_filename, file_names=None): """ Loads stored routines into the current schema. :param str config_filename: The name of the configuration file of the current project :param list[str] file_names: The sources that must be loaded. If empty all sources (if required) wil...
python
def main(self, config_filename, file_names=None): """ Loads stored routines into the current schema. :param str config_filename: The name of the configuration file of the current project :param list[str] file_names: The sources that must be loaded. If empty all sources (if required) wil...
[ "def", "main", "(", "self", ",", "config_filename", ",", "file_names", "=", "None", ")", ":", "self", ".", "_io", ".", "title", "(", "'Loader'", ")", "if", "file_names", ":", "self", ".", "__load_list", "(", "config_filename", ",", "file_names", ")", "el...
Loads stored routines into the current schema. :param str config_filename: The name of the configuration file of the current project :param list[str] file_names: The sources that must be loaded. If empty all sources (if required) will loaded. :rtype: int The status of exit.
[ "Loads", "stored", "routines", "into", "the", "current", "schema", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L109-L129
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.__log_overview_errors
def __log_overview_errors(self): """ Show info about sources files of stored routines that were not loaded successfully. """ if self.error_file_names: self._io.warning('Routines in the files below are not loaded:') self._io.listing(sorted(self.error_file_names))
python
def __log_overview_errors(self): """ Show info about sources files of stored routines that were not loaded successfully. """ if self.error_file_names: self._io.warning('Routines in the files below are not loaded:') self._io.listing(sorted(self.error_file_names))
[ "def", "__log_overview_errors", "(", "self", ")", ":", "if", "self", ".", "error_file_names", ":", "self", ".", "_io", ".", "warning", "(", "'Routines in the files below are not loaded:'", ")", "self", ".", "_io", ".", "listing", "(", "sorted", "(", "self", "....
Show info about sources files of stored routines that were not loaded successfully.
[ "Show", "info", "about", "sources", "files", "of", "stored", "routines", "that", "were", "not", "loaded", "successfully", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L132-L138
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader._add_replace_pair
def _add_replace_pair(self, name, value, quote): """ Adds a replace part to the map of replace pairs. :param name: The name of the replace pair. :param value: The value of value of the replace pair. """ key = '@' + name + '@' key = key.lower() class_name...
python
def _add_replace_pair(self, name, value, quote): """ Adds a replace part to the map of replace pairs. :param name: The name of the replace pair. :param value: The value of value of the replace pair. """ key = '@' + name + '@' key = key.lower() class_name...
[ "def", "_add_replace_pair", "(", "self", ",", "name", ",", "value", ",", "quote", ")", ":", "key", "=", "'@'", "+", "name", "+", "'@'", "key", "=", "key", ".", "lower", "(", ")", "class_name", "=", "value", ".", "__class__", ".", "__name__", "if", ...
Adds a replace part to the map of replace pairs. :param name: The name of the replace pair. :param value: The value of value of the replace pair.
[ "Adds", "a", "replace", "part", "to", "the", "map", "of", "replace", "pairs", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L157-L179
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.__load_list
def __load_list(self, config_filename, file_names): """ Loads all stored routines in a list into the RDBMS instance. :param str config_filename: The filename of the configuration file. :param list[str] file_names: The list of files to be loaded. """ self._read_configurat...
python
def __load_list(self, config_filename, file_names): """ Loads all stored routines in a list into the RDBMS instance. :param str config_filename: The filename of the configuration file. :param list[str] file_names: The list of files to be loaded. """ self._read_configurat...
[ "def", "__load_list", "(", "self", ",", "config_filename", ",", "file_names", ")", ":", "self", ".", "_read_configuration_file", "(", "config_filename", ")", "self", ".", "connect", "(", ")", "self", ".", "find_source_files_from_list", "(", "file_names", ")", "s...
Loads all stored routines in a list into the RDBMS instance. :param str config_filename: The filename of the configuration file. :param list[str] file_names: The list of files to be loaded.
[ "Loads", "all", "stored", "routines", "in", "a", "list", "into", "the", "RDBMS", "instance", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L182-L199
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.__load_all
def __load_all(self, config_filename): """ Loads all stored routines into the RDBMS instance. :param str config_filename: string The filename of the configuration file. """ self._read_configuration_file(config_filename) self.connect() self.__find_source_files() ...
python
def __load_all(self, config_filename): """ Loads all stored routines into the RDBMS instance. :param str config_filename: string The filename of the configuration file. """ self._read_configuration_file(config_filename) self.connect() self.__find_source_files() ...
[ "def", "__load_all", "(", "self", ",", "config_filename", ")", ":", "self", ".", "_read_configuration_file", "(", "config_filename", ")", "self", ".", "connect", "(", ")", "self", ".", "__find_source_files", "(", ")", "self", ".", "_get_column_type", "(", ")",...
Loads all stored routines into the RDBMS instance. :param str config_filename: string The filename of the configuration file.
[ "Loads", "all", "stored", "routines", "into", "the", "RDBMS", "instance", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L202-L220
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader._read_configuration_file
def _read_configuration_file(self, config_filename): """ Reads parameters from the configuration file. :param str config_filename: The name of the configuration file. """ config = configparser.ConfigParser() config.read(config_filename) self._source_directory = ...
python
def _read_configuration_file(self, config_filename): """ Reads parameters from the configuration file. :param str config_filename: The name of the configuration file. """ config = configparser.ConfigParser() config.read(config_filename) self._source_directory = ...
[ "def", "_read_configuration_file", "(", "self", ",", "config_filename", ")", ":", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "config", ".", "read", "(", "config_filename", ")", "self", ".", "_source_directory", "=", "config", ".", "get", "("...
Reads parameters from the configuration file. :param str config_filename: The name of the configuration file.
[ "Reads", "parameters", "from", "the", "configuration", "file", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L223-L239
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.__find_source_files
def __find_source_files(self): """ Searches recursively for all source files in a directory. """ for dir_path, _, files in os.walk(self._source_directory): for name in files: if name.lower().endswith(self._source_file_extension): basename =...
python
def __find_source_files(self): """ Searches recursively for all source files in a directory. """ for dir_path, _, files in os.walk(self._source_directory): for name in files: if name.lower().endswith(self._source_file_extension): basename =...
[ "def", "__find_source_files", "(", "self", ")", ":", "for", "dir_path", ",", "_", ",", "files", "in", "os", ".", "walk", "(", "self", ".", "_source_directory", ")", ":", "for", "name", "in", "files", ":", "if", "name", ".", "lower", "(", ")", ".", ...
Searches recursively for all source files in a directory.
[ "Searches", "recursively", "for", "all", "source", "files", "in", "a", "directory", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L242-L257
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.__read_stored_routine_metadata
def __read_stored_routine_metadata(self): """ Reads the metadata of stored routines from the metadata file. """ if os.path.isfile(self._pystratum_metadata_filename): with open(self._pystratum_metadata_filename, 'r') as file: self._pystratum_metadata = json.loa...
python
def __read_stored_routine_metadata(self): """ Reads the metadata of stored routines from the metadata file. """ if os.path.isfile(self._pystratum_metadata_filename): with open(self._pystratum_metadata_filename, 'r') as file: self._pystratum_metadata = json.loa...
[ "def", "__read_stored_routine_metadata", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "_pystratum_metadata_filename", ")", ":", "with", "open", "(", "self", ".", "_pystratum_metadata_filename", ",", "'r'", ")", "as", "file",...
Reads the metadata of stored routines from the metadata file.
[ "Reads", "the", "metadata", "of", "stored", "routines", "from", "the", "metadata", "file", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L260-L266
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.__load_stored_routines
def __load_stored_routines(self): """ Loads all stored routines into the RDBMS instance. """ self._io.writeln('') for routine_name in sorted(self._source_file_names): if routine_name in self._pystratum_metadata: old_metadata = self._pystratum_metadata...
python
def __load_stored_routines(self): """ Loads all stored routines into the RDBMS instance. """ self._io.writeln('') for routine_name in sorted(self._source_file_names): if routine_name in self._pystratum_metadata: old_metadata = self._pystratum_metadata...
[ "def", "__load_stored_routines", "(", "self", ")", ":", "self", ".", "_io", ".", "writeln", "(", "''", ")", "for", "routine_name", "in", "sorted", "(", "self", ".", "_source_file_names", ")", ":", "if", "routine_name", "in", "self", ".", "_pystratum_metadata...
Loads all stored routines into the RDBMS instance.
[ "Loads", "all", "stored", "routines", "into", "the", "RDBMS", "instance", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L291-L318
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.__remove_obsolete_metadata
def __remove_obsolete_metadata(self): """ Removes obsolete entries from the metadata of all stored routines. """ clean = {} for key, _ in self._source_file_names.items(): if key in self._pystratum_metadata: clean[key] = self._pystratum_metadata[key] ...
python
def __remove_obsolete_metadata(self): """ Removes obsolete entries from the metadata of all stored routines. """ clean = {} for key, _ in self._source_file_names.items(): if key in self._pystratum_metadata: clean[key] = self._pystratum_metadata[key] ...
[ "def", "__remove_obsolete_metadata", "(", "self", ")", ":", "clean", "=", "{", "}", "for", "key", ",", "_", "in", "self", ".", "_source_file_names", ".", "items", "(", ")", ":", "if", "key", "in", "self", ".", "_pystratum_metadata", ":", "clean", "[", ...
Removes obsolete entries from the metadata of all stored routines.
[ "Removes", "obsolete", "entries", "from", "the", "metadata", "of", "all", "stored", "routines", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L345-L354
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.__write_stored_routine_metadata
def __write_stored_routine_metadata(self): """ Writes the metadata of all stored routines to the metadata file. """ with open(self._pystratum_metadata_filename, 'w') as stream: json.dump(self._pystratum_metadata, stream, indent=4, sort_keys=True)
python
def __write_stored_routine_metadata(self): """ Writes the metadata of all stored routines to the metadata file. """ with open(self._pystratum_metadata_filename, 'w') as stream: json.dump(self._pystratum_metadata, stream, indent=4, sort_keys=True)
[ "def", "__write_stored_routine_metadata", "(", "self", ")", ":", "with", "open", "(", "self", ".", "_pystratum_metadata_filename", ",", "'w'", ")", "as", "stream", ":", "json", ".", "dump", "(", "self", ".", "_pystratum_metadata", ",", "stream", ",", "indent",...
Writes the metadata of all stored routines to the metadata file.
[ "Writes", "the", "metadata", "of", "all", "stored", "routines", "to", "the", "metadata", "file", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L357-L362
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.find_source_files_from_list
def find_source_files_from_list(self, file_names): """ Finds all source files that actually exists from a list of file names. :param list[str] file_names: The list of file names. """ for file_name in file_names: if os.path.exists(file_name): routine_n...
python
def find_source_files_from_list(self, file_names): """ Finds all source files that actually exists from a list of file names. :param list[str] file_names: The list of file names. """ for file_name in file_names: if os.path.exists(file_name): routine_n...
[ "def", "find_source_files_from_list", "(", "self", ",", "file_names", ")", ":", "for", "file_name", "in", "file_names", ":", "if", "os", ".", "path", ".", "exists", "(", "file_name", ")", ":", "routine_name", "=", "os", ".", "path", ".", "splitext", "(", ...
Finds all source files that actually exists from a list of file names. :param list[str] file_names: The list of file names.
[ "Finds", "all", "source", "files", "that", "actually", "exists", "from", "a", "list", "of", "file", "names", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L365-L382
SetBased/py-stratum
pystratum/RoutineLoader.py
RoutineLoader.__get_constants
def __get_constants(self): """ Gets the constants from the class that acts like a namespace for constants and adds them to the replace pairs. """ helper = ConstantClass(self._constants_class_name, self._io) helper.reload() constants = helper.constants() for name,...
python
def __get_constants(self): """ Gets the constants from the class that acts like a namespace for constants and adds them to the replace pairs. """ helper = ConstantClass(self._constants_class_name, self._io) helper.reload() constants = helper.constants() for name,...
[ "def", "__get_constants", "(", "self", ")", ":", "helper", "=", "ConstantClass", "(", "self", ".", "_constants_class_name", ",", "self", ".", "_io", ")", "helper", ".", "reload", "(", ")", "constants", "=", "helper", ".", "constants", "(", ")", "for", "n...
Gets the constants from the class that acts like a namespace for constants and adds them to the replace pairs.
[ "Gets", "the", "constants", "from", "the", "class", "that", "acts", "like", "a", "namespace", "for", "constants", "and", "adds", "them", "to", "the", "replace", "pairs", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/RoutineLoader.py#L385-L397
DreamLab/VmShepherd
src/vmshepherd/iaas/vm.py
Vm.terminate
async def terminate(self): """ Terminate vm. """ logging.debug('Terminate: %s', self) self.state = VmState.TERMINATED return await self.manager.terminate_vm(self.id)
python
async def terminate(self): """ Terminate vm. """ logging.debug('Terminate: %s', self) self.state = VmState.TERMINATED return await self.manager.terminate_vm(self.id)
[ "async", "def", "terminate", "(", "self", ")", ":", "logging", ".", "debug", "(", "'Terminate: %s'", ",", "self", ")", "self", ".", "state", "=", "VmState", ".", "TERMINATED", "return", "await", "self", ".", "manager", ".", "terminate_vm", "(", "self", "...
Terminate vm.
[ "Terminate", "vm", "." ]
train
https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/iaas/vm.py#L86-L91
ClericPy/torequests
torequests/logs.py
init_logger
def init_logger( name="", handler_path_levels=None, level=logging.INFO, formatter=None, formatter_str=None, datefmt="%Y-%m-%d %H:%M:%S", ): """Add a default handler for logger. Args: name = '' or logger obj. handler_path_levels = [['loggerfile.log',13],['','DEBUG'],['','info']...
python
def init_logger( name="", handler_path_levels=None, level=logging.INFO, formatter=None, formatter_str=None, datefmt="%Y-%m-%d %H:%M:%S", ): """Add a default handler for logger. Args: name = '' or logger obj. handler_path_levels = [['loggerfile.log',13],['','DEBUG'],['','info']...
[ "def", "init_logger", "(", "name", "=", "\"\"", ",", "handler_path_levels", "=", "None", ",", "level", "=", "logging", ".", "INFO", ",", "formatter", "=", "None", ",", "formatter_str", "=", "None", ",", "datefmt", "=", "\"%Y-%m-%d %H:%M:%S\"", ",", ")", ":...
Add a default handler for logger. Args: name = '' or logger obj. handler_path_levels = [['loggerfile.log',13],['','DEBUG'],['','info'],['','notSet']] # [[path,level]] level = the least level for the logger. formatter = logging.Formatter( '%(levelname)-7s %(asctime)s %(name)s (%(file...
[ "Add", "a", "default", "handler", "for", "logger", "." ]
train
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/logs.py#L12-L67
ClericPy/torequests
torequests/logs.py
print_info
def print_info(*messages, **kwargs): """Simple print use logger, print with time / file / line_no. :param sep: sep of messages, " " by default. Basic Usage:: print_info(1, 2, 3) print_info(1, 2, 3) print_info(1, 2, 3) # [2018-10-24 19:12:16] temp_code.py(7): 1 2 3 ...
python
def print_info(*messages, **kwargs): """Simple print use logger, print with time / file / line_no. :param sep: sep of messages, " " by default. Basic Usage:: print_info(1, 2, 3) print_info(1, 2, 3) print_info(1, 2, 3) # [2018-10-24 19:12:16] temp_code.py(7): 1 2 3 ...
[ "def", "print_info", "(", "*", "messages", ",", "*", "*", "kwargs", ")", ":", "sep", "=", "kwargs", ".", "pop", "(", "\"sep\"", ",", "\" \"", ")", "frame", "=", "sys", ".", "_getframe", "(", "1", ")", "ln", "=", "frame", ".", "f_lineno", "_file", ...
Simple print use logger, print with time / file / line_no. :param sep: sep of messages, " " by default. Basic Usage:: print_info(1, 2, 3) print_info(1, 2, 3) print_info(1, 2, 3) # [2018-10-24 19:12:16] temp_code.py(7): 1 2 3 # [2018-10-24 19:12:16] temp_code.py(8):...
[ "Simple", "print", "use", "logger", "print", "with", "time", "/", "file", "/", "line_no", ".", ":", "param", "sep", ":", "sep", "of", "messages", "by", "default", "." ]
train
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/logs.py#L86-L107
Miserlou/django-knockout-modeler
knockout_modeler/ko.py
get_fields
def get_fields(model): """ Returns a Model's knockout_fields, or the default set of field names. """ try: if hasattr(model, "knockout_fields"): fields = model.knockout_fields() else: try: fields = model_to_dict(model).keys() except...
python
def get_fields(model): """ Returns a Model's knockout_fields, or the default set of field names. """ try: if hasattr(model, "knockout_fields"): fields = model.knockout_fields() else: try: fields = model_to_dict(model).keys() except...
[ "def", "get_fields", "(", "model", ")", ":", "try", ":", "if", "hasattr", "(", "model", ",", "\"knockout_fields\"", ")", ":", "fields", "=", "model", ".", "knockout_fields", "(", ")", "else", ":", "try", ":", "fields", "=", "model_to_dict", "(", "model",...
Returns a Model's knockout_fields, or the default set of field names.
[ "Returns", "a", "Model", "s", "knockout_fields", "or", "the", "default", "set", "of", "field", "names", "." ]
train
https://github.com/Miserlou/django-knockout-modeler/blob/714d21cc5ed008f132cea01dbae9f214c2bf1b76/knockout_modeler/ko.py#L18-L37
Miserlou/django-knockout-modeler
knockout_modeler/ko.py
get_object_data
def get_object_data(obj, fields, safe): """ Given an object and a list of fields, recursively build an object for serialization. Returns a dictionary. """ temp_dict = dict() for field in fields: try: attribute = getattr(obj, str(field)) if isinstance(attribute,...
python
def get_object_data(obj, fields, safe): """ Given an object and a list of fields, recursively build an object for serialization. Returns a dictionary. """ temp_dict = dict() for field in fields: try: attribute = getattr(obj, str(field)) if isinstance(attribute,...
[ "def", "get_object_data", "(", "obj", ",", "fields", ",", "safe", ")", ":", "temp_dict", "=", "dict", "(", ")", "for", "field", "in", "fields", ":", "try", ":", "attribute", "=", "getattr", "(", "obj", ",", "str", "(", "field", ")", ")", "if", "isi...
Given an object and a list of fields, recursively build an object for serialization. Returns a dictionary.
[ "Given", "an", "object", "and", "a", "list", "of", "fields", "recursively", "build", "an", "object", "for", "serialization", "." ]
train
https://github.com/Miserlou/django-knockout-modeler/blob/714d21cc5ed008f132cea01dbae9f214c2bf1b76/knockout_modeler/ko.py#L40-L71
Miserlou/django-knockout-modeler
knockout_modeler/ko.py
ko_model
def ko_model(model, field_names=None, data=None): """ Given a model, returns the Knockout Model and the Knockout ViewModel. Takes optional field names and data. """ try: if isinstance(model, str): modelName = model else: modelName = model.__class__.__name__ ...
python
def ko_model(model, field_names=None, data=None): """ Given a model, returns the Knockout Model and the Knockout ViewModel. Takes optional field names and data. """ try: if isinstance(model, str): modelName = model else: modelName = model.__class__.__name__ ...
[ "def", "ko_model", "(", "model", ",", "field_names", "=", "None", ",", "data", "=", "None", ")", ":", "try", ":", "if", "isinstance", "(", "model", ",", "str", ")", ":", "modelName", "=", "model", "else", ":", "modelName", "=", "model", ".", "__class...
Given a model, returns the Knockout Model and the Knockout ViewModel. Takes optional field names and data.
[ "Given", "a", "model", "returns", "the", "Knockout", "Model", "and", "the", "Knockout", "ViewModel", ".", "Takes", "optional", "field", "names", "and", "data", "." ]
train
https://github.com/Miserlou/django-knockout-modeler/blob/714d21cc5ed008f132cea01dbae9f214c2bf1b76/knockout_modeler/ko.py#L74-L104
Miserlou/django-knockout-modeler
knockout_modeler/ko.py
ko_bindings
def ko_bindings(model): """ Given a model, returns the Knockout data bindings. """ try: if isinstance(model, str): modelName = model else: modelName = model.__class__.__name__ modelBindingsString = "ko.applyBindings(new " + modelName + "ViewModel(), $('#...
python
def ko_bindings(model): """ Given a model, returns the Knockout data bindings. """ try: if isinstance(model, str): modelName = model else: modelName = model.__class__.__name__ modelBindingsString = "ko.applyBindings(new " + modelName + "ViewModel(), $('#...
[ "def", "ko_bindings", "(", "model", ")", ":", "try", ":", "if", "isinstance", "(", "model", ",", "str", ")", ":", "modelName", "=", "model", "else", ":", "modelName", "=", "model", ".", "__class__", ".", "__name__", "modelBindingsString", "=", "\"ko.applyB...
Given a model, returns the Knockout data bindings.
[ "Given", "a", "model", "returns", "the", "Knockout", "data", "bindings", "." ]
train
https://github.com/Miserlou/django-knockout-modeler/blob/714d21cc5ed008f132cea01dbae9f214c2bf1b76/knockout_modeler/ko.py#L107-L123
Miserlou/django-knockout-modeler
knockout_modeler/ko.py
ko_json
def ko_json(queryset, field_names=None, name=None, safe=False): """ Given a QuerySet, return just the serialized representation based on the knockout_fields. Useful for middleware/APIs. Convenience method around ko_data. """ return ko_data(queryset, field_names, name, safe, return_json=True)
python
def ko_json(queryset, field_names=None, name=None, safe=False): """ Given a QuerySet, return just the serialized representation based on the knockout_fields. Useful for middleware/APIs. Convenience method around ko_data. """ return ko_data(queryset, field_names, name, safe, return_json=True)
[ "def", "ko_json", "(", "queryset", ",", "field_names", "=", "None", ",", "name", "=", "None", ",", "safe", "=", "False", ")", ":", "return", "ko_data", "(", "queryset", ",", "field_names", ",", "name", ",", "safe", ",", "return_json", "=", "True", ")" ...
Given a QuerySet, return just the serialized representation based on the knockout_fields. Useful for middleware/APIs. Convenience method around ko_data.
[ "Given", "a", "QuerySet", "return", "just", "the", "serialized", "representation", "based", "on", "the", "knockout_fields", ".", "Useful", "for", "middleware", "/", "APIs", "." ]
train
https://github.com/Miserlou/django-knockout-modeler/blob/714d21cc5ed008f132cea01dbae9f214c2bf1b76/knockout_modeler/ko.py#L126-L134
Miserlou/django-knockout-modeler
knockout_modeler/ko.py
ko_data
def ko_data(queryset, field_names=None, name=None, safe=False, return_json=False): """ Given a QuerySet, return just the serialized representation based on the knockout_fields as JavaScript. """ try: try: # Get an inital instance of the QS. queryset_instance = query...
python
def ko_data(queryset, field_names=None, name=None, safe=False, return_json=False): """ Given a QuerySet, return just the serialized representation based on the knockout_fields as JavaScript. """ try: try: # Get an inital instance of the QS. queryset_instance = query...
[ "def", "ko_data", "(", "queryset", ",", "field_names", "=", "None", ",", "name", "=", "None", ",", "safe", "=", "False", ",", "return_json", "=", "False", ")", ":", "try", ":", "try", ":", "# Get an inital instance of the QS.", "queryset_instance", "=", "que...
Given a QuerySet, return just the serialized representation based on the knockout_fields as JavaScript.
[ "Given", "a", "QuerySet", "return", "just", "the", "serialized", "representation", "based", "on", "the", "knockout_fields", "as", "JavaScript", "." ]
train
https://github.com/Miserlou/django-knockout-modeler/blob/714d21cc5ed008f132cea01dbae9f214c2bf1b76/knockout_modeler/ko.py#L137-L187
Miserlou/django-knockout-modeler
knockout_modeler/ko.py
ko
def ko(queryset, field_names=None): """ Converts a Django QuerySet into a complete Knockout implementation. """ try: koDataString = ko_data(queryset, field_names) koModelString = ko_model(queryset[0].__class__.__name__, field_names, data=True) koBindingsString = ko_bindings(quer...
python
def ko(queryset, field_names=None): """ Converts a Django QuerySet into a complete Knockout implementation. """ try: koDataString = ko_data(queryset, field_names) koModelString = ko_model(queryset[0].__class__.__name__, field_names, data=True) koBindingsString = ko_bindings(quer...
[ "def", "ko", "(", "queryset", ",", "field_names", "=", "None", ")", ":", "try", ":", "koDataString", "=", "ko_data", "(", "queryset", ",", "field_names", ")", "koModelString", "=", "ko_model", "(", "queryset", "[", "0", "]", ".", "__class__", ".", "__nam...
Converts a Django QuerySet into a complete Knockout implementation.
[ "Converts", "a", "Django", "QuerySet", "into", "a", "complete", "Knockout", "implementation", "." ]
train
https://github.com/Miserlou/django-knockout-modeler/blob/714d21cc5ed008f132cea01dbae9f214c2bf1b76/knockout_modeler/ko.py#L190-L205
vsoch/helpme
helpme/utils/settings.py
load_keypair
def load_keypair(keypair_file): '''load a keypair from a keypair file. We add attributes key (the raw key) and public_key (the url prepared public key) to the client. Parameters ========== keypair_file: the pem file to load. ''' from Crypto.PublicKey import RSA # Load key ...
python
def load_keypair(keypair_file): '''load a keypair from a keypair file. We add attributes key (the raw key) and public_key (the url prepared public key) to the client. Parameters ========== keypair_file: the pem file to load. ''' from Crypto.PublicKey import RSA # Load key ...
[ "def", "load_keypair", "(", "keypair_file", ")", ":", "from", "Crypto", ".", "PublicKey", "import", "RSA", "# Load key", "with", "open", "(", "keypair_file", ",", "'rb'", ")", "as", "filey", ":", "key", "=", "RSA", ".", "import_key", "(", "filey", ".", "...
load a keypair from a keypair file. We add attributes key (the raw key) and public_key (the url prepared public key) to the client. Parameters ========== keypair_file: the pem file to load.
[ "load", "a", "keypair", "from", "a", "keypair", "file", ".", "We", "add", "attributes", "key", "(", "the", "raw", "key", ")", "and", "public_key", "(", "the", "url", "prepared", "public", "key", ")", "to", "the", "client", "." ]
train
https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/utils/settings.py#L39-L53
vsoch/helpme
helpme/utils/settings.py
generate_keypair
def generate_keypair(keypair_file): '''generate_keypair is used by some of the helpers that need a keypair. The function should be used if the client doesn't have the attribute self.key. We generate the key and return it. We use pycryptodome (3.7.2) Parameters ========= ...
python
def generate_keypair(keypair_file): '''generate_keypair is used by some of the helpers that need a keypair. The function should be used if the client doesn't have the attribute self.key. We generate the key and return it. We use pycryptodome (3.7.2) Parameters ========= ...
[ "def", "generate_keypair", "(", "keypair_file", ")", ":", "from", "Crypto", ".", "PublicKey", "import", "RSA", "key", "=", "RSA", ".", "generate", "(", "2048", ")", "# Ensure helper directory exists", "keypair_dir", "=", "os", ".", "path", ".", "dirname", "(",...
generate_keypair is used by some of the helpers that need a keypair. The function should be used if the client doesn't have the attribute self.key. We generate the key and return it. We use pycryptodome (3.7.2) Parameters ========= keypair_file: fullpath to where to s...
[ "generate_keypair", "is", "used", "by", "some", "of", "the", "helpers", "that", "need", "a", "keypair", ".", "The", "function", "should", "be", "used", "if", "the", "client", "doesn", "t", "have", "the", "attribute", "self", ".", "key", ".", "We", "gener...
train
https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/utils/settings.py#L56-L80
SetBased/py-stratum
pystratum/exception/ResultException.py
ResultException.__message
def __message(expected_row_count, actual_row_count, query): """ Composes the exception message. :param str expected_row_count: The expected row count. :param int actual_row_count: The actual row count. :param str query: The query. :rtype: str """ query =...
python
def __message(expected_row_count, actual_row_count, query): """ Composes the exception message. :param str expected_row_count: The expected row count. :param int actual_row_count: The actual row count. :param str query: The query. :rtype: str """ query =...
[ "def", "__message", "(", "expected_row_count", ",", "actual_row_count", ",", "query", ")", ":", "query", "=", "query", ".", "strip", "(", ")", "message", "=", "'Wrong number of rows selected'", "message", "+=", "os", ".", "linesep", "message", "+=", "'Expected n...
Composes the exception message. :param str expected_row_count: The expected row count. :param int actual_row_count: The actual row count. :param str query: The query. :rtype: str
[ "Composes", "the", "exception", "message", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/exception/ResultException.py#L76-L98
vsoch/helpme
helpme/main/github/__init__.py
Helper._submit
def _submit(self): '''submit the issue to github. When we get here we should have: {'user_prompt_issue': 'I want to do the thing.', 'user_prompt_repo': 'vsoch/hello-world', 'user_prompt_title': 'Error with this thing', 'record_asciinema': '/tmp/helpme...
python
def _submit(self): '''submit the issue to github. When we get here we should have: {'user_prompt_issue': 'I want to do the thing.', 'user_prompt_repo': 'vsoch/hello-world', 'user_prompt_title': 'Error with this thing', 'record_asciinema': '/tmp/helpme...
[ "def", "_submit", "(", "self", ")", ":", "body", "=", "self", ".", "data", "[", "'user_prompt_issue'", "]", "title", "=", "self", ".", "data", "[", "'user_prompt_title'", "]", "repo", "=", "self", ".", "data", "[", "'user_prompt_repo'", "]", "# Step 1: Env...
submit the issue to github. When we get here we should have: {'user_prompt_issue': 'I want to do the thing.', 'user_prompt_repo': 'vsoch/hello-world', 'user_prompt_title': 'Error with this thing', 'record_asciinema': '/tmp/helpme.93o__nt5.json', '...
[ "submit", "the", "issue", "to", "github", ".", "When", "we", "get", "here", "we", "should", "have", ":", "{", "user_prompt_issue", ":", "I", "want", "to", "do", "the", "thing", ".", "user_prompt_repo", ":", "vsoch", "/", "hello", "-", "world", "user_prom...
train
https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/github/__init__.py#L64-L103
julot/sphinxcontrib-dd
sphinxcontrib/dd/yaml.py
resolve_refs
def resolve_refs(uri, spec): """Resolve JSON references in a given dictionary. OpenAPI spec may contain JSON references to its nodes or external sources, so any attempt to rely that there's some expected attribute in the spec may fail. So we need to resolve JSON references before we use it (i.e. re...
python
def resolve_refs(uri, spec): """Resolve JSON references in a given dictionary. OpenAPI spec may contain JSON references to its nodes or external sources, so any attempt to rely that there's some expected attribute in the spec may fail. So we need to resolve JSON references before we use it (i.e. re...
[ "def", "resolve_refs", "(", "uri", ",", "spec", ")", ":", "resolver", "=", "jsonschema", ".", "RefResolver", "(", "uri", ",", "spec", ")", "def", "_do_resolve", "(", "node", ")", ":", "if", "isinstance", "(", "node", ",", "collections", ".", "Mapping", ...
Resolve JSON references in a given dictionary. OpenAPI spec may contain JSON references to its nodes or external sources, so any attempt to rely that there's some expected attribute in the spec may fail. So we need to resolve JSON references before we use it (i.e. replace with referenced object). For d...
[ "Resolve", "JSON", "references", "in", "a", "given", "dictionary", "." ]
train
https://github.com/julot/sphinxcontrib-dd/blob/18619b356508b9a99cc329eeae53cbf299a5d1de/sphinxcontrib/dd/yaml.py#L32-L63
vsoch/helpme
helpme/client/help.py
main
def main(args, extras): '''This is the actual driver for the helper. ''' from helpme.main import get_helper name = args.command if name in HELPME_HELPERS: # Get the helper, do the recording, submit helper = get_helper(name=name) if args.asciinema is not None: ...
python
def main(args, extras): '''This is the actual driver for the helper. ''' from helpme.main import get_helper name = args.command if name in HELPME_HELPERS: # Get the helper, do the recording, submit helper = get_helper(name=name) if args.asciinema is not None: ...
[ "def", "main", "(", "args", ",", "extras", ")", ":", "from", "helpme", ".", "main", "import", "get_helper", "name", "=", "args", ".", "command", "if", "name", "in", "HELPME_HELPERS", ":", "# Get the helper, do the recording, submit", "helper", "=", "get_helper",...
This is the actual driver for the helper.
[ "This", "is", "the", "actual", "driver", "for", "the", "helper", "." ]
train
https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/client/help.py#L27-L44
jurismarches/chopper
chopper/extractor.py
Extractor.extract
def extract(self, html_contents, css_contents=None, base_url=None): """ Extracts the cleaned html tree as a string and only css rules matching the cleaned html tree :param html_contents: The HTML contents to parse :type html_contents: str :param css_contents: The CSS con...
python
def extract(self, html_contents, css_contents=None, base_url=None): """ Extracts the cleaned html tree as a string and only css rules matching the cleaned html tree :param html_contents: The HTML contents to parse :type html_contents: str :param css_contents: The CSS con...
[ "def", "extract", "(", "self", ",", "html_contents", ",", "css_contents", "=", "None", ",", "base_url", "=", "None", ")", ":", "# Clean HTML", "html_extractor", "=", "self", ".", "html_extractor", "(", "html_contents", ",", "self", ".", "_xpaths_to_keep", ",",...
Extracts the cleaned html tree as a string and only css rules matching the cleaned html tree :param html_contents: The HTML contents to parse :type html_contents: str :param css_contents: The CSS contents to parse :type css_contents: str :param base_url: The base page UR...
[ "Extracts", "the", "cleaned", "html", "tree", "as", "a", "string", "and", "only", "css", "rules", "matching", "the", "cleaned", "html", "tree" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/extractor.py#L58-L110
jurismarches/chopper
chopper/extractor.py
Extractor.__add
def __add(self, dest, xpath): """ Adds a Xpath expression to the dest list :param dest: The destination list to add the Xpath :type dest: list :param xpath: The Xpath expression to add :type xpath: str """ assert isinstance(xpath, string_types) de...
python
def __add(self, dest, xpath): """ Adds a Xpath expression to the dest list :param dest: The destination list to add the Xpath :type dest: list :param xpath: The Xpath expression to add :type xpath: str """ assert isinstance(xpath, string_types) de...
[ "def", "__add", "(", "self", ",", "dest", ",", "xpath", ")", ":", "assert", "isinstance", "(", "xpath", ",", "string_types", ")", "dest", ".", "append", "(", "xpath", ")" ]
Adds a Xpath expression to the dest list :param dest: The destination list to add the Xpath :type dest: list :param xpath: The Xpath expression to add :type xpath: str
[ "Adds", "a", "Xpath", "expression", "to", "the", "dest", "list" ]
train
https://github.com/jurismarches/chopper/blob/53c5489a53e3a5d205a5cb207df751c09633e7ce/chopper/extractor.py#L142-L152
SetBased/py-stratum
pystratum/wrapper/Wrapper.py
Wrapper._write_line
def _write_line(self, line=None): """ Appends a line of code to the generated code and adjust the indent level of the generated code. :param line: The line of code (with out LF) that must be appended. """ if line is None: self._write("\n") if self.__inden...
python
def _write_line(self, line=None): """ Appends a line of code to the generated code and adjust the indent level of the generated code. :param line: The line of code (with out LF) that must be appended. """ if line is None: self._write("\n") if self.__inden...
[ "def", "_write_line", "(", "self", ",", "line", "=", "None", ")", ":", "if", "line", "is", "None", ":", "self", ".", "_write", "(", "\"\\n\"", ")", "if", "self", ".", "__indent_level", ">", "1", ":", "self", ".", "__indent_level", "-=", "1", "elif", ...
Appends a line of code to the generated code and adjust the indent level of the generated code. :param line: The line of code (with out LF) that must be appended.
[ "Appends", "a", "line", "of", "code", "to", "the", "generated", "code", "and", "adjust", "the", "indent", "level", "of", "the", "generated", "code", "." ]
train
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/wrapper/Wrapper.py#L66-L82