repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
trevisanj/f311
f311/filetypes/datafile.py
DataFile.init_default
def init_default(self): """ Initializes object with its default values Tries to load self.default_filename from default data directory. For safety, filename is reset to None so that it doesn't point to the original file. """ import f311 if self.default_fi...
python
def init_default(self): """ Initializes object with its default values Tries to load self.default_filename from default data directory. For safety, filename is reset to None so that it doesn't point to the original file. """ import f311 if self.default_fi...
[ "def", "init_default", "(", "self", ")", ":", "import", "f311", "if", "self", ".", "default_filename", "is", "None", ":", "raise", "RuntimeError", "(", "\"Class '{}' has no default filename\"", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ")", ...
Initializes object with its default values Tries to load self.default_filename from default data directory. For safety, filename is reset to None so that it doesn't point to the original file.
[ "Initializes", "object", "with", "its", "default", "values" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/datafile.py#L100-L113
train
56,500
tradenity/python-sdk
tradenity/resources/product.py
Product.availability
def availability(self, availability): """Sets the availability of this Product. :param availability: The availability of this Product. :type: str """ allowed_values = ["available", "comingSoon", "retired"] if availability is not None and availability not in allowed_valu...
python
def availability(self, availability): """Sets the availability of this Product. :param availability: The availability of this Product. :type: str """ allowed_values = ["available", "comingSoon", "retired"] if availability is not None and availability not in allowed_valu...
[ "def", "availability", "(", "self", ",", "availability", ")", ":", "allowed_values", "=", "[", "\"available\"", ",", "\"comingSoon\"", ",", "\"retired\"", "]", "if", "availability", "is", "not", "None", "and", "availability", "not", "in", "allowed_values", ":", ...
Sets the availability of this Product. :param availability: The availability of this Product. :type: str
[ "Sets", "the", "availability", "of", "this", "Product", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/product.py#L716-L730
train
56,501
tradenity/python-sdk
tradenity/resources/product.py
Product.stock_status
def stock_status(self, stock_status): """Sets the stock_status of this Product. :param stock_status: The stock_status of this Product. :type: str """ allowed_values = ["available", "alert", "unavailable"] if stock_status is not None and stock_status not in allowed_value...
python
def stock_status(self, stock_status): """Sets the stock_status of this Product. :param stock_status: The stock_status of this Product. :type: str """ allowed_values = ["available", "alert", "unavailable"] if stock_status is not None and stock_status not in allowed_value...
[ "def", "stock_status", "(", "self", ",", "stock_status", ")", ":", "allowed_values", "=", "[", "\"available\"", ",", "\"alert\"", ",", "\"unavailable\"", "]", "if", "stock_status", "is", "not", "None", "and", "stock_status", "not", "in", "allowed_values", ":", ...
Sets the stock_status of this Product. :param stock_status: The stock_status of this Product. :type: str
[ "Sets", "the", "stock_status", "of", "this", "Product", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/product.py#L911-L925
train
56,502
CodyKochmann/generators
generators/inline_tools.py
asserts
def asserts(input_value, rule, message=''): """ this function allows you to write asserts in generators since there are moments where you actually want the program to halt when certain values are seen. """ assert callable(rule) or type(rule)==bool, 'asserts needs rule to be a callable functi...
python
def asserts(input_value, rule, message=''): """ this function allows you to write asserts in generators since there are moments where you actually want the program to halt when certain values are seen. """ assert callable(rule) or type(rule)==bool, 'asserts needs rule to be a callable functi...
[ "def", "asserts", "(", "input_value", ",", "rule", ",", "message", "=", "''", ")", ":", "assert", "callable", "(", "rule", ")", "or", "type", "(", "rule", ")", "==", "bool", ",", "'asserts needs rule to be a callable function or a test boolean'", "assert", "isin...
this function allows you to write asserts in generators since there are moments where you actually want the program to halt when certain values are seen.
[ "this", "function", "allows", "you", "to", "write", "asserts", "in", "generators", "since", "there", "are", "moments", "where", "you", "actually", "want", "the", "program", "to", "halt", "when", "certain", "values", "are", "seen", "." ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/inline_tools.py#L14-L33
train
56,503
CodyKochmann/generators
generators/inline_tools.py
print
def print(*a): """ print just one that returns what you give it instead of None """ try: _print(*a) return a[0] if len(a) == 1 else a except: _print(*a)
python
def print(*a): """ print just one that returns what you give it instead of None """ try: _print(*a) return a[0] if len(a) == 1 else a except: _print(*a)
[ "def", "print", "(", "*", "a", ")", ":", "try", ":", "_print", "(", "*", "a", ")", "return", "a", "[", "0", "]", "if", "len", "(", "a", ")", "==", "1", "else", "a", "except", ":", "_print", "(", "*", "a", ")" ]
print just one that returns what you give it instead of None
[ "print", "just", "one", "that", "returns", "what", "you", "give", "it", "instead", "of", "None" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/inline_tools.py#L38-L44
train
56,504
remram44/rpaths
rpaths.py
pattern2re
def pattern2re(pattern): """Makes a unicode regular expression from a pattern. Returns ``(start, full_re, int_re)`` where: * `start` is either empty or the subdirectory in which to start searching, * `full_re` is a regular expression object that matches the requested files, i.e. a translation...
python
def pattern2re(pattern): """Makes a unicode regular expression from a pattern. Returns ``(start, full_re, int_re)`` where: * `start` is either empty or the subdirectory in which to start searching, * `full_re` is a regular expression object that matches the requested files, i.e. a translation...
[ "def", "pattern2re", "(", "pattern", ")", ":", "pattern_segs", "=", "filter", "(", "None", ",", "pattern", ".", "split", "(", "'/'", ")", ")", "# This anchors the first component either at the start of the string or at", "# the start of a path component", "if", "not", "...
Makes a unicode regular expression from a pattern. Returns ``(start, full_re, int_re)`` where: * `start` is either empty or the subdirectory in which to start searching, * `full_re` is a regular expression object that matches the requested files, i.e. a translation of the pattern * `int_re` ...
[ "Makes", "a", "unicode", "regular", "expression", "from", "a", "pattern", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L1133-L1210
train
56,505
remram44/rpaths
rpaths.py
AbstractPath._to_backend
def _to_backend(self, p): """Converts something to the correct path representation. If given a Path, this will simply unpack it, if it's the correct type. If given the correct backend, it will return that. If given bytes for unicode of unicode for bytes, it will encode/decode wi...
python
def _to_backend(self, p): """Converts something to the correct path representation. If given a Path, this will simply unpack it, if it's the correct type. If given the correct backend, it will return that. If given bytes for unicode of unicode for bytes, it will encode/decode wi...
[ "def", "_to_backend", "(", "self", ",", "p", ")", ":", "if", "isinstance", "(", "p", ",", "self", ".", "_cmp_base", ")", ":", "return", "p", ".", "path", "elif", "isinstance", "(", "p", ",", "self", ".", "_backend", ")", ":", "return", "p", "elif",...
Converts something to the correct path representation. If given a Path, this will simply unpack it, if it's the correct type. If given the correct backend, it will return that. If given bytes for unicode of unicode for bytes, it will encode/decode with a reasonable encoding. Note that t...
[ "Converts", "something", "to", "the", "correct", "path", "representation", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L70-L90
train
56,506
remram44/rpaths
rpaths.py
AbstractPath.parent
def parent(self): """The parent directory of this path. """ p = self._lib.dirname(self.path) p = self.__class__(p) return p
python
def parent(self): """The parent directory of this path. """ p = self._lib.dirname(self.path) p = self.__class__(p) return p
[ "def", "parent", "(", "self", ")", ":", "p", "=", "self", ".", "_lib", ".", "dirname", "(", "self", ".", "path", ")", "p", "=", "self", ".", "__class__", "(", "p", ")", "return", "p" ]
The parent directory of this path.
[ "The", "parent", "directory", "of", "this", "path", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L275-L280
train
56,507
remram44/rpaths
rpaths.py
AbstractPath.unicodename
def unicodename(self): """The name of this path as unicode. """ n = self._lib.basename(self.path) if self._backend is unicode: return n else: return n.decode(self._encoding, 'replace')
python
def unicodename(self): """The name of this path as unicode. """ n = self._lib.basename(self.path) if self._backend is unicode: return n else: return n.decode(self._encoding, 'replace')
[ "def", "unicodename", "(", "self", ")", ":", "n", "=", "self", ".", "_lib", ".", "basename", "(", "self", ".", "path", ")", "if", "self", ".", "_backend", "is", "unicode", ":", "return", "n", "else", ":", "return", "n", ".", "decode", "(", "self", ...
The name of this path as unicode.
[ "The", "name", "of", "this", "path", "as", "unicode", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L289-L296
train
56,508
remram44/rpaths
rpaths.py
AbstractPath.rel_path_to
def rel_path_to(self, dest): """Builds a relative path leading from this one to the given `dest`. Note that these paths might be both relative, in which case they'll be assumed to start from the same directory. """ dest = self.__class__(dest) orig_list = self.norm_case(...
python
def rel_path_to(self, dest): """Builds a relative path leading from this one to the given `dest`. Note that these paths might be both relative, in which case they'll be assumed to start from the same directory. """ dest = self.__class__(dest) orig_list = self.norm_case(...
[ "def", "rel_path_to", "(", "self", ",", "dest", ")", ":", "dest", "=", "self", ".", "__class__", "(", "dest", ")", "orig_list", "=", "self", ".", "norm_case", "(", ")", ".", "_components", "(", ")", "dest_list", "=", "dest", ".", "_components", "(", ...
Builds a relative path leading from this one to the given `dest`. Note that these paths might be both relative, in which case they'll be assumed to start from the same directory.
[ "Builds", "a", "relative", "path", "leading", "from", "this", "one", "to", "the", "given", "dest", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L380-L404
train
56,509
remram44/rpaths
rpaths.py
AbstractPath.lies_under
def lies_under(self, prefix): """Indicates if the `prefix` is a parent of this path. """ orig_list = self.norm_case()._components() pref_list = self.__class__(prefix).norm_case()._components() return (len(orig_list) >= len(pref_list) and orig_list[:len(pref_list)...
python
def lies_under(self, prefix): """Indicates if the `prefix` is a parent of this path. """ orig_list = self.norm_case()._components() pref_list = self.__class__(prefix).norm_case()._components() return (len(orig_list) >= len(pref_list) and orig_list[:len(pref_list)...
[ "def", "lies_under", "(", "self", ",", "prefix", ")", ":", "orig_list", "=", "self", ".", "norm_case", "(", ")", ".", "_components", "(", ")", "pref_list", "=", "self", ".", "__class__", "(", "prefix", ")", ".", "norm_case", "(", ")", ".", "_components...
Indicates if the `prefix` is a parent of this path.
[ "Indicates", "if", "the", "prefix", "is", "a", "parent", "of", "this", "path", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L406-L413
train
56,510
remram44/rpaths
rpaths.py
Path.tempfile
def tempfile(cls, suffix='', prefix=None, dir=None, text=False): """Returns a new temporary file. The return value is a pair (fd, path) where fd is the file descriptor returned by :func:`os.open`, and path is a :class:`~rpaths.Path` to it. :param suffix: If specified, the file name wil...
python
def tempfile(cls, suffix='', prefix=None, dir=None, text=False): """Returns a new temporary file. The return value is a pair (fd, path) where fd is the file descriptor returned by :func:`os.open`, and path is a :class:`~rpaths.Path` to it. :param suffix: If specified, the file name wil...
[ "def", "tempfile", "(", "cls", ",", "suffix", "=", "''", ",", "prefix", "=", "None", ",", "dir", "=", "None", ",", "text", "=", "False", ")", ":", "if", "prefix", "is", "None", ":", "prefix", "=", "tempfile", ".", "template", "if", "dir", "is", "...
Returns a new temporary file. The return value is a pair (fd, path) where fd is the file descriptor returned by :func:`os.open`, and path is a :class:`~rpaths.Path` to it. :param suffix: If specified, the file name will end with that suffix, otherwise there will be no suffix. ...
[ "Returns", "a", "new", "temporary", "file", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L498-L531
train
56,511
remram44/rpaths
rpaths.py
Path.tempdir
def tempdir(cls, suffix='', prefix=None, dir=None): """Returns a new temporary directory. Arguments are as for :meth:`~rpaths.Path.tempfile`, except that the `text` argument is not accepted. The directory is readable, writable, and searchable only by the creating user. ...
python
def tempdir(cls, suffix='', prefix=None, dir=None): """Returns a new temporary directory. Arguments are as for :meth:`~rpaths.Path.tempfile`, except that the `text` argument is not accepted. The directory is readable, writable, and searchable only by the creating user. ...
[ "def", "tempdir", "(", "cls", ",", "suffix", "=", "''", ",", "prefix", "=", "None", ",", "dir", "=", "None", ")", ":", "if", "prefix", "is", "None", ":", "prefix", "=", "tempfile", ".", "template", "if", "dir", "is", "not", "None", ":", "# Note tha...
Returns a new temporary directory. Arguments are as for :meth:`~rpaths.Path.tempfile`, except that the `text` argument is not accepted. The directory is readable, writable, and searchable only by the creating user. The caller is responsible for deleting the directory when done...
[ "Returns", "a", "new", "temporary", "directory", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L534-L552
train
56,512
remram44/rpaths
rpaths.py
Path.rel_path_to
def rel_path_to(self, dest): """Builds a relative path leading from this one to another. Note that these paths might be both relative, in which case they'll be assumed to be considered starting from the same directory. Contrary to :class:`~rpaths.AbstractPath`'s version, this will also...
python
def rel_path_to(self, dest): """Builds a relative path leading from this one to another. Note that these paths might be both relative, in which case they'll be assumed to be considered starting from the same directory. Contrary to :class:`~rpaths.AbstractPath`'s version, this will also...
[ "def", "rel_path_to", "(", "self", ",", "dest", ")", ":", "return", "super", "(", "Path", ",", "self", ".", "absolute", "(", ")", ")", ".", "rel_path_to", "(", "Path", "(", "dest", ")", ".", "absolute", "(", ")", ")" ]
Builds a relative path leading from this one to another. Note that these paths might be both relative, in which case they'll be assumed to be considered starting from the same directory. Contrary to :class:`~rpaths.AbstractPath`'s version, this will also work if one path is relative an...
[ "Builds", "a", "relative", "path", "leading", "from", "this", "one", "to", "another", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L559-L568
train
56,513
remram44/rpaths
rpaths.py
Path.listdir
def listdir(self, pattern=None): """Returns a list of all the files in this directory. The special entries ``'.'`` and ``'..'`` will not be returned. :param pattern: A pattern to match directory entries against. :type pattern: NoneType | Callable | Pattern | unicode | bytes """...
python
def listdir(self, pattern=None): """Returns a list of all the files in this directory. The special entries ``'.'`` and ``'..'`` will not be returned. :param pattern: A pattern to match directory entries against. :type pattern: NoneType | Callable | Pattern | unicode | bytes """...
[ "def", "listdir", "(", "self", ",", "pattern", "=", "None", ")", ":", "files", "=", "[", "self", "/", "self", ".", "__class__", "(", "p", ")", "for", "p", "in", "os", ".", "listdir", "(", "self", ".", "path", ")", "]", "if", "pattern", "is", "N...
Returns a list of all the files in this directory. The special entries ``'.'`` and ``'..'`` will not be returned. :param pattern: A pattern to match directory entries against. :type pattern: NoneType | Callable | Pattern | unicode | bytes
[ "Returns", "a", "list", "of", "all", "the", "files", "in", "this", "directory", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L582-L611
train
56,514
remram44/rpaths
rpaths.py
Path.recursedir
def recursedir(self, pattern=None, top_down=True, follow_links=False, handle_errors=None): """Recursively lists all files under this directory. :param pattern: An extended patterns, where: * a slash '/' always represents the path separator * a backslash '\' e...
python
def recursedir(self, pattern=None, top_down=True, follow_links=False, handle_errors=None): """Recursively lists all files under this directory. :param pattern: An extended patterns, where: * a slash '/' always represents the path separator * a backslash '\' e...
[ "def", "recursedir", "(", "self", ",", "pattern", "=", "None", ",", "top_down", "=", "True", ",", "follow_links", "=", "False", ",", "handle_errors", "=", "None", ")", ":", "if", "not", "self", ".", "is_dir", "(", ")", ":", "raise", "ValueError", "(", ...
Recursively lists all files under this directory. :param pattern: An extended patterns, where: * a slash '/' always represents the path separator * a backslash '\' escapes other special characters * an initial slash '/' anchors the match at the beginning of the ...
[ "Recursively", "lists", "all", "files", "under", "this", "directory", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L613-L684
train
56,515
remram44/rpaths
rpaths.py
Path.mkdir
def mkdir(self, name=None, parents=False, mode=0o777): """Creates that directory, or a directory under this one. ``path.mkdir(name)`` is a shortcut for ``(path/name).mkdir()``. :param name: Path component to append to this path before creating the directory. :param parents...
python
def mkdir(self, name=None, parents=False, mode=0o777): """Creates that directory, or a directory under this one. ``path.mkdir(name)`` is a shortcut for ``(path/name).mkdir()``. :param name: Path component to append to this path before creating the directory. :param parents...
[ "def", "mkdir", "(", "self", ",", "name", "=", "None", ",", "parents", "=", "False", ",", "mode", "=", "0o777", ")", ":", "if", "name", "is", "not", "None", ":", "return", "(", "self", "/", "name", ")", ".", "mkdir", "(", "parents", "=", "parents...
Creates that directory, or a directory under this one. ``path.mkdir(name)`` is a shortcut for ``(path/name).mkdir()``. :param name: Path component to append to this path before creating the directory. :param parents: If True, missing directories leading to the path will ...
[ "Creates", "that", "directory", "or", "a", "directory", "under", "this", "one", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L811-L834
train
56,516
remram44/rpaths
rpaths.py
Path.rmdir
def rmdir(self, parents=False): """Removes this directory, provided it is empty. Use :func:`~rpaths.Path.rmtree` if it might still contain files. :param parents: If set to True, it will also destroy every empty directory above it until an error is encountered. """ i...
python
def rmdir(self, parents=False): """Removes this directory, provided it is empty. Use :func:`~rpaths.Path.rmtree` if it might still contain files. :param parents: If set to True, it will also destroy every empty directory above it until an error is encountered. """ i...
[ "def", "rmdir", "(", "self", ",", "parents", "=", "False", ")", ":", "if", "parents", ":", "os", ".", "removedirs", "(", "self", ".", "path", ")", "else", ":", "os", ".", "rmdir", "(", "self", ".", "path", ")" ]
Removes this directory, provided it is empty. Use :func:`~rpaths.Path.rmtree` if it might still contain files. :param parents: If set to True, it will also destroy every empty directory above it until an error is encountered.
[ "Removes", "this", "directory", "provided", "it", "is", "empty", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L836-L847
train
56,517
remram44/rpaths
rpaths.py
Path.rename
def rename(self, new, parents=False): """Renames this path to the given new location. :param new: New path where to move this one. :param parents: If set to True, it will create the parent directories of the target if they don't exist. """ if parents: os...
python
def rename(self, new, parents=False): """Renames this path to the given new location. :param new: New path where to move this one. :param parents: If set to True, it will create the parent directories of the target if they don't exist. """ if parents: os...
[ "def", "rename", "(", "self", ",", "new", ",", "parents", "=", "False", ")", ":", "if", "parents", ":", "os", ".", "renames", "(", "self", ".", "path", ",", "self", ".", "_to_backend", "(", "new", ")", ")", "else", ":", "os", ".", "rename", "(", ...
Renames this path to the given new location. :param new: New path where to move this one. :param parents: If set to True, it will create the parent directories of the target if they don't exist.
[ "Renames", "this", "path", "to", "the", "given", "new", "location", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L854-L865
train
56,518
remram44/rpaths
rpaths.py
Path.copyfile
def copyfile(self, target): """Copies this file to the given `target` location. """ shutil.copyfile(self.path, self._to_backend(target))
python
def copyfile(self, target): """Copies this file to the given `target` location. """ shutil.copyfile(self.path, self._to_backend(target))
[ "def", "copyfile", "(", "self", ",", "target", ")", ":", "shutil", ".", "copyfile", "(", "self", ".", "path", ",", "self", ".", "_to_backend", "(", "target", ")", ")" ]
Copies this file to the given `target` location.
[ "Copies", "this", "file", "to", "the", "given", "target", "location", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L891-L894
train
56,519
remram44/rpaths
rpaths.py
Path.copymode
def copymode(self, target): """Copies the mode of this file on the `target` file. The owner is not copied. """ shutil.copymode(self.path, self._to_backend(target))
python
def copymode(self, target): """Copies the mode of this file on the `target` file. The owner is not copied. """ shutil.copymode(self.path, self._to_backend(target))
[ "def", "copymode", "(", "self", ",", "target", ")", ":", "shutil", ".", "copymode", "(", "self", ".", "path", ",", "self", ".", "_to_backend", "(", "target", ")", ")" ]
Copies the mode of this file on the `target` file. The owner is not copied.
[ "Copies", "the", "mode", "of", "this", "file", "on", "the", "target", "file", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L896-L901
train
56,520
remram44/rpaths
rpaths.py
Path.copystat
def copystat(self, target): """Copies the permissions, times and flags from this to the `target`. The owner is not copied. """ shutil.copystat(self.path, self._to_backend(target))
python
def copystat(self, target): """Copies the permissions, times and flags from this to the `target`. The owner is not copied. """ shutil.copystat(self.path, self._to_backend(target))
[ "def", "copystat", "(", "self", ",", "target", ")", ":", "shutil", ".", "copystat", "(", "self", ".", "path", ",", "self", ".", "_to_backend", "(", "target", ")", ")" ]
Copies the permissions, times and flags from this to the `target`. The owner is not copied.
[ "Copies", "the", "permissions", "times", "and", "flags", "from", "this", "to", "the", "target", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L903-L908
train
56,521
remram44/rpaths
rpaths.py
Path.copy
def copy(self, target): """Copies this file the `target`, which might be a directory. The permissions are copied. """ shutil.copy(self.path, self._to_backend(target))
python
def copy(self, target): """Copies this file the `target`, which might be a directory. The permissions are copied. """ shutil.copy(self.path, self._to_backend(target))
[ "def", "copy", "(", "self", ",", "target", ")", ":", "shutil", ".", "copy", "(", "self", ".", "path", ",", "self", ".", "_to_backend", "(", "target", ")", ")" ]
Copies this file the `target`, which might be a directory. The permissions are copied.
[ "Copies", "this", "file", "the", "target", "which", "might", "be", "a", "directory", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L910-L915
train
56,522
remram44/rpaths
rpaths.py
Path.copytree
def copytree(self, target, symlinks=False): """Recursively copies this directory to the `target` location. The permissions and times are copied (like :meth:`~rpaths.Path.copystat`). If the optional `symlinks` flag is true, symbolic links in the source tree result in symbolic li...
python
def copytree(self, target, symlinks=False): """Recursively copies this directory to the `target` location. The permissions and times are copied (like :meth:`~rpaths.Path.copystat`). If the optional `symlinks` flag is true, symbolic links in the source tree result in symbolic li...
[ "def", "copytree", "(", "self", ",", "target", ",", "symlinks", "=", "False", ")", ":", "shutil", ".", "copytree", "(", "self", ".", "path", ",", "self", ".", "_to_backend", "(", "target", ")", ",", "symlinks", ")" ]
Recursively copies this directory to the `target` location. The permissions and times are copied (like :meth:`~rpaths.Path.copystat`). If the optional `symlinks` flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, th...
[ "Recursively", "copies", "this", "directory", "to", "the", "target", "location", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L917-L927
train
56,523
remram44/rpaths
rpaths.py
Path.move
def move(self, target): """Recursively moves a file or directory to the given target location. """ shutil.move(self.path, self._to_backend(target))
python
def move(self, target): """Recursively moves a file or directory to the given target location. """ shutil.move(self.path, self._to_backend(target))
[ "def", "move", "(", "self", ",", "target", ")", ":", "shutil", ".", "move", "(", "self", ".", "path", ",", "self", ".", "_to_backend", "(", "target", ")", ")" ]
Recursively moves a file or directory to the given target location.
[ "Recursively", "moves", "a", "file", "or", "directory", "to", "the", "given", "target", "location", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L937-L940
train
56,524
remram44/rpaths
rpaths.py
Path.open
def open(self, mode='r', name=None, **kwargs): """Opens this file, or a file under this directory. ``path.open(mode, name)`` is a shortcut for ``(path/name).open(mode)``. Note that this uses :func:`io.open()` which behaves differently from :func:`open()` on Python 2; see the appropriat...
python
def open(self, mode='r', name=None, **kwargs): """Opens this file, or a file under this directory. ``path.open(mode, name)`` is a shortcut for ``(path/name).open(mode)``. Note that this uses :func:`io.open()` which behaves differently from :func:`open()` on Python 2; see the appropriat...
[ "def", "open", "(", "self", ",", "mode", "=", "'r'", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "name", "is", "not", "None", ":", "return", "io", ".", "open", "(", "(", "self", "/", "name", ")", ".", "path", ",", "mode...
Opens this file, or a file under this directory. ``path.open(mode, name)`` is a shortcut for ``(path/name).open(mode)``. Note that this uses :func:`io.open()` which behaves differently from :func:`open()` on Python 2; see the appropriate documentation. :param name: Path component to a...
[ "Opens", "this", "file", "or", "a", "file", "under", "this", "directory", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L942-L956
train
56,525
remram44/rpaths
rpaths.py
Path.rewrite
def rewrite(self, mode='r', name=None, temp=None, tempext='~', **kwargs): r"""Replaces this file with new content. This context manager gives you two file objects, (r, w), where r is readable and has the current content of the file, and w is writable and will replace the file at the end...
python
def rewrite(self, mode='r', name=None, temp=None, tempext='~', **kwargs): r"""Replaces this file with new content. This context manager gives you two file objects, (r, w), where r is readable and has the current content of the file, and w is writable and will replace the file at the end...
[ "def", "rewrite", "(", "self", ",", "mode", "=", "'r'", ",", "name", "=", "None", ",", "temp", "=", "None", ",", "tempext", "=", "'~'", ",", "*", "*", "kwargs", ")", ":", "if", "name", "is", "not", "None", ":", "pathr", "=", "self", "/", "name"...
r"""Replaces this file with new content. This context manager gives you two file objects, (r, w), where r is readable and has the current content of the file, and w is writable and will replace the file at the end of the context (unless an exception is raised, in which case it is rolled...
[ "r", "Replaces", "this", "file", "with", "new", "content", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L959-L1026
train
56,526
remram44/rpaths
rpaths.py
Pattern.matches
def matches(self, path): """Tests if the given path matches the pattern. Note that the unicode translation of the patch is matched, so replacement characters might have been added. """ path = self._prepare_path(path) return self.full_regex.search(path) is not None
python
def matches(self, path): """Tests if the given path matches the pattern. Note that the unicode translation of the patch is matched, so replacement characters might have been added. """ path = self._prepare_path(path) return self.full_regex.search(path) is not None
[ "def", "matches", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_prepare_path", "(", "path", ")", "return", "self", ".", "full_regex", ".", "search", "(", "path", ")", "is", "not", "None" ]
Tests if the given path matches the pattern. Note that the unicode translation of the patch is matched, so replacement characters might have been added.
[ "Tests", "if", "the", "given", "path", "matches", "the", "pattern", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L1078-L1085
train
56,527
remram44/rpaths
rpaths.py
Pattern.may_contain_matches
def may_contain_matches(self, path): """Tests whether it's possible for paths under the given one to match. If this method returns None, no path under the given one will match the pattern. """ path = self._prepare_path(path) return self.int_regex.search(path) is not None
python
def may_contain_matches(self, path): """Tests whether it's possible for paths under the given one to match. If this method returns None, no path under the given one will match the pattern. """ path = self._prepare_path(path) return self.int_regex.search(path) is not None
[ "def", "may_contain_matches", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_prepare_path", "(", "path", ")", "return", "self", ".", "int_regex", ".", "search", "(", "path", ")", "is", "not", "None" ]
Tests whether it's possible for paths under the given one to match. If this method returns None, no path under the given one will match the pattern.
[ "Tests", "whether", "it", "s", "possible", "for", "paths", "under", "the", "given", "one", "to", "match", "." ]
e4ff55d985c4d643d9fd214539d45af39ae5a7cd
https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L1087-L1094
train
56,528
micha030201/aionationstates
aionationstates/nation_.py
Nation.tgcanrecruit
def tgcanrecruit(self, region=None): """Whether the nation will receive a recruitment telegram. Useful in conjunction with the Telegrams API. Parameters ---------- region : str Name of the region you are recruiting for. Returns ------- an :c...
python
def tgcanrecruit(self, region=None): """Whether the nation will receive a recruitment telegram. Useful in conjunction with the Telegrams API. Parameters ---------- region : str Name of the region you are recruiting for. Returns ------- an :c...
[ "def", "tgcanrecruit", "(", "self", ",", "region", "=", "None", ")", ":", "params", "=", "{", "'from'", ":", "normalize", "(", "region", ")", "}", "if", "region", "is", "not", "None", "else", "{", "}", "@", "api_query", "(", "'tgcanrecruit'", ",", "*...
Whether the nation will receive a recruitment telegram. Useful in conjunction with the Telegrams API. Parameters ---------- region : str Name of the region you are recruiting for. Returns ------- an :class:`ApiQuery` of bool
[ "Whether", "the", "nation", "will", "receive", "a", "recruitment", "telegram", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L460-L478
train
56,529
micha030201/aionationstates
aionationstates/nation_.py
Nation.govt
async def govt(self, root): """Nation's government expenditure, as percentages. Returns ------- an :class:`ApiQuery` of :class:`collections.OrderedDict` with \ keys of str and values of float Keys being, in order: ``Administration``, ``Defense``, ``Educat...
python
async def govt(self, root): """Nation's government expenditure, as percentages. Returns ------- an :class:`ApiQuery` of :class:`collections.OrderedDict` with \ keys of str and values of float Keys being, in order: ``Administration``, ``Defense``, ``Educat...
[ "async", "def", "govt", "(", "self", ",", "root", ")", ":", "elem", "=", "root", ".", "find", "(", "'GOVT'", ")", "result", "=", "OrderedDict", "(", ")", "result", "[", "'Administration'", "]", "=", "float", "(", "elem", ".", "find", "(", "'ADMINISTR...
Nation's government expenditure, as percentages. Returns ------- an :class:`ApiQuery` of :class:`collections.OrderedDict` with \ keys of str and values of float Keys being, in order: ``Administration``, ``Defense``, ``Education``, ``Environment``, ``Healthcare``,...
[ "Nation", "s", "government", "expenditure", "as", "percentages", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L522-L549
train
56,530
micha030201/aionationstates
aionationstates/nation_.py
Nation.sectors
async def sectors(self, root): """Components of the nation's economy, as percentages. Returns ------- an :class:`ApiQuery` of :class:`collections.OrderedDict` with \ keys of str and values of float Keys being, in order: ``Black Market (estimated)``, ``Government``, ...
python
async def sectors(self, root): """Components of the nation's economy, as percentages. Returns ------- an :class:`ApiQuery` of :class:`collections.OrderedDict` with \ keys of str and values of float Keys being, in order: ``Black Market (estimated)``, ``Government``, ...
[ "async", "def", "sectors", "(", "self", ",", "root", ")", ":", "elem", "=", "root", ".", "find", "(", "'SECTORS'", ")", "result", "=", "OrderedDict", "(", ")", "result", "[", "'Black Market (estimated)'", "]", "=", "float", "(", "elem", ".", "find", "(...
Components of the nation's economy, as percentages. Returns ------- an :class:`ApiQuery` of :class:`collections.OrderedDict` with \ keys of str and values of float Keys being, in order: ``Black Market (estimated)``, ``Government``, ``Private Industry``, and ``Sta...
[ "Components", "of", "the", "nation", "s", "economy", "as", "percentages", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L552-L569
train
56,531
micha030201/aionationstates
aionationstates/nation_.py
Nation.deaths
async def deaths(self, root): """Causes of death in the nation, as percentages. Returns ------- an :class:`ApiQuery` of dict with keys of str and values of float """ return { elem.get('type'): float(elem.text) for elem in root.find('DEATHS') ...
python
async def deaths(self, root): """Causes of death in the nation, as percentages. Returns ------- an :class:`ApiQuery` of dict with keys of str and values of float """ return { elem.get('type'): float(elem.text) for elem in root.find('DEATHS') ...
[ "async", "def", "deaths", "(", "self", ",", "root", ")", ":", "return", "{", "elem", ".", "get", "(", "'type'", ")", ":", "float", "(", "elem", ".", "text", ")", "for", "elem", "in", "root", ".", "find", "(", "'DEATHS'", ")", "}" ]
Causes of death in the nation, as percentages. Returns ------- an :class:`ApiQuery` of dict with keys of str and values of float
[ "Causes", "of", "death", "in", "the", "nation", "as", "percentages", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L572-L582
train
56,532
micha030201/aionationstates
aionationstates/nation_.py
Nation.endorsements
async def endorsements(self, root): """Regional neighbours endorsing the nation. Returns ------- an :class:`ApiQuery` of a list of :class:`Nation` """ text = root.find('ENDORSEMENTS').text return [Nation(name) for name in text.split(',')] if text else []
python
async def endorsements(self, root): """Regional neighbours endorsing the nation. Returns ------- an :class:`ApiQuery` of a list of :class:`Nation` """ text = root.find('ENDORSEMENTS').text return [Nation(name) for name in text.split(',')] if text else []
[ "async", "def", "endorsements", "(", "self", ",", "root", ")", ":", "text", "=", "root", ".", "find", "(", "'ENDORSEMENTS'", ")", ".", "text", "return", "[", "Nation", "(", "name", ")", "for", "name", "in", "text", ".", "split", "(", "','", ")", "]...
Regional neighbours endorsing the nation. Returns ------- an :class:`ApiQuery` of a list of :class:`Nation`
[ "Regional", "neighbours", "endorsing", "the", "nation", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L585-L593
train
56,533
micha030201/aionationstates
aionationstates/nation_.py
Nation.description
async def description(self): """Nation's full description, as seen on its in-game page. Returns ------- an awaitable of str """ resp = await self._call_web(f'nation={self.id}') return html.unescape( re.search( '<div class="nationsummar...
python
async def description(self): """Nation's full description, as seen on its in-game page. Returns ------- an awaitable of str """ resp = await self._call_web(f'nation={self.id}') return html.unescape( re.search( '<div class="nationsummar...
[ "async", "def", "description", "(", "self", ")", ":", "resp", "=", "await", "self", ".", "_call_web", "(", "f'nation={self.id}'", ")", "return", "html", ".", "unescape", "(", "re", ".", "search", "(", "'<div class=\"nationsummary\">(.+?)<p class=\"nationranktext\">'...
Nation's full description, as seen on its in-game page. Returns ------- an awaitable of str
[ "Nation", "s", "full", "description", "as", "seen", "on", "its", "in", "-", "game", "page", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L716-L735
train
56,534
micha030201/aionationstates
aionationstates/nation_.py
IssueOption.accept
def accept(self): """Accept the option. Returns ------- an awaitable of :class:`IssueResult` """ return self._issue._nation._accept_issue(self._issue.id, self._id)
python
def accept(self): """Accept the option. Returns ------- an awaitable of :class:`IssueResult` """ return self._issue._nation._accept_issue(self._issue.id, self._id)
[ "def", "accept", "(", "self", ")", ":", "return", "self", ".", "_issue", ".", "_nation", ".", "_accept_issue", "(", "self", ".", "_issue", ".", "id", ",", "self", ".", "_id", ")" ]
Accept the option. Returns ------- an awaitable of :class:`IssueResult`
[ "Accept", "the", "option", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/nation_.py#L867-L874
train
56,535
stephanh42/ipython_pip_magics
ipython_pip_magics/__init__.py
pip_upgrade_all
def pip_upgrade_all(line): """Attempt to upgrade all packages""" from pip import get_installed_distributions user = set(d.project_name for d in get_installed_distributions(user_only=True)) all = set(d.project_name for d in get_installed_distributions()) for dist in all - user: do_pip(["insta...
python
def pip_upgrade_all(line): """Attempt to upgrade all packages""" from pip import get_installed_distributions user = set(d.project_name for d in get_installed_distributions(user_only=True)) all = set(d.project_name for d in get_installed_distributions()) for dist in all - user: do_pip(["insta...
[ "def", "pip_upgrade_all", "(", "line", ")", ":", "from", "pip", "import", "get_installed_distributions", "user", "=", "set", "(", "d", ".", "project_name", "for", "d", "in", "get_installed_distributions", "(", "user_only", "=", "True", ")", ")", "all", "=", ...
Attempt to upgrade all packages
[ "Attempt", "to", "upgrade", "all", "packages" ]
4a56db4414dff4456158c53d9050a84e926f8b57
https://github.com/stephanh42/ipython_pip_magics/blob/4a56db4414dff4456158c53d9050a84e926f8b57/ipython_pip_magics/__init__.py#L32-L40
train
56,536
trevisanj/a99
a99/gui/xmisc.py
enc_name_descr
def enc_name_descr(name, descr, color=a99.COLOR_DESCR): """Encodes html given name and description.""" return enc_name(name, color)+"<br>"+descr
python
def enc_name_descr(name, descr, color=a99.COLOR_DESCR): """Encodes html given name and description.""" return enc_name(name, color)+"<br>"+descr
[ "def", "enc_name_descr", "(", "name", ",", "descr", ",", "color", "=", "a99", ".", "COLOR_DESCR", ")", ":", "return", "enc_name", "(", "name", ",", "color", ")", "+", "\"<br>\"", "+", "descr" ]
Encodes html given name and description.
[ "Encodes", "html", "given", "name", "and", "description", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L47-L49
train
56,537
trevisanj/a99
a99/gui/xmisc.py
style_checkboxes
def style_checkboxes(widget): """ Iterates over widget children to change checkboxes stylesheet. The default rendering of checkboxes does not allow to tell a focused one from an unfocused one. """ ww = widget.findChildren(QCheckBox) for w in ww: w.setStyleSheet("QCheckBox...
python
def style_checkboxes(widget): """ Iterates over widget children to change checkboxes stylesheet. The default rendering of checkboxes does not allow to tell a focused one from an unfocused one. """ ww = widget.findChildren(QCheckBox) for w in ww: w.setStyleSheet("QCheckBox...
[ "def", "style_checkboxes", "(", "widget", ")", ":", "ww", "=", "widget", ".", "findChildren", "(", "QCheckBox", ")", "for", "w", "in", "ww", ":", "w", ".", "setStyleSheet", "(", "\"QCheckBox:focus {border: 1px solid #000000;}\"", ")" ]
Iterates over widget children to change checkboxes stylesheet. The default rendering of checkboxes does not allow to tell a focused one from an unfocused one.
[ "Iterates", "over", "widget", "children", "to", "change", "checkboxes", "stylesheet", ".", "The", "default", "rendering", "of", "checkboxes", "does", "not", "allow", "to", "tell", "a", "focused", "one", "from", "an", "unfocused", "one", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L57-L67
train
56,538
trevisanj/a99
a99/gui/xmisc.py
reset_table_widget
def reset_table_widget(t, rowCount, colCount): """Clears and resizes a table widget.""" t.reset() t.horizontalHeader().reset() t.clear() t.sortItems(-1) t.setRowCount(rowCount) t.setColumnCount(colCount)
python
def reset_table_widget(t, rowCount, colCount): """Clears and resizes a table widget.""" t.reset() t.horizontalHeader().reset() t.clear() t.sortItems(-1) t.setRowCount(rowCount) t.setColumnCount(colCount)
[ "def", "reset_table_widget", "(", "t", ",", "rowCount", ",", "colCount", ")", ":", "t", ".", "reset", "(", ")", "t", ".", "horizontalHeader", "(", ")", ".", "reset", "(", ")", "t", ".", "clear", "(", ")", "t", ".", "sortItems", "(", "-", "1", ")"...
Clears and resizes a table widget.
[ "Clears", "and", "resizes", "a", "table", "widget", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L127-L134
train
56,539
trevisanj/a99
a99/gui/xmisc.py
place_center
def place_center(window, width=None, height=None): """Places window in the center of the screen.""" screenGeometry = QApplication.desktop().screenGeometry() w, h = window.width(), window.height() if width is not None or height is not None: w = width if width is not None else w ...
python
def place_center(window, width=None, height=None): """Places window in the center of the screen.""" screenGeometry = QApplication.desktop().screenGeometry() w, h = window.width(), window.height() if width is not None or height is not None: w = width if width is not None else w ...
[ "def", "place_center", "(", "window", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "screenGeometry", "=", "QApplication", ".", "desktop", "(", ")", ".", "screenGeometry", "(", ")", "w", ",", "h", "=", "window", ".", "width", "(", ...
Places window in the center of the screen.
[ "Places", "window", "in", "the", "center", "of", "the", "screen", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L201-L214
train
56,540
trevisanj/a99
a99/gui/xmisc.py
get_QApplication
def get_QApplication(args=[]): """Returns the QApplication instance, creating it is does not yet exist.""" global _qapp if _qapp is None: QCoreApplication.setAttribute(Qt.AA_X11InitThreads) _qapp = QApplication(args) return _qapp
python
def get_QApplication(args=[]): """Returns the QApplication instance, creating it is does not yet exist.""" global _qapp if _qapp is None: QCoreApplication.setAttribute(Qt.AA_X11InitThreads) _qapp = QApplication(args) return _qapp
[ "def", "get_QApplication", "(", "args", "=", "[", "]", ")", ":", "global", "_qapp", "if", "_qapp", "is", "None", ":", "QCoreApplication", ".", "setAttribute", "(", "Qt", ".", "AA_X11InitThreads", ")", "_qapp", "=", "QApplication", "(", "args", ")", "return...
Returns the QApplication instance, creating it is does not yet exist.
[ "Returns", "the", "QApplication", "instance", "creating", "it", "is", "does", "not", "yet", "exist", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L324-L331
train
56,541
trevisanj/a99
a99/gui/xmisc.py
get_frame
def get_frame(): """Returns a QFrame formatted in a particular way""" ret = QFrame() ret.setLineWidth(1) ret.setMidLineWidth(0) ret.setFrameShadow(QFrame.Sunken) ret.setFrameShape(QFrame.Box) return ret
python
def get_frame(): """Returns a QFrame formatted in a particular way""" ret = QFrame() ret.setLineWidth(1) ret.setMidLineWidth(0) ret.setFrameShadow(QFrame.Sunken) ret.setFrameShape(QFrame.Box) return ret
[ "def", "get_frame", "(", ")", ":", "ret", "=", "QFrame", "(", ")", "ret", ".", "setLineWidth", "(", "1", ")", "ret", ".", "setMidLineWidth", "(", "0", ")", "ret", ".", "setFrameShadow", "(", "QFrame", ".", "Sunken", ")", "ret", ".", "setFrameShape", ...
Returns a QFrame formatted in a particular way
[ "Returns", "a", "QFrame", "formatted", "in", "a", "particular", "way" ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L549-L556
train
56,542
trevisanj/a99
a99/gui/xmisc.py
SignalProxy.add_signal
def add_signal(self, signal): """Adds "input" signal to connected signals. Internally connects the signal to a control slot.""" self.__signals.append(signal) if self.__connected: # Connects signal if the current state is "connected" self.__connect_signal(sig...
python
def add_signal(self, signal): """Adds "input" signal to connected signals. Internally connects the signal to a control slot.""" self.__signals.append(signal) if self.__connected: # Connects signal if the current state is "connected" self.__connect_signal(sig...
[ "def", "add_signal", "(", "self", ",", "signal", ")", ":", "self", ".", "__signals", ".", "append", "(", "signal", ")", "if", "self", ".", "__connected", ":", "# Connects signal if the current state is \"connected\"\r", "self", ".", "__connect_signal", "(", "signa...
Adds "input" signal to connected signals. Internally connects the signal to a control slot.
[ "Adds", "input", "signal", "to", "connected", "signals", ".", "Internally", "connects", "the", "signal", "to", "a", "control", "slot", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L424-L430
train
56,543
trevisanj/a99
a99/gui/xmisc.py
SignalProxy.disconnect_all
def disconnect_all(self): """Disconnects all signals and slots. If already in "disconnected" state, ignores the call. """ if not self.__connected: return # assert self.__connected, "disconnect_all() already in \"disconnected\" state" self.__disconnecting = Tr...
python
def disconnect_all(self): """Disconnects all signals and slots. If already in "disconnected" state, ignores the call. """ if not self.__connected: return # assert self.__connected, "disconnect_all() already in \"disconnected\" state" self.__disconnecting = Tr...
[ "def", "disconnect_all", "(", "self", ")", ":", "if", "not", "self", ".", "__connected", ":", "return", "# assert self.__connected, \"disconnect_all() already in \\\"disconnected\\\" state\"\r", "self", ".", "__disconnecting", "=", "True", "try", ":", "for", "signal", "...
Disconnects all signals and slots. If already in "disconnected" state, ignores the call.
[ "Disconnects", "all", "signals", "and", "slots", ".", "If", "already", "in", "disconnected", "state", "ignores", "the", "call", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L446-L461
train
56,544
trevisanj/a99
a99/gui/xmisc.py
SignalProxy.__signalReceived
def __signalReceived(self, *args): """Received signal. Cancel previous timer and store args to be forwarded later.""" if self.__disconnecting: return with self.__lock: self.__args = args if self.__rateLimit == 0: self.__timer.stop() ...
python
def __signalReceived(self, *args): """Received signal. Cancel previous timer and store args to be forwarded later.""" if self.__disconnecting: return with self.__lock: self.__args = args if self.__rateLimit == 0: self.__timer.stop() ...
[ "def", "__signalReceived", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "__disconnecting", ":", "return", "with", "self", ".", "__lock", ":", "self", ".", "__args", "=", "args", "if", "self", ".", "__rateLimit", "==", "0", ":", "self", ...
Received signal. Cancel previous timer and store args to be forwarded later.
[ "Received", "signal", ".", "Cancel", "previous", "timer", "and", "store", "args", "to", "be", "forwarded", "later", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L463-L483
train
56,545
trevisanj/a99
a99/gui/xmisc.py
SignalProxy.__flush
def __flush(self): """If there is a signal queued up, send it now.""" if self.__args is None or self.__disconnecting: return False #self.emit(self.signal, *self.args) self.__sigDelayed.emit(self.__args) self.__args = None self.__timer.stop() se...
python
def __flush(self): """If there is a signal queued up, send it now.""" if self.__args is None or self.__disconnecting: return False #self.emit(self.signal, *self.args) self.__sigDelayed.emit(self.__args) self.__args = None self.__timer.stop() se...
[ "def", "__flush", "(", "self", ")", ":", "if", "self", ".", "__args", "is", "None", "or", "self", ".", "__disconnecting", ":", "return", "False", "#self.emit(self.signal, *self.args)\r", "self", ".", "__sigDelayed", ".", "emit", "(", "self", ".", "__args", "...
If there is a signal queued up, send it now.
[ "If", "there", "is", "a", "signal", "queued", "up", "send", "it", "now", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L485-L494
train
56,546
blockadeio/analyst_toolbench
blockade/common/utils.py
clean_indicators
def clean_indicators(indicators): """Remove any extra details from indicators.""" output = list() for indicator in indicators: strip = ['http://', 'https://'] for item in strip: indicator = indicator.replace(item, '') indicator = indicator.strip('.').strip() parts...
python
def clean_indicators(indicators): """Remove any extra details from indicators.""" output = list() for indicator in indicators: strip = ['http://', 'https://'] for item in strip: indicator = indicator.replace(item, '') indicator = indicator.strip('.').strip() parts...
[ "def", "clean_indicators", "(", "indicators", ")", ":", "output", "=", "list", "(", ")", "for", "indicator", "in", "indicators", ":", "strip", "=", "[", "'http://'", ",", "'https://'", "]", "for", "item", "in", "strip", ":", "indicator", "=", "indicator", ...
Remove any extra details from indicators.
[ "Remove", "any", "extra", "details", "from", "indicators", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L4-L17
train
56,547
blockadeio/analyst_toolbench
blockade/common/utils.py
hash_values
def hash_values(values, alg="md5"): """Hash a list of values.""" import hashlib if alg not in ['md5', 'sha1', 'sha256']: raise Exception("Invalid hashing algorithm!") hasher = getattr(hashlib, alg) if type(values) == str: output = hasher(values).hexdigest() elif type(values) == ...
python
def hash_values(values, alg="md5"): """Hash a list of values.""" import hashlib if alg not in ['md5', 'sha1', 'sha256']: raise Exception("Invalid hashing algorithm!") hasher = getattr(hashlib, alg) if type(values) == str: output = hasher(values).hexdigest() elif type(values) == ...
[ "def", "hash_values", "(", "values", ",", "alg", "=", "\"md5\"", ")", ":", "import", "hashlib", "if", "alg", "not", "in", "[", "'md5'", ",", "'sha1'", ",", "'sha256'", "]", ":", "raise", "Exception", "(", "\"Invalid hashing algorithm!\"", ")", "hasher", "=...
Hash a list of values.
[ "Hash", "a", "list", "of", "values", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L26-L39
train
56,548
blockadeio/analyst_toolbench
blockade/common/utils.py
check_whitelist
def check_whitelist(values): """Check the indicators against known whitelists.""" import os import tldextract whitelisted = list() for name in ['alexa.txt', 'cisco.txt']: config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, name) whitel...
python
def check_whitelist(values): """Check the indicators against known whitelists.""" import os import tldextract whitelisted = list() for name in ['alexa.txt', 'cisco.txt']: config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, name) whitel...
[ "def", "check_whitelist", "(", "values", ")", ":", "import", "os", "import", "tldextract", "whitelisted", "=", "list", "(", ")", "for", "name", "in", "[", "'alexa.txt'", ",", "'cisco.txt'", "]", ":", "config_path", "=", "os", ".", "path", ".", "expanduser"...
Check the indicators against known whitelists.
[ "Check", "the", "indicators", "against", "known", "whitelists", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L42-L57
train
56,549
blockadeio/analyst_toolbench
blockade/common/utils.py
cache_items
def cache_items(values): """Cache indicators that were successfully sent to avoid dups.""" import os config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, 'cache.txt') if not os.path.isfile(file_path): file(file_path, 'w').close() written = [x.strip...
python
def cache_items(values): """Cache indicators that were successfully sent to avoid dups.""" import os config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, 'cache.txt') if not os.path.isfile(file_path): file(file_path, 'w').close() written = [x.strip...
[ "def", "cache_items", "(", "values", ")", ":", "import", "os", "config_path", "=", "os", ".", "path", ".", "expanduser", "(", "'~/.config/blockade'", ")", "file_path", "=", "os", ".", "path", ".", "join", "(", "config_path", ",", "'cache.txt'", ")", "if", ...
Cache indicators that were successfully sent to avoid dups.
[ "Cache", "indicators", "that", "were", "successfully", "sent", "to", "avoid", "dups", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L60-L81
train
56,550
blockadeio/analyst_toolbench
blockade/common/utils.py
prune_cached
def prune_cached(values): """Remove the items that have already been cached.""" import os config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, 'cache.txt') if not os.path.isfile(file_path): return values cached = [x.strip() for x in open(file_path,...
python
def prune_cached(values): """Remove the items that have already been cached.""" import os config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, 'cache.txt') if not os.path.isfile(file_path): return values cached = [x.strip() for x in open(file_path,...
[ "def", "prune_cached", "(", "values", ")", ":", "import", "os", "config_path", "=", "os", ".", "path", ".", "expanduser", "(", "'~/.config/blockade'", ")", "file_path", "=", "os", ".", "path", ".", "join", "(", "config_path", ",", "'cache.txt'", ")", "if",...
Remove the items that have already been cached.
[ "Remove", "the", "items", "that", "have", "already", "been", "cached", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L84-L98
train
56,551
blockadeio/analyst_toolbench
blockade/common/utils.py
get_logger
def get_logger(name): """Get a logging instance we can use.""" import logging import sys logger = logging.getLogger(name) logger.setLevel(logging.DEBUG) shandler = logging.StreamHandler(sys.stdout) fmt = "" fmt += '\033[1;32m%(levelname)-5s %(module)s:%(funcName)s():' fmt += '%(linen...
python
def get_logger(name): """Get a logging instance we can use.""" import logging import sys logger = logging.getLogger(name) logger.setLevel(logging.DEBUG) shandler = logging.StreamHandler(sys.stdout) fmt = "" fmt += '\033[1;32m%(levelname)-5s %(module)s:%(funcName)s():' fmt += '%(linen...
[ "def", "get_logger", "(", "name", ")", ":", "import", "logging", "import", "sys", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "shandler", "=", "logging", ".", "StreamHandler", ...
Get a logging instance we can use.
[ "Get", "a", "logging", "instance", "we", "can", "use", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L101-L114
train
56,552
blockadeio/analyst_toolbench
blockade/common/utils.py
process_whitelists
def process_whitelists(): """Download approved top 1M lists.""" import csv import grequests import os import StringIO import zipfile mapping = { 'http://s3.amazonaws.com/alexa-static/top-1m.csv.zip': { 'name': 'alexa.txt' }, 'http://s3-us-west-1.amazonaws.com/umbr...
python
def process_whitelists(): """Download approved top 1M lists.""" import csv import grequests import os import StringIO import zipfile mapping = { 'http://s3.amazonaws.com/alexa-static/top-1m.csv.zip': { 'name': 'alexa.txt' }, 'http://s3-us-west-1.amazonaws.com/umbr...
[ "def", "process_whitelists", "(", ")", ":", "import", "csv", "import", "grequests", "import", "os", "import", "StringIO", "import", "zipfile", "mapping", "=", "{", "'http://s3.amazonaws.com/alexa-static/top-1m.csv.zip'", ":", "{", "'name'", ":", "'alexa.txt'", "}", ...
Download approved top 1M lists.
[ "Download", "approved", "top", "1M", "lists", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L117-L148
train
56,553
tradenity/python-sdk
tradenity/resources/braintree_gateway.py
BraintreeGateway.mode
def mode(self, mode): """Sets the mode of this BraintreeGateway. :param mode: The mode of this BraintreeGateway. :type: str """ allowed_values = ["test", "live"] if mode is not None and mode not in allowed_values: raise ValueError( "Invalid v...
python
def mode(self, mode): """Sets the mode of this BraintreeGateway. :param mode: The mode of this BraintreeGateway. :type: str """ allowed_values = ["test", "live"] if mode is not None and mode not in allowed_values: raise ValueError( "Invalid v...
[ "def", "mode", "(", "self", ",", "mode", ")", ":", "allowed_values", "=", "[", "\"test\"", ",", "\"live\"", "]", "if", "mode", "is", "not", "None", "and", "mode", "not", "in", "allowed_values", ":", "raise", "ValueError", "(", "\"Invalid value for `mode` ({0...
Sets the mode of this BraintreeGateway. :param mode: The mode of this BraintreeGateway. :type: str
[ "Sets", "the", "mode", "of", "this", "BraintreeGateway", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/braintree_gateway.py#L158-L172
train
56,554
a2liu/mr-clean
mr_clean/core/tools/diagnose.py
diagnose
def diagnose(df,preview_rows = 2, display_max_cols = 0,display_width = None): """ Prints information about the DataFrame pertinent to data cleaning. Parameters ---------- df - DataFrame The DataFrame to summarize preview_rows - int, default 5 Amount of rows to preview f...
python
def diagnose(df,preview_rows = 2, display_max_cols = 0,display_width = None): """ Prints information about the DataFrame pertinent to data cleaning. Parameters ---------- df - DataFrame The DataFrame to summarize preview_rows - int, default 5 Amount of rows to preview f...
[ "def", "diagnose", "(", "df", ",", "preview_rows", "=", "2", ",", "display_max_cols", "=", "0", ",", "display_width", "=", "None", ")", ":", "assert", "type", "(", "df", ")", "is", "pd", ".", "DataFrame", "# Diagnose problems with the data formats that can be ad...
Prints information about the DataFrame pertinent to data cleaning. Parameters ---------- df - DataFrame The DataFrame to summarize preview_rows - int, default 5 Amount of rows to preview from the head and tail of the DataFrame display_max_cols - int, default None Maximum amo...
[ "Prints", "information", "about", "the", "DataFrame", "pertinent", "to", "data", "cleaning", "." ]
0ee4ee5639f834dec4b59b94442fa84373f3c176
https://github.com/a2liu/mr-clean/blob/0ee4ee5639f834dec4b59b94442fa84373f3c176/mr_clean/core/tools/diagnose.py#L7-L78
train
56,555
trevisanj/f311
f311/explorer/util.py
cut_spectrum
def cut_spectrum(sp, l0, lf): """ Cuts spectrum given a wavelength interval, leaving origina intact Args: sp: Spectrum instance l0: initial wavelength lf: final wavelength Returns: Spectrum: cut spectrum """ if l0 >= lf: raise ValueError("l0 must be low...
python
def cut_spectrum(sp, l0, lf): """ Cuts spectrum given a wavelength interval, leaving origina intact Args: sp: Spectrum instance l0: initial wavelength lf: final wavelength Returns: Spectrum: cut spectrum """ if l0 >= lf: raise ValueError("l0 must be low...
[ "def", "cut_spectrum", "(", "sp", ",", "l0", ",", "lf", ")", ":", "if", "l0", ">=", "lf", ":", "raise", "ValueError", "(", "\"l0 must be lower than lf\"", ")", "idx0", "=", "np", ".", "argmin", "(", "np", ".", "abs", "(", "sp", ".", "x", "-", "l0",...
Cuts spectrum given a wavelength interval, leaving origina intact Args: sp: Spectrum instance l0: initial wavelength lf: final wavelength Returns: Spectrum: cut spectrum
[ "Cuts", "spectrum", "given", "a", "wavelength", "interval", "leaving", "origina", "intact" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/util.py#L14-L34
train
56,556
CodyKochmann/generators
generators/skip_first.py
skip_first
def skip_first(pipe, items=1): ''' this is an alias for skip to parallel the dedicated skip_last function to provide a little more readability to the code. the action of actually skipping does not occur until the first iteration is done ''' pipe = iter(pipe) for i in skip(pipe, items): ...
python
def skip_first(pipe, items=1): ''' this is an alias for skip to parallel the dedicated skip_last function to provide a little more readability to the code. the action of actually skipping does not occur until the first iteration is done ''' pipe = iter(pipe) for i in skip(pipe, items): ...
[ "def", "skip_first", "(", "pipe", ",", "items", "=", "1", ")", ":", "pipe", "=", "iter", "(", "pipe", ")", "for", "i", "in", "skip", "(", "pipe", ",", "items", ")", ":", "yield", "i" ]
this is an alias for skip to parallel the dedicated skip_last function to provide a little more readability to the code. the action of actually skipping does not occur until the first iteration is done
[ "this", "is", "an", "alias", "for", "skip", "to", "parallel", "the", "dedicated", "skip_last", "function", "to", "provide", "a", "little", "more", "readability", "to", "the", "code", ".", "the", "action", "of", "actually", "skipping", "does", "not", "occur",...
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/skip_first.py#L9-L16
train
56,557
slickqa/python-client
slickqa/connection.py
SlickApiPart.find
def find(self, query=None, **kwargs): """ You can pass in the appropriate model object from the queries module, or a dictionary with the keys and values for the query, or a set of key=value parameters. """ url = self.getUrl() if query is not None: if i...
python
def find(self, query=None, **kwargs): """ You can pass in the appropriate model object from the queries module, or a dictionary with the keys and values for the query, or a set of key=value parameters. """ url = self.getUrl() if query is not None: if i...
[ "def", "find", "(", "self", ",", "query", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "getUrl", "(", ")", "if", "query", "is", "not", "None", ":", "if", "isinstance", "(", "query", ",", "queries", ".", "SlickQuery", "...
You can pass in the appropriate model object from the queries module, or a dictionary with the keys and values for the query, or a set of key=value parameters.
[ "You", "can", "pass", "in", "the", "appropriate", "model", "object", "from", "the", "queries", "module", "or", "a", "dictionary", "with", "the", "keys", "and", "values", "for", "the", "query", "or", "a", "set", "of", "key", "=", "value", "parameters", "....
1d36b4977cd4140d7d24917cab2b3f82b60739c2
https://github.com/slickqa/python-client/blob/1d36b4977cd4140d7d24917cab2b3f82b60739c2/slickqa/connection.py#L89-L123
train
56,558
slickqa/python-client
slickqa/connection.py
SlickApiPart.findOne
def findOne(self, query=None, mode=FindOneMode.FIRST, **kwargs): """ Perform a find, with the same options present, but only return a maximum of one result. If find returns an empty array, then None is returned. If there are multiple results from find, the one returned depends on the m...
python
def findOne(self, query=None, mode=FindOneMode.FIRST, **kwargs): """ Perform a find, with the same options present, but only return a maximum of one result. If find returns an empty array, then None is returned. If there are multiple results from find, the one returned depends on the m...
[ "def", "findOne", "(", "self", ",", "query", "=", "None", ",", "mode", "=", "FindOneMode", ".", "FIRST", ",", "*", "*", "kwargs", ")", ":", "results", "=", "self", ".", "find", "(", "query", ",", "*", "*", "kwargs", ")", "if", "len", "(", "result...
Perform a find, with the same options present, but only return a maximum of one result. If find returns an empty array, then None is returned. If there are multiple results from find, the one returned depends on the mode parameter. If mode is FindOneMode.FIRST, then the first result is return...
[ "Perform", "a", "find", "with", "the", "same", "options", "present", "but", "only", "return", "a", "maximum", "of", "one", "result", ".", "If", "find", "returns", "an", "empty", "array", "then", "None", "is", "returned", "." ]
1d36b4977cd4140d7d24917cab2b3f82b60739c2
https://github.com/slickqa/python-client/blob/1d36b4977cd4140d7d24917cab2b3f82b60739c2/slickqa/connection.py#L127-L142
train
56,559
nuSTORM/gnomon
gnomon/GeneratorAction.py
lookup_cc_partner
def lookup_cc_partner(nu_pid): """Lookup the charge current partner Takes as an input neutrino nu_pid is a PDG code, then returns the charged lepton partner. So 12 (nu_e) returns 11. Keeps sign """ neutrino_type = math.fabs(nu_pid) assert neutrino_type in [12, 14, 16] cc_partner = neutr...
python
def lookup_cc_partner(nu_pid): """Lookup the charge current partner Takes as an input neutrino nu_pid is a PDG code, then returns the charged lepton partner. So 12 (nu_e) returns 11. Keeps sign """ neutrino_type = math.fabs(nu_pid) assert neutrino_type in [12, 14, 16] cc_partner = neutr...
[ "def", "lookup_cc_partner", "(", "nu_pid", ")", ":", "neutrino_type", "=", "math", ".", "fabs", "(", "nu_pid", ")", "assert", "neutrino_type", "in", "[", "12", ",", "14", ",", "16", "]", "cc_partner", "=", "neutrino_type", "-", "1", "# get e, mu, tau", "cc...
Lookup the charge current partner Takes as an input neutrino nu_pid is a PDG code, then returns the charged lepton partner. So 12 (nu_e) returns 11. Keeps sign
[ "Lookup", "the", "charge", "current", "partner" ]
7616486ecd6e26b76f677c380e62db1c0ade558a
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/GeneratorAction.py#L24-L39
train
56,560
chaosim/dao
dao/t/classic_utils.py
block_comment
def block_comment(solver, start, end): '''embedable block comment''' text, pos = solver.parse_state length = len(text) startlen = len(start) endlen = len(end) if pos==length: return if not text[pos:].startswith(start): return level = 1 p = pos+1 while p<length: if text[p:].starts...
python
def block_comment(solver, start, end): '''embedable block comment''' text, pos = solver.parse_state length = len(text) startlen = len(start) endlen = len(end) if pos==length: return if not text[pos:].startswith(start): return level = 1 p = pos+1 while p<length: if text[p:].starts...
[ "def", "block_comment", "(", "solver", ",", "start", ",", "end", ")", ":", "text", ",", "pos", "=", "solver", ".", "parse_state", "length", "=", "len", "(", "text", ")", "startlen", "=", "len", "(", "start", ")", "endlen", "=", "len", "(", "end", "...
embedable block comment
[ "embedable", "block", "comment" ]
d7ba65c98ee063aefd1ff4eabb192d1536fdbaaa
https://github.com/chaosim/dao/blob/d7ba65c98ee063aefd1ff4eabb192d1536fdbaaa/dao/t/classic_utils.py#L242-L266
train
56,561
e3krisztian/pyrene
pyrene/util.py
pip_install
def pip_install(*args): ''' Run pip install ... Explicitly ignores user's config. ''' pip_cmd = os.path.join(os.path.dirname(sys.executable), 'pip') with set_env('PIP_CONFIG_FILE', os.devnull): cmd = [pip_cmd, 'install'] + list(args) print_command(cmd) subprocess.call(cm...
python
def pip_install(*args): ''' Run pip install ... Explicitly ignores user's config. ''' pip_cmd = os.path.join(os.path.dirname(sys.executable), 'pip') with set_env('PIP_CONFIG_FILE', os.devnull): cmd = [pip_cmd, 'install'] + list(args) print_command(cmd) subprocess.call(cm...
[ "def", "pip_install", "(", "*", "args", ")", ":", "pip_cmd", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "sys", ".", "executable", ")", ",", "'pip'", ")", "with", "set_env", "(", "'PIP_CONFIG_FILE'", ",", "os", ...
Run pip install ... Explicitly ignores user's config.
[ "Run", "pip", "install", "..." ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/util.py#L49-L59
train
56,562
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
indent_text
def indent_text(text, nb_tabs=0, tab_str=" ", linebreak_input="\n", linebreak_output="\n", wrap=False): r"""Add tabs to each line of text. :param text: the text to indent :param nb_tabs: number of tabs to add :param tab_st...
python
def indent_text(text, nb_tabs=0, tab_str=" ", linebreak_input="\n", linebreak_output="\n", wrap=False): r"""Add tabs to each line of text. :param text: the text to indent :param nb_tabs: number of tabs to add :param tab_st...
[ "def", "indent_text", "(", "text", ",", "nb_tabs", "=", "0", ",", "tab_str", "=", "\" \"", ",", "linebreak_input", "=", "\"\\n\"", ",", "linebreak_output", "=", "\"\\n\"", ",", "wrap", "=", "False", ")", ":", "if", "not", "wrap", ":", "lines", "=", "t...
r"""Add tabs to each line of text. :param text: the text to indent :param nb_tabs: number of tabs to add :param tab_str: type of tab (could be, for example "\t", default: 2 spaces :param linebreak_input: linebreak on input :param linebreak_output: linebreak on output :param wrap: wethever to ap...
[ "r", "Add", "tabs", "to", "each", "line", "of", "text", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L149-L175
train
56,563
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
wait_for_user
def wait_for_user(msg=""): """ Print MSG and a confirmation prompt. Waiting for user's confirmation, unless silent '--yes-i-know' command line option was used, in which case the function returns immediately without printing anything. """ if '--yes-i-know' in sys.argv: return pri...
python
def wait_for_user(msg=""): """ Print MSG and a confirmation prompt. Waiting for user's confirmation, unless silent '--yes-i-know' command line option was used, in which case the function returns immediately without printing anything. """ if '--yes-i-know' in sys.argv: return pri...
[ "def", "wait_for_user", "(", "msg", "=", "\"\"", ")", ":", "if", "'--yes-i-know'", "in", "sys", ".", "argv", ":", "return", "print", "(", "msg", ")", "try", ":", "answer", "=", "raw_input", "(", "\"Please confirm by typing 'Yes, I know!': \"", ")", "except", ...
Print MSG and a confirmation prompt. Waiting for user's confirmation, unless silent '--yes-i-know' command line option was used, in which case the function returns immediately without printing anything.
[ "Print", "MSG", "and", "a", "confirmation", "prompt", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L325-L344
train
56,564
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
guess_minimum_encoding
def guess_minimum_encoding(text, charsets=('ascii', 'latin1', 'utf8')): """Try to guess the minimum charset that is able to represent. Try to guess the minimum charset that is able to represent the given text using the provided charsets. text is supposed to be encoded in utf8. Returns (encoded_text, ch...
python
def guess_minimum_encoding(text, charsets=('ascii', 'latin1', 'utf8')): """Try to guess the minimum charset that is able to represent. Try to guess the minimum charset that is able to represent the given text using the provided charsets. text is supposed to be encoded in utf8. Returns (encoded_text, ch...
[ "def", "guess_minimum_encoding", "(", "text", ",", "charsets", "=", "(", "'ascii'", ",", "'latin1'", ",", "'utf8'", ")", ")", ":", "text_in_unicode", "=", "text", ".", "decode", "(", "'utf8'", ",", "'replace'", ")", "for", "charset", "in", "charsets", ":",...
Try to guess the minimum charset that is able to represent. Try to guess the minimum charset that is able to represent the given text using the provided charsets. text is supposed to be encoded in utf8. Returns (encoded_text, charset) where charset is the first charset in the sequence being able to enc...
[ "Try", "to", "guess", "the", "minimum", "charset", "that", "is", "able", "to", "represent", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L347-L365
train
56,565
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
encode_for_xml
def encode_for_xml(text, wash=False, xml_version='1.0', quote=False): """Encode special characters in a text so that it would be XML-compliant. :param text: text to encode :return: an encoded text """ text = text.replace('&', '&amp;') text = text.replace('<', '&lt;') if quote: text ...
python
def encode_for_xml(text, wash=False, xml_version='1.0', quote=False): """Encode special characters in a text so that it would be XML-compliant. :param text: text to encode :return: an encoded text """ text = text.replace('&', '&amp;') text = text.replace('<', '&lt;') if quote: text ...
[ "def", "encode_for_xml", "(", "text", ",", "wash", "=", "False", ",", "xml_version", "=", "'1.0'", ",", "quote", "=", "False", ")", ":", "text", "=", "text", ".", "replace", "(", "'&'", ",", "'&amp;'", ")", "text", "=", "text", ".", "replace", "(", ...
Encode special characters in a text so that it would be XML-compliant. :param text: text to encode :return: an encoded text
[ "Encode", "special", "characters", "in", "a", "text", "so", "that", "it", "would", "be", "XML", "-", "compliant", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L368-L380
train
56,566
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
wash_for_xml
def wash_for_xml(text, xml_version='1.0'): """Remove any character which isn't a allowed characters for XML. The allowed characters depends on the version of XML. - XML 1.0: <http://www.w3.org/TR/REC-xml/#charsets> - XML 1.1: <http://www.w3.org/TR/xml11/#charsets> ...
python
def wash_for_xml(text, xml_version='1.0'): """Remove any character which isn't a allowed characters for XML. The allowed characters depends on the version of XML. - XML 1.0: <http://www.w3.org/TR/REC-xml/#charsets> - XML 1.1: <http://www.w3.org/TR/xml11/#charsets> ...
[ "def", "wash_for_xml", "(", "text", ",", "xml_version", "=", "'1.0'", ")", ":", "if", "xml_version", "==", "'1.0'", ":", "return", "RE_ALLOWED_XML_1_0_CHARS", ".", "sub", "(", "''", ",", "unicode", "(", "text", ",", "'utf-8'", ")", ")", ".", "encode", "(...
Remove any character which isn't a allowed characters for XML. The allowed characters depends on the version of XML. - XML 1.0: <http://www.w3.org/TR/REC-xml/#charsets> - XML 1.1: <http://www.w3.org/TR/xml11/#charsets> :param text: input string to wash. :param ...
[ "Remove", "any", "character", "which", "isn", "t", "a", "allowed", "characters", "for", "XML", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L399-L419
train
56,567
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
wash_for_utf8
def wash_for_utf8(text, correct=True): """Return UTF-8 encoded binary string with incorrect characters washed away. :param text: input string to wash (can be either a binary or Unicode string) :param correct: whether to correct bad characters or throw exception """ if isinstance(text, unicode): ...
python
def wash_for_utf8(text, correct=True): """Return UTF-8 encoded binary string with incorrect characters washed away. :param text: input string to wash (can be either a binary or Unicode string) :param correct: whether to correct bad characters or throw exception """ if isinstance(text, unicode): ...
[ "def", "wash_for_utf8", "(", "text", ",", "correct", "=", "True", ")", ":", "if", "isinstance", "(", "text", ",", "unicode", ")", ":", "return", "text", ".", "encode", "(", "'utf-8'", ")", "errors", "=", "\"ignore\"", "if", "correct", "else", "\"strict\"...
Return UTF-8 encoded binary string with incorrect characters washed away. :param text: input string to wash (can be either a binary or Unicode string) :param correct: whether to correct bad characters or throw exception
[ "Return", "UTF", "-", "8", "encoded", "binary", "string", "with", "incorrect", "characters", "washed", "away", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L422-L432
train
56,568
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
nice_number
def nice_number(number, thousands_separator=',', max_ndigits_after_dot=None): """Return nicely printed number NUMBER in language LN. Return nicely printed number NUMBER in language LN using given THOUSANDS_SEPARATOR character. If max_ndigits_after_dot is specified and the number is float, the numbe...
python
def nice_number(number, thousands_separator=',', max_ndigits_after_dot=None): """Return nicely printed number NUMBER in language LN. Return nicely printed number NUMBER in language LN using given THOUSANDS_SEPARATOR character. If max_ndigits_after_dot is specified and the number is float, the numbe...
[ "def", "nice_number", "(", "number", ",", "thousands_separator", "=", "','", ",", "max_ndigits_after_dot", "=", "None", ")", ":", "if", "isinstance", "(", "number", ",", "float", ")", ":", "if", "max_ndigits_after_dot", "is", "not", "None", ":", "number", "=...
Return nicely printed number NUMBER in language LN. Return nicely printed number NUMBER in language LN using given THOUSANDS_SEPARATOR character. If max_ndigits_after_dot is specified and the number is float, the number is rounded by taking in consideration up to max_ndigits_after_dot digit after t...
[ "Return", "nicely", "printed", "number", "NUMBER", "in", "language", "LN", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L435-L462
train
56,569
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
nice_size
def nice_size(size): """Nice size. :param size: the size. :type size: int :return: a nicely printed size. :rtype: string """ unit = 'B' if size > 1024: size /= 1024.0 unit = 'KB' if size > 1024: size /= 1024.0 unit = 'MB' if si...
python
def nice_size(size): """Nice size. :param size: the size. :type size: int :return: a nicely printed size. :rtype: string """ unit = 'B' if size > 1024: size /= 1024.0 unit = 'KB' if size > 1024: size /= 1024.0 unit = 'MB' if si...
[ "def", "nice_size", "(", "size", ")", ":", "unit", "=", "'B'", "if", "size", ">", "1024", ":", "size", "/=", "1024.0", "unit", "=", "'KB'", "if", "size", ">", "1024", ":", "size", "/=", "1024.0", "unit", "=", "'MB'", "if", "size", ">", "1024", ":...
Nice size. :param size: the size. :type size: int :return: a nicely printed size. :rtype: string
[ "Nice", "size", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L465-L483
train
56,570
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
remove_line_breaks
def remove_line_breaks(text): """Remove line breaks from input. Including unicode 'line separator', 'paragraph separator', and 'next line' characters. """ return unicode(text, 'utf-8').replace('\f', '').replace('\n', '') \ .replace('\r', '').replace(u'\xe2\x80\xa8', '') \ .replace(u...
python
def remove_line_breaks(text): """Remove line breaks from input. Including unicode 'line separator', 'paragraph separator', and 'next line' characters. """ return unicode(text, 'utf-8').replace('\f', '').replace('\n', '') \ .replace('\r', '').replace(u'\xe2\x80\xa8', '') \ .replace(u...
[ "def", "remove_line_breaks", "(", "text", ")", ":", "return", "unicode", "(", "text", ",", "'utf-8'", ")", ".", "replace", "(", "'\\f'", ",", "''", ")", ".", "replace", "(", "'\\n'", ",", "''", ")", ".", "replace", "(", "'\\r'", ",", "''", ")", "."...
Remove line breaks from input. Including unicode 'line separator', 'paragraph separator', and 'next line' characters.
[ "Remove", "line", "breaks", "from", "input", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L486-L495
train
56,571
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
decode_to_unicode
def decode_to_unicode(text, default_encoding='utf-8'): """Decode input text into Unicode representation. Decode input text into Unicode representation by first using the default encoding utf-8. If the operation fails, it detects the type of encoding used in the given text. For optimal result, i...
python
def decode_to_unicode(text, default_encoding='utf-8'): """Decode input text into Unicode representation. Decode input text into Unicode representation by first using the default encoding utf-8. If the operation fails, it detects the type of encoding used in the given text. For optimal result, i...
[ "def", "decode_to_unicode", "(", "text", ",", "default_encoding", "=", "'utf-8'", ")", ":", "if", "not", "text", ":", "return", "\"\"", "try", ":", "return", "text", ".", "decode", "(", "default_encoding", ")", "except", "(", "UnicodeError", ",", "LookupErro...
Decode input text into Unicode representation. Decode input text into Unicode representation by first using the default encoding utf-8. If the operation fails, it detects the type of encoding used in the given text. For optimal result, it is recommended that the 'chardet' module is installed. ...
[ "Decode", "input", "text", "into", "Unicode", "representation", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L498-L541
train
56,572
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
to_unicode
def to_unicode(text): """Convert to unicode.""" if isinstance(text, unicode): return text if isinstance(text, six.string_types): return decode_to_unicode(text) return unicode(text)
python
def to_unicode(text): """Convert to unicode.""" if isinstance(text, unicode): return text if isinstance(text, six.string_types): return decode_to_unicode(text) return unicode(text)
[ "def", "to_unicode", "(", "text", ")", ":", "if", "isinstance", "(", "text", ",", "unicode", ")", ":", "return", "text", "if", "isinstance", "(", "text", ",", "six", ".", "string_types", ")", ":", "return", "decode_to_unicode", "(", "text", ")", "return"...
Convert to unicode.
[ "Convert", "to", "unicode", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L544-L550
train
56,573
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
translate_latex2unicode
def translate_latex2unicode(text, kb_file=None): """Translate latex text to unicode. This function will take given text, presumably containing LaTeX symbols, and attempts to translate it to Unicode using the given or default KB translation table located under CFG_ETCDIR/bibconvert/KB/latex-to-unico...
python
def translate_latex2unicode(text, kb_file=None): """Translate latex text to unicode. This function will take given text, presumably containing LaTeX symbols, and attempts to translate it to Unicode using the given or default KB translation table located under CFG_ETCDIR/bibconvert/KB/latex-to-unico...
[ "def", "translate_latex2unicode", "(", "text", ",", "kb_file", "=", "None", ")", ":", "if", "kb_file", "is", "None", ":", "kb_file", "=", "get_kb_filename", "(", ")", "# First decode input text to Unicode", "try", ":", "text", "=", "decode_to_unicode", "(", "tex...
Translate latex text to unicode. This function will take given text, presumably containing LaTeX symbols, and attempts to translate it to Unicode using the given or default KB translation table located under CFG_ETCDIR/bibconvert/KB/latex-to-unicode.kb. The translated Unicode string will then be re...
[ "Translate", "latex", "text", "to", "unicode", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L553-L595
train
56,574
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
_load_latex2unicode_constants
def _load_latex2unicode_constants(kb_file=None): """Load LaTeX2Unicode translation table dictionary. Load LaTeX2Unicode translation table dictionary and regular expression object from KB to a global dictionary. :param kb_file: full path to file containing latex2unicode translations. ...
python
def _load_latex2unicode_constants(kb_file=None): """Load LaTeX2Unicode translation table dictionary. Load LaTeX2Unicode translation table dictionary and regular expression object from KB to a global dictionary. :param kb_file: full path to file containing latex2unicode translations. ...
[ "def", "_load_latex2unicode_constants", "(", "kb_file", "=", "None", ")", ":", "if", "kb_file", "is", "None", ":", "kb_file", "=", "get_kb_filename", "(", ")", "try", ":", "data", "=", "open", "(", "kb_file", ")", "except", "IOError", ":", "# File not found ...
Load LaTeX2Unicode translation table dictionary. Load LaTeX2Unicode translation table dictionary and regular expression object from KB to a global dictionary. :param kb_file: full path to file containing latex2unicode translations. Defaults to CFG_ETCDIR/bibconvert/KB/latex-to-unicode....
[ "Load", "LaTeX2Unicode", "translation", "table", "dictionary", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L598-L634
train
56,575
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
translate_to_ascii
def translate_to_ascii(values): r"""Transliterate the string into ascii representation. Transliterate the string contents of the given sequence into ascii representation. Returns a sequence with the modified values if the module 'unidecode' is available. Otherwise it will fall back to the inferior ...
python
def translate_to_ascii(values): r"""Transliterate the string into ascii representation. Transliterate the string contents of the given sequence into ascii representation. Returns a sequence with the modified values if the module 'unidecode' is available. Otherwise it will fall back to the inferior ...
[ "def", "translate_to_ascii", "(", "values", ")", ":", "if", "not", "values", "and", "not", "isinstance", "(", "values", ",", "str", ")", ":", "return", "values", "if", "isinstance", "(", "values", ",", "str", ")", ":", "values", "=", "[", "values", "]"...
r"""Transliterate the string into ascii representation. Transliterate the string contents of the given sequence into ascii representation. Returns a sequence with the modified values if the module 'unidecode' is available. Otherwise it will fall back to the inferior strip_accents function. For...
[ "r", "Transliterate", "the", "string", "into", "ascii", "representation", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L637-L677
train
56,576
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
xml_entities_to_utf8
def xml_entities_to_utf8(text, skip=('lt', 'gt', 'amp')): """Translate HTML or XML character references to UTF-8. Removes HTML or XML character references and entities from a text string and replaces them with their UTF-8 representation, if possible. :param text: The HTML (or XML) source text. :ty...
python
def xml_entities_to_utf8(text, skip=('lt', 'gt', 'amp')): """Translate HTML or XML character references to UTF-8. Removes HTML or XML character references and entities from a text string and replaces them with their UTF-8 representation, if possible. :param text: The HTML (or XML) source text. :ty...
[ "def", "xml_entities_to_utf8", "(", "text", ",", "skip", "=", "(", "'lt'", ",", "'gt'", ",", "'amp'", ")", ")", ":", "def", "fixup", "(", "m", ")", ":", "text", "=", "m", ".", "group", "(", "0", ")", "if", "text", "[", ":", "2", "]", "==", "\...
Translate HTML or XML character references to UTF-8. Removes HTML or XML character references and entities from a text string and replaces them with their UTF-8 representation, if possible. :param text: The HTML (or XML) source text. :type text: string :param skip: list of entity names to skip wh...
[ "Translate", "HTML", "or", "XML", "character", "references", "to", "UTF", "-", "8", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L680-L716
train
56,577
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
strip_accents
def strip_accents(x): u"""Strip accents in the input phrase X. Strip accents in the input phrase X (assumed in UTF-8) by replacing accented characters with their unaccented cousins (e.g. é by e). :param x: the input phrase to strip. :type x: string :return: Return such a stripped X. """ ...
python
def strip_accents(x): u"""Strip accents in the input phrase X. Strip accents in the input phrase X (assumed in UTF-8) by replacing accented characters with their unaccented cousins (e.g. é by e). :param x: the input phrase to strip. :type x: string :return: Return such a stripped X. """ ...
[ "def", "strip_accents", "(", "x", ")", ":", "x", "=", "re_latex_lowercase_a", ".", "sub", "(", "\"a\"", ",", "x", ")", "x", "=", "re_latex_lowercase_ae", ".", "sub", "(", "\"ae\"", ",", "x", ")", "x", "=", "re_latex_lowercase_oe", ".", "sub", "(", "\"o...
u"""Strip accents in the input phrase X. Strip accents in the input phrase X (assumed in UTF-8) by replacing accented characters with their unaccented cousins (e.g. é by e). :param x: the input phrase to strip. :type x: string :return: Return such a stripped X.
[ "u", "Strip", "accents", "in", "the", "input", "phrase", "X", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L719-L780
train
56,578
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
show_diff
def show_diff(original, modified, prefix='', suffix='', prefix_unchanged=' ', suffix_unchanged='', prefix_removed='-', suffix_removed='', prefix_added='+', suffix_added=''): """Return the diff view between original and modified stri...
python
def show_diff(original, modified, prefix='', suffix='', prefix_unchanged=' ', suffix_unchanged='', prefix_removed='-', suffix_removed='', prefix_added='+', suffix_added=''): """Return the diff view between original and modified stri...
[ "def", "show_diff", "(", "original", ",", "modified", ",", "prefix", "=", "''", ",", "suffix", "=", "''", ",", "prefix_unchanged", "=", "' '", ",", "suffix_unchanged", "=", "''", ",", "prefix_removed", "=", "'-'", ",", "suffix_removed", "=", "''", ",", "...
Return the diff view between original and modified strings. Function checks both arguments line by line and returns a string with a: - prefix_unchanged when line is common to both sequences - prefix_removed when line is unique to sequence 1 - prefix_added when line is unique to sequence 2 and a...
[ "Return", "the", "diff", "view", "between", "original", "and", "modified", "strings", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L793-L839
train
56,579
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
escape_latex
def escape_latex(text): r"""Escape characters of given text. This function takes the given text and escapes characters that have a special meaning in LaTeX: # $ % ^ & _ { } ~ \ """ text = unicode(text.decode('utf-8')) CHARS = { '&': r'\&', '%': r'\%', '$': r'\$', ...
python
def escape_latex(text): r"""Escape characters of given text. This function takes the given text and escapes characters that have a special meaning in LaTeX: # $ % ^ & _ { } ~ \ """ text = unicode(text.decode('utf-8')) CHARS = { '&': r'\&', '%': r'\%', '$': r'\$', ...
[ "def", "escape_latex", "(", "text", ")", ":", "text", "=", "unicode", "(", "text", ".", "decode", "(", "'utf-8'", ")", ")", "CHARS", "=", "{", "'&'", ":", "r'\\&'", ",", "'%'", ":", "r'\\%'", ",", "'$'", ":", "r'\\$'", ",", "'#'", ":", "r'\\#'", ...
r"""Escape characters of given text. This function takes the given text and escapes characters that have a special meaning in LaTeX: # $ % ^ & _ { } ~ \
[ "r", "Escape", "characters", "of", "given", "text", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L863-L883
train
56,580
trevisanj/f311
f311/filetypes/filepy.py
FilePy._copy_attr
def _copy_attr(self, module, varname, cls, attrname=None): """ Copies attribute from module object to self. Raises if object not of expected class Args: module: module object varname: variable name cls: expected class of variable attrname: attribu...
python
def _copy_attr(self, module, varname, cls, attrname=None): """ Copies attribute from module object to self. Raises if object not of expected class Args: module: module object varname: variable name cls: expected class of variable attrname: attribu...
[ "def", "_copy_attr", "(", "self", ",", "module", ",", "varname", ",", "cls", ",", "attrname", "=", "None", ")", ":", "if", "not", "hasattr", "(", "module", ",", "varname", ")", ":", "raise", "RuntimeError", "(", "\"Variable '{}' not found\"", ".", "format"...
Copies attribute from module object to self. Raises if object not of expected class Args: module: module object varname: variable name cls: expected class of variable attrname: attribute name of self. Falls back to varname
[ "Copies", "attribute", "from", "module", "object", "to", "self", ".", "Raises", "if", "object", "not", "of", "expected", "class" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filepy.py#L49-L72
train
56,581
dsoprea/PathScan
fss/workers/generator.py
GeneratorWorker.__check_to_permit
def __check_to_permit(self, entry_type, entry_filename): """Applying the filter rules.""" rules = self.__filter_rules[entry_type] # Should explicitly include? for pattern in rules[fss.constants.FILTER_INCLUDE]: if fnmatch.fnmatch(entry_filename, pattern): _L...
python
def __check_to_permit(self, entry_type, entry_filename): """Applying the filter rules.""" rules = self.__filter_rules[entry_type] # Should explicitly include? for pattern in rules[fss.constants.FILTER_INCLUDE]: if fnmatch.fnmatch(entry_filename, pattern): _L...
[ "def", "__check_to_permit", "(", "self", ",", "entry_type", ",", "entry_filename", ")", ":", "rules", "=", "self", ".", "__filter_rules", "[", "entry_type", "]", "# Should explicitly include?", "for", "pattern", "in", "rules", "[", "fss", ".", "constants", ".", ...
Applying the filter rules.
[ "Applying", "the", "filter", "rules", "." ]
1195a94f3b14c202ddf3e593630be5556e974dd1
https://github.com/dsoprea/PathScan/blob/1195a94f3b14c202ddf3e593630be5556e974dd1/fss/workers/generator.py#L85-L113
train
56,582
micha030201/aionationstates
aionationstates/shared.py
Census.census
def census(self, *scales): """Current World Census data. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales at once you can do ``x.census(*range(81))``. Parameters ...
python
def census(self, *scales): """Current World Census data. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales at once you can do ``x.census(*range(81))``. Parameters ...
[ "def", "census", "(", "self", ",", "*", "scales", ")", ":", "params", "=", "{", "'mode'", ":", "'score+rank+rrank+prank+prrank'", "}", "if", "scales", ":", "params", "[", "'scale'", "]", "=", "'+'", ".", "join", "(", "str", "(", "x", ")", "for", "x",...
Current World Census data. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales at once you can do ``x.census(*range(81))``. Parameters ---------- scales : int ...
[ "Current", "World", "Census", "data", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/shared.py#L271-L298
train
56,583
micha030201/aionationstates
aionationstates/shared.py
Census.censushistory
def censushistory(self, *scales): """Historical World Census data. Was split into its own method for the sake of simplicity. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales ...
python
def censushistory(self, *scales): """Historical World Census data. Was split into its own method for the sake of simplicity. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales ...
[ "def", "censushistory", "(", "self", ",", "*", "scales", ")", ":", "params", "=", "{", "'mode'", ":", "'history'", "}", "if", "scales", ":", "params", "[", "'scale'", "]", "=", "'+'", ".", "join", "(", "str", "(", "x", ")", "for", "x", "in", "sca...
Historical World Census data. Was split into its own method for the sake of simplicity. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales at once you can do ``x.censushistory(...
[ "Historical", "World", "Census", "data", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/shared.py#L300-L332
train
56,584
micha030201/aionationstates
aionationstates/shared.py
CensusRanks.censusranks
async def censusranks(self, scale): """Iterate through nations ranked on the World Census scale. If the ranks change while you interate over them, they may be inconsistent. Parameters ---------- scale : int A World Census scale, an integer between 0 and 85 i...
python
async def censusranks(self, scale): """Iterate through nations ranked on the World Census scale. If the ranks change while you interate over them, they may be inconsistent. Parameters ---------- scale : int A World Census scale, an integer between 0 and 85 i...
[ "async", "def", "censusranks", "(", "self", ",", "scale", ")", ":", "order", "=", "count", "(", "1", ")", "for", "offset", "in", "count", "(", "1", ",", "20", ")", ":", "census_ranks", "=", "await", "self", ".", "_get_censusranks", "(", "scale", "=",...
Iterate through nations ranked on the World Census scale. If the ranks change while you interate over them, they may be inconsistent. Parameters ---------- scale : int A World Census scale, an integer between 0 and 85 inclusive. Returns ------- ...
[ "Iterate", "through", "nations", "ranked", "on", "the", "World", "Census", "scale", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/shared.py#L433-L456
train
56,585
inveniosoftware-attic/invenio-utils
invenio_utils/serializers.py
ZlibMarshal.loads
def loads(astring): """Decompress and deserialize string into Python object via marshal.""" try: return marshal.loads(zlib.decompress(astring)) except zlib.error as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ) ...
python
def loads(astring): """Decompress and deserialize string into Python object via marshal.""" try: return marshal.loads(zlib.decompress(astring)) except zlib.error as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ) ...
[ "def", "loads", "(", "astring", ")", ":", "try", ":", "return", "marshal", ".", "loads", "(", "zlib", ".", "decompress", "(", "astring", ")", ")", "except", "zlib", ".", "error", "as", "e", ":", "raise", "SerializerError", "(", "'Cannot decompress object (...
Decompress and deserialize string into Python object via marshal.
[ "Decompress", "and", "deserialize", "string", "into", "Python", "object", "via", "marshal", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/serializers.py#L48-L60
train
56,586
inveniosoftware-attic/invenio-utils
invenio_utils/serializers.py
ZlibPickle.loads
def loads(astring): """Decompress and deserialize string into Python object via pickle.""" try: return pickle.loads(zlib.decompress(astring)) except zlib.error as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ) ...
python
def loads(astring): """Decompress and deserialize string into Python object via pickle.""" try: return pickle.loads(zlib.decompress(astring)) except zlib.error as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ) ...
[ "def", "loads", "(", "astring", ")", ":", "try", ":", "return", "pickle", ".", "loads", "(", "zlib", ".", "decompress", "(", "astring", ")", ")", "except", "zlib", ".", "error", "as", "e", ":", "raise", "SerializerError", "(", "'Cannot decompress object (\...
Decompress and deserialize string into Python object via pickle.
[ "Decompress", "and", "deserialize", "string", "into", "Python", "object", "via", "pickle", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/serializers.py#L77-L88
train
56,587
inveniosoftware-attic/invenio-utils
invenio_utils/serializers.py
LzmaPickle.loads
def loads(astring): """Decompress and deserialize string into a Python object via pickle.""" try: return pickle.loads(lzma.decompress(astring)) except lzma.LZMAError as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ...
python
def loads(astring): """Decompress and deserialize string into a Python object via pickle.""" try: return pickle.loads(lzma.decompress(astring)) except lzma.LZMAError as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ...
[ "def", "loads", "(", "astring", ")", ":", "try", ":", "return", "pickle", ".", "loads", "(", "lzma", ".", "decompress", "(", "astring", ")", ")", "except", "lzma", ".", "LZMAError", "as", "e", ":", "raise", "SerializerError", "(", "'Cannot decompress objec...
Decompress and deserialize string into a Python object via pickle.
[ "Decompress", "and", "deserialize", "string", "into", "a", "Python", "object", "via", "pickle", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/serializers.py#L105-L116
train
56,588
flashashen/flange
flange/data.py
Data.search
def search(self, path_expression, mode=UXP, values=None, ifunc=lambda x: x): """ find matches for the given path expression in the data :param path_expression: path tuple or string :return: """ # keys = path_expression if isinstance(path_expression, six.string_types) els...
python
def search(self, path_expression, mode=UXP, values=None, ifunc=lambda x: x): """ find matches for the given path expression in the data :param path_expression: path tuple or string :return: """ # keys = path_expression if isinstance(path_expression, six.string_types) els...
[ "def", "search", "(", "self", ",", "path_expression", ",", "mode", "=", "UXP", ",", "values", "=", "None", ",", "ifunc", "=", "lambda", "x", ":", "x", ")", ":", "# keys = path_expression if isinstance(path_expression, six.string_types) else path_expression[-1]", "path...
find matches for the given path expression in the data :param path_expression: path tuple or string :return:
[ "find", "matches", "for", "the", "given", "path", "expression", "in", "the", "data" ]
67ebaf70e39887f65ce1163168d182a8e4c2774a
https://github.com/flashashen/flange/blob/67ebaf70e39887f65ce1163168d182a8e4c2774a/flange/data.py#L37-L52
train
56,589
flashashen/flange
flange/data.py
Data.__visit_index_path
def __visit_index_path(self, src, p, k, v): """ Called during processing of source data """ cp = p + (k,) self.path_index[cp] = self.indexed_obj_factory(p, k, v, self.path_index.get(cp)) if cp in self.path_index: # if self.path_index[cp].assert_val_equals(...
python
def __visit_index_path(self, src, p, k, v): """ Called during processing of source data """ cp = p + (k,) self.path_index[cp] = self.indexed_obj_factory(p, k, v, self.path_index.get(cp)) if cp in self.path_index: # if self.path_index[cp].assert_val_equals(...
[ "def", "__visit_index_path", "(", "self", ",", "src", ",", "p", ",", "k", ",", "v", ")", ":", "cp", "=", "p", "+", "(", "k", ",", ")", "self", ".", "path_index", "[", "cp", "]", "=", "self", ".", "indexed_obj_factory", "(", "p", ",", "k", ",", ...
Called during processing of source data
[ "Called", "during", "processing", "of", "source", "data" ]
67ebaf70e39887f65ce1163168d182a8e4c2774a
https://github.com/flashashen/flange/blob/67ebaf70e39887f65ce1163168d182a8e4c2774a/flange/data.py#L72-L83
train
56,590
trevisanj/f311
f311/pathfinder.py
get_default_data_path
def get_default_data_path(*args, module=None, class_=None, flag_raise=True): """ Returns path to default data directory Arguments 'module' and 'class' give the chance to return path relative to package other than f311.filetypes Args: module: Python module object. It is expected that this m...
python
def get_default_data_path(*args, module=None, class_=None, flag_raise=True): """ Returns path to default data directory Arguments 'module' and 'class' give the chance to return path relative to package other than f311.filetypes Args: module: Python module object. It is expected that this m...
[ "def", "get_default_data_path", "(", "*", "args", ",", "module", "=", "None", ",", "class_", "=", "None", ",", "flag_raise", "=", "True", ")", ":", "if", "module", "is", "None", ":", "module", "=", "__get_filetypes_module", "(", ")", "if", "class_", "is"...
Returns path to default data directory Arguments 'module' and 'class' give the chance to return path relative to package other than f311.filetypes Args: module: Python module object. It is expected that this module has a sub-subdirectory named 'data/default' class_: Python ...
[ "Returns", "path", "to", "default", "data", "directory" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/pathfinder.py#L8-L43
train
56,591
trevisanj/f311
f311/pathfinder.py
copy_default_data_file
def copy_default_data_file(filename, module=None): """Copies file from default data directory to local directory.""" if module is None: module = __get_filetypes_module() fullpath = get_default_data_path(filename, module=module) shutil.copy(fullpath, ".")
python
def copy_default_data_file(filename, module=None): """Copies file from default data directory to local directory.""" if module is None: module = __get_filetypes_module() fullpath = get_default_data_path(filename, module=module) shutil.copy(fullpath, ".")
[ "def", "copy_default_data_file", "(", "filename", ",", "module", "=", "None", ")", ":", "if", "module", "is", "None", ":", "module", "=", "__get_filetypes_module", "(", ")", "fullpath", "=", "get_default_data_path", "(", "filename", ",", "module", "=", "module...
Copies file from default data directory to local directory.
[ "Copies", "file", "from", "default", "data", "directory", "to", "local", "directory", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/pathfinder.py#L46-L51
train
56,592
ten10solutions/Geist
geist/backends/xvfb.py
GeistXvfbBackend._find_display
def _find_display(self): """ Find a usable display, which doesn't have an existing Xvfb file """ self.display_num = 2 while os.path.isdir(XVFB_PATH % (self.display_num,)): self.display_num += 1
python
def _find_display(self): """ Find a usable display, which doesn't have an existing Xvfb file """ self.display_num = 2 while os.path.isdir(XVFB_PATH % (self.display_num,)): self.display_num += 1
[ "def", "_find_display", "(", "self", ")", ":", "self", ".", "display_num", "=", "2", "while", "os", ".", "path", ".", "isdir", "(", "XVFB_PATH", "%", "(", "self", ".", "display_num", ",", ")", ")", ":", "self", ".", "display_num", "+=", "1" ]
Find a usable display, which doesn't have an existing Xvfb file
[ "Find", "a", "usable", "display", "which", "doesn", "t", "have", "an", "existing", "Xvfb", "file" ]
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/backends/xvfb.py#L85-L91
train
56,593
inveniosoftware-attic/invenio-comments
invenio_comments/views.py
comments
def comments(recid): """Display comments.""" from invenio_access.local_config import VIEWRESTRCOLL from invenio_access.mailcookie import \ mail_cookie_create_authorize_action from .api import check_user_can_view_comments auth_code, auth_msg = check_user_can_view_comments(current_user, recid)...
python
def comments(recid): """Display comments.""" from invenio_access.local_config import VIEWRESTRCOLL from invenio_access.mailcookie import \ mail_cookie_create_authorize_action from .api import check_user_can_view_comments auth_code, auth_msg = check_user_can_view_comments(current_user, recid)...
[ "def", "comments", "(", "recid", ")", ":", "from", "invenio_access", ".", "local_config", "import", "VIEWRESTRCOLL", "from", "invenio_access", ".", "mailcookie", "import", "mail_cookie_create_authorize_action", "from", ".", "api", "import", "check_user_can_view_comments",...
Display comments.
[ "Display", "comments", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/views.py#L189-L213
train
56,594
stxnext/mappet
mappet/mappet.py
Node.getattr
def getattr(self, key, default=None, callback=None): u"""Getting the attribute of an element. >>> xml = etree.Element('root') >>> xml.text = 'text' >>> Node(xml).getattr('text') 'text' >>> Node(xml).getattr('text', callback=str.upper) 'TEXT' >>> Node(xml)...
python
def getattr(self, key, default=None, callback=None): u"""Getting the attribute of an element. >>> xml = etree.Element('root') >>> xml.text = 'text' >>> Node(xml).getattr('text') 'text' >>> Node(xml).getattr('text', callback=str.upper) 'TEXT' >>> Node(xml)...
[ "def", "getattr", "(", "self", ",", "key", ",", "default", "=", "None", ",", "callback", "=", "None", ")", ":", "value", "=", "self", ".", "_xml", ".", "text", "if", "key", "==", "'text'", "else", "self", ".", "_xml", ".", "get", "(", "key", ",",...
u"""Getting the attribute of an element. >>> xml = etree.Element('root') >>> xml.text = 'text' >>> Node(xml).getattr('text') 'text' >>> Node(xml).getattr('text', callback=str.upper) 'TEXT' >>> Node(xml).getattr('wrong_attr', default='default') 'default'
[ "u", "Getting", "the", "attribute", "of", "an", "element", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L75-L88
train
56,595
stxnext/mappet
mappet/mappet.py
Node.setattr
def setattr(self, key, value): u"""Sets an attribute on a node. >>> xml = etree.Element('root') >>> Node(xml).setattr('text', 'text2') >>> Node(xml).getattr('text') 'text2' >>> Node(xml).setattr('attr', 'val') >>> Node(xml).getattr('attr') 'val' "...
python
def setattr(self, key, value): u"""Sets an attribute on a node. >>> xml = etree.Element('root') >>> Node(xml).setattr('text', 'text2') >>> Node(xml).getattr('text') 'text2' >>> Node(xml).setattr('attr', 'val') >>> Node(xml).getattr('attr') 'val' "...
[ "def", "setattr", "(", "self", ",", "key", ",", "value", ")", ":", "if", "key", "==", "'text'", ":", "self", ".", "_xml", ".", "text", "=", "str", "(", "value", ")", "else", ":", "self", ".", "_xml", ".", "set", "(", "key", ",", "str", "(", "...
u"""Sets an attribute on a node. >>> xml = etree.Element('root') >>> Node(xml).setattr('text', 'text2') >>> Node(xml).getattr('text') 'text2' >>> Node(xml).setattr('attr', 'val') >>> Node(xml).getattr('attr') 'val'
[ "u", "Sets", "an", "attribute", "on", "a", "node", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L90-L104
train
56,596
stxnext/mappet
mappet/mappet.py
Literal.get
def get(self, default=None, callback=None): u"""Returns leaf's value.""" value = self._xml.text if self._xml.text else default return callback(value) if callback else value
python
def get(self, default=None, callback=None): u"""Returns leaf's value.""" value = self._xml.text if self._xml.text else default return callback(value) if callback else value
[ "def", "get", "(", "self", ",", "default", "=", "None", ",", "callback", "=", "None", ")", ":", "value", "=", "self", ".", "_xml", ".", "text", "if", "self", ".", "_xml", ".", "text", "else", "default", "return", "callback", "(", "value", ")", "if"...
u"""Returns leaf's value.
[ "u", "Returns", "leaf", "s", "value", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L209-L212
train
56,597
stxnext/mappet
mappet/mappet.py
Mappet.to_str
def to_str(self, pretty_print=False, encoding=None, **kw): u"""Converts a node with all of it's children to a string. Remaining arguments are passed to etree.tostring as is. kwarg without_comments: bool because it works only in C14N flags: 'pretty print' and 'encoding' are ignored. ...
python
def to_str(self, pretty_print=False, encoding=None, **kw): u"""Converts a node with all of it's children to a string. Remaining arguments are passed to etree.tostring as is. kwarg without_comments: bool because it works only in C14N flags: 'pretty print' and 'encoding' are ignored. ...
[ "def", "to_str", "(", "self", ",", "pretty_print", "=", "False", ",", "encoding", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "kw", ".", "get", "(", "'without_comments'", ")", "and", "not", "kw", ".", "get", "(", "'method'", ")", ":", "kw", ...
u"""Converts a node with all of it's children to a string. Remaining arguments are passed to etree.tostring as is. kwarg without_comments: bool because it works only in C14N flags: 'pretty print' and 'encoding' are ignored. :param bool pretty_print: whether to format the output ...
[ "u", "Converts", "a", "node", "with", "all", "of", "it", "s", "children", "to", "a", "string", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L384-L406
train
56,598
stxnext/mappet
mappet/mappet.py
Mappet.iter_children
def iter_children(self, key=None): u"""Iterates over children. :param key: A key for filtering children by tagname. """ tag = None if key: tag = self._get_aliases().get(key) if not tag: raise KeyError(key) for child in self._xml...
python
def iter_children(self, key=None): u"""Iterates over children. :param key: A key for filtering children by tagname. """ tag = None if key: tag = self._get_aliases().get(key) if not tag: raise KeyError(key) for child in self._xml...
[ "def", "iter_children", "(", "self", ",", "key", "=", "None", ")", ":", "tag", "=", "None", "if", "key", ":", "tag", "=", "self", ".", "_get_aliases", "(", ")", ".", "get", "(", "key", ")", "if", "not", "tag", ":", "raise", "KeyError", "(", "key"...
u"""Iterates over children. :param key: A key for filtering children by tagname.
[ "u", "Iterates", "over", "children", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L412-L429
train
56,599