repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
xtrementl/focus
focus/parser/parser.py
SettingParser._expect_token
def _expect_token(self, expected): """ Compares the next token in the stream to the specified token. `expected` Expected token string to match. * Raises a ``ParseError`` exception if token doesn't match `expected`. """ item = self._lex...
python
def _expect_token(self, expected): """ Compares the next token in the stream to the specified token. `expected` Expected token string to match. * Raises a ``ParseError`` exception if token doesn't match `expected`. """ item = self._lex...
[ "def", "_expect_token", "(", "self", ",", "expected", ")", ":", "item", "=", "self", ".", "_lexer", ".", "get_token", "(", ")", "if", "not", "item", ":", "raise", "ParseError", "(", "u'Unexpected end of file'", ")", "else", ":", "line_no", ",", "token", ...
Compares the next token in the stream to the specified token. `expected` Expected token string to match. * Raises a ``ParseError`` exception if token doesn't match `expected`.
[ "Compares", "the", "next", "token", "in", "the", "stream", "to", "the", "specified", "token", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L232-L254
xtrementl/focus
focus/parser/parser.py
SettingParser._expect_empty
def _expect_empty(self): """ Checks if the token stream is empty. * Raises a ``ParseError` exception if a token is found. """ item = self._lexer.get_token() if item: line_no, token = item raise ParseError(u"Unexpected token '{0}' on line {1}" ...
python
def _expect_empty(self): """ Checks if the token stream is empty. * Raises a ``ParseError` exception if a token is found. """ item = self._lexer.get_token() if item: line_no, token = item raise ParseError(u"Unexpected token '{0}' on line {1}" ...
[ "def", "_expect_empty", "(", "self", ")", ":", "item", "=", "self", ".", "_lexer", ".", "get_token", "(", ")", "if", "item", ":", "line_no", ",", "token", "=", "item", "raise", "ParseError", "(", "u\"Unexpected token '{0}' on line {1}\"", ".", "format", "(",...
Checks if the token stream is empty. * Raises a ``ParseError` exception if a token is found.
[ "Checks", "if", "the", "token", "stream", "is", "empty", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L256-L266
xtrementl/focus
focus/parser/parser.py
SettingParser._rule_container
def _rule_container(self): """ Parses the production rule:: container : NAME '{' (option | block)* '}' EOF Returns tuple (type_name, options_list, blocks_list). """ type_name = self._get_token(self.RE_NAME) self._expect_token('{') # consume elem...
python
def _rule_container(self): """ Parses the production rule:: container : NAME '{' (option | block)* '}' EOF Returns tuple (type_name, options_list, blocks_list). """ type_name = self._get_token(self.RE_NAME) self._expect_token('{') # consume elem...
[ "def", "_rule_container", "(", "self", ")", ":", "type_name", "=", "self", ".", "_get_token", "(", "self", ".", "RE_NAME", ")", "self", ".", "_expect_token", "(", "'{'", ")", "# consume elements if available", "options", "=", "[", "]", "blocks", "=", "[", ...
Parses the production rule:: container : NAME '{' (option | block)* '}' EOF Returns tuple (type_name, options_list, blocks_list).
[ "Parses", "the", "production", "rule", "::", "container", ":", "NAME", "{", "(", "option", "|", "block", ")", "*", "}", "EOF" ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L268-L310
xtrementl/focus
focus/parser/parser.py
SettingParser._rule_option
def _rule_option(self): """ Parses the production rule:: option : NAME value ';' Returns list (name, value_list). """ name = self._get_token(self.RE_NAME) value = self._rule_value() self._expect_token(';') return [name, value]
python
def _rule_option(self): """ Parses the production rule:: option : NAME value ';' Returns list (name, value_list). """ name = self._get_token(self.RE_NAME) value = self._rule_value() self._expect_token(';') return [name, value]
[ "def", "_rule_option", "(", "self", ")", ":", "name", "=", "self", ".", "_get_token", "(", "self", ".", "RE_NAME", ")", "value", "=", "self", ".", "_rule_value", "(", ")", "self", ".", "_expect_token", "(", "';'", ")", "return", "[", "name", ",", "va...
Parses the production rule:: option : NAME value ';' Returns list (name, value_list).
[ "Parses", "the", "production", "rule", "::", "option", ":", "NAME", "value", ";" ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L312-L322
xtrementl/focus
focus/parser/parser.py
SettingParser._rule_value
def _rule_value(self): """ Parses the production rule:: value : TERM (',' TERM)* Returns list of string terms. """ terms = [self._get_token()] # consume additional terms if available while self._lookahead_token() == ',': self._get_to...
python
def _rule_value(self): """ Parses the production rule:: value : TERM (',' TERM)* Returns list of string terms. """ terms = [self._get_token()] # consume additional terms if available while self._lookahead_token() == ',': self._get_to...
[ "def", "_rule_value", "(", "self", ")", ":", "terms", "=", "[", "self", ".", "_get_token", "(", ")", "]", "# consume additional terms if available", "while", "self", ".", "_lookahead_token", "(", ")", "==", "','", ":", "self", ".", "_get_token", "(", ")", ...
Parses the production rule:: value : TERM (',' TERM)* Returns list of string terms.
[ "Parses", "the", "production", "rule", "::", "value", ":", "TERM", "(", "TERM", ")", "*" ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L324-L338
xtrementl/focus
focus/parser/parser.py
SettingParser._rule_block
def _rule_block(self): """ Parses the production rule:: block : NAME '{' option* '}' Returns tuple (name, options_list). """ name = self._get_token(self.RE_NAME) self._expect_token('{') # consume additional options if available options =...
python
def _rule_block(self): """ Parses the production rule:: block : NAME '{' option* '}' Returns tuple (name, options_list). """ name = self._get_token(self.RE_NAME) self._expect_token('{') # consume additional options if available options =...
[ "def", "_rule_block", "(", "self", ")", ":", "name", "=", "self", ".", "_get_token", "(", "self", ".", "RE_NAME", ")", "self", ".", "_expect_token", "(", "'{'", ")", "# consume additional options if available", "options", "=", "[", "]", "while", "self", ".",...
Parses the production rule:: block : NAME '{' option* '}' Returns tuple (name, options_list).
[ "Parses", "the", "production", "rule", "::", "block", ":", "NAME", "{", "option", "*", "}" ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L340-L356
xtrementl/focus
focus/parser/parser.py
SettingParser._parse
def _parse(self): """ Performs parsing process against token stream to generate the internal abstract syntax tree (AST) for general purpose use. * Raises a ``ParseError`` exception upon failure. """ try: # parse token stream into abstract syntax tree (AST...
python
def _parse(self): """ Performs parsing process against token stream to generate the internal abstract syntax tree (AST) for general purpose use. * Raises a ``ParseError`` exception upon failure. """ try: # parse token stream into abstract syntax tree (AST...
[ "def", "_parse", "(", "self", ")", ":", "try", ":", "# parse token stream into abstract syntax tree (AST)", "self", ".", "_ast", "=", "self", ".", "_rule_container", "(", ")", "except", "ParseError", ":", "raise", "except", "Exception", "as", "exc", ":", "raise"...
Performs parsing process against token stream to generate the internal abstract syntax tree (AST) for general purpose use. * Raises a ``ParseError`` exception upon failure.
[ "Performs", "parsing", "process", "against", "token", "stream", "to", "generate", "the", "internal", "abstract", "syntax", "tree", "(", "AST", ")", "for", "general", "purpose", "use", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L358-L372
xtrementl/focus
focus/parser/parser.py
SettingParser.readstream
def readstream(self, stream): """ Reads the specified stream and parses the token elements generated from tokenizing the input data. `stream` ``File``-like object. Returns boolean. """ self._reset() try: # tokenize i...
python
def readstream(self, stream): """ Reads the specified stream and parses the token elements generated from tokenizing the input data. `stream` ``File``-like object. Returns boolean. """ self._reset() try: # tokenize i...
[ "def", "readstream", "(", "self", ",", "stream", ")", ":", "self", ".", "_reset", "(", ")", "try", ":", "# tokenize input stream", "self", ".", "_lexer", "=", "SettingLexer", "(", ")", "self", ".", "_lexer", ".", "readstream", "(", "stream", ")", "# pars...
Reads the specified stream and parses the token elements generated from tokenizing the input data. `stream` ``File``-like object. Returns boolean.
[ "Reads", "the", "specified", "stream", "and", "parses", "the", "token", "elements", "generated", "from", "tokenizing", "the", "input", "data", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L393-L416
xtrementl/focus
focus/parser/parser.py
SettingParser.write
def write(self, filename, header=None): """ Writes the AST as a configuration file. `filename` Filename to save configuration file to. `header` Header string to use for the file. Returns boolean. """ origfile = self._file...
python
def write(self, filename, header=None): """ Writes the AST as a configuration file. `filename` Filename to save configuration file to. `header` Header string to use for the file. Returns boolean. """ origfile = self._file...
[ "def", "write", "(", "self", ",", "filename", ",", "header", "=", "None", ")", ":", "origfile", "=", "self", ".", "_filename", "try", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "_file", ":", "self", ".", "writestream", "(", "_file",...
Writes the AST as a configuration file. `filename` Filename to save configuration file to. `header` Header string to use for the file. Returns boolean.
[ "Writes", "the", "AST", "as", "a", "configuration", "file", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L418-L439
xtrementl/focus
focus/parser/parser.py
SettingParser.add_option
def add_option(self, block, name, *values): """ Adds an option to the AST, either as a non-block option or for an existing block. `block` Block name. Set to ``None`` for non-block option. `name` Option name. `*values` ...
python
def add_option(self, block, name, *values): """ Adds an option to the AST, either as a non-block option or for an existing block. `block` Block name. Set to ``None`` for non-block option. `name` Option name. `*values` ...
[ "def", "add_option", "(", "self", ",", "block", ",", "name", ",", "*", "values", ")", ":", "if", "not", "self", ".", "RE_NAME", ".", "match", "(", "name", ")", ":", "raise", "ValueError", "(", "u\"Invalid option name '{0}'\"", ".", "format", "(", "common...
Adds an option to the AST, either as a non-block option or for an existing block. `block` Block name. Set to ``None`` for non-block option. `name` Option name. `*values` String values for the option. * Raises a...
[ "Adds", "an", "option", "to", "the", "AST", "either", "as", "a", "non", "-", "block", "option", "or", "for", "an", "existing", "block", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L509-L547
xtrementl/focus
focus/parser/parser.py
SettingParser.remove_option
def remove_option(self, block, name): """ Removes first matching option that exists from the AST. `block` Block name. Set to ``None`` for non-block option. `name` Option name to remove. * Raises a ``ValueError`` exception if `name` and/or `bl...
python
def remove_option(self, block, name): """ Removes first matching option that exists from the AST. `block` Block name. Set to ``None`` for non-block option. `name` Option name to remove. * Raises a ``ValueError`` exception if `name` and/or `bl...
[ "def", "remove_option", "(", "self", ",", "block", ",", "name", ")", ":", "if", "block", ":", "# block doesn't exist", "if", "not", "self", ".", "_ast", "or", "not", "block", "in", "self", ".", "_block_map", ":", "raise", "ValueError", "(", "u\"Block '{0}'...
Removes first matching option that exists from the AST. `block` Block name. Set to ``None`` for non-block option. `name` Option name to remove. * Raises a ``ValueError`` exception if `name` and/or `block` haven't been added.
[ "Removes", "first", "matching", "option", "that", "exists", "from", "the", "AST", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L549-L597
xtrementl/focus
focus/parser/parser.py
SettingParser.add_block
def add_block(self, name): """ Adds a new block to the AST. `name` Block name. * Raises a ``ValueError`` exception if `name` is invalid or an existing block name matches value provided for `name`. """ if not self.RE_NAME.match(name): ...
python
def add_block(self, name): """ Adds a new block to the AST. `name` Block name. * Raises a ``ValueError`` exception if `name` is invalid or an existing block name matches value provided for `name`. """ if not self.RE_NAME.match(name): ...
[ "def", "add_block", "(", "self", ",", "name", ")", ":", "if", "not", "self", ".", "RE_NAME", ".", "match", "(", "name", ")", ":", "raise", "ValueError", "(", "u\"Invalid block name '{0}'\"", ".", "format", "(", "common", ".", "from_utf8", "(", "name", ")...
Adds a new block to the AST. `name` Block name. * Raises a ``ValueError`` exception if `name` is invalid or an existing block name matches value provided for `name`.
[ "Adds", "a", "new", "block", "to", "the", "AST", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L599-L621
xtrementl/focus
focus/parser/parser.py
SettingParser.remove_block
def remove_block(self, name): """ Removes an existing block from the AST. `name` Block name. * Raises a ``ValueError`` exception if `name` hasn't been added. """ if not self._ast or not name in self._block_map: raise ValueError(u"Block '...
python
def remove_block(self, name): """ Removes an existing block from the AST. `name` Block name. * Raises a ``ValueError`` exception if `name` hasn't been added. """ if not self._ast or not name in self._block_map: raise ValueError(u"Block '...
[ "def", "remove_block", "(", "self", ",", "name", ")", ":", "if", "not", "self", ".", "_ast", "or", "not", "name", "in", "self", ".", "_block_map", ":", "raise", "ValueError", "(", "u\"Block '{0}' does not exist\"", ".", "format", "(", "common", ".", "from_...
Removes an existing block from the AST. `name` Block name. * Raises a ``ValueError`` exception if `name` hasn't been added.
[ "Removes", "an", "existing", "block", "from", "the", "AST", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L623-L640
tschaume/ccsgp_get_started
ccsgp_get_started/examples/gp_ccX.py
gp_ccX
def gp_ccX(): """fit experimental data""" inDir, outDir = getWorkDirs() data, alldata = OrderedDict(), None for infile in os.listdir(inDir): # get key and import data key = os.path.splitext(infile)[0].replace('_', '/') data_import = np.loadtxt(open(os.path.join(inDir, infile), 'r...
python
def gp_ccX(): """fit experimental data""" inDir, outDir = getWorkDirs() data, alldata = OrderedDict(), None for infile in os.listdir(inDir): # get key and import data key = os.path.splitext(infile)[0].replace('_', '/') data_import = np.loadtxt(open(os.path.join(inDir, infile), 'r...
[ "def", "gp_ccX", "(", ")", ":", "inDir", ",", "outDir", "=", "getWorkDirs", "(", ")", "data", ",", "alldata", "=", "OrderedDict", "(", ")", ",", "None", "for", "infile", "in", "os", ".", "listdir", "(", "inDir", ")", ":", "# get key and import data", "...
fit experimental data
[ "fit", "experimental", "data" ]
train
https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/gp_ccX.py#L19-L92
fedora-infra/fmn.lib
fmn/lib/models.py
init
def init(db_url, alembic_ini=None, debug=False, create=False): """ Create the tables in the database using the information from the url obtained. :arg db_url, URL used to connect to the database. The URL contains information with regards to the database engine, the host to connect to, the u...
python
def init(db_url, alembic_ini=None, debug=False, create=False): """ Create the tables in the database using the information from the url obtained. :arg db_url, URL used to connect to the database. The URL contains information with regards to the database engine, the host to connect to, the u...
[ "def", "init", "(", "db_url", ",", "alembic_ini", "=", "None", ",", "debug", "=", "False", ",", "create", "=", "False", ")", ":", "engine", "=", "create_engine", "(", "db_url", ",", "echo", "=", "debug", ")", "if", "create", ":", "BASE", ".", "metada...
Create the tables in the database using the information from the url obtained. :arg db_url, URL used to connect to the database. The URL contains information with regards to the database engine, the host to connect to, the user and password and the database name. ie: <engine>://<user>...
[ "Create", "the", "tables", "in", "the", "database", "using", "the", "information", "from", "the", "url", "obtained", "." ]
train
https://github.com/fedora-infra/fmn.lib/blob/3120725556153d07c1809530f0fadcf250439110/fmn/lib/models.py#L69-L104
fedora-infra/fmn.lib
fmn/lib/models.py
hash_producer
def hash_producer(*args, **kwargs): """ Returns a random hash for a confirmation secret. """ return hashlib.md5(six.text_type(uuid.uuid4()).encode('utf-8')).hexdigest()
python
def hash_producer(*args, **kwargs): """ Returns a random hash for a confirmation secret. """ return hashlib.md5(six.text_type(uuid.uuid4()).encode('utf-8')).hexdigest()
[ "def", "hash_producer", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "hashlib", ".", "md5", "(", "six", ".", "text_type", "(", "uuid", ".", "uuid4", "(", ")", ")", ".", "encode", "(", "'utf-8'", ")", ")", ".", "hexdigest", "(", ...
Returns a random hash for a confirmation secret.
[ "Returns", "a", "random", "hash", "for", "a", "confirmation", "secret", "." ]
train
https://github.com/fedora-infra/fmn.lib/blob/3120725556153d07c1809530f0fadcf250439110/fmn/lib/models.py#L724-L726
fedora-infra/fmn.lib
fmn/lib/models.py
Rule.validate_code_path
def validate_code_path(valid_paths, code_path, **kw): """ Raise an exception if code_path is not one of our whitelisted valid_paths. """ root, name = code_path.split(':', 1) if name not in valid_paths[root]: raise ValueError("%r is not a valid code_path" % code_path)
python
def validate_code_path(valid_paths, code_path, **kw): """ Raise an exception if code_path is not one of our whitelisted valid_paths. """ root, name = code_path.split(':', 1) if name not in valid_paths[root]: raise ValueError("%r is not a valid code_path" % code_path)
[ "def", "validate_code_path", "(", "valid_paths", ",", "code_path", ",", "*", "*", "kw", ")", ":", "root", ",", "name", "=", "code_path", ".", "split", "(", "':'", ",", "1", ")", "if", "name", "not", "in", "valid_paths", "[", "root", "]", ":", "raise"...
Raise an exception if code_path is not one of our whitelisted valid_paths.
[ "Raise", "an", "exception", "if", "code_path", "is", "not", "one", "of", "our", "whitelisted", "valid_paths", "." ]
train
https://github.com/fedora-infra/fmn.lib/blob/3120725556153d07c1809530f0fadcf250439110/fmn/lib/models.py#L281-L288
veltzer/pydmt
pydmt/utils/python.py
hlp_source_under
def hlp_source_under(folder): """ this function finds all the python packages under a folder and write the 'packages' and 'package_dir' entries for a python setup.py script """ # walk the folder and find the __init__.py entries for packages. packages = [] package_dir = dict() for roo...
python
def hlp_source_under(folder): """ this function finds all the python packages under a folder and write the 'packages' and 'package_dir' entries for a python setup.py script """ # walk the folder and find the __init__.py entries for packages. packages = [] package_dir = dict() for roo...
[ "def", "hlp_source_under", "(", "folder", ")", ":", "# walk the folder and find the __init__.py entries for packages.", "packages", "=", "[", "]", "package_dir", "=", "dict", "(", ")", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "fold...
this function finds all the python packages under a folder and write the 'packages' and 'package_dir' entries for a python setup.py script
[ "this", "function", "finds", "all", "the", "python", "packages", "under", "a", "folder", "and", "write", "the", "packages", "and", "package_dir", "entries", "for", "a", "python", "setup", ".", "py", "script" ]
train
https://github.com/veltzer/pydmt/blob/11d3db7ea079756c1e4137d3dd8a2cabbcc98bf7/pydmt/utils/python.py#L6-L24
seryl/Python-Cotendo
cotendo/cotendohelper.py
CotendoDNS.show
def show(self): """This could use some love, it's currently here as reference""" for entry in self._entries: print "{'%s': %s, 'records': %s}" % ( entry._record_type, entry.host, entry.records) print
python
def show(self): """This could use some love, it's currently here as reference""" for entry in self._entries: print "{'%s': %s, 'records': %s}" % ( entry._record_type, entry.host, entry.records) print
[ "def", "show", "(", "self", ")", ":", "for", "entry", "in", "self", ".", "_entries", ":", "print", "\"{'%s': %s, 'records': %s}\"", "%", "(", "entry", ".", "_record_type", ",", "entry", ".", "host", ",", "entry", ".", "records", ")", "print" ]
This could use some love, it's currently here as reference
[ "This", "could", "use", "some", "love", "it", "s", "currently", "here", "as", "reference" ]
train
https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/cotendohelper.py#L53-L58
seryl/Python-Cotendo
cotendo/cotendohelper.py
CotendoDNS.add_record
def add_record(self, record): """Add or update a given DNS record""" rec = self.get_record(record._record_type, record.host) if rec: rec = record for i,r in enumerate(self._entries): if r._record_type == record._record_type \ and r....
python
def add_record(self, record): """Add or update a given DNS record""" rec = self.get_record(record._record_type, record.host) if rec: rec = record for i,r in enumerate(self._entries): if r._record_type == record._record_type \ and r....
[ "def", "add_record", "(", "self", ",", "record", ")", ":", "rec", "=", "self", ".", "get_record", "(", "record", ".", "_record_type", ",", "record", ".", "host", ")", "if", "rec", ":", "rec", "=", "record", "for", "i", ",", "r", "in", "enumerate", ...
Add or update a given DNS record
[ "Add", "or", "update", "a", "given", "DNS", "record" ]
train
https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/cotendohelper.py#L60-L72
seryl/Python-Cotendo
cotendo/cotendohelper.py
CotendoDNS.diff_record
def diff_record(self, record): """Return the removed and added diffs""" rec = self.get_record(record._record_type, record.host) if rec is not None and record is not None: return {'removed': tuple(set(rec.results) - set(record.results)), 'added': tuple(set(record.r...
python
def diff_record(self, record): """Return the removed and added diffs""" rec = self.get_record(record._record_type, record.host) if rec is not None and record is not None: return {'removed': tuple(set(rec.results) - set(record.results)), 'added': tuple(set(record.r...
[ "def", "diff_record", "(", "self", ",", "record", ")", ":", "rec", "=", "self", ".", "get_record", "(", "record", ".", "_record_type", ",", "record", ".", "host", ")", "if", "rec", "is", "not", "None", "and", "record", "is", "not", "None", ":", "retu...
Return the removed and added diffs
[ "Return", "the", "removed", "and", "added", "diffs" ]
train
https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/cotendohelper.py#L74-L81
seryl/Python-Cotendo
cotendo/cotendohelper.py
CotendoDNS.get_record
def get_record(self, dns_record_type, host): """Fetch a DNS record""" record_list = self._entries for record in record_list: if record._record_type == dns_record_type \ and record.host == host: return record return False
python
def get_record(self, dns_record_type, host): """Fetch a DNS record""" record_list = self._entries for record in record_list: if record._record_type == dns_record_type \ and record.host == host: return record return False
[ "def", "get_record", "(", "self", ",", "dns_record_type", ",", "host", ")", ":", "record_list", "=", "self", ".", "_entries", "for", "record", "in", "record_list", ":", "if", "record", ".", "_record_type", "==", "dns_record_type", "and", "record", ".", "host...
Fetch a DNS record
[ "Fetch", "a", "DNS", "record" ]
train
https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/cotendohelper.py#L83-L90
seryl/Python-Cotendo
cotendo/cotendohelper.py
CotendoDNS.del_record
def del_record(self, dns_record_type, host): """Remove a DNS record""" rec = self.get_record(dns_record_type, host) if rec: self._entries = list(set(self._entries) - set([rec])) return True
python
def del_record(self, dns_record_type, host): """Remove a DNS record""" rec = self.get_record(dns_record_type, host) if rec: self._entries = list(set(self._entries) - set([rec])) return True
[ "def", "del_record", "(", "self", ",", "dns_record_type", ",", "host", ")", ":", "rec", "=", "self", ".", "get_record", "(", "dns_record_type", ",", "host", ")", "if", "rec", ":", "self", ".", "_entries", "=", "list", "(", "set", "(", "self", ".", "_...
Remove a DNS record
[ "Remove", "a", "DNS", "record" ]
train
https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/cotendohelper.py#L92-L97
seryl/Python-Cotendo
cotendo/cotendohelper.py
CotendoDNS.CreateRecord
def CreateRecord(record_type, host, results): """ Create a record of type (record_type) and fill it with the given dict of results """ record_class = dns_tag_lookup[record_type] record = etree.Element("a") record.set("host", host) for params in results: ...
python
def CreateRecord(record_type, host, results): """ Create a record of type (record_type) and fill it with the given dict of results """ record_class = dns_tag_lookup[record_type] record = etree.Element("a") record.set("host", host) for params in results: ...
[ "def", "CreateRecord", "(", "record_type", ",", "host", ",", "results", ")", ":", "record_class", "=", "dns_tag_lookup", "[", "record_type", "]", "record", "=", "etree", ".", "Element", "(", "\"a\"", ")", "record", ".", "set", "(", "\"host\"", ",", "host",...
Create a record of type (record_type) and fill it with the given dict of results
[ "Create", "a", "record", "of", "type", "(", "record_type", ")", "and", "fill", "it", "with", "the", "given", "dict", "of", "results" ]
train
https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/cotendohelper.py#L124-L138
seryl/Python-Cotendo
cotendo/cotendohelper.py
CotendoDNS.config
def config(self): """Create the finalized configuration""" root = etree.Element("xml") resource_records = etree.SubElement(root, "resource_records") # Append SOA and NS records resource_records.append(SOARecord()._etree) resource_records.append(NSRecord()._etree) ...
python
def config(self): """Create the finalized configuration""" root = etree.Element("xml") resource_records = etree.SubElement(root, "resource_records") # Append SOA and NS records resource_records.append(SOARecord()._etree) resource_records.append(NSRecord()._etree) ...
[ "def", "config", "(", "self", ")", ":", "root", "=", "etree", ".", "Element", "(", "\"xml\"", ")", "resource_records", "=", "etree", ".", "SubElement", "(", "root", ",", "\"resource_records\"", ")", "# Append SOA and NS records", "resource_records", ".", "append...
Create the finalized configuration
[ "Create", "the", "finalized", "configuration" ]
train
https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/cotendohelper.py#L141-L155
vietjtnguyen/nut
nut/relay.py
parsePortSpec
def parsePortSpec(spec, separator='-'): ''' Parses a port specification in two forms into the same form. In the first form the specification is just an integer. In this case a tuple is returned containing the same integer twice. In the second form the specification is two numbers separated by a hy...
python
def parsePortSpec(spec, separator='-'): ''' Parses a port specification in two forms into the same form. In the first form the specification is just an integer. In this case a tuple is returned containing the same integer twice. In the second form the specification is two numbers separated by a hy...
[ "def", "parsePortSpec", "(", "spec", ",", "separator", "=", "'-'", ")", ":", "x", "=", "list", "(", "map", "(", "lambda", "x", ":", "x", ".", "strip", "(", ")", ",", "spec", ".", "split", "(", "separator", ")", ")", ")", "return", "tuple", "(", ...
Parses a port specification in two forms into the same form. In the first form the specification is just an integer. In this case a tuple is returned containing the same integer twice. In the second form the specification is two numbers separated by a hyphen ('-' by default, specifiable with :param se...
[ "Parses", "a", "port", "specification", "in", "two", "forms", "into", "the", "same", "form", "." ]
train
https://github.com/vietjtnguyen/nut/blob/3b9c272ebc6d858c790e43d2fc507885d8029d36/nut/relay.py#L831-L851
vietjtnguyen/nut
nut/relay.py
UdpRelay._createSocket
def _createSocket(self, port): ''' Creates a UDP socket bound to any interface (empty string host address) but to the specified port. ''' self._logger.info( 'Setting up UDP socket to listen to port {:}'.format(port)) sock = socket.socket(socket.AF_INET, socket...
python
def _createSocket(self, port): ''' Creates a UDP socket bound to any interface (empty string host address) but to the specified port. ''' self._logger.info( 'Setting up UDP socket to listen to port {:}'.format(port)) sock = socket.socket(socket.AF_INET, socket...
[ "def", "_createSocket", "(", "self", ",", "port", ")", ":", "self", ".", "_logger", ".", "info", "(", "'Setting up UDP socket to listen to port {:}'", ".", "format", "(", "port", ")", ")", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ...
Creates a UDP socket bound to any interface (empty string host address) but to the specified port.
[ "Creates", "a", "UDP", "socket", "bound", "to", "any", "interface", "(", "empty", "string", "host", "address", ")", "but", "to", "the", "specified", "port", "." ]
train
https://github.com/vietjtnguyen/nut/blob/3b9c272ebc6d858c790e43d2fc507885d8029d36/nut/relay.py#L205-L227
vietjtnguyen/nut
nut/relay.py
TcpRelay._handleReadableSocket
def _handleReadableSocket(self, src_socket): ''' :returns: :data:`python:True` if the connect has been disconnected and :data:`python:False` if the connection is still alive and everything was processed normally ''' msg = src_socket.recv(self._max_mess...
python
def _handleReadableSocket(self, src_socket): ''' :returns: :data:`python:True` if the connect has been disconnected and :data:`python:False` if the connection is still alive and everything was processed normally ''' msg = src_socket.recv(self._max_mess...
[ "def", "_handleReadableSocket", "(", "self", ",", "src_socket", ")", ":", "msg", "=", "src_socket", ".", "recv", "(", "self", ".", "_max_message_size", ")", "return", "self", ".", "_handleMessage", "(", "src_socket", ",", "msg", ")" ]
:returns: :data:`python:True` if the connect has been disconnected and :data:`python:False` if the connection is still alive and everything was processed normally
[ ":", "returns", ":", ":", "data", ":", "python", ":", "True", "if", "the", "connect", "has", "been", "disconnected", "and", ":", "data", ":", "python", ":", "False", "if", "the", "connection", "is", "still", "alive", "and", "everything", "was", "processe...
train
https://github.com/vietjtnguyen/nut/blob/3b9c272ebc6d858c790e43d2fc507885d8029d36/nut/relay.py#L471-L478
vietjtnguyen/nut
nut/relay.py
TcpRelay._handleMessage
def _handleMessage(self, src_socket, msg): ''' :returns: :data:`python:True` if the connect has been disconnected and :data:`python:False` if the connection is still alive and everything was processed normally ''' self._logger.debug('Message received: ...
python
def _handleMessage(self, src_socket, msg): ''' :returns: :data:`python:True` if the connect has been disconnected and :data:`python:False` if the connection is still alive and everything was processed normally ''' self._logger.debug('Message received: ...
[ "def", "_handleMessage", "(", "self", ",", "src_socket", ",", "msg", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'Message received: {!r}'", ".", "format", "(", "msg", ")", ")", "# Check where the message came from and determine where it's going", "if", "sr...
:returns: :data:`python:True` if the connect has been disconnected and :data:`python:False` if the connection is still alive and everything was processed normally
[ ":", "returns", ":", ":", "data", ":", "python", ":", "True", "if", "the", "connect", "has", "been", "disconnected", "and", ":", "data", ":", "python", ":", "False", "if", "the", "connection", "is", "still", "alive", "and", "everything", "was", "processe...
train
https://github.com/vietjtnguyen/nut/blob/3b9c272ebc6d858c790e43d2fc507885d8029d36/nut/relay.py#L480-L527
vietjtnguyen/nut
nut/relay.py
Dump.dump
def dump(self, msg): ''' Dumps the provided message to this dump. ''' msg_size = len(msg) # We start a new batch if the resulting batch file is larger than the # max batch file size. However, if the current batch file size is zero # then that means the message al...
python
def dump(self, msg): ''' Dumps the provided message to this dump. ''' msg_size = len(msg) # We start a new batch if the resulting batch file is larger than the # max batch file size. However, if the current batch file size is zero # then that means the message al...
[ "def", "dump", "(", "self", ",", "msg", ")", ":", "msg_size", "=", "len", "(", "msg", ")", "# We start a new batch if the resulting batch file is larger than the", "# max batch file size. However, if the current batch file size is zero", "# then that means the message alone is larger...
Dumps the provided message to this dump.
[ "Dumps", "the", "provided", "message", "to", "this", "dump", "." ]
train
https://github.com/vietjtnguyen/nut/blob/3b9c272ebc6d858c790e43d2fc507885d8029d36/nut/relay.py#L1023-L1055
20c/xbahn
xbahn/shortcuts.py
api_client
def api_client(connection, client_class=xbahn.api.Client): """ Establishes an API client for one-way communication connection with an API Server Arguments: - connection (xbahn.connection.Connection) Keyword Arguments: - client_class (xbahn.api.Client): if supplied use this clas...
python
def api_client(connection, client_class=xbahn.api.Client): """ Establishes an API client for one-way communication connection with an API Server Arguments: - connection (xbahn.connection.Connection) Keyword Arguments: - client_class (xbahn.api.Client): if supplied use this clas...
[ "def", "api_client", "(", "connection", ",", "client_class", "=", "xbahn", ".", "api", ".", "Client", ")", ":", "return", "client_class", "(", "link", "=", "xbahn", ".", "connection", ".", "link", ".", "Link", "(", "# use the connection receive messages (server ...
Establishes an API client for one-way communication connection with an API Server Arguments: - connection (xbahn.connection.Connection) Keyword Arguments: - client_class (xbahn.api.Client): if supplied use this class to initantiate the client object. If omitted will use xba...
[ "Establishes", "an", "API", "client", "for", "one", "-", "way", "communication", "connection", "with", "an", "API", "Server", "Arguments", ":", "-", "connection", "(", "xbahn", ".", "connection", ".", "Connection", ")" ]
train
https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/shortcuts.py#L9-L32
20c/xbahn
xbahn/shortcuts.py
api_client_two_way
def api_client_two_way(connection, connection_responder, client_class=xbahn.api.Client): """ Establishes an API client for two-way communication connection with an API Server Arguments: - connection (xbahn.connection.Connection) - connection_responder (xbahn.connection.Connection): ...
python
def api_client_two_way(connection, connection_responder, client_class=xbahn.api.Client): """ Establishes an API client for two-way communication connection with an API Server Arguments: - connection (xbahn.connection.Connection) - connection_responder (xbahn.connection.Connection): ...
[ "def", "api_client_two_way", "(", "connection", ",", "connection_responder", ",", "client_class", "=", "xbahn", ".", "api", ".", "Client", ")", ":", "# create connection link instance", "link", "=", "xbahn", ".", "connection", ".", "link", ".", "Link", "(", ")",...
Establishes an API client for two-way communication connection with an API Server Arguments: - connection (xbahn.connection.Connection) - connection_responder (xbahn.connection.Connection): This connection will be used by the server to send requests to the client Keyword Ar...
[ "Establishes", "an", "API", "client", "for", "two", "-", "way", "communication", "connection", "with", "an", "API", "Server", "Arguments", ":", "-", "connection", "(", "xbahn", ".", "connection", ".", "Connection", ")", "-", "connection_responder", "(", "xbahn...
train
https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/shortcuts.py#L35-L76
20c/xbahn
xbahn/shortcuts.py
api_server
def api_server(connection, server_class): """ Establishes an API Server on the supplied connection Arguments: - connection (xbahn.connection.Connection) - server_class (xbahn.api.Server) Returns: - server_class: server instance """ # run api server on connection re...
python
def api_server(connection, server_class): """ Establishes an API Server on the supplied connection Arguments: - connection (xbahn.connection.Connection) - server_class (xbahn.api.Server) Returns: - server_class: server instance """ # run api server on connection re...
[ "def", "api_server", "(", "connection", ",", "server_class", ")", ":", "# run api server on connection", "return", "server_class", "(", "link", "=", "xbahn", ".", "connection", ".", "link", ".", "Link", "(", "# use the connection to receive messages", "receive", "=", ...
Establishes an API Server on the supplied connection Arguments: - connection (xbahn.connection.Connection) - server_class (xbahn.api.Server) Returns: - server_class: server instance
[ "Establishes", "an", "API", "Server", "on", "the", "supplied", "connection" ]
train
https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/shortcuts.py#L79-L99
opinkerfi/nago
nago/extensions/nodes.py
list_nodes
def list_nodes(search="unsigned"): """ List all connected nodes """ nodes = nago.core.get_nodes() if search == "all": return map(lambda x: {x[0]: x[1].data}, nodes.items()) elif search == 'unsigned': result = {} for token, node in nodes.items(): if node.get('acces...
python
def list_nodes(search="unsigned"): """ List all connected nodes """ nodes = nago.core.get_nodes() if search == "all": return map(lambda x: {x[0]: x[1].data}, nodes.items()) elif search == 'unsigned': result = {} for token, node in nodes.items(): if node.get('acces...
[ "def", "list_nodes", "(", "search", "=", "\"unsigned\"", ")", ":", "nodes", "=", "nago", ".", "core", ".", "get_nodes", "(", ")", "if", "search", "==", "\"all\"", ":", "return", "map", "(", "lambda", "x", ":", "{", "x", "[", "0", "]", ":", "x", "...
List all connected nodes
[ "List", "all", "connected", "nodes" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/nodes.py#L11-L29
opinkerfi/nago
nago/extensions/nodes.py
add
def add(node_name, **kwargs): """ Create a new node and generate a token for it """ result = {} kwargs = kwargs.copy() overwrite = kwargs.pop('overwrite', False) node = nago.core.get_node(node_name) if not node: node = nago.core.Node() elif not overwrite: result['status'] = '...
python
def add(node_name, **kwargs): """ Create a new node and generate a token for it """ result = {} kwargs = kwargs.copy() overwrite = kwargs.pop('overwrite', False) node = nago.core.get_node(node_name) if not node: node = nago.core.Node() elif not overwrite: result['status'] = '...
[ "def", "add", "(", "node_name", ",", "*", "*", "kwargs", ")", ":", "result", "=", "{", "}", "kwargs", "=", "kwargs", ".", "copy", "(", ")", "overwrite", "=", "kwargs", ".", "pop", "(", "'overwrite'", ",", "False", ")", "node", "=", "nago", ".", "...
Create a new node and generate a token for it
[ "Create", "a", "new", "node", "and", "generate", "a", "token", "for", "it" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/nodes.py#L32-L53
opinkerfi/nago
nago/extensions/nodes.py
delete
def delete(node_name): """ Delete a specific node """ result = {} node = nago.core.get_node(node_name) if not node: result['status'] = 'error' result['message'] = "node not found." else: node.delete() result['status'] = 'success' result['message'] = 'node dele...
python
def delete(node_name): """ Delete a specific node """ result = {} node = nago.core.get_node(node_name) if not node: result['status'] = 'error' result['message'] = "node not found." else: node.delete() result['status'] = 'success' result['message'] = 'node dele...
[ "def", "delete", "(", "node_name", ")", ":", "result", "=", "{", "}", "node", "=", "nago", ".", "core", ".", "get_node", "(", "node_name", ")", "if", "not", "node", ":", "result", "[", "'status'", "]", "=", "'error'", "result", "[", "'message'", "]",...
Delete a specific node
[ "Delete", "a", "specific", "node" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/nodes.py#L56-L67
opinkerfi/nago
nago/extensions/nodes.py
sign
def sign(node=None): """ Sign a specific node to grant it access you can specify "all" to sign all nodes returns the nodes that were signed """ if not node: raise Exception("Specify either 'all' your specify token/host_name of node to sign. ") if node == 'all': node = 'unsign...
python
def sign(node=None): """ Sign a specific node to grant it access you can specify "all" to sign all nodes returns the nodes that were signed """ if not node: raise Exception("Specify either 'all' your specify token/host_name of node to sign. ") if node == 'all': node = 'unsign...
[ "def", "sign", "(", "node", "=", "None", ")", ":", "if", "not", "node", ":", "raise", "Exception", "(", "\"Specify either 'all' your specify token/host_name of node to sign. \"", ")", "if", "node", "==", "'all'", ":", "node", "=", "'unsigned'", "nodes", "=", "li...
Sign a specific node to grant it access you can specify "all" to sign all nodes returns the nodes that were signed
[ "Sign", "a", "specific", "node", "to", "grant", "it", "access" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/nodes.py#L70-L87
opinkerfi/nago
nago/extensions/nodes.py
set_attribute
def set_attribute(token_or_hostname, **kwargs): """ Change the attributes of a connected node """ node = nago.core.get_node(token_or_hostname) or {} if not kwargs: return "No changes made" for k, v in kwargs.items(): node[k] = v node.save() return "Saved %s changes" % len(kwargs)
python
def set_attribute(token_or_hostname, **kwargs): """ Change the attributes of a connected node """ node = nago.core.get_node(token_or_hostname) or {} if not kwargs: return "No changes made" for k, v in kwargs.items(): node[k] = v node.save() return "Saved %s changes" % len(kwargs)
[ "def", "set_attribute", "(", "token_or_hostname", ",", "*", "*", "kwargs", ")", ":", "node", "=", "nago", ".", "core", ".", "get_node", "(", "token_or_hostname", ")", "or", "{", "}", "if", "not", "kwargs", ":", "return", "\"No changes made\"", "for", "k", ...
Change the attributes of a connected node
[ "Change", "the", "attributes", "of", "a", "connected", "node" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/nodes.py#L90-L98
opinkerfi/nago
nago/extensions/nodes.py
ping
def ping(token_or_hostname=None): """ Send an echo request to a nago host. Arguments: token_or_host_name -- The remote node to ping If node is not provided, simply return pong You can use the special nodenames "server" or "master" """ if...
python
def ping(token_or_hostname=None): """ Send an echo request to a nago host. Arguments: token_or_host_name -- The remote node to ping If node is not provided, simply return pong You can use the special nodenames "server" or "master" """ if...
[ "def", "ping", "(", "token_or_hostname", "=", "None", ")", ":", "if", "not", "token_or_hostname", ":", "return", "\"Pong!\"", "node", "=", "nago", ".", "core", ".", "get_node", "(", "token_or_hostname", ")", "if", "not", "node", "and", "token_or_hostname", "...
Send an echo request to a nago host. Arguments: token_or_host_name -- The remote node to ping If node is not provided, simply return pong You can use the special nodenames "server" or "master"
[ "Send", "an", "echo", "request", "to", "a", "nago", "host", "." ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/nodes.py#L101-L127
opinkerfi/nago
nago/extensions/nodes.py
connect
def connect(remote_host): """ Connect to remote host and show our status """ if remote_host in ('master', 'server'): remote_host = nago.settings.get_option('server') node = nago.core.get_node(remote_host) if not node: try: address = socket.gethostbyname(remote_host) ...
python
def connect(remote_host): """ Connect to remote host and show our status """ if remote_host in ('master', 'server'): remote_host = nago.settings.get_option('server') node = nago.core.get_node(remote_host) if not node: try: address = socket.gethostbyname(remote_host) ...
[ "def", "connect", "(", "remote_host", ")", ":", "if", "remote_host", "in", "(", "'master'", ",", "'server'", ")", ":", "remote_host", "=", "nago", ".", "settings", ".", "get_option", "(", "'server'", ")", "node", "=", "nago", ".", "core", ".", "get_node"...
Connect to remote host and show our status
[ "Connect", "to", "remote", "host", "and", "show", "our", "status" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/nodes.py#L130-L151
djtaylor/python-lsbinit
lsbinit/__init__.py
set_environ
def set_environ(inherit=True, append={}): """ Helper method for passing environment variables to the subprocess. """ _environ = {} if not inherit else environ for k,v in append.iteritems(): _environ[k] = v return _environ
python
def set_environ(inherit=True, append={}): """ Helper method for passing environment variables to the subprocess. """ _environ = {} if not inherit else environ for k,v in append.iteritems(): _environ[k] = v return _environ
[ "def", "set_environ", "(", "inherit", "=", "True", ",", "append", "=", "{", "}", ")", ":", "_environ", "=", "{", "}", "if", "not", "inherit", "else", "environ", "for", "k", ",", "v", "in", "append", ".", "iteritems", "(", ")", ":", "_environ", "[",...
Helper method for passing environment variables to the subprocess.
[ "Helper", "method", "for", "passing", "environment", "variables", "to", "the", "subprocess", "." ]
train
https://github.com/djtaylor/python-lsbinit/blob/a41fc551226f61ac2bf1b8b0f3f5395db85e75a2/lsbinit/__init__.py#L21-L28
djtaylor/python-lsbinit
lsbinit/__init__.py
LSBInit._colorize
def _colorize(self, msg, color=None, encode=False): """ Colorize a string. """ # Valid colors colors = { 'red': '31', 'green': '32', 'yellow': '33' } # No color specified or unsupported color if not...
python
def _colorize(self, msg, color=None, encode=False): """ Colorize a string. """ # Valid colors colors = { 'red': '31', 'green': '32', 'yellow': '33' } # No color specified or unsupported color if not...
[ "def", "_colorize", "(", "self", ",", "msg", ",", "color", "=", "None", ",", "encode", "=", "False", ")", ":", "# Valid colors", "colors", "=", "{", "'red'", ":", "'31'", ",", "'green'", ":", "'32'", ",", "'yellow'", ":", "'33'", "}", "# No color speci...
Colorize a string.
[ "Colorize", "a", "string", "." ]
train
https://github.com/djtaylor/python-lsbinit/blob/a41fc551226f61ac2bf1b8b0f3f5395db85e75a2/lsbinit/__init__.py#L51-L70
djtaylor/python-lsbinit
lsbinit/__init__.py
LSBInit.is_running
def is_running(self): """ Check if the service is running. """ try: kill(int(self.pid.get()), 0) return True # Process not running, remove PID/lock file if it exists except: self.pid.remove() self.lock.remove() ...
python
def is_running(self): """ Check if the service is running. """ try: kill(int(self.pid.get()), 0) return True # Process not running, remove PID/lock file if it exists except: self.pid.remove() self.lock.remove() ...
[ "def", "is_running", "(", "self", ")", ":", "try", ":", "kill", "(", "int", "(", "self", ".", "pid", ".", "get", "(", ")", ")", ",", "0", ")", "return", "True", "# Process not running, remove PID/lock file if it exists", "except", ":", "self", ".", "pid", ...
Check if the service is running.
[ "Check", "if", "the", "service", "is", "running", "." ]
train
https://github.com/djtaylor/python-lsbinit/blob/a41fc551226f61ac2bf1b8b0f3f5395db85e75a2/lsbinit/__init__.py#L72-L84
djtaylor/python-lsbinit
lsbinit/__init__.py
LSBInit.set_output
def set_output(self): """ Set the output for the service command. """ if not self.output: return open(devnull, 'w') # Get the output file path output_dir = dirname(self.output) # Make the path exists if not isdir(output_dir): ...
python
def set_output(self): """ Set the output for the service command. """ if not self.output: return open(devnull, 'w') # Get the output file path output_dir = dirname(self.output) # Make the path exists if not isdir(output_dir): ...
[ "def", "set_output", "(", "self", ")", ":", "if", "not", "self", ".", "output", ":", "return", "open", "(", "devnull", ",", "'w'", ")", "# Get the output file path", "output_dir", "=", "dirname", "(", "self", ".", "output", ")", "# Make the path exists", "if...
Set the output for the service command.
[ "Set", "the", "output", "for", "the", "service", "command", "." ]
train
https://github.com/djtaylor/python-lsbinit/blob/a41fc551226f61ac2bf1b8b0f3f5395db85e75a2/lsbinit/__init__.py#L86-L102
djtaylor/python-lsbinit
lsbinit/__init__.py
LSBInit.do_status
def do_status(self): """ Get the status of the service. """ # Get the PID of the service pid = self.pid.get() # Status color / attributes status_color = 'green' if pid else 'red' status_dot = self._colorize(UNICODE['dot'], status_c...
python
def do_status(self): """ Get the status of the service. """ # Get the PID of the service pid = self.pid.get() # Status color / attributes status_color = 'green' if pid else 'red' status_dot = self._colorize(UNICODE['dot'], status_c...
[ "def", "do_status", "(", "self", ")", ":", "# Get the PID of the service", "pid", "=", "self", ".", "pid", ".", "get", "(", ")", "# Status color / attributes", "status_color", "=", "'green'", "if", "pid", "else", "'red'", "status_dot", "=", "self", ".", "_colo...
Get the status of the service.
[ "Get", "the", "status", "of", "the", "service", "." ]
train
https://github.com/djtaylor/python-lsbinit/blob/a41fc551226f61ac2bf1b8b0f3f5395db85e75a2/lsbinit/__init__.py#L151-L182
djtaylor/python-lsbinit
lsbinit/__init__.py
LSBInit.interface
def interface(self): """ Public method for handling service command argument. """ # Possible control arguments controls = { 'start': self.do_start, 'stop': self.do_stop, 'status': self.do_status, 'restart': self.do_restart,...
python
def interface(self): """ Public method for handling service command argument. """ # Possible control arguments controls = { 'start': self.do_start, 'stop': self.do_stop, 'status': self.do_status, 'restart': self.do_restart,...
[ "def", "interface", "(", "self", ")", ":", "# Possible control arguments", "controls", "=", "{", "'start'", ":", "self", ".", "do_start", ",", "'stop'", ":", "self", ".", "do_stop", ",", "'status'", ":", "self", ".", "do_status", ",", "'restart'", ":", "se...
Public method for handling service command argument.
[ "Public", "method", "for", "handling", "service", "command", "argument", "." ]
train
https://github.com/djtaylor/python-lsbinit/blob/a41fc551226f61ac2bf1b8b0f3f5395db85e75a2/lsbinit/__init__.py#L195-L214
treycucco/bidon
bidon/spreadsheet/csv.py
CSVWorksheet.parse_cell
def parse_cell(self, cell, coords, cell_mode=CellMode.cooked): """Tries to convert the value first to an int, then a float and if neither is successful it returns the string value. """ try: return int(cell) except ValueError: pass try: return float(cell) except ValueError: ...
python
def parse_cell(self, cell, coords, cell_mode=CellMode.cooked): """Tries to convert the value first to an int, then a float and if neither is successful it returns the string value. """ try: return int(cell) except ValueError: pass try: return float(cell) except ValueError: ...
[ "def", "parse_cell", "(", "self", ",", "cell", ",", "coords", ",", "cell_mode", "=", "CellMode", ".", "cooked", ")", ":", "try", ":", "return", "int", "(", "cell", ")", "except", "ValueError", ":", "pass", "try", ":", "return", "float", "(", "cell", ...
Tries to convert the value first to an int, then a float and if neither is successful it returns the string value.
[ "Tries", "to", "convert", "the", "value", "first", "to", "an", "int", "then", "a", "float", "and", "if", "neither", "is", "successful", "it", "returns", "the", "string", "value", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/csv.py#L20-L33
treycucco/bidon
bidon/spreadsheet/csv.py
CSVWorkbook.iterate_sheets
def iterate_sheets(self, *args, **kwargs): """Opens self.filename and reads it with a csv reader. If self.filename ends with .gz, the file will be decompressed with gzip before being passed to csv.reader. If the filename is not a string, it is assumed to be a file-like object which will be passed direc...
python
def iterate_sheets(self, *args, **kwargs): """Opens self.filename and reads it with a csv reader. If self.filename ends with .gz, the file will be decompressed with gzip before being passed to csv.reader. If the filename is not a string, it is assumed to be a file-like object which will be passed direc...
[ "def", "iterate_sheets", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "self", ".", "filename", ",", "str", ")", ":", "if", "self", ".", "filename", ".", "endswith", "(", "\".gz\"", ")", "or", "self", "....
Opens self.filename and reads it with a csv reader. If self.filename ends with .gz, the file will be decompressed with gzip before being passed to csv.reader. If the filename is not a string, it is assumed to be a file-like object which will be passed directly to csv.reader.
[ "Opens", "self", ".", "filename", "and", "reads", "it", "with", "a", "csv", "reader", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/csv.py#L47-L65
jaraco/jaraco.structures
jaraco/structures/binary.py
get_bit_values
def get_bit_values(number, size=32): """ Get bit values as a list for a given number >>> get_bit_values(1) == [0]*31 + [1] True >>> get_bit_values(0xDEADBEEF) [1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, \ 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1] You may override the default word size of...
python
def get_bit_values(number, size=32): """ Get bit values as a list for a given number >>> get_bit_values(1) == [0]*31 + [1] True >>> get_bit_values(0xDEADBEEF) [1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, \ 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1] You may override the default word size of...
[ "def", "get_bit_values", "(", "number", ",", "size", "=", "32", ")", ":", "number", "+=", "2", "**", "size", "return", "list", "(", "map", "(", "int", ",", "bin", "(", "number", ")", "[", "-", "size", ":", "]", ")", ")" ]
Get bit values as a list for a given number >>> get_bit_values(1) == [0]*31 + [1] True >>> get_bit_values(0xDEADBEEF) [1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, \ 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1] You may override the default word size of 32-bits to match your actual application. ...
[ "Get", "bit", "values", "as", "a", "list", "for", "a", "given", "number", ">>>", "get_bit_values", "(", "1", ")", "==", "[", "0", "]", "*", "31", "+", "[", "1", "]", "True", ">>>", "get_bit_values", "(", "0xDEADBEEF", ")", "[", "1", "1", "0", "1"...
train
https://github.com/jaraco/jaraco.structures/blob/216e55f6e532a4dac47074c3911e5d65bc9d8b58/jaraco/structures/binary.py#L7-L28
jaraco/jaraco.structures
jaraco/structures/binary.py
coalesce
def coalesce(bits): """ Take a sequence of bits, most significant first, and coalesce them into a number. >>> coalesce([1,0,1]) 5 """ def operation(a, b): return a << 1 | b return reduce(operation, bits)
python
def coalesce(bits): """ Take a sequence of bits, most significant first, and coalesce them into a number. >>> coalesce([1,0,1]) 5 """ def operation(a, b): return a << 1 | b return reduce(operation, bits)
[ "def", "coalesce", "(", "bits", ")", ":", "def", "operation", "(", "a", ",", "b", ")", ":", "return", "a", "<<", "1", "|", "b", "return", "reduce", "(", "operation", ",", "bits", ")" ]
Take a sequence of bits, most significant first, and coalesce them into a number. >>> coalesce([1,0,1]) 5
[ "Take", "a", "sequence", "of", "bits", "most", "significant", "first", "and", "coalesce", "them", "into", "a", "number", ".", ">>>", "coalesce", "(", "[", "1", "0", "1", "]", ")", "5" ]
train
https://github.com/jaraco/jaraco.structures/blob/216e55f6e532a4dac47074c3911e5d65bc9d8b58/jaraco/structures/binary.py#L43-L53
langloisjp/pysvcmetrics
metrics.py
configure
def configure(host=DEFAULT_HOST, port=DEFAULT_PORT, prefix=''): """ >>> configure() >>> configure('localhost', 8125, 'mymetrics') """ global _client logging.info("Reconfiguring metrics: {}:{}/{}".format(host, port, prefix)) _client = statsdclient.StatsdClient(host, port, prefix)
python
def configure(host=DEFAULT_HOST, port=DEFAULT_PORT, prefix=''): """ >>> configure() >>> configure('localhost', 8125, 'mymetrics') """ global _client logging.info("Reconfiguring metrics: {}:{}/{}".format(host, port, prefix)) _client = statsdclient.StatsdClient(host, port, prefix)
[ "def", "configure", "(", "host", "=", "DEFAULT_HOST", ",", "port", "=", "DEFAULT_PORT", ",", "prefix", "=", "''", ")", ":", "global", "_client", "logging", ".", "info", "(", "\"Reconfiguring metrics: {}:{}/{}\"", ".", "format", "(", "host", ",", "port", ",",...
>>> configure() >>> configure('localhost', 8125, 'mymetrics')
[ ">>>", "configure", "()", ">>>", "configure", "(", "localhost", "8125", "mymetrics", ")" ]
train
https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/metrics.py#L43-L50
langloisjp/pysvcmetrics
metrics.py
timeit
def timeit(metric, func, *args, **kwargs): """ >>> import time >>> timeit("metric", time.sleep, 0.1) >>> resetclient() >>> timeit("metric", time.sleep, 0.1) """ return _client.timeit(metric, func, *args, **kwargs)
python
def timeit(metric, func, *args, **kwargs): """ >>> import time >>> timeit("metric", time.sleep, 0.1) >>> resetclient() >>> timeit("metric", time.sleep, 0.1) """ return _client.timeit(metric, func, *args, **kwargs)
[ "def", "timeit", "(", "metric", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "_client", ".", "timeit", "(", "metric", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
>>> import time >>> timeit("metric", time.sleep, 0.1) >>> resetclient() >>> timeit("metric", time.sleep, 0.1)
[ ">>>", "import", "time", ">>>", "timeit", "(", "metric", "time", ".", "sleep", "0", ".", "1", ")", ">>>", "resetclient", "()", ">>>", "timeit", "(", "metric", "time", ".", "sleep", "0", ".", "1", ")" ]
train
https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/metrics.py#L72-L79
langloisjp/pysvcmetrics
metrics.py
timed
def timed(prefix=None): """ Decorator to time execution of function. Metric name is function name (as given under f.__name__). Optionally provide a prefix (without the '.'). >>> @timed() ... def f(): ... print('ok') ... >>> f() ok >>> @timed(prefix='mymetrics') ... d...
python
def timed(prefix=None): """ Decorator to time execution of function. Metric name is function name (as given under f.__name__). Optionally provide a prefix (without the '.'). >>> @timed() ... def f(): ... print('ok') ... >>> f() ok >>> @timed(prefix='mymetrics') ... d...
[ "def", "timed", "(", "prefix", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "\"\"\"wrap func so it is timed\"\"\"", "metricname", "=", "func", ".", "__name__", "if", "prefix", ":", "metricname", "=", "prefix", "+", "'.'", "+", "metricnam...
Decorator to time execution of function. Metric name is function name (as given under f.__name__). Optionally provide a prefix (without the '.'). >>> @timed() ... def f(): ... print('ok') ... >>> f() ok >>> @timed(prefix='mymetrics') ... def g(): ... print('ok') ...
[ "Decorator", "to", "time", "execution", "of", "function", ".", "Metric", "name", "is", "function", "name", "(", "as", "given", "under", "f", ".", "__name__", ")", ".", "Optionally", "provide", "a", "prefix", "(", "without", "the", ".", ")", "." ]
train
https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/metrics.py#L90-L121
langloisjp/pysvcmetrics
metrics.py
time_methods
def time_methods(obj, methods, prefix=None): """ Patch obj so calls to given methods are timed >>> class C(object): ... def m1(self): ... return 'ok' ... ... def m2(self, arg): ... return arg ... >>> c = C() >>> time_methods(c, ['m1', 'm2']) >>> c...
python
def time_methods(obj, methods, prefix=None): """ Patch obj so calls to given methods are timed >>> class C(object): ... def m1(self): ... return 'ok' ... ... def m2(self, arg): ... return arg ... >>> c = C() >>> time_methods(c, ['m1', 'm2']) >>> c...
[ "def", "time_methods", "(", "obj", ",", "methods", ",", "prefix", "=", "None", ")", ":", "if", "prefix", ":", "prefix", "=", "prefix", "+", "'.'", "else", ":", "prefix", "=", "''", "for", "method", "in", "methods", ":", "current_method", "=", "getattr"...
Patch obj so calls to given methods are timed >>> class C(object): ... def m1(self): ... return 'ok' ... ... def m2(self, arg): ... return arg ... >>> c = C() >>> time_methods(c, ['m1', 'm2']) >>> c.m1() 'ok' >>> c.m2('ok') 'ok' >>> c = C(...
[ "Patch", "obj", "so", "calls", "to", "given", "methods", "are", "timed" ]
train
https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/metrics.py#L123-L151
CodyKochmann/stricttuple
build/lib/stricttuple/__init__.py
typedtuple.validate_all_types
def validate_all_types(kwargs): """ validates that all values of the arguments are types """ for key in kwargs: assert isinstance(kwargs[key], type), """\n Typedtuple needs its arguments to be types. Argument "{k:}" was {type_name:}({val_repr}). You might want to try: {k:} = ...
python
def validate_all_types(kwargs): """ validates that all values of the arguments are types """ for key in kwargs: assert isinstance(kwargs[key], type), """\n Typedtuple needs its arguments to be types. Argument "{k:}" was {type_name:}({val_repr}). You might want to try: {k:} = ...
[ "def", "validate_all_types", "(", "kwargs", ")", ":", "for", "key", "in", "kwargs", ":", "assert", "isinstance", "(", "kwargs", "[", "key", "]", ",", "type", ")", ",", "\"\"\"\\n\n Typedtuple needs its arguments to be types. Argument \"{k:}\" was {type_name:}({val_repr...
validates that all values of the arguments are types
[ "validates", "that", "all", "values", "of", "the", "arguments", "are", "types" ]
train
https://github.com/CodyKochmann/stricttuple/blob/072cbd6f7b90f3f666dc0f2c10ab6056d86dfc72/build/lib/stricttuple/__init__.py#L37-L43
CodyKochmann/stricttuple
build/lib/stricttuple/__init__.py
typedtuple.validate_fields
def validate_fields(self, **kwargs): """ ensures that all incoming fields are the types that were specified """ for field in self.fields: value = kwargs[field] required_type = self.fields[field] if type(value) != required_type: raise TypeError('{}.{} n...
python
def validate_fields(self, **kwargs): """ ensures that all incoming fields are the types that were specified """ for field in self.fields: value = kwargs[field] required_type = self.fields[field] if type(value) != required_type: raise TypeError('{}.{} n...
[ "def", "validate_fields", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "field", "in", "self", ".", "fields", ":", "value", "=", "kwargs", "[", "field", "]", "required_type", "=", "self", ".", "fields", "[", "field", "]", "if", "type", "(", ...
ensures that all incoming fields are the types that were specified
[ "ensures", "that", "all", "incoming", "fields", "are", "the", "types", "that", "were", "specified" ]
train
https://github.com/CodyKochmann/stricttuple/blob/072cbd6f7b90f3f666dc0f2c10ab6056d86dfc72/build/lib/stricttuple/__init__.py#L45-L56
DoWhileGeek/authentise-services
authentise_services/slicing_settings.py
SlicingSettings.upload
def upload(self, path, engine, description=None): """Create a new config resource in the slicing service and upload the path contents to it""" if description is None: head, tail = ntpath.split(path) description = tail or ntpath.basename(head) url = "http://quickslice.{}...
python
def upload(self, path, engine, description=None): """Create a new config resource in the slicing service and upload the path contents to it""" if description is None: head, tail = ntpath.split(path) description = tail or ntpath.basename(head) url = "http://quickslice.{}...
[ "def", "upload", "(", "self", ",", "path", ",", "engine", ",", "description", "=", "None", ")", ":", "if", "description", "is", "None", ":", "head", ",", "tail", "=", "ntpath", ".", "split", "(", "path", ")", "description", "=", "tail", "or", "ntpath...
Create a new config resource in the slicing service and upload the path contents to it
[ "Create", "a", "new", "config", "resource", "in", "the", "slicing", "service", "and", "upload", "the", "path", "contents", "to", "it" ]
train
https://github.com/DoWhileGeek/authentise-services/blob/ee32bd7f7de15d3fb24c0a6374640d3a1ec8096d/authentise_services/slicing_settings.py#L31-L53
DoWhileGeek/authentise-services
authentise_services/slicing_settings.py
SlicingSettings.download
def download(self, path): """downloads a config resource to the path""" service_get_resp = requests.get(self.location, cookies={"session": self.session}) payload = service_get_resp.json() download_get_resp = requests.get(payload["content"]) with open(path, "wb") as config_file:...
python
def download(self, path): """downloads a config resource to the path""" service_get_resp = requests.get(self.location, cookies={"session": self.session}) payload = service_get_resp.json() download_get_resp = requests.get(payload["content"]) with open(path, "wb") as config_file:...
[ "def", "download", "(", "self", ",", "path", ")", ":", "service_get_resp", "=", "requests", ".", "get", "(", "self", ".", "location", ",", "cookies", "=", "{", "\"session\"", ":", "self", ".", "session", "}", ")", "payload", "=", "service_get_resp", ".",...
downloads a config resource to the path
[ "downloads", "a", "config", "resource", "to", "the", "path" ]
train
https://github.com/DoWhileGeek/authentise-services/blob/ee32bd7f7de15d3fb24c0a6374640d3a1ec8096d/authentise_services/slicing_settings.py#L55-L63
edeposit/edeposit.amqp.antivirus
src/edeposit/amqp/antivirus/antivirus.py
scan_file
def scan_file(path): """ Scan `path` for viruses using ``clamd`` or ``clamscan`` (depends on :attr:`settings.USE_CLAMD`. Args: path (str): Relative or absolute path of file/directory you need to scan. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or bla...
python
def scan_file(path): """ Scan `path` for viruses using ``clamd`` or ``clamscan`` (depends on :attr:`settings.USE_CLAMD`. Args: path (str): Relative or absolute path of file/directory you need to scan. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or bla...
[ "def", "scan_file", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "if", "settings", ".", "USE_CLAMD", ":", "return", "clamd", ".", "scan_file", "(", "path", ")", "else", ":", "return", "clamscan", ".", "scan...
Scan `path` for viruses using ``clamd`` or ``clamscan`` (depends on :attr:`settings.USE_CLAMD`. Args: path (str): Relative or absolute path of file/directory you need to scan. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or blank dict. Raises: Val...
[ "Scan", "path", "for", "viruses", "using", "clamd", "or", "clamscan", "(", "depends", "on", ":", "attr", ":", "settings", ".", "USE_CLAMD", "." ]
train
https://github.com/edeposit/edeposit.amqp.antivirus/blob/011b38bbe920819fab99a5891b1e70732321a598/src/edeposit/amqp/antivirus/antivirus.py#L24-L44
edeposit/edeposit.amqp.antivirus
src/edeposit/amqp/antivirus/antivirus.py
save_and_scan
def save_and_scan(filename, b64_data): """ Save `b64_data` to temporary file and scan it for viruses. Args: filename (str): Name of the file - used as basename for tmp file. b64_data (str): Content of the file encoded in base64. Returns: dict: ``{filename: ("FOUND", "virus type...
python
def save_and_scan(filename, b64_data): """ Save `b64_data` to temporary file and scan it for viruses. Args: filename (str): Name of the file - used as basename for tmp file. b64_data (str): Content of the file encoded in base64. Returns: dict: ``{filename: ("FOUND", "virus type...
[ "def", "save_and_scan", "(", "filename", ",", "b64_data", ")", ":", "with", "NTFile", "(", "suffix", "=", "\"_\"", "+", "os", ".", "path", ".", "basename", "(", "filename", ")", ",", "mode", "=", "\"wb\"", ")", "as", "ifile", ":", "ifile", ".", "writ...
Save `b64_data` to temporary file and scan it for viruses. Args: filename (str): Name of the file - used as basename for tmp file. b64_data (str): Content of the file encoded in base64. Returns: dict: ``{filename: ("FOUND", "virus type")}`` or blank dict.
[ "Save", "b64_data", "to", "temporary", "file", "and", "scan", "it", "for", "viruses", "." ]
train
https://github.com/edeposit/edeposit.amqp.antivirus/blob/011b38bbe920819fab99a5891b1e70732321a598/src/edeposit/amqp/antivirus/antivirus.py#L47-L66
fedora-infra/fmn.rules
fmn/rules/pagure.py
pagure_specific_project_filter
def pagure_specific_project_filter(config, message, project=None, *args, **kw): """ Particular pagure projects Adding this rule allows you to get notifications for one or more `pagure.io <https://pagure.io>`_ projects. Specify multiple projects by separating them with a comma ','. """ if n...
python
def pagure_specific_project_filter(config, message, project=None, *args, **kw): """ Particular pagure projects Adding this rule allows you to get notifications for one or more `pagure.io <https://pagure.io>`_ projects. Specify multiple projects by separating them with a comma ','. """ if n...
[ "def", "pagure_specific_project_filter", "(", "config", ",", "message", ",", "project", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "not", "pagure_catchall", "(", "config", ",", "message", ")", ":", "return", "False", "project", "...
Particular pagure projects Adding this rule allows you to get notifications for one or more `pagure.io <https://pagure.io>`_ projects. Specify multiple projects by separating them with a comma ','.
[ "Particular", "pagure", "projects" ]
train
https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/pagure.py#L18-L41
fedora-infra/fmn.rules
fmn/rules/pagure.py
pagure_specific_project_tag_filter
def pagure_specific_project_tag_filter(config, message, tags=None, *args, **kw): """ Particular pagure project tags Adding this rule allows you to get notifications for one or more `pagure.io <https://pagure.io>`_ projects having the specified tags. Specify multiple tags by separating them with a co...
python
def pagure_specific_project_tag_filter(config, message, tags=None, *args, **kw): """ Particular pagure project tags Adding this rule allows you to get notifications for one or more `pagure.io <https://pagure.io>`_ projects having the specified tags. Specify multiple tags by separating them with a co...
[ "def", "pagure_specific_project_tag_filter", "(", "config", ",", "message", ",", "tags", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "not", "pagure_catchall", "(", "config", ",", "message", ")", ":", "return", "False", "tags", "="...
Particular pagure project tags Adding this rule allows you to get notifications for one or more `pagure.io <https://pagure.io>`_ projects having the specified tags. Specify multiple tags by separating them with a comma ','.
[ "Particular", "pagure", "project", "tags" ]
train
https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/pagure.py#L45-L68
chatfirst/chatfirst
chatfirst/__init__.py
build_uri
def build_uri(orig_uriparts, kwargs): """ Build the URI from the original uriparts and kwargs. Modifies kwargs. """ uriparts = [] for uripart in orig_uriparts: # If this part matches a keyword argument (starting with _), use # the supplied value. Otherwise, just use the part. ...
python
def build_uri(orig_uriparts, kwargs): """ Build the URI from the original uriparts and kwargs. Modifies kwargs. """ uriparts = [] for uripart in orig_uriparts: # If this part matches a keyword argument (starting with _), use # the supplied value. Otherwise, just use the part. ...
[ "def", "build_uri", "(", "orig_uriparts", ",", "kwargs", ")", ":", "uriparts", "=", "[", "]", "for", "uripart", "in", "orig_uriparts", ":", "# If this part matches a keyword argument (starting with _), use", "# the supplied value. Otherwise, just use the part.", "if", "uripar...
Build the URI from the original uriparts and kwargs. Modifies kwargs.
[ "Build", "the", "URI", "from", "the", "original", "uriparts", "and", "kwargs", ".", "Modifies", "kwargs", "." ]
train
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/__init__.py#L100-L121
nicholasbishop/trask
trask/phase1.py
load
def load(path): """Load |path| and recursively expand any includes.""" with open(path) as rfile: steps = MODEL.parse(rfile.read()) new_steps = [] for step in steps: new_steps += expand_includes(step, path) return new_steps
python
def load(path): """Load |path| and recursively expand any includes.""" with open(path) as rfile: steps = MODEL.parse(rfile.read()) new_steps = [] for step in steps: new_steps += expand_includes(step, path) return new_steps
[ "def", "load", "(", "path", ")", ":", "with", "open", "(", "path", ")", "as", "rfile", ":", "steps", "=", "MODEL", ".", "parse", "(", "rfile", ".", "read", "(", ")", ")", "new_steps", "=", "[", "]", "for", "step", "in", "steps", ":", "new_steps",...
Load |path| and recursively expand any includes.
[ "Load", "|path|", "and", "recursively", "expand", "any", "includes", "." ]
train
https://github.com/nicholasbishop/trask/blob/a97688425f70b539c7710b498627da9a6e39afd8/trask/phase1.py#L68-L77
abe-winter/pg13-py
pg13/syncmessage.py
translate_key
def translate_key(jsonkey): "helper for translate_*" nombre,pkey,field=ujson.loads(jsonkey) return FieldKey(nombre,tuple(pkey),field)
python
def translate_key(jsonkey): "helper for translate_*" nombre,pkey,field=ujson.loads(jsonkey) return FieldKey(nombre,tuple(pkey),field)
[ "def", "translate_key", "(", "jsonkey", ")", ":", "nombre", ",", "pkey", ",", "field", "=", "ujson", ".", "loads", "(", "jsonkey", ")", "return", "FieldKey", "(", "nombre", ",", "tuple", "(", "pkey", ")", ",", "field", ")" ]
helper for translate_*
[ "helper", "for", "translate_", "*" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/syncmessage.py#L28-L31
abe-winter/pg13-py
pg13/syncmessage.py
parse_serialdiff
def parse_serialdiff(sd_dict): "helper for translate_check" if isinstance(sd_dict,list): if len(sd_dict)!=2 or sd_dict[0]!='checkstale': raise NotImplementedError(sd_dict[0],len(sd_dict)) return CheckStale(sd_dict[1]) if isinstance(sd_dict['deltas'],list): # i.e. for VHString the whole deltas field is a s...
python
def parse_serialdiff(sd_dict): "helper for translate_check" if isinstance(sd_dict,list): if len(sd_dict)!=2 or sd_dict[0]!='checkstale': raise NotImplementedError(sd_dict[0],len(sd_dict)) return CheckStale(sd_dict[1]) if isinstance(sd_dict['deltas'],list): # i.e. for VHString the whole deltas field is a s...
[ "def", "parse_serialdiff", "(", "sd_dict", ")", ":", "if", "isinstance", "(", "sd_dict", ",", "list", ")", ":", "if", "len", "(", "sd_dict", ")", "!=", "2", "or", "sd_dict", "[", "0", "]", "!=", "'checkstale'", ":", "raise", "NotImplementedError", "(", ...
helper for translate_check
[ "helper", "for", "translate_check" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/syncmessage.py#L32-L40
abe-winter/pg13-py
pg13/syncmessage.py
translate_update
def translate_update(blob): "converts JSON parse output to self-aware objects" # note below: v will be int or null return {translate_key(k):parse_serialdiff(v) for k,v in blob.items()}
python
def translate_update(blob): "converts JSON parse output to self-aware objects" # note below: v will be int or null return {translate_key(k):parse_serialdiff(v) for k,v in blob.items()}
[ "def", "translate_update", "(", "blob", ")", ":", "# note below: v will be int or null", "return", "{", "translate_key", "(", "k", ")", ":", "parse_serialdiff", "(", "v", ")", "for", "k", ",", "v", "in", "blob", ".", "items", "(", ")", "}" ]
converts JSON parse output to self-aware objects
[ "converts", "JSON", "parse", "output", "to", "self", "-", "aware", "objects" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/syncmessage.py#L41-L44
abe-winter/pg13-py
pg13/syncmessage.py
fkapply
def fkapply(models,pool,fn,missing_fn,(nombre,pkey,field),*args): "wrapper for do_* funcs to call process_* with missing handler. Unpacks the FieldKey." if (nombre,pkey) in models: return fn(pool,models[nombre,pkey],field,*args) else: return missing_fn(pool,field,*args) if missing_fn else ['missing']
python
def fkapply(models,pool,fn,missing_fn,(nombre,pkey,field),*args): "wrapper for do_* funcs to call process_* with missing handler. Unpacks the FieldKey." if (nombre,pkey) in models: return fn(pool,models[nombre,pkey],field,*args) else: return missing_fn(pool,field,*args) if missing_fn else ['missing']
[ "def", "fkapply", "(", "models", ",", "pool", ",", "fn", ",", "missing_fn", ",", "(", "nombre", ",", "pkey", ",", "field", ")", ",", "*", "args", ")", ":", "if", "(", "nombre", ",", "pkey", ")", "in", "models", ":", "return", "fn", "(", "pool", ...
wrapper for do_* funcs to call process_* with missing handler. Unpacks the FieldKey.
[ "wrapper", "for", "do_", "*", "funcs", "to", "call", "process_", "*", "with", "missing", "handler", ".", "Unpacks", "the", "FieldKey", "." ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/syncmessage.py#L49-L52
abe-winter/pg13-py
pg13/syncmessage.py
do_update
def do_update(pool,request,models): "unlike *_check() below, update doesn't worry about missing children" return {k:fkapply(models,pool,process_update,missing_update,k,v) for k,v in request.items()}
python
def do_update(pool,request,models): "unlike *_check() below, update doesn't worry about missing children" return {k:fkapply(models,pool,process_update,missing_update,k,v) for k,v in request.items()}
[ "def", "do_update", "(", "pool", ",", "request", ",", "models", ")", ":", "return", "{", "k", ":", "fkapply", "(", "models", ",", "pool", ",", "process_update", ",", "missing_update", ",", "k", ",", "v", ")", "for", "k", ",", "v", "in", "request", ...
unlike *_check() below, update doesn't worry about missing children
[ "unlike", "*", "_check", "()", "below", "update", "doesn", "t", "worry", "about", "missing", "children" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/syncmessage.py#L84-L86
abe-winter/pg13-py
pg13/syncmessage.py
process_check
def process_check(pool,model,field,version): "helper for do_check. version is an integer or null. returns ..." try: syncable=model[field] except pg.FieldError: return ['?field'] if not isinstance(syncable,syncschema.Syncable): return ['here',None,syncable] if syncable.version()>version: # this includes versio...
python
def process_check(pool,model,field,version): "helper for do_check. version is an integer or null. returns ..." try: syncable=model[field] except pg.FieldError: return ['?field'] if not isinstance(syncable,syncschema.Syncable): return ['here',None,syncable] if syncable.version()>version: # this includes versio...
[ "def", "process_check", "(", "pool", ",", "model", ",", "field", ",", "version", ")", ":", "try", ":", "syncable", "=", "model", "[", "field", "]", "except", "pg", ".", "FieldError", ":", "return", "[", "'?field'", "]", "if", "not", "isinstance", "(", ...
helper for do_check. version is an integer or null. returns ...
[ "helper", "for", "do_check", ".", "version", "is", "an", "integer", "or", "null", ".", "returns", "..." ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/syncmessage.py#L88-L97
abe-winter/pg13-py
pg13/syncmessage.py
merge_null_missing
def merge_null_missing(request,name,field,pkeys): "helper for add_missing_children. sets k:None for the field for pkeys not already in request." request.update({rk:None for rk in [FieldKey(name,pkey,field) for pkey in pkeys] if rk not in request})
python
def merge_null_missing(request,name,field,pkeys): "helper for add_missing_children. sets k:None for the field for pkeys not already in request." request.update({rk:None for rk in [FieldKey(name,pkey,field) for pkey in pkeys] if rk not in request})
[ "def", "merge_null_missing", "(", "request", ",", "name", ",", "field", ",", "pkeys", ")", ":", "request", ".", "update", "(", "{", "rk", ":", "None", "for", "rk", "in", "[", "FieldKey", "(", "name", ",", "pkey", ",", "field", ")", "for", "pkey", "...
helper for add_missing_children. sets k:None for the field for pkeys not already in request.
[ "helper", "for", "add_missing_children", ".", "sets", "k", ":", "None", "for", "the", "field", "for", "pkeys", "not", "already", "in", "request", "." ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/syncmessage.py#L98-L100
abe-winter/pg13-py
pg13/syncmessage.py
add_missing_children
def add_missing_children(models,request,include_children_for,modelgb): "helper for do_check. mutates request" for (nombre,pkey),model in models.items(): for modelclass,pkeys in model.refkeys(include_children_for.get(nombre,())).items(): # warning: this is defaulting to all fields of child object. don't gi...
python
def add_missing_children(models,request,include_children_for,modelgb): "helper for do_check. mutates request" for (nombre,pkey),model in models.items(): for modelclass,pkeys in model.refkeys(include_children_for.get(nombre,())).items(): # warning: this is defaulting to all fields of child object. don't gi...
[ "def", "add_missing_children", "(", "models", ",", "request", ",", "include_children_for", ",", "modelgb", ")", ":", "for", "(", "nombre", ",", "pkey", ")", ",", "model", "in", "models", ".", "items", "(", ")", ":", "for", "modelclass", ",", "pkeys", "in...
helper for do_check. mutates request
[ "helper", "for", "do_check", ".", "mutates", "request" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/syncmessage.py#L101-L112
abe-winter/pg13-py
pg13/syncmessage.py
do_check
def do_check(pool,request,models,include_children_for,modelgb): "request is the output of translate_check. models a dict of {(model_name,pkey_tuple):model}.\ ICF is a {model_name:fields_list} for which we want to add nulls in request for missing children. see AMC for how it's used.\ The caller should have gone th...
python
def do_check(pool,request,models,include_children_for,modelgb): "request is the output of translate_check. models a dict of {(model_name,pkey_tuple):model}.\ ICF is a {model_name:fields_list} for which we want to add nulls in request for missing children. see AMC for how it's used.\ The caller should have gone th...
[ "def", "do_check", "(", "pool", ",", "request", ",", "models", ",", "include_children_for", ",", "modelgb", ")", ":", "add_missing_children", "(", "models", ",", "request", ",", "include_children_for", ",", "modelgb", ")", "return", "{", "k", ":", "fkapply", ...
request is the output of translate_check. models a dict of {(model_name,pkey_tuple):model}.\ ICF is a {model_name:fields_list} for which we want to add nulls in request for missing children. see AMC for how it's used.\ The caller should have gone through the same ICF logic when looking up models so the arg has all ...
[ "request", "is", "the", "output", "of", "translate_check", ".", "models", "a", "dict", "of", "{", "(", "model_name", "pkey_tuple", ")", ":", "model", "}", ".", "\\", "ICF", "is", "a", "{", "model_name", ":", "fields_list", "}", "for", "which", "we", "w...
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/syncmessage.py#L113-L119
ScienceLogic/amiuploader
amiimporter/amiupload.py
parse_args
def parse_args(): """ Argument parser and validator """ parser = argparse.ArgumentParser(description="Uploads specified VMDK file to AWS s3 bucket, and converts to AMI") parser.add_argument('-r', '--aws_regions', type=str, nargs='+', required=True, help='list of AWS regions w...
python
def parse_args(): """ Argument parser and validator """ parser = argparse.ArgumentParser(description="Uploads specified VMDK file to AWS s3 bucket, and converts to AMI") parser.add_argument('-r', '--aws_regions', type=str, nargs='+', required=True, help='list of AWS regions w...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Uploads specified VMDK file to AWS s3 bucket, and converts to AMI\"", ")", "parser", ".", "add_argument", "(", "'-r'", ",", "'--aws_regions'", ",", "type", ...
Argument parser and validator
[ "Argument", "parser", "and", "validator" ]
train
https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/amiupload.py#L17-L41
ScienceLogic/amiuploader
amiimporter/amiupload.py
validate_args
def validate_args(args): """ Perform necessary validation checks :param args: :return: """ # print size of vm to be dl, if dl dir exists, check that file to uplad is a vmdk if not os.path.isdir(args.directory): print "Directory {} does not exist".format(args.directory) sys.ex...
python
def validate_args(args): """ Perform necessary validation checks :param args: :return: """ # print size of vm to be dl, if dl dir exists, check that file to uplad is a vmdk if not os.path.isdir(args.directory): print "Directory {} does not exist".format(args.directory) sys.ex...
[ "def", "validate_args", "(", "args", ")", ":", "# print size of vm to be dl, if dl dir exists, check that file to uplad is a vmdk", "if", "not", "os", ".", "path", ".", "isdir", "(", "args", ".", "directory", ")", ":", "print", "\"Directory {} does not exist\"", ".", "f...
Perform necessary validation checks :param args: :return:
[ "Perform", "necessary", "validation", "checks", ":", "param", "args", ":", ":", "return", ":" ]
train
https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/amiupload.py#L44-L66
ScienceLogic/amiuploader
amiimporter/amiupload.py
vmdk_to_ami
def vmdk_to_ami(args): """ Calls methods to perform vmdk import :param args: :return: """ aws_importer = AWSUtilities.AWSUtils(args.directory, args.aws_profile, args.s3_bucket, args.aws_regions, args.ami_name, args.vmdk_upload_file) aws_importer.impor...
python
def vmdk_to_ami(args): """ Calls methods to perform vmdk import :param args: :return: """ aws_importer = AWSUtilities.AWSUtils(args.directory, args.aws_profile, args.s3_bucket, args.aws_regions, args.ami_name, args.vmdk_upload_file) aws_importer.impor...
[ "def", "vmdk_to_ami", "(", "args", ")", ":", "aws_importer", "=", "AWSUtilities", ".", "AWSUtils", "(", "args", ".", "directory", ",", "args", ".", "aws_profile", ",", "args", ".", "s3_bucket", ",", "args", ".", "aws_regions", ",", "args", ".", "ami_name",...
Calls methods to perform vmdk import :param args: :return:
[ "Calls", "methods", "to", "perform", "vmdk", "import", ":", "param", "args", ":", ":", "return", ":" ]
train
https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/amiupload.py#L69-L77
eddiejessup/spatious
spatious/rotation.py
R_rot_2d
def R_rot_2d(th): """Return a 2-dimensional rotation matrix. Parameters ---------- th: array, shape (n, 1) Angles about which to rotate. Returns ------- R: array, shape (n, 2, 2) """ s, = np.sin(th).T c, = np.cos(th).T R = np.empty((len(th), 2, 2), dtype=np.float) ...
python
def R_rot_2d(th): """Return a 2-dimensional rotation matrix. Parameters ---------- th: array, shape (n, 1) Angles about which to rotate. Returns ------- R: array, shape (n, 2, 2) """ s, = np.sin(th).T c, = np.cos(th).T R = np.empty((len(th), 2, 2), dtype=np.float) ...
[ "def", "R_rot_2d", "(", "th", ")", ":", "s", ",", "=", "np", ".", "sin", "(", "th", ")", ".", "T", "c", ",", "=", "np", ".", "cos", "(", "th", ")", ".", "T", "R", "=", "np", ".", "empty", "(", "(", "len", "(", "th", ")", ",", "2", ","...
Return a 2-dimensional rotation matrix. Parameters ---------- th: array, shape (n, 1) Angles about which to rotate. Returns ------- R: array, shape (n, 2, 2)
[ "Return", "a", "2", "-", "dimensional", "rotation", "matrix", "." ]
train
https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/rotation.py#L8-L30
eddiejessup/spatious
spatious/rotation.py
R_rot_3d
def R_rot_3d(th): """Return a 3-dimensional rotation matrix. Parameters ---------- th: array, shape (n, 3) Angles about which to rotate along each axis. Returns ------- R: array, shape (n, 3, 3) """ sx, sy, sz = np.sin(th).T cx, cy, cz = np.cos(th).T R = np.empty((l...
python
def R_rot_3d(th): """Return a 3-dimensional rotation matrix. Parameters ---------- th: array, shape (n, 3) Angles about which to rotate along each axis. Returns ------- R: array, shape (n, 3, 3) """ sx, sy, sz = np.sin(th).T cx, cy, cz = np.cos(th).T R = np.empty((l...
[ "def", "R_rot_3d", "(", "th", ")", ":", "sx", ",", "sy", ",", "sz", "=", "np", ".", "sin", "(", "th", ")", ".", "T", "cx", ",", "cy", ",", "cz", "=", "np", ".", "cos", "(", "th", ")", ".", "T", "R", "=", "np", ".", "empty", "(", "(", ...
Return a 3-dimensional rotation matrix. Parameters ---------- th: array, shape (n, 3) Angles about which to rotate along each axis. Returns ------- R: array, shape (n, 3, 3)
[ "Return", "a", "3", "-", "dimensional", "rotation", "matrix", "." ]
train
https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/rotation.py#L33-L60
eddiejessup/spatious
spatious/rotation.py
R_rot
def R_rot(th): """Return a rotation matrix. Parameters ---------- th: array, shape (n, m) Angles by which to rotate about each m rotational degree of freedom (m=1 in 2 dimensions, m=3 in 3 dimensions). Returns ------- R: array, shape (n, m, m) """ try: dof =...
python
def R_rot(th): """Return a rotation matrix. Parameters ---------- th: array, shape (n, m) Angles by which to rotate about each m rotational degree of freedom (m=1 in 2 dimensions, m=3 in 3 dimensions). Returns ------- R: array, shape (n, m, m) """ try: dof =...
[ "def", "R_rot", "(", "th", ")", ":", "try", ":", "dof", "=", "th", ".", "shape", "[", "-", "1", "]", "# If th is a python float", "except", "AttributeError", ":", "dof", "=", "1", "th", "=", "np", ".", "array", "(", "[", "th", "]", ")", "except", ...
Return a rotation matrix. Parameters ---------- th: array, shape (n, m) Angles by which to rotate about each m rotational degree of freedom (m=1 in 2 dimensions, m=3 in 3 dimensions). Returns ------- R: array, shape (n, m, m)
[ "Return", "a", "rotation", "matrix", "." ]
train
https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/rotation.py#L63-L91
eddiejessup/spatious
spatious/rotation.py
rotate
def rotate(a, th): """Return cartesian vectors, after rotation by specified angles about each degree of freedom. Parameters ---------- a: array, shape (n, d) Input d-dimensional cartesian vectors, left unchanged. th: array, shape (n, m) Angles by which to rotate about each m rot...
python
def rotate(a, th): """Return cartesian vectors, after rotation by specified angles about each degree of freedom. Parameters ---------- a: array, shape (n, d) Input d-dimensional cartesian vectors, left unchanged. th: array, shape (n, m) Angles by which to rotate about each m rot...
[ "def", "rotate", "(", "a", ",", "th", ")", ":", "return", "np", ".", "sum", "(", "a", "[", "...", ",", "np", ".", "newaxis", "]", "*", "R_rot", "(", "th", ")", ",", "axis", "=", "-", "2", ")" ]
Return cartesian vectors, after rotation by specified angles about each degree of freedom. Parameters ---------- a: array, shape (n, d) Input d-dimensional cartesian vectors, left unchanged. th: array, shape (n, m) Angles by which to rotate about each m rotational degree of freedom ...
[ "Return", "cartesian", "vectors", "after", "rotation", "by", "specified", "angles", "about", "each", "degree", "of", "freedom", "." ]
train
https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/rotation.py#L94-L111
westerncapelabs/django-snappy-vumi-bouncer
snappybouncer/actions.py
export_select_fields_csv_action
def export_select_fields_csv_action( description="Export selected objects as CSV file", fields=None, exclude=None, header=True): """ This function returns an export csv action 'fields' is a list of tuples denoting the field and label to be exported. Labels make up the header row of the ...
python
def export_select_fields_csv_action( description="Export selected objects as CSV file", fields=None, exclude=None, header=True): """ This function returns an export csv action 'fields' is a list of tuples denoting the field and label to be exported. Labels make up the header row of the ...
[ "def", "export_select_fields_csv_action", "(", "description", "=", "\"Export selected objects as CSV file\"", ",", "fields", "=", "None", ",", "exclude", "=", "None", ",", "header", "=", "True", ")", ":", "def", "export_as_csv", "(", "modeladmin", ",", "request", ...
This function returns an export csv action 'fields' is a list of tuples denoting the field and label to be exported. Labels make up the header row of the exported file if header=True. fields=[ ('field1', 'label1'), ('field2', 'label2'), ('field3', 'label...
[ "This", "function", "returns", "an", "export", "csv", "action" ]
train
https://github.com/westerncapelabs/django-snappy-vumi-bouncer/blob/5750827020aa83f0f5eecee87a2fe8f19dfaac16/snappybouncer/actions.py#L5-L59
michaelkuty/django-service-templates
django_service_templates/engine.py
JinjaRenderer.render
def render(self, name=None, template=None, context={}): ''''Render Template meta from jinja2 templates. ''' if isinstance(template, Template): _template = template else: _template = Template.objects.get(name=name) # Maybe cache or save local ? r...
python
def render(self, name=None, template=None, context={}): ''''Render Template meta from jinja2 templates. ''' if isinstance(template, Template): _template = template else: _template = Template.objects.get(name=name) # Maybe cache or save local ? r...
[ "def", "render", "(", "self", ",", "name", "=", "None", ",", "template", "=", "None", ",", "context", "=", "{", "}", ")", ":", "if", "isinstance", "(", "template", ",", "Template", ")", ":", "_template", "=", "template", "else", ":", "_template", "="...
Render Template meta from jinja2 templates.
[ "Render", "Template", "meta", "from", "jinja2", "templates", "." ]
train
https://github.com/michaelkuty/django-service-templates/blob/4f85bd812aeac8e01e1031f2118a68b344793118/django_service_templates/engine.py#L11-L25
sci-bots/mpm
mpm/bin/build.py
parse_args
def parse_args(args=None): ''' Parses arguments, returns ``(options, args)``. .. versionchanged:: 0.24.1 Fix handling of optional :data:`args`. ''' if args is None: args = sys.argv[1:] parser = argparse.ArgumentParser(description='MicroDrop plugin ' ...
python
def parse_args(args=None): ''' Parses arguments, returns ``(options, args)``. .. versionchanged:: 0.24.1 Fix handling of optional :data:`args`. ''' if args is None: args = sys.argv[1:] parser = argparse.ArgumentParser(description='MicroDrop plugin ' ...
[ "def", "parse_args", "(", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'MicroDrop plugin '", "'Conda recip...
Parses arguments, returns ``(options, args)``. .. versionchanged:: 0.24.1 Fix handling of optional :data:`args`.
[ "Parses", "arguments", "returns", "(", "options", "args", ")", ".", "..", "versionchanged", "::", "0", ".", "24", ".", "1", "Fix", "handling", "of", "optional", ":", "data", ":", "args", "." ]
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/bin/build.py#L14-L51
sci-bots/mpm
mpm/bin/build.py
build
def build(source_dir, target_dir, package_name=None, version_number=None): ''' Create a release of a MicroDrop plugin source directory in the target directory path. Skip the following patterns: - ``bld.bat`` - ``.conda-recipe/*`` - ``.git/*`` .. versionchanged:: 0.24.1 ...
python
def build(source_dir, target_dir, package_name=None, version_number=None): ''' Create a release of a MicroDrop plugin source directory in the target directory path. Skip the following patterns: - ``bld.bat`` - ``.conda-recipe/*`` - ``.git/*`` .. versionchanged:: 0.24.1 ...
[ "def", "build", "(", "source_dir", ",", "target_dir", ",", "package_name", "=", "None", ",", "version_number", "=", "None", ")", ":", "source_dir", "=", "ph", ".", "path", "(", "source_dir", ")", ".", "realpath", "(", ")", "target_dir", "=", "ph", ".", ...
Create a release of a MicroDrop plugin source directory in the target directory path. Skip the following patterns: - ``bld.bat`` - ``.conda-recipe/*`` - ``.git/*`` .. versionchanged:: 0.24.1 Remove temporary archive after extraction. Change directory into sourc...
[ "Create", "a", "release", "of", "a", "MicroDrop", "plugin", "source", "directory", "in", "the", "target", "directory", "path", ".", "Skip", "the", "following", "patterns", ":", "-", "bld", ".", "bat", "-", ".", "conda", "-", "recipe", "/", "*", "-", "....
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/bin/build.py#L54-L147
townsenddw/jhubctl
jhubctl/hubs/single.py
Hub.get
def get(self): """Get specific information about this hub.""" output = helm("get", self.release) if output.returncode != 0: print("Something went wrong!") print(output.stderr) else: print(output.stdout)
python
def get(self): """Get specific information about this hub.""" output = helm("get", self.release) if output.returncode != 0: print("Something went wrong!") print(output.stderr) else: print(output.stdout)
[ "def", "get", "(", "self", ")", ":", "output", "=", "helm", "(", "\"get\"", ",", "self", ".", "release", ")", "if", "output", ".", "returncode", "!=", "0", ":", "print", "(", "\"Something went wrong!\"", ")", "print", "(", "output", ".", "stderr", ")",...
Get specific information about this hub.
[ "Get", "specific", "information", "about", "this", "hub", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/hubs/single.py#L52-L59
townsenddw/jhubctl
jhubctl/hubs/single.py
Hub.create
def create(self): """Create a single instance of notebook.""" # Point to chart repo. out = helm( "repo", "add", "jupyterhub", self.helm_repo ) out = helm("repo", "update") # Get token to secure Jupyterhub secret_yam...
python
def create(self): """Create a single instance of notebook.""" # Point to chart repo. out = helm( "repo", "add", "jupyterhub", self.helm_repo ) out = helm("repo", "update") # Get token to secure Jupyterhub secret_yam...
[ "def", "create", "(", "self", ")", ":", "# Point to chart repo.", "out", "=", "helm", "(", "\"repo\"", ",", "\"add\"", ",", "\"jupyterhub\"", ",", "self", ".", "helm_repo", ")", "out", "=", "helm", "(", "\"repo\"", ",", "\"update\"", ")", "# Get token to sec...
Create a single instance of notebook.
[ "Create", "a", "single", "instance", "of", "notebook", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/hubs/single.py#L61-L88
townsenddw/jhubctl
jhubctl/hubs/single.py
Hub.delete
def delete(self): """Delete a Jupyterhub.""" # Delete the Helm Release out = helm( "delete", self.release, "--purge" ) if out.returncode != 0: print(out.stderr) else: print(out.stdout) # Delete the Kuber...
python
def delete(self): """Delete a Jupyterhub.""" # Delete the Helm Release out = helm( "delete", self.release, "--purge" ) if out.returncode != 0: print(out.stderr) else: print(out.stdout) # Delete the Kuber...
[ "def", "delete", "(", "self", ")", ":", "# Delete the Helm Release", "out", "=", "helm", "(", "\"delete\"", ",", "self", ".", "release", ",", "\"--purge\"", ")", "if", "out", ".", "returncode", "!=", "0", ":", "print", "(", "out", ".", "stderr", ")", "...
Delete a Jupyterhub.
[ "Delete", "a", "Jupyterhub", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/hubs/single.py#L90-L112
townsenddw/jhubctl
jhubctl/hubs/single.py
Hub._parse_description
def _parse_description(self, description_text): """Turn description to dictionary.""" text = description_text text = text.strip() lines = text.split('\n') data = {} for line in lines: if ":" in line: idx = line.index(":") key =...
python
def _parse_description(self, description_text): """Turn description to dictionary.""" text = description_text text = text.strip() lines = text.split('\n') data = {} for line in lines: if ":" in line: idx = line.index(":") key =...
[ "def", "_parse_description", "(", "self", ",", "description_text", ")", ":", "text", "=", "description_text", "text", "=", "text", ".", "strip", "(", ")", "lines", "=", "text", ".", "split", "(", "'\\n'", ")", "data", "=", "{", "}", "for", "line", "in"...
Turn description to dictionary.
[ "Turn", "description", "to", "dictionary", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/hubs/single.py#L125-L143
townsenddw/jhubctl
jhubctl/hubs/single.py
Hub.get_description
def get_description(self): """Get description (as dictionary)""" message = self._get_description_message() data = self._parse_description(message) return data
python
def get_description(self): """Get description (as dictionary)""" message = self._get_description_message() data = self._parse_description(message) return data
[ "def", "get_description", "(", "self", ")", ":", "message", "=", "self", ".", "_get_description_message", "(", ")", "data", "=", "self", ".", "_parse_description", "(", "message", ")", "return", "data" ]
Get description (as dictionary)
[ "Get", "description", "(", "as", "dictionary", ")" ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/hubs/single.py#L145-L149
geertj/looping
lib/looping/winsocketpair.py
socketpair
def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): """Emulate the Unix socketpair() function on Windows.""" # We create a connected TCP socket. Note the trick with setblocking(0) # that prevents us from having to create a thread. lsock = socket.socket(family, type, proto) lsock...
python
def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): """Emulate the Unix socketpair() function on Windows.""" # We create a connected TCP socket. Note the trick with setblocking(0) # that prevents us from having to create a thread. lsock = socket.socket(family, type, proto) lsock...
[ "def", "socketpair", "(", "family", "=", "socket", ".", "AF_INET", ",", "type", "=", "socket", ".", "SOCK_STREAM", ",", "proto", "=", "0", ")", ":", "# We create a connected TCP socket. Note the trick with setblocking(0)", "# that prevents us from having to create a thread....
Emulate the Unix socketpair() function on Windows.
[ "Emulate", "the", "Unix", "socketpair", "()", "function", "on", "Windows", "." ]
train
https://github.com/geertj/looping/blob/b60303714685aede18b37c0d80f8f55175ad7a65/lib/looping/winsocketpair.py#L18-L38
keithhackbarth/clowder_python_client
clowder.py
_validate_data
def _validate_data(data): """Validates the given data and raises an error if any non-allowed keys are provided or any required keys are missing. :param data: Data to send to API :type data: dict """ data_keys = set(data.keys()) extra_keys = data_keys - set(ALLOWED_KEYS) missing_keys = s...
python
def _validate_data(data): """Validates the given data and raises an error if any non-allowed keys are provided or any required keys are missing. :param data: Data to send to API :type data: dict """ data_keys = set(data.keys()) extra_keys = data_keys - set(ALLOWED_KEYS) missing_keys = s...
[ "def", "_validate_data", "(", "data", ")", ":", "data_keys", "=", "set", "(", "data", ".", "keys", "(", ")", ")", "extra_keys", "=", "data_keys", "-", "set", "(", "ALLOWED_KEYS", ")", "missing_keys", "=", "set", "(", "REQUIRED_KEYS", ")", "-", "data_keys...
Validates the given data and raises an error if any non-allowed keys are provided or any required keys are missing. :param data: Data to send to API :type data: dict
[ "Validates", "the", "given", "data", "and", "raises", "an", "error", "if", "any", "non", "-", "allowed", "keys", "are", "provided", "or", "any", "required", "keys", "are", "missing", "." ]
train
https://github.com/keithhackbarth/clowder_python_client/blob/ebe91dd348e347461fc6a244ca45bb41d767a5be/clowder.py#L22-L41
keithhackbarth/clowder_python_client
clowder.py
_send
def _send(data): """Send data to the Clowder API. :param data: Dictionary of API data :type data: dict """ url = data.get('url', CLOWDER_API_URL) _validate_data(data) if api_key is not None: data['api_key'] = api_key if 'value' not in data: data['value'] = data.get('s...
python
def _send(data): """Send data to the Clowder API. :param data: Dictionary of API data :type data: dict """ url = data.get('url', CLOWDER_API_URL) _validate_data(data) if api_key is not None: data['api_key'] = api_key if 'value' not in data: data['value'] = data.get('s...
[ "def", "_send", "(", "data", ")", ":", "url", "=", "data", ".", "get", "(", "'url'", ",", "CLOWDER_API_URL", ")", "_validate_data", "(", "data", ")", "if", "api_key", "is", "not", "None", ":", "data", "[", "'api_key'", "]", "=", "api_key", "if", "'va...
Send data to the Clowder API. :param data: Dictionary of API data :type data: dict
[ "Send", "data", "to", "the", "Clowder", "API", "." ]
train
https://github.com/keithhackbarth/clowder_python_client/blob/ebe91dd348e347461fc6a244ca45bb41d767a5be/clowder.py#L44-L75
keithhackbarth/clowder_python_client
clowder.py
submit
def submit(**kwargs): """Shortcut that takes an alert to evaluate and makes the appropriate API call based on the results. :param kwargs: A list of keyword arguments :type kwargs: dict """ if 'alert' not in kwargs: raise ValueError('Alert required') if 'value' not in kwargs: ...
python
def submit(**kwargs): """Shortcut that takes an alert to evaluate and makes the appropriate API call based on the results. :param kwargs: A list of keyword arguments :type kwargs: dict """ if 'alert' not in kwargs: raise ValueError('Alert required') if 'value' not in kwargs: ...
[ "def", "submit", "(", "*", "*", "kwargs", ")", ":", "if", "'alert'", "not", "in", "kwargs", ":", "raise", "ValueError", "(", "'Alert required'", ")", "if", "'value'", "not", "in", "kwargs", ":", "raise", "ValueError", "(", "'Value required'", ")", "alert",...
Shortcut that takes an alert to evaluate and makes the appropriate API call based on the results. :param kwargs: A list of keyword arguments :type kwargs: dict
[ "Shortcut", "that", "takes", "an", "alert", "to", "evaluate", "and", "makes", "the", "appropriate", "API", "call", "based", "on", "the", "results", "." ]
train
https://github.com/keithhackbarth/clowder_python_client/blob/ebe91dd348e347461fc6a244ca45bb41d767a5be/clowder.py#L120-L139
keithhackbarth/clowder_python_client
clowder.py
_clean_frequency
def _clean_frequency(frequency): """Converts a frequency value to an integer. Raises an error if an invalid type is given. :param frequency: A frequency :type frequency: int or datetime.timedelta :rtype: int """ if isinstance(frequency, int): return frequency elif isinstance(fre...
python
def _clean_frequency(frequency): """Converts a frequency value to an integer. Raises an error if an invalid type is given. :param frequency: A frequency :type frequency: int or datetime.timedelta :rtype: int """ if isinstance(frequency, int): return frequency elif isinstance(fre...
[ "def", "_clean_frequency", "(", "frequency", ")", ":", "if", "isinstance", "(", "frequency", ",", "int", ")", ":", "return", "frequency", "elif", "isinstance", "(", "frequency", ",", "datetime", ".", "timedelta", ")", ":", "return", "int", "(", "frequency", ...
Converts a frequency value to an integer. Raises an error if an invalid type is given. :param frequency: A frequency :type frequency: int or datetime.timedelta :rtype: int
[ "Converts", "a", "frequency", "value", "to", "an", "integer", ".", "Raises", "an", "error", "if", "an", "invalid", "type", "is", "given", "." ]
train
https://github.com/keithhackbarth/clowder_python_client/blob/ebe91dd348e347461fc6a244ca45bb41d767a5be/clowder.py#L142-L155
emencia/emencia_paste_djangocms_3
emencia_paste_djangocms_3/django_buildout/project/utils/file_fields.py
content_file_name
def content_file_name(upload_to_path, instance, filename=None, new_extension=None): """ Méthode à utiliser pour l'attribut "upload_to" d'un FileField/ImageField pour renommer automatiquement le nom de fichier avec un nom unique et empêcher la conservation de fichier avec des caractères spéciaux. ...
python
def content_file_name(upload_to_path, instance, filename=None, new_extension=None): """ Méthode à utiliser pour l'attribut "upload_to" d'un FileField/ImageField pour renommer automatiquement le nom de fichier avec un nom unique et empêcher la conservation de fichier avec des caractères spéciaux. ...
[ "def", "content_file_name", "(", "upload_to_path", ",", "instance", ",", "filename", "=", "None", ",", "new_extension", "=", "None", ")", ":", "upload_to", "=", "real_datetime", ".", "now", "(", ")", ".", "strftime", "(", "upload_to_path", ")", "if", "not", ...
Méthode à utiliser pour l'attribut "upload_to" d'un FileField/ImageField pour renommer automatiquement le nom de fichier avec un nom unique et empêcher la conservation de fichier avec des caractères spéciaux. À ne pas utiliser directement sur l'attribut "FileField.upload_to" mais via un callable...
[ "Méthode", "à", "utiliser", "pour", "l", "attribut", "upload_to", "d", "un", "FileField", "/", "ImageField", "pour", "renommer", "automatiquement", "le", "nom", "de", "fichier", "avec", "un", "nom", "unique", "et", "empêcher", "la", "conservation", "de", "fich...
train
https://github.com/emencia/emencia_paste_djangocms_3/blob/29eabbcb17e21996a6e1d99592fc719dc8833b59/emencia_paste_djangocms_3/django_buildout/project/utils/file_fields.py#L12-L33
emencia/emencia_paste_djangocms_3
emencia_paste_djangocms_3/django_buildout/project/utils/file_fields.py
get_unique_filename
def get_unique_filename(filename, new_filename=None, new_extension=None): """ Génère un nouveau nom pour un fichier en gardant son extension Soit le nouveau nom est généré à partir de la date (heures+minutes+secondes+microsecondes) soit un nouveau nom est spécifié et on l'utilise tel quel. ...
python
def get_unique_filename(filename, new_filename=None, new_extension=None): """ Génère un nouveau nom pour un fichier en gardant son extension Soit le nouveau nom est généré à partir de la date (heures+minutes+secondes+microsecondes) soit un nouveau nom est spécifié et on l'utilise tel quel. ...
[ "def", "get_unique_filename", "(", "filename", ",", "new_filename", "=", "None", ",", "new_extension", "=", "None", ")", ":", "if", "new_extension", ":", "extension", "=", "new_extension", "else", ":", "extension", "=", "splitext", "(", "filename", ")", "[", ...
Génère un nouveau nom pour un fichier en gardant son extension Soit le nouveau nom est généré à partir de la date (heures+minutes+secondes+microsecondes) soit un nouveau nom est spécifié et on l'utilise tel quel. :type filename: string :param filename: Nom du fichier original :t...
[ "Génère", "un", "nouveau", "nom", "pour", "un", "fichier", "en", "gardant", "son", "extension", "Soit", "le", "nouveau", "nom", "est", "généré", "à", "partir", "de", "la", "date", "(", "heures", "+", "minutes", "+", "secondes", "+", "microsecondes", ")", ...
train
https://github.com/emencia/emencia_paste_djangocms_3/blob/29eabbcb17e21996a6e1d99592fc719dc8833b59/emencia_paste_djangocms_3/django_buildout/project/utils/file_fields.py#L35-L66
emencia/emencia_paste_djangocms_3
emencia_paste_djangocms_3/django_buildout/project/utils/file_fields.py
generate_valid_path
def generate_valid_path(filename, path, create_it=True, root_base=settings.MEDIA_ROOT, permissions=settings.FILE_UPLOAD_PERMISSIONS): """ Génére le chemin prévu pour un fichier et créé le chemin si besoin :type filename: string :param filename: Nom du fichier cible :type path: string :...
python
def generate_valid_path(filename, path, create_it=True, root_base=settings.MEDIA_ROOT, permissions=settings.FILE_UPLOAD_PERMISSIONS): """ Génére le chemin prévu pour un fichier et créé le chemin si besoin :type filename: string :param filename: Nom du fichier cible :type path: string :...
[ "def", "generate_valid_path", "(", "filename", ",", "path", ",", "create_it", "=", "True", ",", "root_base", "=", "settings", ".", "MEDIA_ROOT", ",", "permissions", "=", "settings", ".", "FILE_UPLOAD_PERMISSIONS", ")", ":", "if", "not", "permissions", ":", "pe...
Génére le chemin prévu pour un fichier et créé le chemin si besoin :type filename: string :param filename: Nom du fichier cible :type path: string :param path: Chemin relatif (au répertoire des médias, ``settings.MEDIA_ROOT``) du répertoire contenant le fichier, peut contenir...
[ "Génére", "le", "chemin", "prévu", "pour", "un", "fichier", "et", "créé", "le", "chemin", "si", "besoin", ":", "type", "filename", ":", "string", ":", "param", "filename", ":", "Nom", "du", "fichier", "cible", ":", "type", "path", ":", "string", ":", "...
train
https://github.com/emencia/emencia_paste_djangocms_3/blob/29eabbcb17e21996a6e1d99592fc719dc8833b59/emencia_paste_djangocms_3/django_buildout/project/utils/file_fields.py#L68-L111
fedora-infra/fmn.rules
fmn/rules/koschei.py
koschei_group
def koschei_group(config, message, group=None): """ Particular Koschei package groups This rule limits message to particular `Koschei <https://apps.fedoraproject.org/koschei/>`_ groups. You can specify more groups separated by commas. """ if not group or 'koschei' not in message['topic']: ...
python
def koschei_group(config, message, group=None): """ Particular Koschei package groups This rule limits message to particular `Koschei <https://apps.fedoraproject.org/koschei/>`_ groups. You can specify more groups separated by commas. """ if not group or 'koschei' not in message['topic']: ...
[ "def", "koschei_group", "(", "config", ",", "message", ",", "group", "=", "None", ")", ":", "if", "not", "group", "or", "'koschei'", "not", "in", "message", "[", "'topic'", "]", ":", "return", "False", "groups", "=", "set", "(", "[", "item", ".", "st...
Particular Koschei package groups This rule limits message to particular `Koschei <https://apps.fedoraproject.org/koschei/>`_ groups. You can specify more groups separated by commas.
[ "Particular", "Koschei", "package", "groups" ]
train
https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/koschei.py#L15-L25
naphatkrit/easyci
easyci/commands/init.py
init
def init(ctx): """Initialize the project for use with EasyCI. This installs the necessary git hooks (pre-commit + pre-push) and add a config file if one does not already exists. """ # install hooks git = ctx.obj['vcs'] click.echo("Installing hooks...", nl=False) for old in ['commit-msg']...
python
def init(ctx): """Initialize the project for use with EasyCI. This installs the necessary git hooks (pre-commit + pre-push) and add a config file if one does not already exists. """ # install hooks git = ctx.obj['vcs'] click.echo("Installing hooks...", nl=False) for old in ['commit-msg']...
[ "def", "init", "(", "ctx", ")", ":", "# install hooks", "git", "=", "ctx", ".", "obj", "[", "'vcs'", "]", "click", ".", "echo", "(", "\"Installing hooks...\"", ",", "nl", "=", "False", ")", "for", "old", "in", "[", "'commit-msg'", "]", ":", "path", "...
Initialize the project for use with EasyCI. This installs the necessary git hooks (pre-commit + pre-push) and add a config file if one does not already exists.
[ "Initialize", "the", "project", "for", "use", "with", "EasyCI", ".", "This", "installs", "the", "necessary", "git", "hooks", "(", "pre", "-", "commit", "+", "pre", "-", "push", ")", "and", "add", "a", "config", "file", "if", "one", "does", "not", "alre...
train
https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/commands/init.py#L16-L47
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
Requester.on_start
def on_start(self): """ start requester """ LOGGER.debug("rabbitmq.Requester.on_start") if not self.fire_and_forget: self.channel.basic_consume(self.on_response, no_ack=True, queue=self.callback_queue)
python
def on_start(self): """ start requester """ LOGGER.debug("rabbitmq.Requester.on_start") if not self.fire_and_forget: self.channel.basic_consume(self.on_response, no_ack=True, queue=self.callback_queue)
[ "def", "on_start", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Requester.on_start\"", ")", "if", "not", "self", ".", "fire_and_forget", ":", "self", ".", "channel", ".", "basic_consume", "(", "self", ".", "on_response", ",", "no_ack", "="...
start requester
[ "start", "requester" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L97-L104