repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
hotzenklotz/pybeerxml
pybeerxml/parser.py
Parser.parse
def parse(self, xml_file): "Get a list of parsed recipes from BeerXML input" recipes = [] with open(xml_file, "rt") as f: tree = ElementTree.parse(f) for recipeNode in tree.iter(): if self.to_lower(recipeNode.tag) != "recipe": continue ...
python
def parse(self, xml_file): "Get a list of parsed recipes from BeerXML input" recipes = [] with open(xml_file, "rt") as f: tree = ElementTree.parse(f) for recipeNode in tree.iter(): if self.to_lower(recipeNode.tag) != "recipe": continue ...
[ "def", "parse", "(", "self", ",", "xml_file", ")", ":", "recipes", "=", "[", "]", "with", "open", "(", "xml_file", ",", "\"rt\"", ")", "as", "f", ":", "tree", "=", "ElementTree", ".", "parse", "(", "f", ")", "for", "recipeNode", "in", "tree", ".", ...
Get a list of parsed recipes from BeerXML input
[ "Get", "a", "list", "of", "parsed", "recipes", "from", "BeerXML", "input" ]
e9cf8d6090b1e01e5bbb101e255792b134affbe0
https://github.com/hotzenklotz/pybeerxml/blob/e9cf8d6090b1e01e5bbb101e255792b134affbe0/pybeerxml/parser.py#L40-L104
train
Get a list of parsed recipes from BeerXML input
hotzenklotz/pybeerxml
pybeerxml/parser.py
Parser.to_lower
def to_lower(self, string): "Helper function to transform strings to lower case" value = None try: value = string.lower() except AttributeError: value = "" finally: return value
python
def to_lower(self, string): "Helper function to transform strings to lower case" value = None try: value = string.lower() except AttributeError: value = "" finally: return value
[ "def", "to_lower", "(", "self", ",", "string", ")", ":", "value", "=", "None", "try", ":", "value", "=", "string", ".", "lower", "(", ")", "except", "AttributeError", ":", "value", "=", "\"\"", "finally", ":", "return", "value" ]
Helper function to transform strings to lower case
[ "Helper", "function", "to", "transform", "strings", "to", "lower", "case" ]
e9cf8d6090b1e01e5bbb101e255792b134affbe0
https://github.com/hotzenklotz/pybeerxml/blob/e9cf8d6090b1e01e5bbb101e255792b134affbe0/pybeerxml/parser.py#L106-L114
train
Helper function to transform strings to lower case
maxzheng/localconfig
localconfig/manager.py
LocalConfig._to_dot_key
def _to_dot_key(cls, section, key=None): """ Return the section and key in dot notation format. """ if key: return (NON_ALPHA_NUM.sub('_', section.lower()), NON_ALPHA_NUM.sub('_', key.lower())) else: return NON_ALPHA_NUM.sub('_', section.lower())
python
def _to_dot_key(cls, section, key=None): """ Return the section and key in dot notation format. """ if key: return (NON_ALPHA_NUM.sub('_', section.lower()), NON_ALPHA_NUM.sub('_', key.lower())) else: return NON_ALPHA_NUM.sub('_', section.lower())
[ "def", "_to_dot_key", "(", "cls", ",", "section", ",", "key", "=", "None", ")", ":", "if", "key", ":", "return", "(", "NON_ALPHA_NUM", ".", "sub", "(", "'_'", ",", "section", ".", "lower", "(", ")", ")", ",", "NON_ALPHA_NUM", ".", "sub", "(", "'_'"...
Return the section and key in dot notation format.
[ "Return", "the", "section", "and", "key", "in", "dot", "notation", "format", "." ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L102-L107
train
Return the section and key in dot notation format.
maxzheng/localconfig
localconfig/manager.py
LocalConfig._add_dot_key
def _add_dot_key(self, section, key=None): """ :param str section: Config section :param str key: Config key """ if key: self._dot_keys[self._to_dot_key(section, key)] = (section, key) else: self._dot_keys[self._to_dot_key(section)] = section
python
def _add_dot_key(self, section, key=None): """ :param str section: Config section :param str key: Config key """ if key: self._dot_keys[self._to_dot_key(section, key)] = (section, key) else: self._dot_keys[self._to_dot_key(section)] = section
[ "def", "_add_dot_key", "(", "self", ",", "section", ",", "key", "=", "None", ")", ":", "if", "key", ":", "self", ".", "_dot_keys", "[", "self", ".", "_to_dot_key", "(", "section", ",", "key", ")", "]", "=", "(", "section", ",", "key", ")", "else", ...
:param str section: Config section :param str key: Config key
[ ":", "param", "str", "section", ":", "Config", "section", ":", "param", "str", "key", ":", "Config", "key" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L109-L117
train
Adds a dot key to the internal dict.
maxzheng/localconfig
localconfig/manager.py
LocalConfig.read
def read(self, sources): """ Queues the config sources to be read later (when config is accessed), or reads immediately if config has already been accessed. :param file/str/list sources: Config source string, file name, or file pointer, or list of the other sources. ...
python
def read(self, sources): """ Queues the config sources to be read later (when config is accessed), or reads immediately if config has already been accessed. :param file/str/list sources: Config source string, file name, or file pointer, or list of the other sources. ...
[ "def", "read", "(", "self", ",", "sources", ")", ":", "all_read", "=", "True", "if", "not", "isinstance", "(", "sources", ",", "list", ")", ":", "sources", "=", "[", "sources", "]", "if", "self", ".", "_sources_read", ":", "for", "source", "in", "sou...
Queues the config sources to be read later (when config is accessed), or reads immediately if config has already been accessed. :param file/str/list sources: Config source string, file name, or file pointer, or list of the other sources. If file source does not exi...
[ "Queues", "the", "config", "sources", "to", "be", "read", "later", "(", "when", "config", "is", "accessed", ")", "or", "reads", "immediately", "if", "config", "has", "already", "been", "accessed", "." ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L119-L143
train
Reads the config sources.
maxzheng/localconfig
localconfig/manager.py
LocalConfig._read
def _read(self, source): """ Reads and parses the config source :param file/str source: Config source string, file name, or file pointer. If file name does not exist, it is ignored. :return: True if source was successfully read, otherwise False ""...
python
def _read(self, source): """ Reads and parses the config source :param file/str source: Config source string, file name, or file pointer. If file name does not exist, it is ignored. :return: True if source was successfully read, otherwise False ""...
[ "def", "_read", "(", "self", ",", "source", ")", ":", "if", "isinstance", "(", "source", ",", "str", ")", "and", "is_config", "(", "source", ")", ":", "source_fp", "=", "StringIO", "(", "source", ")", "elif", "isinstance", "(", "source", ",", "IOBase",...
Reads and parses the config source :param file/str source: Config source string, file name, or file pointer. If file name does not exist, it is ignored. :return: True if source was successfully read, otherwise False
[ "Reads", "and", "parses", "the", "config", "source" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L145-L166
train
Reads and parses the config file
maxzheng/localconfig
localconfig/manager.py
LocalConfig.save
def save(self, target_file=None, as_template=False): """ Save the config :param str target_file: File to save to. Defaults to `self._last_source` if set :param bool as_template: Save the config with all keys and sections commented out for user to modify :raise AttributeError: if...
python
def save(self, target_file=None, as_template=False): """ Save the config :param str target_file: File to save to. Defaults to `self._last_source` if set :param bool as_template: Save the config with all keys and sections commented out for user to modify :raise AttributeError: if...
[ "def", "save", "(", "self", ",", "target_file", "=", "None", ",", "as_template", "=", "False", ")", ":", "self", ".", "_read_sources", "(", ")", "if", "not", "target_file", ":", "if", "not", "self", ".", "_last_source", ":", "raise", "AttributeError", "(...
Save the config :param str target_file: File to save to. Defaults to `self._last_source` if set :param bool as_template: Save the config with all keys and sections commented out for user to modify :raise AttributeError: if target file is not provided and `self._last_source` is not set
[ "Save", "the", "config" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L203-L229
train
Save the current config to a file.
maxzheng/localconfig
localconfig/manager.py
LocalConfig._parse_extra
def _parse_extra(self, fp): """ Parse and store the config comments and create maps for dot notion lookup """ comment = '' section = '' fp.seek(0) for line in fp: line = line.rstrip() if not line: if comment: comment ...
python
def _parse_extra(self, fp): """ Parse and store the config comments and create maps for dot notion lookup """ comment = '' section = '' fp.seek(0) for line in fp: line = line.rstrip() if not line: if comment: comment ...
[ "def", "_parse_extra", "(", "self", ",", "fp", ")", ":", "comment", "=", "''", "section", "=", "''", "fp", ".", "seek", "(", "0", ")", "for", "line", "in", "fp", ":", "line", "=", "line", ".", "rstrip", "(", ")", "if", "not", "line", ":", "if",...
Parse and store the config comments and create maps for dot notion lookup
[ "Parse", "and", "store", "the", "config", "comments", "and", "create", "maps", "for", "dot", "notion", "lookup" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L231-L265
train
Parse and store the comments and create maps for dot notion lookup
maxzheng/localconfig
localconfig/manager.py
LocalConfig.get
def get(self, section, key, default=NO_DEFAULT_VALUE): """ Get config value with data type transformation (from str) :param str section: Section to get config for. :param str key: Key to get config for. :param default: Default value for key if key was not found. :return:...
python
def get(self, section, key, default=NO_DEFAULT_VALUE): """ Get config value with data type transformation (from str) :param str section: Section to get config for. :param str key: Key to get config for. :param default: Default value for key if key was not found. :return:...
[ "def", "get", "(", "self", ",", "section", ",", "key", ",", "default", "=", "NO_DEFAULT_VALUE", ")", ":", "self", ".", "_read_sources", "(", ")", "if", "(", "section", ",", "key", ")", "in", "self", ".", "_dot_keys", ":", "section", ",", "key", "=", ...
Get config value with data type transformation (from str) :param str section: Section to get config for. :param str key: Key to get config for. :param default: Default value for key if key was not found. :return: Value for the section/key or `default` if set and key does not exist. ...
[ "Get", "config", "value", "with", "data", "type", "transformation", "(", "from", "str", ")" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L267-L290
train
Get the config value with data type transformation
maxzheng/localconfig
localconfig/manager.py
LocalConfig.set
def set(self, section, key, value, comment=None): """ Set config value with data type transformation (to str) :param str section: Section to set config for :param str key: Key to set config for :param value: Value for key. It can be any primitive type. :param str comment...
python
def set(self, section, key, value, comment=None): """ Set config value with data type transformation (to str) :param str section: Section to set config for :param str key: Key to set config for :param value: Value for key. It can be any primitive type. :param str comment...
[ "def", "set", "(", "self", ",", "section", ",", "key", ",", "value", ",", "comment", "=", "None", ")", ":", "self", ".", "_read_sources", "(", ")", "if", "(", "section", ",", "key", ")", "in", "self", ".", "_dot_keys", ":", "section", ",", "key", ...
Set config value with data type transformation (to str) :param str section: Section to set config for :param str key: Key to set config for :param value: Value for key. It can be any primitive type. :param str comment: Comment for the key
[ "Set", "config", "value", "with", "data", "type", "transformation", "(", "to", "str", ")" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L292-L316
train
Set the value of the key in section to value.
maxzheng/localconfig
localconfig/manager.py
LocalConfig._typed_value
def _typed_value(self, value): """ Transform string value to an actual data type of the same value. """ if value not in self._value_cache: new_value = value if is_int(value): new_value = int(value) elif is_float(value): new_value = flo...
python
def _typed_value(self, value): """ Transform string value to an actual data type of the same value. """ if value not in self._value_cache: new_value = value if is_int(value): new_value = int(value) elif is_float(value): new_value = flo...
[ "def", "_typed_value", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "self", ".", "_value_cache", ":", "new_value", "=", "value", "if", "is_int", "(", "value", ")", ":", "new_value", "=", "int", "(", "value", ")", "elif", "is_float",...
Transform string value to an actual data type of the same value.
[ "Transform", "string", "value", "to", "an", "actual", "data", "type", "of", "the", "same", "value", "." ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L330-L345
train
Transform string value to an actual data type of the same value.
maxzheng/localconfig
localconfig/manager.py
LocalConfig.add_section
def add_section(self, section, comment=None): """ Add a section :param str section: Section to add :raise DuplicateSectionError: if section already exist. """ self._read_sources() if self._to_dot_key(section) in self._dot_keys: raise DuplicateSection...
python
def add_section(self, section, comment=None): """ Add a section :param str section: Section to add :raise DuplicateSectionError: if section already exist. """ self._read_sources() if self._to_dot_key(section) in self._dot_keys: raise DuplicateSection...
[ "def", "add_section", "(", "self", ",", "section", ",", "comment", "=", "None", ")", ":", "self", ".", "_read_sources", "(", ")", "if", "self", ".", "_to_dot_key", "(", "section", ")", "in", "self", ".", "_dot_keys", ":", "raise", "DuplicateSectionError", ...
Add a section :param str section: Section to add :raise DuplicateSectionError: if section already exist.
[ "Add", "a", "section" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L381-L396
train
Add a section to the log.
maxzheng/localconfig
localconfig/manager.py
LocalConfig._set_comment
def _set_comment(self, section, comment, key=None): """ Set a comment for section or key :param str section: Section to add comment to :param str comment: Comment to add :param str key: Key to add comment to """ if '\n' in comment: comment = '\n# '.j...
python
def _set_comment(self, section, comment, key=None): """ Set a comment for section or key :param str section: Section to add comment to :param str comment: Comment to add :param str key: Key to add comment to """ if '\n' in comment: comment = '\n# '.j...
[ "def", "_set_comment", "(", "self", ",", "section", ",", "comment", ",", "key", "=", "None", ")", ":", "if", "'\\n'", "in", "comment", ":", "comment", "=", "'\\n# '", ".", "join", "(", "comment", ".", "split", "(", "'\\n'", ")", ")", "comment", "=", ...
Set a comment for section or key :param str section: Section to add comment to :param str comment: Comment to add :param str key: Key to add comment to
[ "Set", "a", "comment", "for", "section", "or", "key" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L398-L414
train
Set a comment for the key or the section
maxzheng/localconfig
localconfig/manager.py
LocalConfig.items
def items(self, section): """ Items for section with data type transformation (from str) :param str section: Section to get items for. :return: Generator of (key, value) for the section """ self._read_sources() if section in self._dot_keys: section =...
python
def items(self, section): """ Items for section with data type transformation (from str) :param str section: Section to get items for. :return: Generator of (key, value) for the section """ self._read_sources() if section in self._dot_keys: section =...
[ "def", "items", "(", "self", ",", "section", ")", ":", "self", ".", "_read_sources", "(", ")", "if", "section", "in", "self", ".", "_dot_keys", ":", "section", "=", "self", ".", "_dot_keys", "[", "section", "]", "for", "item", "in", "self", ".", "_pa...
Items for section with data type transformation (from str) :param str section: Section to get items for. :return: Generator of (key, value) for the section
[ "Items", "for", "section", "with", "data", "type", "transformation", "(", "from", "str", ")" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L416-L431
train
Get items for a given section
geophysics-ubonn/crtomo_tools
src/sd_plot.py
handle_options
def handle_options(): '''Handle options. ''' parser = OptionParser() parser.set_defaults(cmaglin=False) parser.set_defaults(single=False) parser.set_defaults(alpha_cov=False) parser.add_option('-x', '--xmin', dest='xmin', help...
python
def handle_options(): '''Handle options. ''' parser = OptionParser() parser.set_defaults(cmaglin=False) parser.set_defaults(single=False) parser.set_defaults(alpha_cov=False) parser.add_option('-x', '--xmin', dest='xmin', help...
[ "def", "handle_options", "(", ")", ":", "parser", "=", "OptionParser", "(", ")", "parser", ".", "set_defaults", "(", "cmaglin", "=", "False", ")", "parser", ".", "set_defaults", "(", "single", "=", "False", ")", "parser", ".", "set_defaults", "(", "alpha_c...
Handle options.
[ "Handle", "options", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sd_plot.py#L18-L124
train
Handle options.
geophysics-ubonn/crtomo_tools
src/sd_plot.py
overview_plot.getfigsize
def getfigsize(self, opt): '''calculate appropriate sizes for the subfigures ''' if opt.xmin is None: opt.xmin = self.plotman.grid.grid['x'].min() if opt.xmax is None: opt.xmax = self.plotman.grid.grid['x'].max() if opt.zmin is None: opt.zmin =...
python
def getfigsize(self, opt): '''calculate appropriate sizes for the subfigures ''' if opt.xmin is None: opt.xmin = self.plotman.grid.grid['x'].min() if opt.xmax is None: opt.xmax = self.plotman.grid.grid['x'].max() if opt.zmin is None: opt.zmin =...
[ "def", "getfigsize", "(", "self", ",", "opt", ")", ":", "if", "opt", ".", "xmin", "is", "None", ":", "opt", ".", "xmin", "=", "self", ".", "plotman", ".", "grid", ".", "grid", "[", "'x'", "]", ".", "min", "(", ")", "if", "opt", ".", "xmax", "...
calculate appropriate sizes for the subfigures
[ "calculate", "appropriate", "sizes", "for", "the", "subfigures" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sd_plot.py#L184-L208
train
calculate appropriate sizes for the subfigures
geophysics-ubonn/crtomo_tools
src/sd_plot.py
overview_plot.load_grid
def load_grid(self, alpha): '''Load grid and calculate alpha values from the coverage/2.5. ''' grid = CRGrid.crt_grid(self.dirs[0] + '/grid/elem.dat', self.dirs[0] + '/grid/elec.dat') self.plotman = CRPlot.plotManager(grid=grid) name = self.dirs[0]...
python
def load_grid(self, alpha): '''Load grid and calculate alpha values from the coverage/2.5. ''' grid = CRGrid.crt_grid(self.dirs[0] + '/grid/elem.dat', self.dirs[0] + '/grid/elec.dat') self.plotman = CRPlot.plotManager(grid=grid) name = self.dirs[0]...
[ "def", "load_grid", "(", "self", ",", "alpha", ")", ":", "grid", "=", "CRGrid", ".", "crt_grid", "(", "self", ".", "dirs", "[", "0", "]", "+", "'/grid/elem.dat'", ",", "self", ".", "dirs", "[", "0", "]", "+", "'/grid/elec.dat'", ")", "self", ".", "...
Load grid and calculate alpha values from the coverage/2.5.
[ "Load", "grid", "and", "calculate", "alpha", "values", "from", "the", "coverage", "/", "2", ".", "5", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sd_plot.py#L214-L231
train
Load grid and calculate alpha values from the coverage / 2. 5.
thiagopbueno/tf-rddlsim
tfrddlsim/policy/random_policy.py
RandomPolicy._sample_actions
def _sample_actions(self, state: Sequence[tf.Tensor]) -> Tuple[Sequence[tf.Tensor], tf.Tensor, tf.Tensor]: '''Returns sampled action fluents and tensors related to the sampling. Args: state (Sequence[tf.Tensor]): A list of state fluents. Returns: Tuple[Seque...
python
def _sample_actions(self, state: Sequence[tf.Tensor]) -> Tuple[Sequence[tf.Tensor], tf.Tensor, tf.Tensor]: '''Returns sampled action fluents and tensors related to the sampling. Args: state (Sequence[tf.Tensor]): A list of state fluents. Returns: Tuple[Seque...
[ "def", "_sample_actions", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "Tuple", "[", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "tf", ".", "Tensor", ",", "tf", ".", "Tensor", "]", ":", "default", "=", ...
Returns sampled action fluents and tensors related to the sampling. Args: state (Sequence[tf.Tensor]): A list of state fluents. Returns: Tuple[Sequence[tf.Tensor], tf.Tensor, tf.Tensor]: A tuple with action fluents, an integer tensor for the number of samples, and ...
[ "Returns", "sampled", "action", "fluents", "and", "tensors", "related", "to", "the", "sampling", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/policy/random_policy.py#L70-L86
train
Returns sampled action fluents and tensors related to the sampling.
thiagopbueno/tf-rddlsim
tfrddlsim/policy/random_policy.py
RandomPolicy._check_preconditions
def _check_preconditions(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], bound_constraints: Dict[str, Constraints], default: Sequence[tf.Tensor]) -> Tuple[tf.Tensor, Sequence[tf.Tensor], tf.Tensor]: '''Samples action fluents until all preconditions ...
python
def _check_preconditions(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], bound_constraints: Dict[str, Constraints], default: Sequence[tf.Tensor]) -> Tuple[tf.Tensor, Sequence[tf.Tensor], tf.Tensor]: '''Samples action fluents until all preconditions ...
[ "def", "_check_preconditions", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "action", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "bound_constraints", ":", "Dict", "[", "str", ",", "Constraints", "]", ",", "d...
Samples action fluents until all preconditions are satisfied. Checks action preconditions for the sampled `action` and current `state`, and iff all preconditions are satisfied it returns the sampled action fluents. Args: state (Sequence[tf.Tensor]): A list of state fluents. ...
[ "Samples", "action", "fluents", "until", "all", "preconditions", "are", "satisfied", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/policy/random_policy.py#L88-L127
train
Returns a tuple of the fluents and the actions that are in the state and the default action fluents.
thiagopbueno/tf-rddlsim
tfrddlsim/policy/random_policy.py
RandomPolicy._sample_action
def _sample_action(self, constraints: Dict[str, Constraints], default: Sequence[tf.Tensor], prob: float = 0.3) -> Sequence[tf.Tensor]: '''Samples action fluents respecting the given bound `constraints`. With probability `prob` it chooses the action fluent default val...
python
def _sample_action(self, constraints: Dict[str, Constraints], default: Sequence[tf.Tensor], prob: float = 0.3) -> Sequence[tf.Tensor]: '''Samples action fluents respecting the given bound `constraints`. With probability `prob` it chooses the action fluent default val...
[ "def", "_sample_action", "(", "self", ",", "constraints", ":", "Dict", "[", "str", ",", "Constraints", "]", ",", "default", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "prob", ":", "float", "=", "0.3", ")", "->", "Sequence", "[", "tf", ".", ...
Samples action fluents respecting the given bound `constraints`. With probability `prob` it chooses the action fluent default value, with probability 1-`prob` it samples the fluent w.r.t. its bounds. Args: constraints (Dict[str, Tuple[Optional[TensorFluent], Optional[TensorFluent]]...
[ "Samples", "action", "fluents", "respecting", "the", "given", "bound", "constraints", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/policy/random_policy.py#L129-L155
train
Samples action fluents respecting the given constraints.
thiagopbueno/tf-rddlsim
tfrddlsim/policy/random_policy.py
RandomPolicy._sample_action_fluent
def _sample_action_fluent(self, name: str, dtype: tf.DType, size: Sequence[int], constraints: Dict[str, Constraints], default_value: tf.Tensor, prob: float) -> tf.Tensor: '''Samples the action fluent with given `name`, `dtype`, and `size`. ...
python
def _sample_action_fluent(self, name: str, dtype: tf.DType, size: Sequence[int], constraints: Dict[str, Constraints], default_value: tf.Tensor, prob: float) -> tf.Tensor: '''Samples the action fluent with given `name`, `dtype`, and `size`. ...
[ "def", "_sample_action_fluent", "(", "self", ",", "name", ":", "str", ",", "dtype", ":", "tf", ".", "DType", ",", "size", ":", "Sequence", "[", "int", "]", ",", "constraints", ":", "Dict", "[", "str", ",", "Constraints", "]", ",", "default_value", ":",...
Samples the action fluent with given `name`, `dtype`, and `size`. With probability `prob` it chooses the action fluent `default_value`, with probability 1-`prob` it samples the fluent w.r.t. its `constraints`. Args: name (str): The name of the action fluent. dtype (tf.D...
[ "Samples", "the", "action", "fluent", "with", "given", "name", "dtype", "and", "size", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/policy/random_policy.py#L157-L215
train
Samples the action fluent with given name dtype and size and returns the tensor of the action fluent.
eventifyio/eventify
eventify/drivers/kafka.py
Component.emit_event
async def emit_event(self, event): """ Publish an event :param event: Event object """ self.log.info("publishing event on %s", self.publish_topic) if self.config.extra['config']['pub_options']['retain']: try: await persist_event( ...
python
async def emit_event(self, event): """ Publish an event :param event: Event object """ self.log.info("publishing event on %s", self.publish_topic) if self.config.extra['config']['pub_options']['retain']: try: await persist_event( ...
[ "async", "def", "emit_event", "(", "self", ",", "event", ")", ":", "self", ".", "log", ".", "info", "(", "\"publishing event on %s\"", ",", "self", ".", "publish_topic", ")", "if", "self", ".", "config", ".", "extra", "[", "'config'", "]", "[", "'pub_opt...
Publish an event :param event: Event object
[ "Publish", "an", "event", ":", "param", "event", ":", "Event", "object" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/kafka.py#L56-L87
train
Publish an event to the broker.
Nic30/hwtGraph
hwtGraph/elk/fromHwt/convertor.py
UnitToLNode
def UnitToLNode(u: Unit, node: Optional[LNode]=None, toL: Optional[dict]=None, optimizations=[]) -> LNode: """ Build LNode instance from Unit instance :attention: unit has to be synthesized """ if toL is None: toL = {} if node is None: root = LNod...
python
def UnitToLNode(u: Unit, node: Optional[LNode]=None, toL: Optional[dict]=None, optimizations=[]) -> LNode: """ Build LNode instance from Unit instance :attention: unit has to be synthesized """ if toL is None: toL = {} if node is None: root = LNod...
[ "def", "UnitToLNode", "(", "u", ":", "Unit", ",", "node", ":", "Optional", "[", "LNode", "]", "=", "None", ",", "toL", ":", "Optional", "[", "dict", "]", "=", "None", ",", "optimizations", "=", "[", "]", ")", "->", "LNode", ":", "if", "toL", "is"...
Build LNode instance from Unit instance :attention: unit has to be synthesized
[ "Build", "LNode", "instance", "from", "Unit", "instance" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/convertor.py#L20-L102
train
Build LNode instance from Unit instance u and optional node to LNode instance toL.
redhat-openstack/python-tripleo-helper
tripleohelper/host0.py
Host0.configure
def configure(self, rhsm=None, repositories=None): """This method will configure the host0 and run the hypervisor.""" if rhsm is not None: self.rhsm_register(rhsm) if repositories is not None: self.enable_repositories(repositories) self.create_stack_user() ...
python
def configure(self, rhsm=None, repositories=None): """This method will configure the host0 and run the hypervisor.""" if rhsm is not None: self.rhsm_register(rhsm) if repositories is not None: self.enable_repositories(repositories) self.create_stack_user() ...
[ "def", "configure", "(", "self", ",", "rhsm", "=", "None", ",", "repositories", "=", "None", ")", ":", "if", "rhsm", "is", "not", "None", ":", "self", ".", "rhsm_register", "(", "rhsm", ")", "if", "repositories", "is", "not", "None", ":", "self", "."...
This method will configure the host0 and run the hypervisor.
[ "This", "method", "will", "configure", "the", "host0", "and", "run", "the", "hypervisor", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/host0.py#L35-L42
train
This method will configure the host0 and run the hypervisor.
redhat-openstack/python-tripleo-helper
tripleohelper/host0.py
Host0.deploy_hypervisor
def deploy_hypervisor(self): """Install the libvirtd and instack-undercloud packages. """ self.yum_install(['libvirt-daemon-driver-nwfilter', 'libvirt-client', 'libvirt-daemon-config-network', 'libvirt-daemon-driver-nodedev', 'libvirt-daemon-kvm', 'libvirt-python', 'libvirt-daemon-config-nwfilte...
python
def deploy_hypervisor(self): """Install the libvirtd and instack-undercloud packages. """ self.yum_install(['libvirt-daemon-driver-nwfilter', 'libvirt-client', 'libvirt-daemon-config-network', 'libvirt-daemon-driver-nodedev', 'libvirt-daemon-kvm', 'libvirt-python', 'libvirt-daemon-config-nwfilte...
[ "def", "deploy_hypervisor", "(", "self", ")", ":", "self", ".", "yum_install", "(", "[", "'libvirt-daemon-driver-nwfilter'", ",", "'libvirt-client'", ",", "'libvirt-daemon-config-network'", ",", "'libvirt-daemon-driver-nodedev'", ",", "'libvirt-daemon-kvm'", ",", "'libvirt-...
Install the libvirtd and instack-undercloud packages.
[ "Install", "the", "libvirtd", "and", "instack", "-", "undercloud", "packages", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/host0.py#L44-L54
train
Deploy the hypervisor and the base packages.
redhat-openstack/python-tripleo-helper
tripleohelper/host0.py
Host0.build_undercloud_on_libvirt
def build_undercloud_on_libvirt(self, image_path, rhsm=None, repositories=[]): """Build the Undercloud by using instack-virt-setup script.""" self.run('sysctl net.ipv4.ip_forward=1') self.fetch_image(path=image_path, dest='/home/stack/guest_image.qcow2', ...
python
def build_undercloud_on_libvirt(self, image_path, rhsm=None, repositories=[]): """Build the Undercloud by using instack-virt-setup script.""" self.run('sysctl net.ipv4.ip_forward=1') self.fetch_image(path=image_path, dest='/home/stack/guest_image.qcow2', ...
[ "def", "build_undercloud_on_libvirt", "(", "self", ",", "image_path", ",", "rhsm", "=", "None", ",", "repositories", "=", "[", "]", ")", ":", "self", ".", "run", "(", "'sysctl net.ipv4.ip_forward=1'", ")", "self", ".", "fetch_image", "(", "path", "=", "image...
Build the Undercloud by using instack-virt-setup script.
[ "Build", "the", "Undercloud", "by", "using", "instack", "-", "virt", "-", "setup", "script", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/host0.py#L56-L105
train
Build the Undercloud by using instack - virt - setup script.
peterbe/gg
gg/builtins/bugzilla.py
login
def login(config, api_key=""): """Store your Bugzilla API Key""" if not api_key: info_out( "If you don't have an API Key, go to:\n" "https://bugzilla.mozilla.org/userprefs.cgi?tab=apikey\n" ) api_key = getpass.getpass("API Key: ") # Before we store it, let's ...
python
def login(config, api_key=""): """Store your Bugzilla API Key""" if not api_key: info_out( "If you don't have an API Key, go to:\n" "https://bugzilla.mozilla.org/userprefs.cgi?tab=apikey\n" ) api_key = getpass.getpass("API Key: ") # Before we store it, let's ...
[ "def", "login", "(", "config", ",", "api_key", "=", "\"\"", ")", ":", "if", "not", "api_key", ":", "info_out", "(", "\"If you don't have an API Key, go to:\\n\"", "\"https://bugzilla.mozilla.org/userprefs.cgi?tab=apikey\\n\"", ")", "api_key", "=", "getpass", ".", "getpa...
Store your Bugzilla API Key
[ "Store", "your", "Bugzilla", "API", "Key" ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/bugzilla.py#L35-L64
train
Login to Bugzilla.
peterbe/gg
gg/builtins/bugzilla.py
logout
def logout(config): """Remove and forget your Bugzilla credentials""" state = read(config.configfile) if state.get("BUGZILLA"): remove(config.configfile, "BUGZILLA") success_out("Forgotten") else: error_out("No stored Bugzilla credentials")
python
def logout(config): """Remove and forget your Bugzilla credentials""" state = read(config.configfile) if state.get("BUGZILLA"): remove(config.configfile, "BUGZILLA") success_out("Forgotten") else: error_out("No stored Bugzilla credentials")
[ "def", "logout", "(", "config", ")", ":", "state", "=", "read", "(", "config", ".", "configfile", ")", "if", "state", ".", "get", "(", "\"BUGZILLA\"", ")", ":", "remove", "(", "config", ".", "configfile", ",", "\"BUGZILLA\"", ")", "success_out", "(", "...
Remove and forget your Bugzilla credentials
[ "Remove", "and", "forget", "your", "Bugzilla", "credentials" ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/bugzilla.py#L69-L76
train
Remove and forget your Bugzilla credentials
flo-compbio/xlmhg
xlmhg/visualize.py
get_hypergeometric_stats
def get_hypergeometric_stats(N, indices): """Calculates hypergeom. p-values and fold enrichments for all cutoffs. Parameters ---------- N: int The length of the list indices: `numpy.ndarray` with ``dtype=np.uint16`` The (sorted) indices of the "1's" in the list. """ assert ...
python
def get_hypergeometric_stats(N, indices): """Calculates hypergeom. p-values and fold enrichments for all cutoffs. Parameters ---------- N: int The length of the list indices: `numpy.ndarray` with ``dtype=np.uint16`` The (sorted) indices of the "1's" in the list. """ assert ...
[ "def", "get_hypergeometric_stats", "(", "N", ",", "indices", ")", ":", "assert", "isinstance", "(", "N", ",", "(", "int", ",", "np", ".", "integer", ")", ")", "assert", "isinstance", "(", "indices", ",", "np", ".", "ndarray", ")", "and", "np", ".", "...
Calculates hypergeom. p-values and fold enrichments for all cutoffs. Parameters ---------- N: int The length of the list indices: `numpy.ndarray` with ``dtype=np.uint16`` The (sorted) indices of the "1's" in the list.
[ "Calculates", "hypergeom", ".", "p", "-", "values", "and", "fold", "enrichments", "for", "all", "cutoffs", "." ]
8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1
https://github.com/flo-compbio/xlmhg/blob/8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1/xlmhg/visualize.py#L35-L77
train
Calculates the hypergeometric p - values and fold enrichments for all cutoffs.
flo-compbio/xlmhg
xlmhg/visualize.py
get_result_figure
def get_result_figure( result, show_title=False, title=None, show_inset=True, plot_fold_enrichment=False, width=800, height=350, font_size=24, margin=None, font_family='Computer Modern Roman, serif', score_color='rgb(0,109,219)', enrichment_color='rgb(219,109,0)', ...
python
def get_result_figure( result, show_title=False, title=None, show_inset=True, plot_fold_enrichment=False, width=800, height=350, font_size=24, margin=None, font_family='Computer Modern Roman, serif', score_color='rgb(0,109,219)', enrichment_color='rgb(219,109,0)', ...
[ "def", "get_result_figure", "(", "result", ",", "show_title", "=", "False", ",", "title", "=", "None", ",", "show_inset", "=", "True", ",", "plot_fold_enrichment", "=", "False", ",", "width", "=", "800", ",", "height", "=", "350", ",", "font_size", "=", ...
Visualize an XL-mHG test result. Parameters ---------- result : `mHGResult` The test result. show_title : bool, optional Whether to include a title in the figure. If `title` is not ``None``, this parameter is ignored. [False] title : str or None, optional Figure titl...
[ "Visualize", "an", "XL", "-", "mHG", "test", "result", "." ]
8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1
https://github.com/flo-compbio/xlmhg/blob/8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1/xlmhg/visualize.py#L80-L432
train
Returns a figure that can be used to display the test result.
gofed/gofedlib
gofedlib/providers/upstreamprovider.py
UpstreamProvider.parse
def parse(self, prefix): """ Parse import path into provider, project, repository and other recognizable parts :param importpath: import path to parse :type importpath: str :return: bool """ # reset to default values self._prefix = "" url = re.sub(r'http://', '', prefix) url = re.sub(r'https://',...
python
def parse(self, prefix): """ Parse import path into provider, project, repository and other recognizable parts :param importpath: import path to parse :type importpath: str :return: bool """ # reset to default values self._prefix = "" url = re.sub(r'http://', '', prefix) url = re.sub(r'https://',...
[ "def", "parse", "(", "self", ",", "prefix", ")", ":", "# reset to default values", "self", ".", "_prefix", "=", "\"\"", "url", "=", "re", ".", "sub", "(", "r'http://'", ",", "''", ",", "prefix", ")", "url", "=", "re", ".", "sub", "(", "r'https://'", ...
Parse import path into provider, project, repository and other recognizable parts :param importpath: import path to parse :type importpath: str :return: bool
[ "Parse", "import", "path", "into", "provider", "project", "repository", "and", "other", "recognizable", "parts" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/providers/upstreamprovider.py#L20-L44
train
Parse import path into provider project repository and other recognizable parts and other recognizable parts self. _prefix is the prefix of the import path.
gofed/gofedlib
gofedlib/providers/upstreamprovider.py
UpstreamProvider.detectCustomImportPaths
def detectCustomImportPaths(self, prefix): """ Some prefixes does not reflect provider prefix e.g. camlistore.org/pkg/googlestorage is actually at github.com/camlistore/camlistore repository under pkg/googlestorage directory. """ for assignment in self.ip2pp_mapping: if prefix.startswith(assignment["ip...
python
def detectCustomImportPaths(self, prefix): """ Some prefixes does not reflect provider prefix e.g. camlistore.org/pkg/googlestorage is actually at github.com/camlistore/camlistore repository under pkg/googlestorage directory. """ for assignment in self.ip2pp_mapping: if prefix.startswith(assignment["ip...
[ "def", "detectCustomImportPaths", "(", "self", ",", "prefix", ")", ":", "for", "assignment", "in", "self", ".", "ip2pp_mapping", ":", "if", "prefix", ".", "startswith", "(", "assignment", "[", "\"ipprefix\"", "]", ")", ":", "return", "{", "\"prefix\"", ":", ...
Some prefixes does not reflect provider prefix e.g. camlistore.org/pkg/googlestorage is actually at github.com/camlistore/camlistore repository under pkg/googlestorage directory.
[ "Some", "prefixes", "does", "not", "reflect", "provider", "prefix", "e", ".", "g", ".", "camlistore", ".", "org", "/", "pkg", "/", "googlestorage", "is", "actually", "at", "github", ".", "com", "/", "camlistore", "/", "camlistore", "repository", "under", "...
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/providers/upstreamprovider.py#L52-L63
train
detect custom import paths for a given prefix
gofed/gofedlib
gofedlib/providers/upstreamprovider.py
UpstreamProvider.detectKnownRepo
def detectKnownRepo(self, url): """ For given import path detect provider. """ if url.startswith('github.com'): return GITHUB if url.startswith('code.google.com/p'): return GOOGLECODE if url.startswith('golang.org/x'): return GOLANGORG if url.startswith('gopkg.in'): return GOPKG if url.start...
python
def detectKnownRepo(self, url): """ For given import path detect provider. """ if url.startswith('github.com'): return GITHUB if url.startswith('code.google.com/p'): return GOOGLECODE if url.startswith('golang.org/x'): return GOLANGORG if url.startswith('gopkg.in'): return GOPKG if url.start...
[ "def", "detectKnownRepo", "(", "self", ",", "url", ")", ":", "if", "url", ".", "startswith", "(", "'github.com'", ")", ":", "return", "GITHUB", "if", "url", ".", "startswith", "(", "'code.google.com/p'", ")", ":", "return", "GOOGLECODE", "if", "url", ".", ...
For given import path detect provider.
[ "For", "given", "import", "path", "detect", "provider", "." ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/providers/upstreamprovider.py#L83-L100
train
detect known repo
gofed/gofedlib
gofedlib/providers/upstreamprovider.py
UpstreamProvider.parseGithubImportPath
def parseGithubImportPath(self, path): """ Definition: github.com/<project>/<repo> """ parts = path.split("/") if len(parts) < 3: raise ValueError("Import path %s not in github.com/<project>/<repo> form" % path) repo = {} repo["prefix"] = "/".join(parts[:3]) repo["signature"] = {"provider": "github...
python
def parseGithubImportPath(self, path): """ Definition: github.com/<project>/<repo> """ parts = path.split("/") if len(parts) < 3: raise ValueError("Import path %s not in github.com/<project>/<repo> form" % path) repo = {} repo["prefix"] = "/".join(parts[:3]) repo["signature"] = {"provider": "github...
[ "def", "parseGithubImportPath", "(", "self", ",", "path", ")", ":", "parts", "=", "path", ".", "split", "(", "\"/\"", ")", "if", "len", "(", "parts", ")", "<", "3", ":", "raise", "ValueError", "(", "\"Import path %s not in github.com/<project>/<repo> form\"", ...
Definition: github.com/<project>/<repo>
[ "Definition", ":", "github", ".", "com", "/", "<project", ">", "/", "<repo", ">" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/providers/upstreamprovider.py#L102-L115
train
Parse a github import path into a dictionary.
gofed/gofedlib
gofedlib/providers/upstreamprovider.py
UpstreamProvider.parseGopkgImportPath
def parseGopkgImportPath(self, path): """ Definition: gopkg.in/<v>/<repo> || gopkg.in/<repo>.<v> || gopkg.in/<project>/<repo> """ parts = path.split('/') if re.match('v[0-9]+', parts[1]): if len(parts) < 3: raise ValueError("Import path %s is not in gopkg.in/<v>/<repo> form" % path) project = "" ...
python
def parseGopkgImportPath(self, path): """ Definition: gopkg.in/<v>/<repo> || gopkg.in/<repo>.<v> || gopkg.in/<project>/<repo> """ parts = path.split('/') if re.match('v[0-9]+', parts[1]): if len(parts) < 3: raise ValueError("Import path %s is not in gopkg.in/<v>/<repo> form" % path) project = "" ...
[ "def", "parseGopkgImportPath", "(", "self", ",", "path", ")", ":", "parts", "=", "path", ".", "split", "(", "'/'", ")", "if", "re", ".", "match", "(", "'v[0-9]+'", ",", "parts", "[", "1", "]", ")", ":", "if", "len", "(", "parts", ")", "<", "3", ...
Definition: gopkg.in/<v>/<repo> || gopkg.in/<repo>.<v> || gopkg.in/<project>/<repo>
[ "Definition", ":", "gopkg", ".", "in", "/", "<v", ">", "/", "<repo", ">", "||", "gopkg", ".", "in", "/", "<repo", ">", ".", "<v", ">", "||", "gopkg", ".", "in", "/", "<project", ">", "/", "<repo", ">" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/providers/upstreamprovider.py#L147-L194
train
Parse a path into a tuple of gopkg. in and gopkg. in. <v > and gopkg. in. <repo >. <v >.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/ecdsakey.py
ECDSAKey.generate
def generate(bits, progress_func=None): """ Generate a new private RSA key. This factory function can be used to generate a new host key or authentication key. @param bits: number of bits the generated key should be. @type bits: int @param progress_func: an optional fun...
python
def generate(bits, progress_func=None): """ Generate a new private RSA key. This factory function can be used to generate a new host key or authentication key. @param bits: number of bits the generated key should be. @type bits: int @param progress_func: an optional fun...
[ "def", "generate", "(", "bits", ",", "progress_func", "=", "None", ")", ":", "signing_key", "=", "ECDSA", ".", "generate", "(", ")", "key", "=", "ECDSAKey", "(", "vals", "=", "(", "signing_key", ",", "signing_key", ".", "get_verifying_key", "(", ")", ")"...
Generate a new private RSA key. This factory function can be used to generate a new host key or authentication key. @param bits: number of bits the generated key should be. @type bits: int @param progress_func: an optional function to call at key points in key generation (u...
[ "Generate", "a", "new", "private", "RSA", "key", ".", "This", "factory", "function", "can", "be", "used", "to", "generate", "a", "new", "host", "key", "or", "authentication", "key", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/ecdsakey.py#L128-L143
train
This factory function can be used to generate a new private RSA key. This factory function can be used to generate a new private RSA key.
unt-libraries/pyuntl
pyuntl/form_logic.py
get_qualifier_dict
def get_qualifier_dict(vocabularies, qualifier_vocab): """Get the qualifier dictionary based on the element's qualifier vocabulary. """ # Raise exception if the vocabulary can't be found. if vocabularies.get(qualifier_vocab, None) is None: raise UNTLFormException( 'Could not retr...
python
def get_qualifier_dict(vocabularies, qualifier_vocab): """Get the qualifier dictionary based on the element's qualifier vocabulary. """ # Raise exception if the vocabulary can't be found. if vocabularies.get(qualifier_vocab, None) is None: raise UNTLFormException( 'Could not retr...
[ "def", "get_qualifier_dict", "(", "vocabularies", ",", "qualifier_vocab", ")", ":", "# Raise exception if the vocabulary can't be found.", "if", "vocabularies", ".", "get", "(", "qualifier_vocab", ",", "None", ")", "is", "None", ":", "raise", "UNTLFormException", "(", ...
Get the qualifier dictionary based on the element's qualifier vocabulary.
[ "Get", "the", "qualifier", "dictionary", "based", "on", "the", "element", "s", "qualifier", "vocabulary", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/form_logic.py#L30-L42
train
Get the qualifier dictionary based on the element s qualifier vocabulary.
unt-libraries/pyuntl
pyuntl/form_logic.py
get_content_dict
def get_content_dict(vocabularies, content_vocab): """Get the content dictionary based on the element's content vocabulary. """ # Raise exception if the vocabulary can't be found. if vocabularies.get(content_vocab, None) is None: raise UNTLFormException( 'Could not retrieve conte...
python
def get_content_dict(vocabularies, content_vocab): """Get the content dictionary based on the element's content vocabulary. """ # Raise exception if the vocabulary can't be found. if vocabularies.get(content_vocab, None) is None: raise UNTLFormException( 'Could not retrieve conte...
[ "def", "get_content_dict", "(", "vocabularies", ",", "content_vocab", ")", ":", "# Raise exception if the vocabulary can't be found.", "if", "vocabularies", ".", "get", "(", "content_vocab", ",", "None", ")", "is", "None", ":", "raise", "UNTLFormException", "(", "'Cou...
Get the content dictionary based on the element's content vocabulary.
[ "Get", "the", "content", "dictionary", "based", "on", "the", "element", "s", "content", "vocabulary", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/form_logic.py#L45-L57
train
Get the content dictionary based on the element s content vocabulary.
unt-libraries/pyuntl
pyuntl/form_logic.py
FormGroup.get_group_hidden
def get_group_hidden(self): """Determine if the entire group of elements is hidden (decide whether to hide the entire group). """ # Loop through all the elements in the group. for element in self.group_list: # Handle element that is not hidden or has a form. ...
python
def get_group_hidden(self): """Determine if the entire group of elements is hidden (decide whether to hide the entire group). """ # Loop through all the elements in the group. for element in self.group_list: # Handle element that is not hidden or has a form. ...
[ "def", "get_group_hidden", "(", "self", ")", ":", "# Loop through all the elements in the group.", "for", "element", "in", "self", ".", "group_list", ":", "# Handle element that is not hidden or has a form.", "if", "element", ".", "form", ".", "view_type", "!=", "'none'",...
Determine if the entire group of elements is hidden (decide whether to hide the entire group).
[ "Determine", "if", "the", "entire", "group", "of", "elements", "is", "hidden", "(", "decide", "whether", "to", "hide", "the", "entire", "group", ")", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/form_logic.py#L85-L99
train
Determine if the entire group of elements is hidden.
unt-libraries/pyuntl
pyuntl/form_logic.py
FormGroup.get_group_usage_link
def get_group_usage_link(self): """Get the usage link for the group element.""" first_element = self.group_list[0] usage_link = getattr(first_element.form, 'usage_link', None) return usage_link
python
def get_group_usage_link(self): """Get the usage link for the group element.""" first_element = self.group_list[0] usage_link = getattr(first_element.form, 'usage_link', None) return usage_link
[ "def", "get_group_usage_link", "(", "self", ")", ":", "first_element", "=", "self", ".", "group_list", "[", "0", "]", "usage_link", "=", "getattr", "(", "first_element", ".", "form", ",", "'usage_link'", ",", "None", ")", "return", "usage_link" ]
Get the usage link for the group element.
[ "Get", "the", "usage", "link", "for", "the", "group", "element", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/form_logic.py#L101-L105
train
Get the usage link for the group element.
unt-libraries/pyuntl
pyuntl/form_logic.py
FormGroup.get_adjustable_form
def get_adjustable_form(self, element_dispatch): """Create an adjustable form from an element dispatch table.""" adjustable_form = {} # Loop through the qualifiers to create the adjustable form. for key in element_dispatch.keys(): adjustable_form[key] = element_dispatch[key](...
python
def get_adjustable_form(self, element_dispatch): """Create an adjustable form from an element dispatch table.""" adjustable_form = {} # Loop through the qualifiers to create the adjustable form. for key in element_dispatch.keys(): adjustable_form[key] = element_dispatch[key](...
[ "def", "get_adjustable_form", "(", "self", ",", "element_dispatch", ")", ":", "adjustable_form", "=", "{", "}", "# Loop through the qualifiers to create the adjustable form.", "for", "key", "in", "element_dispatch", ".", "keys", "(", ")", ":", "adjustable_form", "[", ...
Create an adjustable form from an element dispatch table.
[ "Create", "an", "adjustable", "form", "from", "an", "element", "dispatch", "table", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/form_logic.py#L107-L113
train
Create an adjustable form from an element dispatch table.
unt-libraries/pyuntl
pyuntl/form_logic.py
CoverageGroup.set_coverage_placeName
def set_coverage_placeName(self): """Determine the properties for the placeName coverage field.""" if (self.solr_response and self.solr_response != 'error' and self.solr_response.response != 'error'): location_list = self.solr_response.get_location_list_facet(...
python
def set_coverage_placeName(self): """Determine the properties for the placeName coverage field.""" if (self.solr_response and self.solr_response != 'error' and self.solr_response.response != 'error'): location_list = self.solr_response.get_location_list_facet(...
[ "def", "set_coverage_placeName", "(", "self", ")", ":", "if", "(", "self", ".", "solr_response", "and", "self", ".", "solr_response", "!=", "'error'", "and", "self", ".", "solr_response", ".", "response", "!=", "'error'", ")", ":", "location_list", "=", "sel...
Determine the properties for the placeName coverage field.
[ "Determine", "the", "properties", "for", "the", "placeName", "coverage", "field", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/form_logic.py#L143-L156
train
Determine the properties for the placeName coverage field.
unt-libraries/pyuntl
pyuntl/form_logic.py
Meta.get_meta_attributes
def get_meta_attributes(self, **kwargs): """Determine the form attributes for the meta field.""" superuser = kwargs.get('superuser', False) if (self.untl_object.qualifier == 'recordStatus' or self.untl_object.qualifier == 'system'): if superuser: self....
python
def get_meta_attributes(self, **kwargs): """Determine the form attributes for the meta field.""" superuser = kwargs.get('superuser', False) if (self.untl_object.qualifier == 'recordStatus' or self.untl_object.qualifier == 'system'): if superuser: self....
[ "def", "get_meta_attributes", "(", "self", ",", "*", "*", "kwargs", ")", ":", "superuser", "=", "kwargs", ".", "get", "(", "'superuser'", ",", "False", ")", "if", "(", "self", ".", "untl_object", ".", "qualifier", "==", "'recordStatus'", "or", "self", "....
Determine the form attributes for the meta field.
[ "Determine", "the", "form", "attributes", "for", "the", "meta", "field", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/form_logic.py#L746-L762
train
Determine the form attributes for the meta field.
zeldamods/evfl
evfl/dic.py
_bit_mismatch
def _bit_mismatch(int1: int, int2: int) -> int: """Returns the index of the first different bit or -1 if the values are the same.""" for i in range(max(int1.bit_length(), int2.bit_length())): if (int1 >> i) & 1 != (int2 >> i) & 1: return i return -1
python
def _bit_mismatch(int1: int, int2: int) -> int: """Returns the index of the first different bit or -1 if the values are the same.""" for i in range(max(int1.bit_length(), int2.bit_length())): if (int1 >> i) & 1 != (int2 >> i) & 1: return i return -1
[ "def", "_bit_mismatch", "(", "int1", ":", "int", ",", "int2", ":", "int", ")", "->", "int", ":", "for", "i", "in", "range", "(", "max", "(", "int1", ".", "bit_length", "(", ")", ",", "int2", ".", "bit_length", "(", ")", ")", ")", ":", "if", "("...
Returns the index of the first different bit or -1 if the values are the same.
[ "Returns", "the", "index", "of", "the", "first", "different", "bit", "or", "-", "1", "if", "the", "values", "are", "the", "same", "." ]
208b39ab817de5bbef419cdae4606255695e83ac
https://github.com/zeldamods/evfl/blob/208b39ab817de5bbef419cdae4606255695e83ac/evfl/dic.py#L5-L10
train
Returns the index of the first different bit or - 1 if the values are the same.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/client.py
SSHClient.save_host_keys
def save_host_keys(self, filename): """ Save the host keys back to a file. Only the host keys loaded with `load_host_keys` (plus any added directly) will be saved -- not any host keys loaded with `load_system_host_keys`. :param str filename: the filename to save to :ra...
python
def save_host_keys(self, filename): """ Save the host keys back to a file. Only the host keys loaded with `load_host_keys` (plus any added directly) will be saved -- not any host keys loaded with `load_system_host_keys`. :param str filename: the filename to save to :ra...
[ "def", "save_host_keys", "(", "self", ",", "filename", ")", ":", "# update local host keys from file (in case other SSH clients", "# have written to the known_hosts file meanwhile.", "if", "self", ".", "_host_keys_filename", "is", "not", "None", ":", "self", ".", "load_host_k...
Save the host keys back to a file. Only the host keys loaded with `load_host_keys` (plus any added directly) will be saved -- not any host keys loaded with `load_system_host_keys`. :param str filename: the filename to save to :raises IOError: if the file could not be written
[ "Save", "the", "host", "keys", "back", "to", "a", "file", ".", "Only", "the", "host", "keys", "loaded", "with", "load_host_keys", "(", "plus", "any", "added", "directly", ")", "will", "be", "saved", "--", "not", "any", "host", "keys", "loaded", "with", ...
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/client.py#L120-L139
train
Save the host keys to a file.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/client.py
SSHClient.connect
def connect(self, hostname, port=SSH_PORT, username=None, password=None, pkey=None, key_filename=None, timeout=None, allow_agent=True, look_for_keys=True, compress=False, sock=None): """ Connect to an SSH server and authenticate to it. The server's host key is ch...
python
def connect(self, hostname, port=SSH_PORT, username=None, password=None, pkey=None, key_filename=None, timeout=None, allow_agent=True, look_for_keys=True, compress=False, sock=None): """ Connect to an SSH server and authenticate to it. The server's host key is ch...
[ "def", "connect", "(", "self", ",", "hostname", ",", "port", "=", "SSH_PORT", ",", "username", "=", "None", ",", "password", "=", "None", ",", "pkey", "=", "None", ",", "key_filename", "=", "None", ",", "timeout", "=", "None", ",", "allow_agent", "=", ...
Connect to an SSH server and authenticate to it. The server's host key is checked against the system host keys (see `load_system_host_keys`) and any local host keys (`load_host_keys`). If the server's hostname is not found in either set of host keys, the missing host key policy is used...
[ "Connect", "to", "an", "SSH", "server", "and", "authenticate", "to", "it", ".", "The", "server", "s", "host", "key", "is", "checked", "against", "the", "system", "host", "keys", "(", "see", "load_system_host_keys", ")", "and", "any", "local", "host", "keys...
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/client.py#L172-L273
train
Connect to an SSH server and authenticate to it.
Nic30/hwtGraph
hwtGraph/elk/fromHwt/flattenTrees.py
searchRootOfTree
def searchRootOfTree(reducibleChildren: Set[LNode], nodeFromTree: LNode): """ Walk tree of nodes to root :param reducibleChildren: nodes which are part of tree :param nodeFromTree: node where to start the search """ while True: out_e = nodeFromTree.east[0].outgoingEdges # node ...
python
def searchRootOfTree(reducibleChildren: Set[LNode], nodeFromTree: LNode): """ Walk tree of nodes to root :param reducibleChildren: nodes which are part of tree :param nodeFromTree: node where to start the search """ while True: out_e = nodeFromTree.east[0].outgoingEdges # node ...
[ "def", "searchRootOfTree", "(", "reducibleChildren", ":", "Set", "[", "LNode", "]", ",", "nodeFromTree", ":", "LNode", ")", ":", "while", "True", ":", "out_e", "=", "nodeFromTree", ".", "east", "[", "0", "]", ".", "outgoingEdges", "# node has no successors", ...
Walk tree of nodes to root :param reducibleChildren: nodes which are part of tree :param nodeFromTree: node where to start the search
[ "Walk", "tree", "of", "nodes", "to", "root" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/flattenTrees.py#L7-L27
train
Search the tree of nodes to find the root of the tree.
Nic30/hwtGraph
hwtGraph/elk/fromHwt/flattenTrees.py
collectNodesInTree
def collectNodesInTree(treeRoot: LNode, reducibleChildren: Set[LNode]): """ Collect nodes which will be reduced and input nodes of tree for tree of nodes. :param treeRoot: root node of tree :param reducibleChildren: members of tree :return: Tuple[reducedNodes, inputEdges] where reducedNodes is List...
python
def collectNodesInTree(treeRoot: LNode, reducibleChildren: Set[LNode]): """ Collect nodes which will be reduced and input nodes of tree for tree of nodes. :param treeRoot: root node of tree :param reducibleChildren: members of tree :return: Tuple[reducedNodes, inputEdges] where reducedNodes is List...
[ "def", "collectNodesInTree", "(", "treeRoot", ":", "LNode", ",", "reducibleChildren", ":", "Set", "[", "LNode", "]", ")", ":", "# List[Tuple[LNode, LPort, LEdge]]", "inputEdges", "=", "[", "]", "# List[LNode]", "reducedNodes", "=", "[", "]", "# Set[LNode]", "reduc...
Collect nodes which will be reduced and input nodes of tree for tree of nodes. :param treeRoot: root node of tree :param reducibleChildren: members of tree :return: Tuple[reducedNodes, inputEdges] where reducedNodes is List[LNode] and inputEdges is List[Tuple[LNode, LPort, LEdge]]
[ "Collect", "nodes", "which", "will", "be", "reduced", "and", "input", "nodes", "of", "tree", "for", "tree", "of", "nodes", "." ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/flattenTrees.py#L30-L65
train
Collect nodes which will be reduced and input nodes of tree of nodes.
Nic30/hwtGraph
hwtGraph/elk/fromHwt/flattenTrees.py
flattenTrees
def flattenTrees(root, nodeSelector: Callable[[LNode], bool]): """ Walk all nodes and discover trees of nodes (usually operators) and reduce them to single node with multiple outputs :attention: selected nodes has to have single output and has to be connected to nets with single driver ...
python
def flattenTrees(root, nodeSelector: Callable[[LNode], bool]): """ Walk all nodes and discover trees of nodes (usually operators) and reduce them to single node with multiple outputs :attention: selected nodes has to have single output and has to be connected to nets with single driver ...
[ "def", "flattenTrees", "(", "root", ",", "nodeSelector", ":", "Callable", "[", "[", "LNode", "]", ",", "bool", "]", ")", ":", "for", "ch", "in", "root", ".", "children", ":", "if", "ch", ".", "children", ":", "flattenTrees", "(", "ch", ",", "nodeSele...
Walk all nodes and discover trees of nodes (usually operators) and reduce them to single node with multiple outputs :attention: selected nodes has to have single output and has to be connected to nets with single driver
[ "Walk", "all", "nodes", "and", "discover", "trees", "of", "nodes", "(", "usually", "operators", ")", "and", "reduce", "them", "to", "single", "node", "with", "multiple", "outputs" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/flattenTrees.py#L68-L130
train
Walk all nodes and discover trees of nodes and reduce them to single node with multiple outputs
pszafer/epson_projector
epson_projector/main.py
Projector.__initLock
def __initLock(self): """Init lock for sending request to projector when it is busy.""" self._isLocked = False self._timer = 0 self._operation = False
python
def __initLock(self): """Init lock for sending request to projector when it is busy.""" self._isLocked = False self._timer = 0 self._operation = False
[ "def", "__initLock", "(", "self", ")", ":", "self", ".", "_isLocked", "=", "False", "self", ".", "_timer", "=", "0", "self", ".", "_operation", "=", "False" ]
Init lock for sending request to projector when it is busy.
[ "Init", "lock", "for", "sending", "request", "to", "projector", "when", "it", "is", "busy", "." ]
b8a10ace56e0a5cf858546041819c0e7ebca208f
https://github.com/pszafer/epson_projector/blob/b8a10ace56e0a5cf858546041819c0e7ebca208f/epson_projector/main.py#L52-L56
train
Init lock for sending request to projector when it is busy.
pszafer/epson_projector
epson_projector/main.py
Projector.__setLock
def __setLock(self, command): """Set lock on requests.""" if command in (TURN_ON, TURN_OFF): self._operation = command elif command in INV_SOURCES: self._operation = SOURCE else: self._operation = ALL self._isLocked = True self._timer =...
python
def __setLock(self, command): """Set lock on requests.""" if command in (TURN_ON, TURN_OFF): self._operation = command elif command in INV_SOURCES: self._operation = SOURCE else: self._operation = ALL self._isLocked = True self._timer =...
[ "def", "__setLock", "(", "self", ",", "command", ")", ":", "if", "command", "in", "(", "TURN_ON", ",", "TURN_OFF", ")", ":", "self", ".", "_operation", "=", "command", "elif", "command", "in", "INV_SOURCES", ":", "self", ".", "_operation", "=", "SOURCE",...
Set lock on requests.
[ "Set", "lock", "on", "requests", "." ]
b8a10ace56e0a5cf858546041819c0e7ebca208f
https://github.com/pszafer/epson_projector/blob/b8a10ace56e0a5cf858546041819c0e7ebca208f/epson_projector/main.py#L58-L67
train
Set lock on requests.
pszafer/epson_projector
epson_projector/main.py
Projector.__unLock
def __unLock(self): """Unlock sending requests to projector.""" self._operation = False self._timer = 0 self._isLocked = False
python
def __unLock(self): """Unlock sending requests to projector.""" self._operation = False self._timer = 0 self._isLocked = False
[ "def", "__unLock", "(", "self", ")", ":", "self", ".", "_operation", "=", "False", "self", ".", "_timer", "=", "0", "self", ".", "_isLocked", "=", "False" ]
Unlock sending requests to projector.
[ "Unlock", "sending", "requests", "to", "projector", "." ]
b8a10ace56e0a5cf858546041819c0e7ebca208f
https://github.com/pszafer/epson_projector/blob/b8a10ace56e0a5cf858546041819c0e7ebca208f/epson_projector/main.py#L69-L73
train
Unlock sending requests to projector.
pszafer/epson_projector
epson_projector/main.py
Projector.__checkLock
def __checkLock(self): """ Lock checking. Check if there is lock pending and check if enough time passed so requests can be unlocked. """ if self._isLocked: if (time.time() - self._timer) > TIMEOUT_TIMES[self._operation]: self.__unLock() ...
python
def __checkLock(self): """ Lock checking. Check if there is lock pending and check if enough time passed so requests can be unlocked. """ if self._isLocked: if (time.time() - self._timer) > TIMEOUT_TIMES[self._operation]: self.__unLock() ...
[ "def", "__checkLock", "(", "self", ")", ":", "if", "self", ".", "_isLocked", ":", "if", "(", "time", ".", "time", "(", ")", "-", "self", ".", "_timer", ")", ">", "TIMEOUT_TIMES", "[", "self", ".", "_operation", "]", ":", "self", ".", "__unLock", "(...
Lock checking. Check if there is lock pending and check if enough time passed so requests can be unlocked.
[ "Lock", "checking", "." ]
b8a10ace56e0a5cf858546041819c0e7ebca208f
https://github.com/pszafer/epson_projector/blob/b8a10ace56e0a5cf858546041819c0e7ebca208f/epson_projector/main.py#L75-L87
train
Check if there is a lock pending and check if enough time has passed.
pszafer/epson_projector
epson_projector/main.py
Projector.get_property
async def get_property(self, command): """Get property state from device.""" _LOGGER.debug("Getting property %s", command) if self.__checkLock(): return BUSY timeout = self.__get_timeout(command) response = await self.send_request( timeout=timeout, ...
python
async def get_property(self, command): """Get property state from device.""" _LOGGER.debug("Getting property %s", command) if self.__checkLock(): return BUSY timeout = self.__get_timeout(command) response = await self.send_request( timeout=timeout, ...
[ "async", "def", "get_property", "(", "self", ",", "command", ")", ":", "_LOGGER", ".", "debug", "(", "\"Getting property %s\"", ",", "command", ")", "if", "self", ".", "__checkLock", "(", ")", ":", "return", "BUSY", "timeout", "=", "self", ".", "__get_time...
Get property state from device.
[ "Get", "property", "state", "from", "device", "." ]
b8a10ace56e0a5cf858546041819c0e7ebca208f
https://github.com/pszafer/epson_projector/blob/b8a10ace56e0a5cf858546041819c0e7ebca208f/epson_projector/main.py#L89-L104
train
Get property state from device.
pszafer/epson_projector
epson_projector/main.py
Projector.send_command
async def send_command(self, command): """Send command to Epson.""" _LOGGER.debug("Sending command to projector %s", command) if self.__checkLock(): return False self.__setLock(command) response = await self.send_request( timeout=self.__get_timeout(command...
python
async def send_command(self, command): """Send command to Epson.""" _LOGGER.debug("Sending command to projector %s", command) if self.__checkLock(): return False self.__setLock(command) response = await self.send_request( timeout=self.__get_timeout(command...
[ "async", "def", "send_command", "(", "self", ",", "command", ")", ":", "_LOGGER", ".", "debug", "(", "\"Sending command to projector %s\"", ",", "command", ")", "if", "self", ".", "__checkLock", "(", ")", ":", "return", "False", "self", ".", "__setLock", "("...
Send command to Epson.
[ "Send", "command", "to", "Epson", "." ]
b8a10ace56e0a5cf858546041819c0e7ebca208f
https://github.com/pszafer/epson_projector/blob/b8a10ace56e0a5cf858546041819c0e7ebca208f/epson_projector/main.py#L106-L117
train
Send a command to the Epson.
pszafer/epson_projector
epson_projector/main.py
Projector.send_request
async def send_request(self, params, timeout, type='json_query', command=False): """Send request to Epson.""" try: with async_timeout.timeout(timeout): url = '{url}{type}'.format( url=self._http_url, type=type...
python
async def send_request(self, params, timeout, type='json_query', command=False): """Send request to Epson.""" try: with async_timeout.timeout(timeout): url = '{url}{type}'.format( url=self._http_url, type=type...
[ "async", "def", "send_request", "(", "self", ",", "params", ",", "timeout", ",", "type", "=", "'json_query'", ",", "command", "=", "False", ")", ":", "try", ":", "with", "async_timeout", ".", "timeout", "(", "timeout", ")", ":", "url", "=", "'{url}{type}...
Send request to Epson.
[ "Send", "request", "to", "Epson", "." ]
b8a10ace56e0a5cf858546041819c0e7ebca208f
https://github.com/pszafer/epson_projector/blob/b8a10ace56e0a5cf858546041819c0e7ebca208f/epson_projector/main.py#L119-L141
train
Send request to Epson.
redhat-openstack/python-tripleo-helper
tripleohelper/provisioners/openstack/utils.py
remove_instances_by_prefix
def remove_instances_by_prefix(nova_api, prefix): """Remove all the instances on which their name start by a prefix.""" for server in nova_api.servers.list(): if server.name.startswith(prefix): LOG.info("Remove instance '%s'" % server.name) server.delete()
python
def remove_instances_by_prefix(nova_api, prefix): """Remove all the instances on which their name start by a prefix.""" for server in nova_api.servers.list(): if server.name.startswith(prefix): LOG.info("Remove instance '%s'" % server.name) server.delete()
[ "def", "remove_instances_by_prefix", "(", "nova_api", ",", "prefix", ")", ":", "for", "server", "in", "nova_api", ".", "servers", ".", "list", "(", ")", ":", "if", "server", ".", "name", ".", "startswith", "(", "prefix", ")", ":", "LOG", ".", "info", "...
Remove all the instances on which their name start by a prefix.
[ "Remove", "all", "the", "instances", "on", "which", "their", "name", "start", "by", "a", "prefix", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/provisioners/openstack/utils.py#L106-L111
train
Remove all the instances on which their name start by a prefix.
redhat-openstack/python-tripleo-helper
tripleohelper/ovb_shell.py
purge_existing_ovb
def purge_existing_ovb(nova_api, neutron): """Purge any trace of an existing OVB deployment. """ LOG.info('Cleaning up OVB environment from the tenant.') for server in nova_api.servers.list(): if server.name in ('bmc', 'undercloud'): server.delete() if server.name.startswith(...
python
def purge_existing_ovb(nova_api, neutron): """Purge any trace of an existing OVB deployment. """ LOG.info('Cleaning up OVB environment from the tenant.') for server in nova_api.servers.list(): if server.name in ('bmc', 'undercloud'): server.delete() if server.name.startswith(...
[ "def", "purge_existing_ovb", "(", "nova_api", ",", "neutron", ")", ":", "LOG", ".", "info", "(", "'Cleaning up OVB environment from the tenant.'", ")", "for", "server", "in", "nova_api", ".", "servers", ".", "list", "(", ")", ":", "if", "server", ".", "name", ...
Purge any trace of an existing OVB deployment.
[ "Purge", "any", "trace", "of", "an", "existing", "OVB", "deployment", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_shell.py#L39-L94
train
Purge any trace of an existing OVB deployment.
redhat-openstack/python-tripleo-helper
tripleohelper/ovb_shell.py
initialize_network
def initialize_network(neutron): """Initialize an OVB network called provision_bob. """ body_sample = { "network": { "name": 'provision_bob', "admin_state_up": True, } } netw = neutron.create_network(body=body_sample)['network'] body_create_subnet = { ...
python
def initialize_network(neutron): """Initialize an OVB network called provision_bob. """ body_sample = { "network": { "name": 'provision_bob', "admin_state_up": True, } } netw = neutron.create_network(body=body_sample)['network'] body_create_subnet = { ...
[ "def", "initialize_network", "(", "neutron", ")", ":", "body_sample", "=", "{", "\"network\"", ":", "{", "\"name\"", ":", "'provision_bob'", ",", "\"admin_state_up\"", ":", "True", ",", "}", "}", "netw", "=", "neutron", ".", "create_network", "(", "body", "=...
Initialize an OVB network called provision_bob.
[ "Initialize", "an", "OVB", "network", "called", "provision_bob", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_shell.py#L105-L131
train
Initialize an OVB network called provision_bob.
unt-libraries/pyuntl
pyuntl/dc_structure.py
description_director
def description_director(**kwargs): """Direct which class should be used based on the director qualifier. """ description_type = {'physical': DCFormat} qualifier = kwargs.get('qualifier') # Determine the type of element needed, based on the qualifier. element_class = description_type.get(qu...
python
def description_director(**kwargs): """Direct which class should be used based on the director qualifier. """ description_type = {'physical': DCFormat} qualifier = kwargs.get('qualifier') # Determine the type of element needed, based on the qualifier. element_class = description_type.get(qu...
[ "def", "description_director", "(", "*", "*", "kwargs", ")", ":", "description_type", "=", "{", "'physical'", ":", "DCFormat", "}", "qualifier", "=", "kwargs", ".", "get", "(", "'qualifier'", ")", "# Determine the type of element needed, based on the qualifier.", "ele...
Direct which class should be used based on the director qualifier.
[ "Direct", "which", "class", "should", "be", "used", "based", "on", "the", "director", "qualifier", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/dc_structure.py#L220-L233
train
Direct which class should be used based on the director qualifier.
unt-libraries/pyuntl
pyuntl/dc_structure.py
identifier_director
def identifier_director(**kwargs): """Direct how to handle the identifier element.""" ark = kwargs.get('ark', None) domain_name = kwargs.get('domain_name', None) # Set default scheme if it is None or is not supplied. scheme = kwargs.get('scheme') or 'http' qualifier = kwargs.get('qualifier', Non...
python
def identifier_director(**kwargs): """Direct how to handle the identifier element.""" ark = kwargs.get('ark', None) domain_name = kwargs.get('domain_name', None) # Set default scheme if it is None or is not supplied. scheme = kwargs.get('scheme') or 'http' qualifier = kwargs.get('qualifier', Non...
[ "def", "identifier_director", "(", "*", "*", "kwargs", ")", ":", "ark", "=", "kwargs", ".", "get", "(", "'ark'", ",", "None", ")", "domain_name", "=", "kwargs", ".", "get", "(", "'domain_name'", ",", "None", ")", "# Set default scheme if it is None or is not s...
Direct how to handle the identifier element.
[ "Direct", "how", "to", "handle", "the", "identifier", "element", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/dc_structure.py#L247-L270
train
Direct how to handle the identifier element.
unt-libraries/pyuntl
pyuntl/dc_structure.py
DCElement.add_child
def add_child(self, child): """This adds a child object to the current one. It will check the contained_children list to make sure that the object is allowable, and throw an exception if not. """ # Make sure the child exists before adding it. if child: # Appe...
python
def add_child(self, child): """This adds a child object to the current one. It will check the contained_children list to make sure that the object is allowable, and throw an exception if not. """ # Make sure the child exists before adding it. if child: # Appe...
[ "def", "add_child", "(", "self", ",", "child", ")", ":", "# Make sure the child exists before adding it.", "if", "child", ":", "# Append child if it is allowed to exist under the parent.", "if", "child", ".", "tag", "in", "self", ".", "contained_children", ":", "self", ...
This adds a child object to the current one. It will check the contained_children list to make sure that the object is allowable, and throw an exception if not.
[ "This", "adds", "a", "child", "object", "to", "the", "current", "one", ".", "It", "will", "check", "the", "contained_children", "list", "to", "make", "sure", "that", "the", "object", "is", "allowable", "and", "throw", "an", "exception", "if", "not", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/dc_structure.py#L66-L80
train
This method adds a child object to the current object. It will check that the object is not already in the list of contained children.
unt-libraries/pyuntl
pyuntl/dc_structure.py
DCElement.determine_vocab
def determine_vocab(self, qualifier): """Determine the vocab from the qualifier.""" vocab_value = VOCAB_INDEX.get(self.tag, None) if isinstance(vocab_value, dict): if qualifier is None: qualifier = 'None' # Find the value based on the qualifier. ...
python
def determine_vocab(self, qualifier): """Determine the vocab from the qualifier.""" vocab_value = VOCAB_INDEX.get(self.tag, None) if isinstance(vocab_value, dict): if qualifier is None: qualifier = 'None' # Find the value based on the qualifier. ...
[ "def", "determine_vocab", "(", "self", ",", "qualifier", ")", ":", "vocab_value", "=", "VOCAB_INDEX", ".", "get", "(", "self", ".", "tag", ",", "None", ")", "if", "isinstance", "(", "vocab_value", ",", "dict", ")", ":", "if", "qualifier", "is", "None", ...
Determine the vocab from the qualifier.
[ "Determine", "the", "vocab", "from", "the", "qualifier", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/dc_structure.py#L91-L102
train
Determine the vocab from the qualifier.
unt-libraries/pyuntl
pyuntl/dc_structure.py
DCElement.resolver
def resolver(self, vocab_data, attribute): """Pull the requested attribute based on the given vocabulary and content. """ term_list = vocab_data.get(self.content_vocab, []) # Loop through the terms from the vocabulary. for term_dict in term_list: # Match the n...
python
def resolver(self, vocab_data, attribute): """Pull the requested attribute based on the given vocabulary and content. """ term_list = vocab_data.get(self.content_vocab, []) # Loop through the terms from the vocabulary. for term_dict in term_list: # Match the n...
[ "def", "resolver", "(", "self", ",", "vocab_data", ",", "attribute", ")", ":", "term_list", "=", "vocab_data", ".", "get", "(", "self", ".", "content_vocab", ",", "[", "]", ")", "# Loop through the terms from the vocabulary.", "for", "term_dict", "in", "term_lis...
Pull the requested attribute based on the given vocabulary and content.
[ "Pull", "the", "requested", "attribute", "based", "on", "the", "given", "vocabulary", "and", "content", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/dc_structure.py#L104-L114
train
Pull the requested attribute based on the given vocabulary and content.
peterbe/gg
gg/builtins/rebase/gg_rebase.py
rebase
def rebase(config): """Rebase the current branch against origin/master""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out("You're already on the master branch.") active_branch_name = active_branch.name if repo.is_dirty(): error...
python
def rebase(config): """Rebase the current branch against origin/master""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out("You're already on the master branch.") active_branch_name = active_branch.name if repo.is_dirty(): error...
[ "def", "rebase", "(", "config", ")", ":", "repo", "=", "config", ".", "repo", "active_branch", "=", "repo", ".", "active_branch", "if", "active_branch", ".", "name", "==", "\"master\"", ":", "error_out", "(", "\"You're already on the master branch.\"", ")", "act...
Rebase the current branch against origin/master
[ "Rebase", "the", "current", "branch", "against", "origin", "/", "master" ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/rebase/gg_rebase.py#L8-L41
train
Rebase the current branch against origin
gofed/gofedlib
gofedlib/repository/gitlocalclient.py
GitLocalClient.branches
def branches(self): """Return a list of branches for given repository :return: [str] """ # get all remote branches refs = filter(lambda l: isinstance(l, git.RemoteReference), self.repo.references) # filter out HEAD branch refs = filter(lambda l: l.name != "origin/HEAD", refs) # filter out all branches ...
python
def branches(self): """Return a list of branches for given repository :return: [str] """ # get all remote branches refs = filter(lambda l: isinstance(l, git.RemoteReference), self.repo.references) # filter out HEAD branch refs = filter(lambda l: l.name != "origin/HEAD", refs) # filter out all branches ...
[ "def", "branches", "(", "self", ")", ":", "# get all remote branches", "refs", "=", "filter", "(", "lambda", "l", ":", "isinstance", "(", "l", ",", "git", ".", "RemoteReference", ")", ",", "self", ".", "repo", ".", "references", ")", "# filter out HEAD branc...
Return a list of branches for given repository :return: [str]
[ "Return", "a", "list", "of", "branches", "for", "given", "repository" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/gitlocalclient.py#L16-L31
train
Return a list of branches for given repository
gofed/gofedlib
gofedlib/repository/gitlocalclient.py
GitLocalClient._commitData
def _commitData(self, commit): """Get data from a commit object :param commit: commit object :type commit: git.objects.commit.Commit """ return { "hexsha": commit.hexsha, "adate": commit.authored_date, "cdate": commit.committed_date, "author": "%s <%s>" % (commit.author.name, commit.author.email...
python
def _commitData(self, commit): """Get data from a commit object :param commit: commit object :type commit: git.objects.commit.Commit """ return { "hexsha": commit.hexsha, "adate": commit.authored_date, "cdate": commit.committed_date, "author": "%s <%s>" % (commit.author.name, commit.author.email...
[ "def", "_commitData", "(", "self", ",", "commit", ")", ":", "return", "{", "\"hexsha\"", ":", "commit", ".", "hexsha", ",", "\"adate\"", ":", "commit", ".", "authored_date", ",", "\"cdate\"", ":", "commit", ".", "committed_date", ",", "\"author\"", ":", "\...
Get data from a commit object :param commit: commit object :type commit: git.objects.commit.Commit
[ "Get", "data", "from", "a", "commit", "object" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/gitlocalclient.py#L33-L45
train
Get data from a commit object
gofed/gofedlib
gofedlib/repository/gitlocalclient.py
GitLocalClient.commits
def commits(self, branch, since = 0, to = int(time.time()) + 86400): """For given branch return a list of commits. Each commit contains basic information about itself. :param branch: git branch :type branch: [str]{} :param since: minimal timestamp for commit's commit date :type since: int :param to: ma...
python
def commits(self, branch, since = 0, to = int(time.time()) + 86400): """For given branch return a list of commits. Each commit contains basic information about itself. :param branch: git branch :type branch: [str]{} :param since: minimal timestamp for commit's commit date :type since: int :param to: ma...
[ "def", "commits", "(", "self", ",", "branch", ",", "since", "=", "0", ",", "to", "=", "int", "(", "time", ".", "time", "(", ")", ")", "+", "86400", ")", ":", "# checkout the branch", "self", ".", "repo", ".", "create_head", "(", "branch", ",", "\"r...
For given branch return a list of commits. Each commit contains basic information about itself. :param branch: git branch :type branch: [str]{} :param since: minimal timestamp for commit's commit date :type since: int :param to: maximal timestamp for commit's commit date :type to: int
[ "For", "given", "branch", "return", "a", "list", "of", "commits", ".", "Each", "commit", "contains", "basic", "information", "about", "itself", "." ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/gitlocalclient.py#L48-L71
train
For given branch return a list of commits.
gofed/gofedlib
gofedlib/repository/gitlocalclient.py
GitLocalClient.commit
def commit(self, commit): """Get data for a given commit Raises KeyError if a commit is not found or not parsed. :param commit: repository commit :type commit: string """ try: return self._commitData(self.repo.commit(commit)) except (ValueError, KeyError, BadObject): if self._repo_info: raise...
python
def commit(self, commit): """Get data for a given commit Raises KeyError if a commit is not found or not parsed. :param commit: repository commit :type commit: string """ try: return self._commitData(self.repo.commit(commit)) except (ValueError, KeyError, BadObject): if self._repo_info: raise...
[ "def", "commit", "(", "self", ",", "commit", ")", ":", "try", ":", "return", "self", ".", "_commitData", "(", "self", ".", "repo", ".", "commit", "(", "commit", ")", ")", "except", "(", "ValueError", ",", "KeyError", ",", "BadObject", ")", ":", "if",...
Get data for a given commit Raises KeyError if a commit is not found or not parsed. :param commit: repository commit :type commit: string
[ "Get", "data", "for", "a", "given", "commit" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/gitlocalclient.py#L73-L87
train
Get data for a given commit.
grundprinzip/pyxplorer
pyxplorer/loader.py
Loader.check_separator
def check_separator(self, data): """ THis method evaluates a list of separators on the input data to check which one is correct. This is done by first splitting the input by newline and then checking if the split by separator is equal for each input row except the last that might...
python
def check_separator(self, data): """ THis method evaluates a list of separators on the input data to check which one is correct. This is done by first splitting the input by newline and then checking if the split by separator is equal for each input row except the last that might...
[ "def", "check_separator", "(", "self", ",", "data", ")", ":", "sep_list", "=", "[", "r'\\t'", ",", "r';'", ",", "r','", ",", "r'|'", ",", "r'\\s+'", "]", "data_copy", "=", "data", "for", "sep", "in", "sep_list", ":", "# Check if the count matches each line",...
THis method evaluates a list of separators on the input data to check which one is correct. This is done by first splitting the input by newline and then checking if the split by separator is equal for each input row except the last that might be incomplete due to the limited input data ...
[ "THis", "method", "evaluates", "a", "list", "of", "separators", "on", "the", "input", "data", "to", "check", "which", "one", "is", "correct", ".", "This", "is", "done", "by", "first", "splitting", "the", "input", "by", "newline", "and", "then", "checking",...
34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2
https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/loader.py#L67-L99
train
This method evaluates a list of separators on the input data and checks if the separator is correct.
grundprinzip/pyxplorer
pyxplorer/loader.py
Loader.head
def head(self, file_path): """ Onlye read the first packets that come, try to max out at 1024kb :return: up to 1024b of the first block of the file """ processor = lambda path, node, tail_only=True, append=False: self._handle_head( path, node) # Find items a...
python
def head(self, file_path): """ Onlye read the first packets that come, try to max out at 1024kb :return: up to 1024b of the first block of the file """ processor = lambda path, node, tail_only=True, append=False: self._handle_head( path, node) # Find items a...
[ "def", "head", "(", "self", ",", "file_path", ")", ":", "processor", "=", "lambda", "path", ",", "node", ",", "tail_only", "=", "True", ",", "append", "=", "False", ":", "self", ".", "_handle_head", "(", "path", ",", "node", ")", "# Find items and go", ...
Onlye read the first packets that come, try to max out at 1024kb :return: up to 1024b of the first block of the file
[ "Onlye", "read", "the", "first", "packets", "that", "come", "try", "to", "max", "out", "at", "1024kb" ]
34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2
https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/loader.py#L102-L116
train
Return the first item in the file that is read
gofed/gofedlib
gofedlib/distribution/clients/pkgdb/client.py
PkgDBClient.packageExists
def packageExists(self, package): """Check if the package already exists :param package: package name :type package: string """ url = "%s/packages" % self.base_url params = {"pattern": package} response = requests.get(url, params=params) if response.status_code != requests.codes.ok: return False ...
python
def packageExists(self, package): """Check if the package already exists :param package: package name :type package: string """ url = "%s/packages" % self.base_url params = {"pattern": package} response = requests.get(url, params=params) if response.status_code != requests.codes.ok: return False ...
[ "def", "packageExists", "(", "self", ",", "package", ")", ":", "url", "=", "\"%s/packages\"", "%", "self", ".", "base_url", "params", "=", "{", "\"pattern\"", ":", "package", "}", "response", "=", "requests", ".", "get", "(", "url", ",", "params", "=", ...
Check if the package already exists :param package: package name :type package: string
[ "Check", "if", "the", "package", "already", "exists" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/clients/pkgdb/client.py#L27-L39
train
Check if the package already exists in the database
gofed/gofedlib
gofedlib/distribution/clients/pkgdb/client.py
PkgDBClient.getGolangPackages
def getGolangPackages(self): """Get a list of all golang packages for all available branches """ packages = {} # get all packages url = "%s/packages" % self.base_url params = {"pattern": "golang-*", "limit": 200} response = requests.get(url, params=params) if response.status_code != requests.codes.ok:...
python
def getGolangPackages(self): """Get a list of all golang packages for all available branches """ packages = {} # get all packages url = "%s/packages" % self.base_url params = {"pattern": "golang-*", "limit": 200} response = requests.get(url, params=params) if response.status_code != requests.codes.ok:...
[ "def", "getGolangPackages", "(", "self", ")", ":", "packages", "=", "{", "}", "# get all packages", "url", "=", "\"%s/packages\"", "%", "self", ".", "base_url", "params", "=", "{", "\"pattern\"", ":", "\"golang-*\"", ",", "\"limit\"", ":", "200", "}", "respo...
Get a list of all golang packages for all available branches
[ "Get", "a", "list", "of", "all", "golang", "packages", "for", "all", "available", "branches" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/clients/pkgdb/client.py#L98-L144
train
Get a list of all golang packages for all available branches
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/pkey.py
PKey._read_private_key_file
def _read_private_key_file(self, tag, filename, password=None): """ Read an SSH2-format private key file, looking for a string of the type ``"BEGIN xxx PRIVATE KEY"`` for some ``xxx``, base64-decode the text we find, and return it as a string. If the private key is encrypted and ...
python
def _read_private_key_file(self, tag, filename, password=None): """ Read an SSH2-format private key file, looking for a string of the type ``"BEGIN xxx PRIVATE KEY"`` for some ``xxx``, base64-decode the text we find, and return it as a string. If the private key is encrypted and ...
[ "def", "_read_private_key_file", "(", "self", ",", "tag", ",", "filename", ",", "password", "=", "None", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "data", "=", "self", ".", "_read_private_key", "(", "tag", ",", "f", ...
Read an SSH2-format private key file, looking for a string of the type ``"BEGIN xxx PRIVATE KEY"`` for some ``xxx``, base64-decode the text we find, and return it as a string. If the private key is encrypted and ``password`` is not ``None``, the given password will be used to decrypt th...
[ "Read", "an", "SSH2", "-", "format", "private", "key", "file", "looking", "for", "a", "string", "of", "the", "type", "BEGIN", "xxx", "PRIVATE", "KEY", "for", "some", "xxx", "base64", "-", "decode", "the", "text", "we", "find", "and", "return", "it", "a...
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/pkey.py#L234-L256
train
Read a private key file and return it as a string.
eventifyio/eventify
eventify/drivers/crossbar.py
Component.emit_event
async def emit_event(self, event): """ Publish an event back to crossbar :param event: Event object """ self.log.debug("publishing event on %s", self.publish_topic) if self.config.extra['config']['pub_options']['retain']: try: await persist_eve...
python
async def emit_event(self, event): """ Publish an event back to crossbar :param event: Event object """ self.log.debug("publishing event on %s", self.publish_topic) if self.config.extra['config']['pub_options']['retain']: try: await persist_eve...
[ "async", "def", "emit_event", "(", "self", ",", "event", ")", ":", "self", ".", "log", ".", "debug", "(", "\"publishing event on %s\"", ",", "self", ".", "publish_topic", ")", "if", "self", ".", "config", ".", "extra", "[", "'config'", "]", "[", "'pub_op...
Publish an event back to crossbar :param event: Event object
[ "Publish", "an", "event", "back", "to", "crossbar", ":", "param", "event", ":", "Event", "object" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/crossbar.py#L34-L61
train
Publish an event back to crossbar.
eventifyio/eventify
eventify/drivers/crossbar.py
Component.onClose
def onClose(self, wasClean): """ Disconnect when connection to message broker is lost """ self.log.error('lost connection to crossbar on session %' + str(self.session_id)) for task in asyncio.Task.all_tasks(): task.cancel() asyncio.get_event_loop().sto...
python
def onClose(self, wasClean): """ Disconnect when connection to message broker is lost """ self.log.error('lost connection to crossbar on session %' + str(self.session_id)) for task in asyncio.Task.all_tasks(): task.cancel() asyncio.get_event_loop().sto...
[ "def", "onClose", "(", "self", ",", "wasClean", ")", ":", "self", ".", "log", ".", "error", "(", "'lost connection to crossbar on session %'", "+", "str", "(", "self", ".", "session_id", ")", ")", "for", "task", "in", "asyncio", ".", "Task", ".", "all_task...
Disconnect when connection to message broker is lost
[ "Disconnect", "when", "connection", "to", "message", "broker", "is", "lost" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/crossbar.py#L63-L71
train
Disconnect when connection to message broker is lost
eventifyio/eventify
eventify/drivers/crossbar.py
Component.onUserError
def onUserError(self, fail, message): """ Handle user errors """ self.log.error(fail) self.log.error(message)
python
def onUserError(self, fail, message): """ Handle user errors """ self.log.error(fail) self.log.error(message)
[ "def", "onUserError", "(", "self", ",", "fail", ",", "message", ")", ":", "self", ".", "log", ".", "error", "(", "fail", ")", "self", ".", "log", ".", "error", "(", "message", ")" ]
Handle user errors
[ "Handle", "user", "errors" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/crossbar.py#L86-L91
train
Handle user errors
eventifyio/eventify
eventify/drivers/crossbar.py
Component.show_sessions
async def show_sessions(self): """ Returns an object with a lists of the session IDs for all sessions currently attached to the realm http://crossbar.io/docs/Session-Metaevents-and-Procedures/ """ res = await self.call("wamp.session.list") for session_id in res: ...
python
async def show_sessions(self): """ Returns an object with a lists of the session IDs for all sessions currently attached to the realm http://crossbar.io/docs/Session-Metaevents-and-Procedures/ """ res = await self.call("wamp.session.list") for session_id in res: ...
[ "async", "def", "show_sessions", "(", "self", ")", ":", "res", "=", "await", "self", ".", "call", "(", "\"wamp.session.list\"", ")", "for", "session_id", "in", "res", ":", "session", "=", "await", "self", ".", "call", "(", "\"wamp.session.get\"", ",", "ses...
Returns an object with a lists of the session IDs for all sessions currently attached to the realm http://crossbar.io/docs/Session-Metaevents-and-Procedures/
[ "Returns", "an", "object", "with", "a", "lists", "of", "the", "session", "IDs", "for", "all", "sessions", "currently", "attached", "to", "the", "realm" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/crossbar.py#L138-L148
train
Show the currently attached sessions.
eventifyio/eventify
eventify/drivers/crossbar.py
Component.lookup_session
async def lookup_session(self, topic_name): """ Attempts to find the session id for a given topic http://crossbar.io/docs/Subscription-Meta-Events-and-Procedures/ """ res = await self.call("wamp.subscription.lookup", topic_name) self.log.info(res)
python
async def lookup_session(self, topic_name): """ Attempts to find the session id for a given topic http://crossbar.io/docs/Subscription-Meta-Events-and-Procedures/ """ res = await self.call("wamp.subscription.lookup", topic_name) self.log.info(res)
[ "async", "def", "lookup_session", "(", "self", ",", "topic_name", ")", ":", "res", "=", "await", "self", ".", "call", "(", "\"wamp.subscription.lookup\"", ",", "topic_name", ")", "self", ".", "log", ".", "info", "(", "res", ")" ]
Attempts to find the session id for a given topic http://crossbar.io/docs/Subscription-Meta-Events-and-Procedures/
[ "Attempts", "to", "find", "the", "session", "id", "for", "a", "given", "topic" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/crossbar.py#L159-L166
train
Attempts to find the session id for a given topic
eventifyio/eventify
eventify/drivers/crossbar.py
Service.setup_runner
def setup_runner(self): """ Setup instance of runner var """ runner = ApplicationRunner( url=self.config['transport_host'], realm=u'realm1', extra={ 'config': self.config, 'handlers': self.handlers, } ...
python
def setup_runner(self): """ Setup instance of runner var """ runner = ApplicationRunner( url=self.config['transport_host'], realm=u'realm1', extra={ 'config': self.config, 'handlers': self.handlers, } ...
[ "def", "setup_runner", "(", "self", ")", ":", "runner", "=", "ApplicationRunner", "(", "url", "=", "self", ".", "config", "[", "'transport_host'", "]", ",", "realm", "=", "u'realm1'", ",", "extra", "=", "{", "'config'", ":", "self", ".", "config", ",", ...
Setup instance of runner var
[ "Setup", "instance", "of", "runner", "var" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/crossbar.py#L173-L185
train
Setup instance of runner
eventifyio/eventify
eventify/drivers/crossbar.py
Service.reconnect
def reconnect(self): """ Handle reconnect logic if connection to crossbar is lost """ connect_attempt = 0 max_retries = self.config['max_reconnect_retries'] logging.info('attempting to reconnect to crossbar') runner = self.setup_runner() while True...
python
def reconnect(self): """ Handle reconnect logic if connection to crossbar is lost """ connect_attempt = 0 max_retries = self.config['max_reconnect_retries'] logging.info('attempting to reconnect to crossbar') runner = self.setup_runner() while True...
[ "def", "reconnect", "(", "self", ")", ":", "connect_attempt", "=", "0", "max_retries", "=", "self", ".", "config", "[", "'max_reconnect_retries'", "]", "logging", ".", "info", "(", "'attempting to reconnect to crossbar'", ")", "runner", "=", "self", ".", "setup_...
Handle reconnect logic if connection to crossbar is lost
[ "Handle", "reconnect", "logic", "if", "connection", "to", "crossbar", "is", "lost" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/crossbar.py#L199-L235
train
Handle reconnect logic
eventifyio/eventify
eventify/drivers/crossbar.py
Service.start
def start(self, start_loop=True): """ Start a producer/consumer service """ txaio.start_logging() runner = self.setup_runner() if start_loop: try: runner.run(Component) except EventifyHandlerInitializationFailed as initError: ...
python
def start(self, start_loop=True): """ Start a producer/consumer service """ txaio.start_logging() runner = self.setup_runner() if start_loop: try: runner.run(Component) except EventifyHandlerInitializationFailed as initError: ...
[ "def", "start", "(", "self", ",", "start_loop", "=", "True", ")", ":", "txaio", ".", "start_logging", "(", ")", "runner", "=", "self", ".", "setup_runner", "(", ")", "if", "start_loop", ":", "try", ":", "runner", ".", "run", "(", "Component", ")", "e...
Start a producer/consumer service
[ "Start", "a", "producer", "/", "consumer", "service" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/crossbar.py#L237-L264
train
Start a producer or consumer service.
brutus/boozelib
boozelib/boozelib.py
calculate_bw
def calculate_bw(age, weight, height, sex): """Return the amount of water (in liter) in a persons body""" if sex: # female return 0.203 - (0.07 * age) + (0.1069 * height) + (0.2466 * weight) else: # male return 2.447 - (0.09516 * age) + (0.1074 * height) + (0.3362 * weight)
python
def calculate_bw(age, weight, height, sex): """Return the amount of water (in liter) in a persons body""" if sex: # female return 0.203 - (0.07 * age) + (0.1069 * height) + (0.2466 * weight) else: # male return 2.447 - (0.09516 * age) + (0.1074 * height) + (0.3362 * weight)
[ "def", "calculate_bw", "(", "age", ",", "weight", ",", "height", ",", "sex", ")", ":", "if", "sex", ":", "# female", "return", "0.203", "-", "(", "0.07", "*", "age", ")", "+", "(", "0.1069", "*", "height", ")", "+", "(", "0.2466", "*", "weight", ...
Return the amount of water (in liter) in a persons body
[ "Return", "the", "amount", "of", "water", "(", "in", "liter", ")", "in", "a", "persons", "body" ]
02a4aa03ac54b411ef5ac2be85eee0a9af1e60df
https://github.com/brutus/boozelib/blob/02a4aa03ac54b411ef5ac2be85eee0a9af1e60df/boozelib/boozelib.py#L149-L154
train
Calculate the amount of water in a persons body
brutus/boozelib
boozelib/boozelib.py
promille_to_gramm
def promille_to_gramm(bac, age, weight, height, sex): """Return the amount of alcohol (in gramm) for a person with the given body stats and blood alcohol content (per mill) """ bw = calculate_bw(age, weight, height, sex) return (bac * (PB * bw)) / W
python
def promille_to_gramm(bac, age, weight, height, sex): """Return the amount of alcohol (in gramm) for a person with the given body stats and blood alcohol content (per mill) """ bw = calculate_bw(age, weight, height, sex) return (bac * (PB * bw)) / W
[ "def", "promille_to_gramm", "(", "bac", ",", "age", ",", "weight", ",", "height", ",", "sex", ")", ":", "bw", "=", "calculate_bw", "(", "age", ",", "weight", ",", "height", ",", "sex", ")", "return", "(", "bac", "*", "(", "PB", "*", "bw", ")", ")...
Return the amount of alcohol (in gramm) for a person with the given body stats and blood alcohol content (per mill)
[ "Return", "the", "amount", "of", "alcohol", "(", "in", "gramm", ")", "for", "a", "person", "with", "the", "given", "body", "stats", "and", "blood", "alcohol", "content", "(", "per", "mill", ")" ]
02a4aa03ac54b411ef5ac2be85eee0a9af1e60df
https://github.com/brutus/boozelib/blob/02a4aa03ac54b411ef5ac2be85eee0a9af1e60df/boozelib/boozelib.py#L156-L161
train
Calculate the promille of a person with the given body stats and blood alcohol content.
brutus/boozelib
boozelib/boozelib.py
gramm_to_promille
def gramm_to_promille(gramm, age, weight, height, sex): """Return the blood alcohol content (per mill) for a person with the given body stats and amount of alcohol (in gramm) in blood """ bw = calculate_bw(age, weight, height, sex) return (gramm * W) / (PB * bw)
python
def gramm_to_promille(gramm, age, weight, height, sex): """Return the blood alcohol content (per mill) for a person with the given body stats and amount of alcohol (in gramm) in blood """ bw = calculate_bw(age, weight, height, sex) return (gramm * W) / (PB * bw)
[ "def", "gramm_to_promille", "(", "gramm", ",", "age", ",", "weight", ",", "height", ",", "sex", ")", ":", "bw", "=", "calculate_bw", "(", "age", ",", "weight", ",", "height", ",", "sex", ")", "return", "(", "gramm", "*", "W", ")", "/", "(", "PB", ...
Return the blood alcohol content (per mill) for a person with the given body stats and amount of alcohol (in gramm) in blood
[ "Return", "the", "blood", "alcohol", "content", "(", "per", "mill", ")", "for", "a", "person", "with", "the", "given", "body", "stats", "and", "amount", "of", "alcohol", "(", "in", "gramm", ")", "in", "blood" ]
02a4aa03ac54b411ef5ac2be85eee0a9af1e60df
https://github.com/brutus/boozelib/blob/02a4aa03ac54b411ef5ac2be85eee0a9af1e60df/boozelib/boozelib.py#L163-L168
train
Return the promille content for a person with the given body stats and amount of alcohol content in gramm.
brutus/boozelib
boozelib/boozelib.py
get_bac
def get_bac(age, weight, height, sex, volume, percent): """Returns the *Blood Alcohol Content* (raise) for a person (described by the given attributes) after a drink containing *volume* ml of alcohol with the given *percent* (vol/vol). """ return gramm_to_promille( calculate_alcohol(volume, percent)...
python
def get_bac(age, weight, height, sex, volume, percent): """Returns the *Blood Alcohol Content* (raise) for a person (described by the given attributes) after a drink containing *volume* ml of alcohol with the given *percent* (vol/vol). """ return gramm_to_promille( calculate_alcohol(volume, percent)...
[ "def", "get_bac", "(", "age", ",", "weight", ",", "height", ",", "sex", ",", "volume", ",", "percent", ")", ":", "return", "gramm_to_promille", "(", "calculate_alcohol", "(", "volume", ",", "percent", ")", ",", "age", ",", "weight", ",", "height", ",", ...
Returns the *Blood Alcohol Content* (raise) for a person (described by the given attributes) after a drink containing *volume* ml of alcohol with the given *percent* (vol/vol).
[ "Returns", "the", "*", "Blood", "Alcohol", "Content", "*", "(", "raise", ")", "for", "a", "person", "(", "described", "by", "the", "given", "attributes", ")", "after", "a", "drink", "containing", "*", "volume", "*", "ml", "of", "alcohol", "with", "the", ...
02a4aa03ac54b411ef5ac2be85eee0a9af1e60df
https://github.com/brutus/boozelib/blob/02a4aa03ac54b411ef5ac2be85eee0a9af1e60df/boozelib/boozelib.py#L171-L179
train
Returns the Promille of the Alcohol Content after a drink with the given attributes.
brutus/boozelib
boozelib/boozelib.py
get_degradation
def get_degradation(age, weight, height, sex, minutes): """Returns the *alcohol degradation* (per mill) of a person with the given stats in the given number of *minutes*. """ return gramm_to_promille( calculate_degradation(weight, minutes), age, weight, height, sex )
python
def get_degradation(age, weight, height, sex, minutes): """Returns the *alcohol degradation* (per mill) of a person with the given stats in the given number of *minutes*. """ return gramm_to_promille( calculate_degradation(weight, minutes), age, weight, height, sex )
[ "def", "get_degradation", "(", "age", ",", "weight", ",", "height", ",", "sex", ",", "minutes", ")", ":", "return", "gramm_to_promille", "(", "calculate_degradation", "(", "weight", ",", "minutes", ")", ",", "age", ",", "weight", ",", "height", ",", "sex",...
Returns the *alcohol degradation* (per mill) of a person with the given stats in the given number of *minutes*.
[ "Returns", "the", "*", "alcohol", "degradation", "*", "(", "per", "mill", ")", "of", "a", "person", "with", "the", "given", "stats", "in", "the", "given", "number", "of", "*", "minutes", "*", "." ]
02a4aa03ac54b411ef5ac2be85eee0a9af1e60df
https://github.com/brutus/boozelib/blob/02a4aa03ac54b411ef5ac2be85eee0a9af1e60df/boozelib/boozelib.py#L182-L189
train
Returns the degradation of a person with the given age weight height sex and minutes.
Nic30/hwtGraph
hwtGraph/elk/fromHwt/reduceUselessAssignments.py
reduceUselessAssignments
def reduceUselessAssignments(root: LNode): """ Remove assignments if it is only a direct connection and can be replaced with direct link """ for n in root.children: if n.children: reduceUselessAssignments(n) do_update = False for n in root.children: if isinstance(n.o...
python
def reduceUselessAssignments(root: LNode): """ Remove assignments if it is only a direct connection and can be replaced with direct link """ for n in root.children: if n.children: reduceUselessAssignments(n) do_update = False for n in root.children: if isinstance(n.o...
[ "def", "reduceUselessAssignments", "(", "root", ":", "LNode", ")", ":", "for", "n", "in", "root", ".", "children", ":", "if", "n", ".", "children", ":", "reduceUselessAssignments", "(", "n", ")", "do_update", "=", "False", "for", "n", "in", "root", ".", ...
Remove assignments if it is only a direct connection and can be replaced with direct link
[ "Remove", "assignments", "if", "it", "is", "only", "a", "direct", "connection", "and", "can", "be", "replaced", "with", "direct", "link" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/reduceUselessAssignments.py#L7-L55
train
Remove assignments if it is only a direct connection and can be replaced with direct link
gofed/gofedlib
gofedlib/go/apidiff/apidiff.py
GoApiDiff._constructTypeQualifiedName
def _constructTypeQualifiedName(self, type, full=False): """ For given type construct its full qualified name. AnonymousField = [ "*" ] TypeName . TypeName = identifier | QualifiedIdent . QualifiedIdent = PackageName "." identifier . """ t = type["type"] if t == TYPE_IDENT: return type["def"] eli...
python
def _constructTypeQualifiedName(self, type, full=False): """ For given type construct its full qualified name. AnonymousField = [ "*" ] TypeName . TypeName = identifier | QualifiedIdent . QualifiedIdent = PackageName "." identifier . """ t = type["type"] if t == TYPE_IDENT: return type["def"] eli...
[ "def", "_constructTypeQualifiedName", "(", "self", ",", "type", ",", "full", "=", "False", ")", ":", "t", "=", "type", "[", "\"type\"", "]", "if", "t", "==", "TYPE_IDENT", ":", "return", "type", "[", "\"def\"", "]", "elif", "t", "==", "TYPE_POINTER", "...
For given type construct its full qualified name. AnonymousField = [ "*" ] TypeName . TypeName = identifier | QualifiedIdent . QualifiedIdent = PackageName "." identifier .
[ "For", "given", "type", "construct", "its", "full", "qualified", "name", "." ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/apidiff/apidiff.py#L231-L250
train
constructs a qualified name for given type
gebn/wood
setup.py
_read_file
def _read_file(name, encoding='utf-8') -> str: """ Read the contents of a file. :param name: The name of the file in the current directory. :param encoding: The encoding of the file; defaults to utf-8. :return: The contents of the file. """ with open(name, encoding=encoding) as f: r...
python
def _read_file(name, encoding='utf-8') -> str: """ Read the contents of a file. :param name: The name of the file in the current directory. :param encoding: The encoding of the file; defaults to utf-8. :return: The contents of the file. """ with open(name, encoding=encoding) as f: r...
[ "def", "_read_file", "(", "name", ",", "encoding", "=", "'utf-8'", ")", "->", "str", ":", "with", "open", "(", "name", ",", "encoding", "=", "encoding", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")" ]
Read the contents of a file. :param name: The name of the file in the current directory. :param encoding: The encoding of the file; defaults to utf-8. :return: The contents of the file.
[ "Read", "the", "contents", "of", "a", "file", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/setup.py#L5-L14
train
Read the contents of a file.
255BITS/hyperchamber
examples/shared/resize_image_patch.py
crop_to_bounding_box
def crop_to_bounding_box(image, offset_height, offset_width, target_height, target_width, dynamic_shape=False): """Crops an image to a specified bounding box. This op cuts a rectangular part out of `image`. The top-left corner of the returned image is at `offset_height, offset_width` in ...
python
def crop_to_bounding_box(image, offset_height, offset_width, target_height, target_width, dynamic_shape=False): """Crops an image to a specified bounding box. This op cuts a rectangular part out of `image`. The top-left corner of the returned image is at `offset_height, offset_width` in ...
[ "def", "crop_to_bounding_box", "(", "image", ",", "offset_height", ",", "offset_width", ",", "target_height", ",", "target_width", ",", "dynamic_shape", "=", "False", ")", ":", "image", "=", "ops", ".", "convert_to_tensor", "(", "image", ",", "name", "=", "'im...
Crops an image to a specified bounding box. This op cuts a rectangular part out of `image`. The top-left corner of the returned image is at `offset_height, offset_width` in `image`, and its lower-right corner is at `offset_height + target_height, offset_width + target_width`. Args: image: 3-D tensor wit...
[ "Crops", "an", "image", "to", "a", "specified", "bounding", "box", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/resize_image_patch.py#L14-L61
train
Crops an image to a specified bounding box.
255BITS/hyperchamber
examples/shared/resize_image_patch.py
pad_to_bounding_box
def pad_to_bounding_box(image, offset_height, offset_width, target_height, target_width, dynamic_shape=False): """Pad `image` with zeros to the specified `height` and `width`. Adds `offset_height` rows of zeros on top, `offset_width` columns of zeros on the left, and then pads the image o...
python
def pad_to_bounding_box(image, offset_height, offset_width, target_height, target_width, dynamic_shape=False): """Pad `image` with zeros to the specified `height` and `width`. Adds `offset_height` rows of zeros on top, `offset_width` columns of zeros on the left, and then pads the image o...
[ "def", "pad_to_bounding_box", "(", "image", ",", "offset_height", ",", "offset_width", ",", "target_height", ",", "target_width", ",", "dynamic_shape", "=", "False", ")", ":", "image", "=", "ops", ".", "convert_to_tensor", "(", "image", ",", "name", "=", "'ima...
Pad `image` with zeros to the specified `height` and `width`. Adds `offset_height` rows of zeros on top, `offset_width` columns of zeros on the left, and then pads the image on the bottom and right with zeros until it has dimensions `target_height`, `target_width`. This op does nothing if `offset_*` is zero a...
[ "Pad", "image", "with", "zeros", "to", "the", "specified", "height", "and", "width", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/resize_image_patch.py#L66-L127
train
Pads an image with zeros to the specified height and width.
255BITS/hyperchamber
examples/shared/resize_image_patch.py
resize_image_with_crop_or_pad
def resize_image_with_crop_or_pad(image, target_height, target_width, dynamic_shape=False): """Crops and/or pads an image to a target width and height. Resizes an image to a target width and height by either centrally cropping the image or padding it evenly with zeros. If `wi...
python
def resize_image_with_crop_or_pad(image, target_height, target_width, dynamic_shape=False): """Crops and/or pads an image to a target width and height. Resizes an image to a target width and height by either centrally cropping the image or padding it evenly with zeros. If `wi...
[ "def", "resize_image_with_crop_or_pad", "(", "image", ",", "target_height", ",", "target_width", ",", "dynamic_shape", "=", "False", ")", ":", "image", "=", "ops", ".", "convert_to_tensor", "(", "image", ",", "name", "=", "'image'", ")", "_Check3DImage", "(", ...
Crops and/or pads an image to a target width and height. Resizes an image to a target width and height by either centrally cropping the image or padding it evenly with zeros. If `width` or `height` is greater than the specified `target_width` or `target_height` respectively, this op centrally crops along that...
[ "Crops", "and", "/", "or", "pads", "an", "image", "to", "a", "target", "width", "and", "height", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/resize_image_patch.py#L132-L201
train
Resizes an image to a target height and width by either centrally cropping the image or padding it evenly with zeros.
255BITS/hyperchamber
examples/shared/resize_image_patch.py
_ImageDimensions
def _ImageDimensions(images, dynamic_shape=False): """Returns the dimensions of an image tensor. Args: images: 4-D Tensor of shape [batch, height, width, channels] dynamic_shape: Whether the input image has undertermined shape. If set to `True`, shape information will be retrieved at run time. Default...
python
def _ImageDimensions(images, dynamic_shape=False): """Returns the dimensions of an image tensor. Args: images: 4-D Tensor of shape [batch, height, width, channels] dynamic_shape: Whether the input image has undertermined shape. If set to `True`, shape information will be retrieved at run time. Default...
[ "def", "_ImageDimensions", "(", "images", ",", "dynamic_shape", "=", "False", ")", ":", "# A simple abstraction to provide names for each dimension. This abstraction", "# should make it simpler to switch dimensions in the future (e.g. if we ever", "# want to switch height and width.)", "if...
Returns the dimensions of an image tensor. Args: images: 4-D Tensor of shape [batch, height, width, channels] dynamic_shape: Whether the input image has undertermined shape. If set to `True`, shape information will be retrieved at run time. Default to `False`. Returns: list of integers [bat...
[ "Returns", "the", "dimensions", "of", "an", "image", "tensor", ".", "Args", ":", "images", ":", "4", "-", "D", "Tensor", "of", "shape", "[", "batch", "height", "width", "channels", "]", "dynamic_shape", ":", "Whether", "the", "input", "image", "has", "un...
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/resize_image_patch.py#L206-L223
train
Returns the dimensions of an image tensor.
255BITS/hyperchamber
examples/shared/resize_image_patch.py
_Check3DImage
def _Check3DImage(image, require_static=True): """Assert that we are working with properly shaped image. Args: image: 3-D Tensor of shape [height, width, channels] require_static: If `True`, requires that all dimensions of `image` are known and non-zero. Raises: ValueError: if image.shape is no...
python
def _Check3DImage(image, require_static=True): """Assert that we are working with properly shaped image. Args: image: 3-D Tensor of shape [height, width, channels] require_static: If `True`, requires that all dimensions of `image` are known and non-zero. Raises: ValueError: if image.shape is no...
[ "def", "_Check3DImage", "(", "image", ",", "require_static", "=", "True", ")", ":", "try", ":", "image_shape", "=", "image", ".", "get_shape", "(", ")", ".", "with_rank", "(", "3", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "'\\'image\\'...
Assert that we are working with properly shaped image. Args: image: 3-D Tensor of shape [height, width, channels] require_static: If `True`, requires that all dimensions of `image` are known and non-zero. Raises: ValueError: if image.shape is not a [3] vector.
[ "Assert", "that", "we", "are", "working", "with", "properly", "shaped", "image", ".", "Args", ":", "image", ":", "3", "-", "D", "Tensor", "of", "shape", "[", "height", "width", "channels", "]", "require_static", ":", "If", "True", "requires", "that", "al...
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/resize_image_patch.py#L228-L246
train
Checks that we are working with properly shaped image.
unt-libraries/pyuntl
pyuntl/quality.py
determine_completeness
def determine_completeness(py_untl): """Take a Python untl and calculate the completeness. Completeness is based on this: metadata_quality.rst documentation. Returns a float 0.0 - 1.0. """ # Default values for the completeness dictionary. completeness_dict = { 'title': {'present': False...
python
def determine_completeness(py_untl): """Take a Python untl and calculate the completeness. Completeness is based on this: metadata_quality.rst documentation. Returns a float 0.0 - 1.0. """ # Default values for the completeness dictionary. completeness_dict = { 'title': {'present': False...
[ "def", "determine_completeness", "(", "py_untl", ")", ":", "# Default values for the completeness dictionary.", "completeness_dict", "=", "{", "'title'", ":", "{", "'present'", ":", "False", ",", "'weight'", ":", "10", ",", "}", ",", "'description'", ":", "{", "'p...
Take a Python untl and calculate the completeness. Completeness is based on this: metadata_quality.rst documentation. Returns a float 0.0 - 1.0.
[ "Take", "a", "Python", "untl", "and", "calculate", "the", "completeness", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/quality.py#L27-L73
train
Determines the completeness of a Python untl.
Robpol86/Flask-JIRA-Helper
flask_jira.py
read_config
def read_config(config, prefix): """Return a jira.client.JIRA.__init__() compatible dictionary from data in the Flask config. Generate a dictionary compatible with jira.client.JIRA.__init__() keyword arguments from data in the Flask application's configuration values relevant to JIRA. If both basic and OAu...
python
def read_config(config, prefix): """Return a jira.client.JIRA.__init__() compatible dictionary from data in the Flask config. Generate a dictionary compatible with jira.client.JIRA.__init__() keyword arguments from data in the Flask application's configuration values relevant to JIRA. If both basic and OAu...
[ "def", "read_config", "(", "config", ",", "prefix", ")", ":", "# Get all relevant config values from Flask application.", "suffixes", "=", "(", "'SERVER'", ",", "'USER'", ",", "'PASSWORD'", ",", "'TOKEN'", ",", "'SECRET'", ",", "'CONSUMER'", ",", "'CERT'", ")", "c...
Return a jira.client.JIRA.__init__() compatible dictionary from data in the Flask config. Generate a dictionary compatible with jira.client.JIRA.__init__() keyword arguments from data in the Flask application's configuration values relevant to JIRA. If both basic and OAuth settings are specified, OAuth aut...
[ "Return", "a", "jira", ".", "client", ".", "JIRA", ".", "__init__", "()", "compatible", "dictionary", "from", "data", "in", "the", "Flask", "config", "." ]
646d32e6fccee8ab7d55e6401b9fbcb9cf52dc7a
https://github.com/Robpol86/Flask-JIRA-Helper/blob/646d32e6fccee8ab7d55e6401b9fbcb9cf52dc7a/flask_jira.py#L19-L59
train
Read JIRA configuration values from Flask application config dictionary.
Robpol86/Flask-JIRA-Helper
flask_jira.py
JIRA.init_app
def init_app(self, app, config_prefix=None): """Actual method to read JIRA settings from app configuration and initialize the JIRA instance. Positional arguments: app -- Flask application instance. Keyword arguments: config_prefix -- Prefix used in config key names in the Flask...
python
def init_app(self, app, config_prefix=None): """Actual method to read JIRA settings from app configuration and initialize the JIRA instance. Positional arguments: app -- Flask application instance. Keyword arguments: config_prefix -- Prefix used in config key names in the Flask...
[ "def", "init_app", "(", "self", ",", "app", ",", "config_prefix", "=", "None", ")", ":", "# Restore self.kill_session().", "self", ".", "kill_session", "=", "self", ".", "original_kill_session", "# Normalize the prefix and add this instance to app.extensions.", "config_pref...
Actual method to read JIRA settings from app configuration and initialize the JIRA instance. Positional arguments: app -- Flask application instance. Keyword arguments: config_prefix -- Prefix used in config key names in the Flask app's configuration. Useful for applications which ...
[ "Actual", "method", "to", "read", "JIRA", "settings", "from", "app", "configuration", "and", "initialize", "the", "JIRA", "instance", "." ]
646d32e6fccee8ab7d55e6401b9fbcb9cf52dc7a
https://github.com/Robpol86/Flask-JIRA-Helper/blob/646d32e6fccee8ab7d55e6401b9fbcb9cf52dc7a/flask_jira.py#L114-L149
train
Initializes the JIRA instance with the given application instance.
gebn/wood
wood/util.py
zip_dict
def zip_dict(a: Dict[str, A], b: Dict[str, B]) \ -> Dict[str, Tuple[Optional[A], Optional[B]]]: """ Combine the values within two dictionaries by key. :param a: The first dictionary. :param b: The second dictionary. :return: A dictionary containing all keys that appear in the union of a and...
python
def zip_dict(a: Dict[str, A], b: Dict[str, B]) \ -> Dict[str, Tuple[Optional[A], Optional[B]]]: """ Combine the values within two dictionaries by key. :param a: The first dictionary. :param b: The second dictionary. :return: A dictionary containing all keys that appear in the union of a and...
[ "def", "zip_dict", "(", "a", ":", "Dict", "[", "str", ",", "A", "]", ",", "b", ":", "Dict", "[", "str", ",", "B", "]", ")", "->", "Dict", "[", "str", ",", "Tuple", "[", "Optional", "[", "A", "]", ",", "Optional", "[", "B", "]", "]", "]", ...
Combine the values within two dictionaries by key. :param a: The first dictionary. :param b: The second dictionary. :return: A dictionary containing all keys that appear in the union of a and b. Values are pairs where the first part is a's value for the key, and right second part ...
[ "Combine", "the", "values", "within", "two", "dictionaries", "by", "key", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/util.py#L11-L22
train
Combine the values within two dictionaries by key.
gebn/wood
wood/util.py
chunk
def chunk(iterable: Iterable[A], n: int) \ -> Iterable[more_itertools.more.peekable]: """ Produce an iterable of interables of a maximum length from a (presumably longer) iterable. This is useful when only so many elements can be processed at once, such as an API that limits to n things per requ...
python
def chunk(iterable: Iterable[A], n: int) \ -> Iterable[more_itertools.more.peekable]: """ Produce an iterable of interables of a maximum length from a (presumably longer) iterable. This is useful when only so many elements can be processed at once, such as an API that limits to n things per requ...
[ "def", "chunk", "(", "iterable", ":", "Iterable", "[", "A", "]", ",", "n", ":", "int", ")", "->", "Iterable", "[", "more_itertools", ".", "more", ".", "peekable", "]", ":", "iterator", "=", "iter", "(", "iterable", ")", "while", "True", ":", "chunk_"...
Produce an iterable of interables of a maximum length from a (presumably longer) iterable. This is useful when only so many elements can be processed at once, such as an API that limits to n things per request. :param iterable: The iterable to chunk into iterables of size up to n. :param n: The maximum...
[ "Produce", "an", "iterable", "of", "interables", "of", "a", "maximum", "length", "from", "a", "(", "presumably", "longer", ")", "iterable", ".", "This", "is", "useful", "when", "only", "so", "many", "elements", "can", "be", "processed", "at", "once", "such...
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/util.py#L25-L44
train
Takes an iterable of n elements from a presumably longer iterable and returns an iterable of n elements.