_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q262900
BasePlugin.get_user
validation
def get_user(self, username): """ Utility function to query slack for a particular user :param username: The username of the user to lookup :return: SlackUser object or None """ if hasattr(self._bot, 'user_manager'): user = self._bot.user_manager.get_by_usern...
python
{ "resource": "" }
q262901
webhook
validation
def webhook(*args, **kwargs): """ Decorator to mark plugin functions as entry points for web calls * route - web route to register, uses Flask syntax * method - GET/POST, defaults to POST """ def wrapper(func): func.is_webhook = True func.route = args[0] func.form_params...
python
{ "resource": "" }
q262902
freeze
validation
def freeze(value): """ Cast value to its frozen counterpart. """ if isinstance(value, list): return FrozenList(*value) if isinstance(value, dict): return FrozenDict(**value) return value
python
{ "resource": "" }
q262903
Core.help
validation
def help(self, msg, args): """Displays help for each command""" output = [] if len(args) == 0: commands = sorted(self._bot.dispatcher.commands.items(), key=itemgetter(0)) commands = filter(lambda x: x[1].is_subcmd is False, commands) # Filter commands if auth ...
python
{ "resource": "" }
q262904
Core.save
validation
def save(self, msg, args): """Causes the bot to write its current state to backend.""" self.send_message(msg.channel, "Saving current state...") self._bot.plugins.save_state() self.send_message(msg.channel, "Done.")
python
{ "resource": "" }
q262905
Core.shutdown
validation
def shutdown(self, msg, args): """Causes the bot to gracefully shutdown.""" self.log.info("Received shutdown from %s", msg.user.username) self._bot.runnable = False return "Shutting down..."
python
{ "resource": "" }
q262906
Core.whoami
validation
def whoami(self, msg, args): """Prints information about the user and bot version.""" output = ["Hello %s" % msg.user] if hasattr(self._bot.dispatcher, 'auth_manager') and msg.user.is_admin is True: output.append("You are a *bot admin*.") output.append("Bot version: %s-%s" % ...
python
{ "resource": "" }
q262907
Core.sleep
validation
def sleep(self, channel): """Causes the bot to ignore all messages from the channel. Usage: !sleep [channel name] - ignore the specified channel (or current if none specified) """ self.log.info('Sleeping in %s', channel) self._bot.dispatcher.ignore(channel) self....
python
{ "resource": "" }
q262908
Core.wake
validation
def wake(self, channel): """Causes the bot to resume operation in the channel. Usage: !wake [channel name] - unignore the specified channel (or current if none specified) """ self.log.info('Waking up in %s', channel) self._bot.dispatcher.unignore(channel) self.se...
python
{ "resource": "" }
q262909
_sort_by
validation
def _sort_by(key): """ High order function for sort methods. """ @staticmethod def sort_by(p_list, reverse=False): return sorted( p_list, key=lambda p: getattr(p, key), reverse=reverse, ) return sort_by
python
{ "resource": "" }
q262910
PathFilters.select
validation
def select(self, filters=all_true, recursive=True): """Select path by criterion. :param filters: a lambda function that take a `pathlib.Path` as input, boolean as a output. :param recursive: include files in subfolder or not. **中文文档** 根据filters中定义的条件选择路径。 """...
python
{ "resource": "" }
q262911
PathFilters.select_file
validation
def select_file(self, filters=all_true, recursive=True): """Select file path by criterion. **中文文档** 根据filters中定义的条件选择文件。 """ for p in self.select(filters, recursive): if p.is_file(): yield p
python
{ "resource": "" }
q262912
PathFilters.select_dir
validation
def select_dir(self, filters=all_true, recursive=True): """Select dir path by criterion. **中文文档** 根据filters中定义的条件选择文件夹。 """ for p in self.select(filters, recursive): if p.is_dir(): yield p
python
{ "resource": "" }
q262913
PathFilters.n_file
validation
def n_file(self): """ Count how many files in this directory. Including file in sub folder. """ self.assert_is_dir_and_exists() n = 0 for _ in self.select_file(recursive=True): n += 1 return n
python
{ "resource": "" }
q262914
PathFilters.n_dir
validation
def n_dir(self): """ Count how many folders in this directory. Including folder in sub folder. """ self.assert_is_dir_and_exists() n = 0 for _ in self.select_dir(recursive=True): n += 1 return n
python
{ "resource": "" }
q262915
PathFilters.select_by_ext
validation
def select_by_ext(self, ext, recursive=True): """ Select file path by extension. :param ext: **中文文档** 选择与预定义的若干个扩展名匹配的文件。 """ ext = [ext.strip().lower() for ext in ensure_list(ext)] def filters(p): return p.suffix.lower() in ext return self.se...
python
{ "resource": "" }
q262916
PathFilters.select_by_pattern_in_fname
validation
def select_by_pattern_in_fname(self, pattern, recursive=True, case_sensitive=False): """ Select file path by text pattern in file name. **中文文档** 选择文件名中包含指定子字符串的文件。 """ ...
python
{ "resource": "" }
q262917
PathFilters.select_by_pattern_in_abspath
validation
def select_by_pattern_in_abspath(self, pattern, recursive=True, case_sensitive=False): """ Select file path by text pattern in absolute path. **中文文档** 选择绝对路径中包含指定子字符串的文件。 ...
python
{ "resource": "" }
q262918
PathFilters.select_by_size
validation
def select_by_size(self, min_size=0, max_size=1 << 40, recursive=True): """ Select file path by size. **中文文档** 选择所有文件大小在一定范围内的文件。 """ def filters(p): return min_size <= p.size <= max_size return self.select_file(filters, recursive)
python
{ "resource": "" }
q262919
PathFilters.select_by_mtime
validation
def select_by_mtime(self, min_time=0, max_time=ts_2100, recursive=True): """ Select file path by modify time. :param min_time: lower bound timestamp :param max_time: upper bound timestamp **中文文档** 选择所有 :attr:`pathlib_mate.pathlib2.Path.mtime` 在一...
python
{ "resource": "" }
q262920
PathFilters.select_by_atime
validation
def select_by_atime(self, min_time=0, max_time=ts_2100, recursive=True): """ Select file path by access time. :param min_time: lower bound timestamp :param max_time: upper bound timestamp **中文文档** 选择所有 :attr:`pathlib_mate.pathlib2.Path.atime` 在一定范围内的文件。 """ ...
python
{ "resource": "" }
q262921
PathFilters.select_by_ctime
validation
def select_by_ctime(self, min_time=0, max_time=ts_2100, recursive=True): """ Select file path by create time. :param min_time: lower bound timestamp :param max_time: upper bound timestamp **中文文档** 选择所有 :attr:`pathlib_mate.pathlib2.Path.ctime` 在一...
python
{ "resource": "" }
q262922
ToolBoxZip.make_zip_archive
validation
def make_zip_archive(self, dst=None, filters=all_true, compress=True, overwrite=False, makedirs=False, verbose=False): # pragma: no cover """ Make a zip ...
python
{ "resource": "" }
q262923
ToolBoxZip.backup
validation
def backup(self, dst=None, ignore=None, ignore_ext=None, ignore_pattern=None, ignore_size_smaller_than=None, ignore_size_larger_than=None, case_sensitive=False): # pragma: no cover """ Create a comp...
python
{ "resource": "" }
q262924
acquire_lock
validation
def acquire_lock(func): """Decorate methods when locking repository is required.""" @wraps(func) def wrapper(self, *args, **kwargs): with self.locker as r: # get the result acquired, code, _ = r if acquired: try: r = func(self,...
python
{ "resource": "" }
q262925
sync_required
validation
def sync_required(func): """Decorate methods when synchronizing repository is required.""" @wraps(func) def wrapper(self, *args, **kwargs): if not self._keepSynchronized: r = func(self, *args, **kwargs) else: state = self._load_state() #print("----------->...
python
{ "resource": "" }
q262926
get_pickling_errors
validation
def get_pickling_errors(obj, seen=None): """Investigate pickling errors.""" if seen == None: seen = [] if hasattr(obj, "__getstate__"): state = obj.__getstate__() #elif hasattr(obj, "__dict__"): # state = obj.__dict__ else: return None #try: # state = obj.__...
python
{ "resource": "" }
q262927
Repository.walk_files_relative_path
validation
def walk_files_relative_path(self, relativePath=""): """ Walk the repository and yield all found files relative path joined with file name. :parameters: #. relativePath (str): The relative path from which start the walk. """ def walk_files(directory, relativePath): ...
python
{ "resource": "" }
q262928
Repository.walk_directories_relative_path
validation
def walk_directories_relative_path(self, relativePath=""): """ Walk repository and yield all found directories relative path :parameters: #. relativePath (str): The relative path from which start the walk. """ def walk_directories(directory, relativePath): ...
python
{ "resource": "" }
q262929
Repository.walk_directories_info
validation
def walk_directories_info(self, relativePath=""): """ Walk repository and yield all found directories relative path. :parameters: #. relativePath (str): The relative path from which start the walk. """ def walk_directories(directory, relativePath): direct...
python
{ "resource": "" }
q262930
Repository.walk_directory_directories_relative_path
validation
def walk_directory_directories_relative_path(self, relativePath=""): """ Walk a certain directory in repository and yield all found directories relative path. :parameters: #. relativePath (str): The relative path of the directory. """ # get directory info dict ...
python
{ "resource": "" }
q262931
Repository.synchronize
validation
def synchronize(self, verbose=False): """ Synchronizes the Repository information with the directory. All registered but missing files and directories in the directory, will be automatically removed from the Repository. :parameters: #. verbose (boolean): Whether to b...
python
{ "resource": "" }
q262932
Repository.load_repository
validation
def load_repository(self, path): """ Load repository from a directory path and update the current instance. :Parameters: #. path (string): The path of the directory from where to load the repository. If '.' or an empty string is passed, the current working directory w...
python
{ "resource": "" }
q262933
Repository.get_repository
validation
def get_repository(self, path, info=None, verbose=True): """ Create a repository at given real path or load any existing one. This method insures the creation of the directory in the system if it is missing.\n Unlike create_repository, this method doesn't erase any existing repository ...
python
{ "resource": "" }
q262934
Repository.remove_repository
validation
def remove_repository(self, path=None, relatedFiles=False, relatedFolders=False, verbose=True): """ Remove .pyrepinfo file from path if exists and related files and directories when respective flags are set to True. :Parameters: #. path (None, string): The path of the direct...
python
{ "resource": "" }
q262935
Repository.save
validation
def save(self): """ Save repository .pyrepinfo to disk. """ # open file repoInfoPath = os.path.join(self.__path, ".pyrepinfo") try: fdinfo = open(repoInfoPath, 'wb') except Exception as e: raise Exception("unable to open repository info for saving (%s)"%e)...
python
{ "resource": "" }
q262936
Repository.create_package
validation
def create_package(self, path=None, name=None, mode=None): """ Create a tar file package of all the repository files and directories. Only files and directories that are stored in the repository info are stored in the package tar file. **N.B. On some systems packaging requires r...
python
{ "resource": "" }
q262937
Repository.get_directory_info
validation
def get_directory_info(self, relativePath): """ get directory info from the Repository. :Parameters: #. relativePath (string): The relative to the repository path of the directory. :Returns: #. info (None, dictionary): The directory information dictionary. ...
python
{ "resource": "" }
q262938
Repository.get_parent_directory_info
validation
def get_parent_directory_info(self, relativePath): """ get parent directory info of a file or directory from the Repository. :Parameters: #. relativePath (string): The relative to the repository path of the file or directory of which the parent directory info is requested. ...
python
{ "resource": "" }
q262939
Repository.get_file_info
validation
def get_file_info(self, relativePath, name=None): """ get file information dict from the repository given its relative path and name. :Parameters: #. relativePath (string): The relative to the repository path of the directory where the file is. #. name (string): The file...
python
{ "resource": "" }
q262940
Repository.get_file_relative_path_by_id
validation
def get_file_relative_path_by_id(self, id): """ Given an id, get the corresponding file info relative path joined with file name. Parameters: #. id (string): The file unique id string. :Returns: #. relativePath (string): The file relative path joined with file n...
python
{ "resource": "" }
q262941
Repository.get_file_relative_path_by_name
validation
def get_file_relative_path_by_name(self, name, skip=0): """ Get file relative path given the file name. If file name is redundant in different directories in the repository, this method ensures to return all or some of the files according to skip value. Parameters: #...
python
{ "resource": "" }
q262942
Repository.add_directory
validation
def add_directory(self, relativePath, info=None): """ Adds a directory in the repository and creates its attribute in the Repository with utc timestamp. It insures adding all the missing directories in the path. :Parameters: #. relativePath (string): The relative to ...
python
{ "resource": "" }
q262943
Repository.remove_directory
validation
def remove_directory(self, relativePath, removeFromSystem=False): """ Remove directory from repository. :Parameters: #. relativePath (string): The relative to the repository path of the directory to remove from the repository. #. removeFromSystem (boolean): Whether to al...
python
{ "resource": "" }
q262944
Repository.move_directory
validation
def move_directory(self, relativePath, relativeDestination, replace=False, verbose=True): """ Move a directory in the repository from one place to another. It insures moving all the files and subdirectories in the system. :Parameters: #. relativePath (string): The relative t...
python
{ "resource": "" }
q262945
Repository.rename_file
validation
def rename_file(self, relativePath, name, newName, replace=False, verbose=True): """ Rename a directory in the repository. It insures renaming the file in the system. :Parameters: #. relativePath (string): The relative to the repository path of the directory where the file is locate...
python
{ "resource": "" }
q262946
Repository.dump_copy
validation
def dump_copy(self, path, relativePath, name=None, description=None, replace=False, verbose=False): """ Copy an exisitng system file to the repository. attribute in the Repository with utc timestamp. :Parameters: #. path (str):...
python
{ "resource": "" }
q262947
Repository.update_file
validation
def update_file(self, value, relativePath, name=None, description=False, klass=False, dump=False, pull=False, ACID=None, verbose=False): """ Update the value and the utc timestamp of a file that is already in the Repository.\n...
python
{ "resource": "" }
q262948
ensure_str
validation
def ensure_str(value): """ Ensure value is string. """ if isinstance(value, six.string_types): return value else: return six.text_type(value)
python
{ "resource": "" }
q262949
TraceCollector.stats
validation
def stats(cls, traces): """Build per minute stats for each key""" data = {} stats = {} # Group traces by key and minute for trace in traces: key = trace['key'] if key not in data: data[key] = [] stats[key] = {} ...
python
{ "resource": "" }
q262950
SynchronisedFilesDataSource.start
validation
def start(self): """ Monitors data kept in files in the predefined directory in a new thread. Note: Due to the underlying library, it may take a few milliseconds after this method is started for changes to start to being noticed. """ with self._status_lock: i...
python
{ "resource": "" }
q262951
SynchronisedFilesDataSource.stop
validation
def stop(self): """ Stops monitoring the predefined directory. """ with self._status_lock: if self._running: assert self._observer is not None self._observer.stop() self._running = False self._origin_mapped_data ...
python
{ "resource": "" }
q262952
SynchronisedFilesDataSource._on_file_moved
validation
def _on_file_moved(self, event: FileSystemMovedEvent): """ Called when a file in the monitored directory has been moved. Breaks move down into a delete and a create (which it is sometimes detected as!). :param event: the file system event """ if not event.is_directory an...
python
{ "resource": "" }
q262953
TempManager.tear_down
validation
def tear_down(self): """ Tears down all temp files and directories. """ while len(self._temp_directories) > 0: directory = self._temp_directories.pop() shutil.rmtree(directory, ignore_errors=True) while len(self._temp_files) > 0: file = self._t...
python
{ "resource": "" }
q262954
MutateMethods.is_not_exist_or_allow_overwrite
validation
def is_not_exist_or_allow_overwrite(self, overwrite=False): """ Test whether a file target is not exists or it exists but allow overwrite. """ if self.exists() and overwrite is False: return False else: # pragma: no cover return True
python
{ "resource": "" }
q262955
MutateMethods.copyto
validation
def copyto(self, new_abspath=None, new_dirpath=None, new_dirname=None, new_basename=None, new_fname=None, new_ext=None, overwrite=False, makedirs=False): """ Copy this file to other pl...
python
{ "resource": "" }
q262956
create_client
validation
def create_client() -> APIClient: """ Clients a Docker client. Will raise a `ConnectionError` if the Docker daemon is not accessible. :return: the Docker client """ global _client client = _client() if client is None: # First try looking at the environment variables for specific...
python
{ "resource": "" }
q262957
path_required
validation
def path_required(func): """Decorate methods when repository path is required.""" @wraps(func) def wrapper(self, *args, **kwargs): if self.path is None: warnings.warn('Must load (Repository.load_repository) or initialize (Repository.create_repository) the repository first !') ...
python
{ "resource": "" }
q262958
Repository.__clean_before_after
validation
def __clean_before_after(self, stateBefore, stateAfter, keepNoneEmptyDirectory=True): """clean repository given before and after states""" # prepare after for faster search errors = [] afterDict = {} [afterDict.setdefault(list(aitem)[0],[]).append(aitem) for aitem in stateAfte...
python
{ "resource": "" }
q262959
Repository.get_stats
validation
def get_stats(self): """ Get repository descriptive stats :Returns: #. numberOfDirectories (integer): Number of diretories in repository #. numberOfFiles (integer): Number of files in repository """ if self.__path is None: return 0,0 n...
python
{ "resource": "" }
q262960
Repository.reset
validation
def reset(self): """Reset repository instance. """ self.__path = None self.__repo = {'repository_unique_name': str(uuid.uuid1()), 'create_utctime': time.time(), 'last_update_utctime': None, 'pyrep_version': st...
python
{ "resource": "" }
q262961
Repository.load_repository
validation
def load_repository(self, path, verbose=True, ntrials=3): """ Load repository from a directory path and update the current instance. First, new repository still will be loaded. If failed, then old style repository load will be tried. :Parameters: #. path (string): Th...
python
{ "resource": "" }
q262962
Repository.remove_repository
validation
def remove_repository(self, path=None, removeEmptyDirs=True): """ Remove all repository from path along with all repository tracked files. :Parameters: #. path (None, string): The path the repository to remove. #. removeEmptyDirs (boolean): Whether to remove remaining em...
python
{ "resource": "" }
q262963
Repository.is_name_allowed
validation
def is_name_allowed(self, path): """ Get whether creating a file or a directory from the basenane of the given path is allowed :Parameters: #. path (str): The absolute or relative path or simply the file or directory name. :Returns: #. all...
python
{ "resource": "" }
q262964
Repository.to_repo_relative_path
validation
def to_repo_relative_path(self, path, split=False): """ Given a path, return relative path to diretory :Parameters: #. path (str): Path as a string #. split (boolean): Whether to split path to its components :Returns: #. relativePath (str, list): Rel...
python
{ "resource": "" }
q262965
Repository.get_repository_state
validation
def get_repository_state(self, relaPath=None): """ Get a list representation of repository state along with useful information. List state is ordered relativeley to directories level :Parameters: #. relaPath (None, str): relative directory path from where to s...
python
{ "resource": "" }
q262966
Repository.get_file_info
validation
def get_file_info(self, relativePath): """ Get file information dict from the repository given its relative path. :Parameters: #. relativePath (string): The relative to the repository path of the file. :Returns: #. info (None, dictionary): The fil...
python
{ "resource": "" }
q262967
Repository.is_repository_file
validation
def is_repository_file(self, relativePath): """ Check whether a given relative path is a repository file path :Parameters: #. relativePath (string): File relative path :Returns: #. isRepoFile (boolean): Whether file is a repository file. #. isFileOnD...
python
{ "resource": "" }
q262968
Repository.create_package
validation
def create_package(self, path=None, name=None, mode=None): """ Create a tar file package of all the repository files and directories. Only files and directories that are tracked in the repository are stored in the package tar file. **N.B. On some systems packaging requires root ...
python
{ "resource": "" }
q262969
Metadata.rename
validation
def rename(self, key: Any, new_key: Any): """ Renames an item in this collection as a transaction. Will override if new key name already exists. :param key: the current name of the item :param new_key: the new name that the item should have """ if new_key == key:...
python
{ "resource": "" }
q262970
get_text_fingerprint
validation
def get_text_fingerprint(text, hash_meth, encoding="utf-8"): # pragma: no cover """ Use default hash method to return hash value of a piece of string default setting use 'utf-8' encoding. """ m = hash_meth() m.update(text.encode(encoding)) return m.hexdigest()
python
{ "resource": "" }
q262971
md5file
validation
def md5file(abspath, nbytes=0, chunk_size=DEFAULT_CHUNK_SIZE): """ Return md5 hash value of a piece of a file Estimate processing time on: :param abspath: the absolute path to the file :param nbytes: only has first N bytes of the file. if 0 or None, hash all file CPU = i7-4600U 2.10GHz ...
python
{ "resource": "" }
q262972
sha256file
validation
def sha256file(abspath, nbytes=0, chunk_size=DEFAULT_CHUNK_SIZE): """ Return sha256 hash value of a piece of a file Estimate processing time on: :param abspath: the absolute path to the file :param nbytes: only has first N bytes of the file. if 0 or None, hash all file """ return get...
python
{ "resource": "" }
q262973
sha512file
validation
def sha512file(abspath, nbytes=0, chunk_size=DEFAULT_CHUNK_SIZE): """ Return sha512 hash value of a piece of a file Estimate processing time on: :param abspath: the absolute path to the file :param nbytes: only has first N bytes of the file. if 0 or None, hash all file """ return get...
python
{ "resource": "" }
q262974
ToolBox.auto_complete_choices
validation
def auto_complete_choices(self, case_sensitive=False): """ A command line auto complete similar behavior. Find all item with same prefix of this one. :param case_sensitive: toggle if it is case sensitive. :return: list of :class:`pathlib_mate.pathlib2.Path`. """ ...
python
{ "resource": "" }
q262975
ToolBox.print_big_dir
validation
def print_big_dir(self, top_n=5): """ Print ``top_n`` big dir in this dir. """ self.assert_is_dir_and_exists() size_table = sorted( [(p, p.dirsize) for p in self.select_dir(recursive=False)], key=lambda x: x[1], reverse=True, ) ...
python
{ "resource": "" }
q262976
ToolBox.print_big_file
validation
def print_big_file(self, top_n=5): """ Print ``top_n`` big file in this dir. """ self.assert_is_dir_and_exists() size_table = sorted( [(p, p.size) for p in self.select_file(recursive=True)], key=lambda x: x[1], reverse=True, ) ...
python
{ "resource": "" }
q262977
ToolBox.print_big_dir_and_big_file
validation
def print_big_dir_and_big_file(self, top_n=5): """Print ``top_n`` big dir and ``top_n`` big file in each dir. """ self.assert_is_dir_and_exists() size_table1 = sorted( [(p, p.dirsize) for p in self.select_dir(recursive=False)], key=lambda x: x[1], rev...
python
{ "resource": "" }
q262978
ToolBox.mirror_to
validation
def mirror_to(self, dst): # pragma: no cover """ Create a new folder having exactly same structure with this directory. However, all files are just empty file with same file name. :param dst: destination directory. The directory can't exists before you execute this. **...
python
{ "resource": "" }
q262979
ToolBox.execute_pyfile
validation
def execute_pyfile(self, py_exe=None): # pragma: no cover """ Execute every ``.py`` file as main script. :param py_exe: str, python command or python executable path. **中文文档** 将目录下的所有Python文件作为主脚本用当前解释器运行。 """ import subprocess self.assert_is_dir_and_...
python
{ "resource": "" }
q262980
ToolBox.trail_space
validation
def trail_space(self, filters=lambda p: p.ext == ".py"): # pragma: no cover """ Trail white space at end of each line for every ``.py`` file. **中文文档** 将目录下的所有被选择的文件中行末的空格删除。 """ self.assert_is_dir_and_exists() for p in self.select_file(filters): tr...
python
{ "resource": "" }
q262981
ToolBox.autopep8
validation
def autopep8(self, **kwargs): # pragma: no cover """ Auto convert your python code in a directory to pep8 styled code. :param kwargs: arguments for ``autopep8.fix_code`` method. **中文文档** 将目录下的所有Python文件用pep8风格格式化。增加其可读性和规范性。 """ self.assert_is_dir_and_exists()...
python
{ "resource": "" }
q262982
AttrAccessor.size
validation
def size(self): """ File size in bytes. """ try: return self._stat.st_size except: # pragma: no cover self._stat = self.stat() return self.size
python
{ "resource": "" }
q262983
AttrAccessor.mtime
validation
def mtime(self): """ Get most recent modify time in timestamp. """ try: return self._stat.st_mtime except: # pragma: no cover self._stat = self.stat() return self.mtime
python
{ "resource": "" }
q262984
AttrAccessor.atime
validation
def atime(self): """ Get most recent access time in timestamp. """ try: return self._stat.st_atime except: # pragma: no cover self._stat = self.stat() return self.atime
python
{ "resource": "" }
q262985
AttrAccessor.ctime
validation
def ctime(self): """ Get most recent create time in timestamp. """ try: return self._stat.st_ctime except: # pragma: no cover self._stat = self.stat() return self.ctime
python
{ "resource": "" }
q262986
StrictConfigParser.unusedoptions
validation
def unusedoptions(self, sections): """Lists options that have not been used to format other values in their sections. Good for finding out if the user has misspelled any of the options. """ unused = set([]) for section in _list(sections): if not sel...
python
{ "resource": "" }
q262987
tui.keys
validation
def keys(self): """List names of options and positional arguments.""" return self.options.keys() + [p.name for p in self.positional_args]
python
{ "resource": "" }
q262988
tui._add_option
validation
def _add_option(self, option): """Add an Option object to the user interface.""" if option.name in self.options: raise ValueError('name already in use') if option.abbreviation in self.abbreviations: raise ValueError('abbreviation already in use') if option.name in...
python
{ "resource": "" }
q262989
tui._add_positional_argument
validation
def _add_positional_argument(self, posarg): """Append a positional argument to the user interface. Optional positional arguments must be added after the required ones. The user interface can have at most one recurring positional argument, and if present, that argument must be the last...
python
{ "resource": "" }
q262990
tui.read_docs
validation
def read_docs(self, docsfiles): """Read program documentation from a DocParser compatible file. docsfiles is a list of paths to potential docsfiles: parse if present. A string is taken as a list of one item. """ updates = DocParser() for docsfile in _list(docsfiles): ...
python
{ "resource": "" }
q262991
tui.optionhelp
validation
def optionhelp(self, indent=0, maxindent=25, width=79): """Return user friendly help on program options.""" def makelabels(option): labels = '%*s--%s' % (indent, ' ', option.name) if option.abbreviation: labels += ', -' + option.abbreviation return lab...
python
{ "resource": "" }
q262992
tui.posarghelp
validation
def posarghelp(self, indent=0, maxindent=25, width=79): """Return user friendly help on positional arguments in the program.""" docs = [] makelabel = lambda posarg: ' ' * indent + posarg.displayname + ': ' helpindent = _autoindent([makelabel(p) for p in self.positional_args], indent, max...
python
{ "resource": "" }
q262993
tui.strsettings
validation
def strsettings(self, indent=0, maxindent=25, width=0): """Return user friendly help on positional arguments. indent is the number of spaces preceeding the text on each line. The indent of the documentation is dependent on the length of the longest label that is short...
python
{ "resource": "" }
q262994
tui.settingshelp
validation
def settingshelp(self, width=0): """Return a summary of program options, their values and origins. width is maximum allowed page width, use self.width if 0. """ out = [] out.append(self._wrap(self.docs['title'], width=width)) if self.docs['description']: ...
python
{ "resource": "" }
q262995
TextBlockParser.parse
validation
def parse(self, file): """Parse text blocks from a file.""" if isinstance(file, basestring): file = open(file) line_number = 0 label = None block = self.untagged for line in file: line_number += 1 line = line.rstrip('\n') if...
python
{ "resource": "" }
q262996
Format.parse
validation
def parse(self, argv): """Pop, parse and return the first self.nargs items from args. if self.nargs > 1 a list of parsed values will be returned. Raise BadNumberOfArguments or BadArgument on errors. NOTE: argv may be modified in place by this method. """ ...
python
{ "resource": "" }
q262997
Flag.parsestr
validation
def parsestr(self, argstr): """Parse arguments found in settings files. Use the values in self.true for True in settings files, or those in self.false for False, case insensitive. """ argv = shlex.split(argstr, comments=True) if len(argv) != 1: raise...
python
{ "resource": "" }
q262998
Tuple.get_separator
validation
def get_separator(self, i): """Return the separator that preceding format i, or '' for i == 0.""" return i and self.separator[min(i - 1, len(self.separator) - 1)] or ''
python
{ "resource": "" }
q262999
MixcloudOauth.authorize_url
validation
def authorize_url(self): """ Return a URL to redirect the user to for OAuth authentication. """ auth_url = OAUTH_ROOT + '/authorize' params = { 'client_id': self.client_id, 'redirect_uri': self.redirect_uri, } return "{}?{}".format(auth_url...
python
{ "resource": "" }