Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def _trim(self): index = self._get_index() backup_limit = config().backup_count() - 1 for changeset in index[backup_limit:]: self.delete(changeset[0], p_write=False)
[ "\n Removes oldest backups that exceed the limit configured in backup_count\n option.\n\n Does not write back to file system, make sure to call self._write()\n afterwards.\n " ]
Please provide a description of the function:def read_backup(self, p_todolist=None, p_timestamp=None): if not p_timestamp: change_hash = hash_todolist(p_todolist) index = self._get_index() self.timestamp = index[[change[1] for change in index].index(change_hash)][0] ...
[ "\n Retrieves a backup for p_timestamp or p_todolist (if p_timestamp is not\n specified) from backup file and sets timestamp, todolist, archive and\n label attributes to appropriate data from it.\n " ]
Please provide a description of the function:def apply(self, p_todolist, p_archive): if self.todolist and p_todolist: p_todolist.replace(self.todolist.todos()) if self.archive and p_archive: p_archive.replace(self.archive.todos())
[ " Applies backup on supplied p_todolist. " ]
Please provide a description of the function:def run(self): args = self._process_flags() self.todofile = TodoFile.TodoFile(config().todotxt()) self.todolist = TodoList.TodoList(self.todofile.read()) try: (subcommand, args) = get_subcommand(args) except Conf...
[ " Main entry function. " ]
Please provide a description of the function:def pretty_printer_factory(p_todolist, p_additional_filters=None): p_additional_filters = p_additional_filters or [] printer = PrettyPrinter() printer.add_filter(PrettyPrinterNumbers(p_todolist)) for ppf in p_additional_filters: printer.add_fil...
[ " Returns a pretty printer suitable for the ls and dep subcommands. " ]
Please provide a description of the function:def print_todo(self, p_todo): todo_str = p_todo.source() for ppf in self.filters: todo_str = ppf.filter(todo_str, p_todo) return TopydoString(todo_str)
[ " Given a todo item, pretty print it. " ]
Please provide a description of the function:def group(self, p_todos): # preorder todos for the group sort p_todos = _apply_sort_functions(p_todos, self.pregroupfunctions) # initialize result with a single group result = OrderedDict([((), p_todos)]) for (function, labe...
[ "\n Groups the todos according to the given group string.\n " ]
Please provide a description of the function:def humanize_dates(p_due=None, p_start=None, p_creation=None): dates_list = [] if p_creation: dates_list.append(humanize_date(p_creation)) if p_due: dates_list.append('due ' + humanize_date(p_due)) if p_start: now = arrow.now().da...
[ "\n Returns string with humanized versions of p_due, p_start and p_creation.\n Examples:\n - all dates: \"16 days ago, due in a month, started 2 days ago\"\n - p_due and p_start: \"due in a month, started 2 days ago\"\n - p_creation and p_due: \"16 days ago, due in a month\"\n " ]
Please provide a description of the function:def _strip_placeholder_braces(p_matchobj): before = p_matchobj.group('before') or '' placeholder = p_matchobj.group('placeholder') after = p_matchobj.group('after') or '' whitespace = p_matchobj.group('whitespace') or '' return before + '%' + placeh...
[ "\n Returns string with conditional braces around placeholder stripped and\n percent sign glued into placeholder character.\n\n Returned string is composed from 'start', 'before', 'placeholder', 'after',\n 'whitespace', and 'end' match-groups of p_matchobj. Conditional braces are\n stripped from 'bef...
Please provide a description of the function:def _truncate(p_str, p_repl): # 4 is for '...' and an extra space at the end text_lim = _columns() - len(escape_ansi(p_str)) - 4 truncated_str = re.sub(re.escape(p_repl), p_repl[:text_lim] + '...', p_str) return truncated_str
[ "\n Returns p_str with truncated and ended with '...' version of p_repl.\n\n Place of the truncation is calculated depending on p_max_width.\n " ]
Please provide a description of the function:def _right_align(p_str): to_fill = _columns() - len(escape_ansi(p_str)) if to_fill > 0: p_str = re.sub('\t', ' '*to_fill, p_str) else: p_str = re.sub('\t', ' ', p_str) return p_str
[ "\n Returns p_str with content after <TAB> character aligned right.\n\n Right alignment is done using proper number of spaces calculated from\n 'line_width' attribute.\n " ]
Please provide a description of the function:def _preprocess_format(self): format_split = re.split(r'(?<!\\)%', self.format_string) preprocessed_format = [] for idx, substr in enumerate(format_split): if idx == 0: getter = None placeholder = ...
[ "\n Preprocess the format_string attribute.\n\n Splits the format string on each placeholder and returns a list of\n tuples containing substring, placeholder name, and function\n retrieving content for placeholder (getter).\n\n Relevant placeholder functions (getters) are taken fr...
Please provide a description of the function:def parse(self, p_todo): parsed_list = [] repl_trunc = None for substr, placeholder, getter in self.format_list: repl = getter(p_todo) if getter else '' pattern = MAIN_PATTERN.format(ph=placeholder) if pl...
[ "\n Returns fully parsed string from 'format_string' attribute with all\n placeholders properly substituted by content obtained from p_todo.\n\n It uses preprocessed form of 'format_string' (result of\n ListFormatParser._preprocess_format) stored in 'format_list'\n attribute.\n ...
Please provide a description of the function:def _load_file(self): self.todolist.erase() self.todolist.add_list(self.todofile.read()) self.completer = PromptCompleter(self.todolist)
[ "\n Reads the configured todo.txt file and loads it into the todo list\n instance.\n " ]
Please provide a description of the function:def run(self): history = InMemoryHistory() self._load_file() while True: # (re)load the todo.txt file (only if it has been modified) try: user_input = prompt(u'topydo> ', history=history, ...
[ " Main entry function. " ]
Please provide a description of the function:def execute(self): if self.args and self.argument(0) == "help": self.error(self.usage() + "\n\n" + self.help()) return False return True
[ "\n Execute the command. Intercepts the help subsubcommand to show the help\n text.\n " ]
Please provide a description of the function:def argument(self, p_number): try: return self.args[p_number] except IndexError as ie: raise InvalidCommandArgument from ie
[ " Retrieves a value from the argument list at the given position. " ]
Please provide a description of the function:def append(self, p_string, p_color): self.colors[len(self.data)] = p_color self.data += p_string
[ "\n Append a string with the given color (normal Color or an\n AbstractColor).\n " ]
Please provide a description of the function:def config(p_path=None, p_overrides=None): if not config.instance or p_path is not None or p_overrides is not None: try: config.instance = _Config(p_path, p_overrides) except configparser.ParsingError as perr: raise ConfigErro...
[ "\n Retrieve the config instance.\n\n If a path is given, the instance is overwritten by the one that supplies an\n additional filename (for testability). Moreover, no other configuration\n files will be read when a path is given.\n\n Overrides will discard a setting in any configuration file and use...
Please provide a description of the function:def colors(self, p_hint_possible=True): lookup = { 'false': 0, 'no': 0, '0': 0, '1': 16, 'true': 16, 'yes': 16, '16': 16, '256': 256, } try: ...
[ "\n Returns 0, 16 or 256 representing the number of colors that should be\n used in the output.\n\n A hint can be passed whether the device that will output the text\n supports colors.\n " ]
Please provide a description of the function:def hidden_tags(self): hidden_tags = self.cp.get('ls', 'hide_tags') # pylint: disable=no-member return [] if hidden_tags == '' else [tag.strip() for tag in hidden_tags.split(',')]
[ " Returns a list of tags to be hidden from the 'ls' output. " ]
Please provide a description of the function:def hidden_item_tags(self): hidden_item_tags = self.cp.get('ls', 'hidden_item_tags') # pylint: disable=no-member return [] if hidden_item_tags == '' else [tag.strip() for tag in hidden_item_ta...
[ " Returns a list of tags which hide an item from the 'ls' output. " ]
Please provide a description of the function:def priority_color(self, p_priority): def _str_to_dict(p_string): pri_colors_dict = dict() for pri_color in p_string.split(','): pri, color = pri_color.split(':') pri_colors_dict[pri] = Color(color) ...
[ "\n Returns a dict with priorities as keys and color numbers as value.\n " ]
Please provide a description of the function:def aliases(self): aliases = self.cp.items('aliases') alias_dict = dict() for alias, meaning in aliases: try: meaning = shlex.split(meaning) real_subcommand = meaning[0] alias_args ...
[ "\n Returns dict with aliases names as keys and pairs of actual\n subcommand and alias args as values.\n " ]
Please provide a description of the function:def column_keymap(self): keystates = set() shortcuts = self.cp.items('column_keymap') keymap_dict = dict(shortcuts) for combo, action in shortcuts: # add all possible prefixes to keystates combo_as_list = re....
[ " Returns keymap and keystates used in column mode " ]
Please provide a description of the function:def editor(self): result = 'vi' if 'TOPYDO_EDITOR' in os.environ and os.environ['TOPYDO_EDITOR']: result = os.environ['TOPYDO_EDITOR'] else: try: result = str(self.cp.get('edit', 'editor')) ...
[ "\n Returns the editor to invoke. It returns a list with the command in\n the first position and its arguments in the remainder.\n " ]
Please provide a description of the function:def execute(self): if not super().execute(): return False self.printer.add_filter(PrettyPrinterNumbers(self.todolist)) self._process_flags() if self.from_file: try: new_todos = self.get_todos_...
[ " Adds a todo item to the list. " ]
Please provide a description of the function:def advance_recurring_todo(p_todo, p_offset=None, p_strict=False): todo = Todo(p_todo.source()) pattern = todo.tag_value('rec') if not pattern: raise NoRecurrenceException() elif pattern.startswith('+'): p_strict = True # strip o...
[ "\n Given a Todo item, return a new instance of a Todo item with the dates\n shifted according to the recurrence rule.\n\n Strict means that the real due date is taken as a offset, not today or a\n future date to determine the offset.\n\n When the todo item has no due date, then the date is used pass...
Please provide a description of the function:def _get_table_size(p_alphabet, p_num): try: for width, size in sorted(_TABLE_SIZES[len(p_alphabet)].items()): if p_num < size * 0.01: return width, size except KeyError: pass raise _TableSizeException('Could not ...
[ "\n Returns a prime number that is suitable for the hash table size. The size\n is dependent on the alphabet used, and the number of items that need to be\n hashed. The table size is at least 100 times larger than the number of\n items to be hashed, to avoid collisions.\n\n When the alphabet is too l...
Please provide a description of the function:def hash_list_values(p_list, p_key=lambda i: i): # pragma: no branch def to_base(p_alphabet, p_value): result = '' while p_value: p_value, i = divmod(p_value, len(p_alphabet)) result = p_alphabet[i] + result ...
[ "\n Calculates a unique value for each item in the list, these can be used as\n identifiers.\n\n The value is based on hashing an item using the p_key function.\n\n Suitable for lists not larger than approx. 16K items.\n\n Returns a tuple with the status and a list of tuples where each item is\n c...
Please provide a description of the function:def max_id_length(p_num): try: alphabet = config().identifier_alphabet() length, _ = _get_table_size(alphabet, p_num) except _TableSizeException: length, _ = _get_table_size(_DEFAULT_ALPHABET, p_num) return length
[ "\n Returns the length of the IDs used, given the number of items that are\n assigned an ID. Used for padding in lists.\n " ]
Please provide a description of the function:def filter(self, p_todo_str, p_todo): if config().colors(): p_todo_str = TopydoString(p_todo_str, p_todo) priority_color = config().priority_color(p_todo.priority()) colors = [ (r'\B@(\S*\w)', AbstractCol...
[ " Applies the colors. " ]
Please provide a description of the function:def get_filter_list(p_expression): result = [] for arg in p_expression: # when a word starts with -, it should be negated is_negated = len(arg) > 1 and arg[0] == '-' arg = arg[1:] if is_negated else arg argfilter = None f...
[ "\n Returns a list of GrepFilters, OrdinalTagFilters or NegationFilters based\n on the given filter expression.\n\n The filter expression is a list of strings.\n " ]
Please provide a description of the function:def match(self, p_todo): children = self.todolist.children(p_todo) uncompleted = [todo for todo in children if not todo.is_completed()] return not uncompleted
[ "\n Returns True when there are no children that are uncompleted yet.\n " ]
Please provide a description of the function:def match(self, p_todo): try: self.todos.index(p_todo) return True except ValueError: return False
[ "\n Returns True when p_todo appears in the list of given todos.\n " ]
Please provide a description of the function:def match(self, p_todo): for my_tag in config().hidden_item_tags(): my_values = p_todo.tag_values(my_tag) for my_value in my_values: if not my_value in (0, '0', False, 'False'): return False ...
[ "\n Returns True when p_todo doesn't have a tag to mark it as hidden.\n " ]
Please provide a description of the function:def compare_operands(self, p_operand1, p_operand2): if self.operator == '<': return p_operand1 < p_operand2 elif self.operator == '<=': return p_operand1 <= p_operand2 elif self.operator == '=': return p_op...
[ "\n Returns True if conditional constructed from both operands and\n self.operator is valid. Returns False otherwise.\n " ]
Please provide a description of the function:def match(self, p_todo): def resort_to_grep_filter(): grep = GrepFilter(self.expression) return grep.match(p_todo) if not self.key or not p_todo.has_tag(self.key): return False if len(p_todo.tag_values(se...
[ "\n Performs a match on a key:value tag in the todo.\n\n First it tries to convert the value and the user-entered expression to\n a date and makes a comparison if it succeeds, based on the given\n operator (default ==).\n Upon failure, it falls back to converting value and user-en...
Please provide a description of the function:def match(self, p_todo): operand1 = self.value operand2 = p_todo.priority() or 'ZZ' return self.compare_operands(operand1, operand2)
[ "\n Performs a match on a priority in the todo.\n\n It gets priority from p_todo and compares it with user-entered\n expression based on the given operator (default ==). It does that however\n in reversed order to obtain more intuitive result. Example: (>B) will\n match todos with...
Please provide a description of the function:def as_rgb(self): html = self.as_html() return ( int(html[1:3], 16), int(html[3:5], 16), int(html[5:7], 16) )
[ "\n Returns a tuple (r, g, b) of the color.\n " ]
Please provide a description of the function:def date_suggestions(): # don't use strftime, prevent locales to kick in days_of_week = { 0: "Monday", 1: "Tuesday", 2: "Wednesday", 3: "Thursday", 4: "Friday", 5: "Saturday", 6: "Sunday" } dates =...
[ "\n Returns a list of relative date that is presented to the user as auto\n complete suggestions.\n " ]
Please provide a description of the function:def write(p_file, p_string): if not config().colors(p_file.isatty()): p_string = escape_ansi(p_string) if p_string: p_file.write(p_string + "\n")
[ "\n Write p_string to file p_file, trailed by a newline character.\n\n ANSI codes are removed when the file is not a TTY (and colors are\n automatically determined).\n " ]
Please provide a description of the function:def lookup_color(p_color): if not lookup_color.colors: lookup_color.colors[AbstractColor.NEUTRAL] = Color('NEUTRAL') lookup_color.colors[AbstractColor.PROJECT] = config().project_color() lookup_color.colors[AbstractColor.CONTEXT] = config().c...
[ "\n Converts an AbstractColor to a normal Color. Returns the Color itself\n when a normal color is passed.\n " ]
Please provide a description of the function:def insert_ansi(p_string): result = p_string.data for pos, color in sorted(p_string.colors.items(), reverse=True): color = lookup_color(color) result = result[:pos] + color.as_ansi() + result[pos:] return result
[ " Returns a string with color information at the right positions. " ]
Please provide a description of the function:def version(): from topydo.lib.Version import VERSION, LICENSE print("topydo {}\n".format(VERSION)) print(LICENSE) sys.exit(0)
[ " Print the current version and exit. " ]
Please provide a description of the function:def _retrieve_archive(): archive_file = TodoFile.TodoFile(config().archive()) archive = TodoListBase.TodoListBase(archive_file.read()) return (archive, archive_file)
[ "\n Returns a tuple with archive content: the first element is a TodoListBase\n and the second element is a TodoFile.\n " ]
Please provide a description of the function:def _archive(self): archive, archive_file = _retrieve_archive() if self.backup: self.backup.add_archive(archive) if archive: from topydo.commands.ArchiveCommand import ArchiveCommand command = ArchiveComm...
[ "\n Performs an archive action on the todolist.\n\n This means that all completed tasks are moved to the archive file\n (defaults to done.txt).\n " ]
Please provide a description of the function:def is_read_only(p_command): read_only_commands = tuple(cmd for cmd in ('revert', ) + READ_ONLY_COMMANDS) return p_command.name() in read_only_commands
[ " Returns True when the given command class is read-only. " ]
Please provide a description of the function:def _execute(self, p_command, p_args): self._backup(p_command, p_args) command = p_command( p_args, self.todolist, output, error, input) if command.execute() != False: ...
[ "\n Execute a subcommand with arguments. p_command is a class (not an\n object).\n " ]
Please provide a description of the function:def _post_execute(self): if self.todolist.dirty: # do not archive when the value of the filename is an empty string # (i.e. explicitly left empty in the configuration if self.do_archive and config().archive(): ...
[ "\n Should be called when executing the user requested command has been\n completed. It will do some maintenance and write out the final result\n to the todo.txt file.\n " ]
Please provide a description of the function:def get_date(self, p_tag): string = self.tag_value(p_tag) result = None try: result = date_string_to_date(string) if string else None except ValueError: pass return result
[ " Given a date tag, return a date object. " ]
Please provide a description of the function:def is_active(self): start = self.start_date() return not self.is_completed() and (not start or start <= date.today())
[ "\n Returns True when the start date is today or in the past and the\n task has not yet been completed.\n " ]
Please provide a description of the function:def days_till_due(self): due = self.due_date() if due: diff = due - date.today() return diff.days return 0
[ "\n Returns the number of days till the due date. Returns a negative number\n of days when the due date is in the past.\n Returns 0 when the task has no due date.\n " ]
Please provide a description of the function:def length(self): start = self.start_date() or self.creation_date() due = self.due_date() if start and due and start < due: diff = due - start return diff.days else: return 0
[ "\n Returns the length (in days) of the task, by considering the start date\n and the due date. When there is no start date, its creation date is\n used. Returns 0 when one of these dates is missing.\n " ]
Please provide a description of the function:def _handle_ls(self): try: arg1 = self.argument(1) arg2 = self.argument(2) todos = [] if arg2 == 'to' or arg1 == 'before': # dep ls 1 to OR dep ls before 1 number = arg1 if arg2...
[ " Handles the ls subsubcommand. " ]
Please provide a description of the function:def _handle_dot(self): self.printer = DotPrinter(self.todolist) try: arg = self.argument(1) todo = self.todolist.todo(arg) arg = self.argument(1) todos = set([self.todolist.todo(arg)]) todo...
[ " Handles the dot subsubcommand. " ]
Please provide a description of the function:def todo(self, p_identifier): result = None def todo_by_uid(p_identifier): result = None if config().identifiers() == 'text': try: result = self._id_todo_map[p_identifier] ...
[ "\n The _todos list has the same order as in the backend store (usually\n a todo.txt file. The user refers to the first task as number 1, so use\n index 0, etc.\n\n Alternative ways to identify a todo is using a hashed version based on\n the todo's text, or a regexp that matches t...
Please provide a description of the function:def add(self, p_src): todos = self.add_list([p_src]) return todos[0] if len(todos) else None
[ "\n Given a todo string, parse it and put it to the end of the list.\n " ]
Please provide a description of the function:def delete(self, p_todo): try: number = self._todos.index(p_todo) del self._todos[number] self._update_todo_ids() self.dirty = True except ValueError: # todo item couldn't be found, ignore ...
[ " Deletes a todo item from the list. " ]
Please provide a description of the function:def replace(self, p_todos): self.erase() self.add_todos(p_todos) self.dirty = True
[ " Replaces whole todolist with todo objects supplied as p_todos. " ]
Please provide a description of the function:def append(self, p_todo, p_string): if len(p_string) > 0: new_text = p_todo.source() + ' ' + p_string p_todo.set_source_text(new_text) self._update_todo_ids() self.dirty = True
[ "\n Appends a text to the todo, specified by its number.\n The todo will be parsed again, such that tags and projects in de\n appended string are processed.\n " ]
Please provide a description of the function:def projects(self): result = set() for todo in self._todos: projects = todo.projects() result = result.union(projects) return result
[ " Returns a set of all projects in this list. " ]
Please provide a description of the function:def contexts(self): result = set() for todo in self._todos: contexts = todo.contexts() result = result.union(contexts) return result
[ " Returns a set of all contexts in this list. " ]
Please provide a description of the function:def linenumber(self, p_todo): try: return self._todos.index(p_todo) + 1 except ValueError as ex: raise InvalidTodoException from ex
[ "\n Returns the line number of the todo item.\n " ]
Please provide a description of the function:def uid(self, p_todo): try: return self._todo_id_map[p_todo] except KeyError as ex: raise InvalidTodoException from ex
[ "\n Returns the unique text-based ID for a todo item.\n " ]
Please provide a description of the function:def number(self, p_todo): if config().identifiers() == "text": return self.uid(p_todo) else: return self.linenumber(p_todo)
[ "\n Returns the line number or text ID of a todo (depends on the\n configuration.\n " ]
Please provide a description of the function:def max_id_length(self): if config().identifiers() == "text": return max_id_length(len(self._todos)) else: try: return math.ceil(math.log(len(self._todos), 10)) except ValueError: re...
[ "\n Returns the maximum length of a todo ID, used for formatting purposes.\n " ]
Please provide a description of the function:def print_todos(self): printer = PrettyPrinter() return "\n".join([str(s) for s in printer.print_list(self._todos)])
[ "\n Returns a pretty-printed string (without colors) of the todo items in\n this list.\n " ]
Please provide a description of the function:def ids(self): if config().identifiers() == 'text': ids = self._id_todo_map.keys() else: ids = [str(i + 1) for i in range(self.count())] return set(ids)
[ " Returns set with all todo IDs. " ]
Please provide a description of the function:def prepare(self, p_args): if self._todo_ids: id_position = p_args.index('{}') # Not using MultiCommand abilities would make EditCommand awkward if self._multi: p_args[id_position:id_position + 1] = self._...
[ "\n Prepares list of operations to execute based on p_args, list of\n todo items contained in _todo_ids attribute and _subcommand\n attribute.\n " ]
Please provide a description of the function:def execute(self): last_operation = len(self._operations) - 1 for i, operation in enumerate(self._operations): command = self._cmd(operation) if command.execute() is False: return False else: ...
[ "\n Executes each operation from _operations attribute.\n " ]
Please provide a description of the function:def _add_months(p_sourcedate, p_months): month = p_sourcedate.month - 1 + p_months year = p_sourcedate.year + month // 12 month = month % 12 + 1 day = min(p_sourcedate.day, calendar.monthrange(year, month)[1]) return date(year, month, day)
[ "\n Adds a number of months to the source date.\n\n Takes into account shorter months and leap years and such.\n\n https://stackoverflow.com/questions/4130922/how-to-increment-datetime-month-in-python\n " ]
Please provide a description of the function:def _add_business_days(p_sourcedate, p_bdays): result = p_sourcedate delta = 1 if p_bdays > 0 else -1 while abs(p_bdays) > 0: result += timedelta(delta) weekday = result.weekday() if weekday >= 5: continue p_bda...
[ " Adds a number of business days to the source date. " ]
Please provide a description of the function:def _convert_pattern(p_length, p_periodunit, p_offset=None): result = None p_offset = p_offset or date.today() p_length = int(p_length) if p_periodunit == 'd': result = p_offset + timedelta(p_length) elif p_periodunit == 'w': result...
[ "\n Converts a pattern in the form [0-9][dwmyb] and returns a date from the\n offset with the period of time added to it.\n " ]
Please provide a description of the function:def _convert_weekday_pattern(p_weekday): day_value = { 'mo': 0, 'tu': 1, 'we': 2, 'th': 3, 'fr': 4, 'sa': 5, 'su': 6 } target_day_string = p_weekday[:2].lower() target_day = day_value[target_da...
[ "\n Converts a weekday name to an absolute date.\n\n When today's day of the week is entered, it will return next week's date.\n " ]
Please provide a description of the function:def relative_date_to_date(p_date, p_offset=None): result = None p_date = p_date.lower() p_offset = p_offset or date.today() relative = re.match('(?P<length>-?[0-9]+)(?P<period>[dwmyb])$', p_date, re.I) monday = 'mo(n(day)?)?...
[ "\n Transforms a relative date into a date object.\n\n The following formats are understood:\n\n * [0-9][dwmy]\n * 'yesterday', 'today' or 'tomorrow'\n * days of the week (in full or abbreviated)\n " ]
Please provide a description of the function:def filter(self, p_todo_str, p_todo): return "|{:>3}| {}".format(self.todolist.number(p_todo), p_todo_str)
[ " Prepends the number to the todo string. " ]
Please provide a description of the function:def postprocess_input_todo(self, p_todo): def convert_date(p_tag): value = p_todo.tag_value(p_tag) if value: dateobj = relative_date_to_date(value) if dateobj: p_todo.set_tag(p_tag,...
[ "\n Post-processes a parsed todo when adding it to the list.\n\n * It converts relative dates to absolute ones.\n * Automatically inserts a creation date if not present.\n * Handles more user-friendly dependencies with before:, partof: and\n after: tags\n " ]
Please provide a description of the function:def columns(p_alt_layout_path=None): def _get_column_dict(p_cp, p_column): column_dict = dict() filterexpr = p_cp.get(p_column, 'filterexpr') try: title = p_cp.get(p_column, 'title') except NoOptionError: tit...
[ "\n Returns list with complete column configuration dicts.\n " ]
Please provide a description of the function:def _active_todos(self): return [todo for todo in self.todolist.todos() if not self._uncompleted_children(todo) and todo.is_active()]
[ "\n Returns a list of active todos, taking uncompleted subtodos into\n account.\n\n The stored length of the todolist is taken into account, to prevent new\n todos created by recurrence to pop up as newly activated tasks.\n Since these todos pop up at the end of the list, we cut o...
Please provide a description of the function:def _decompress_into_buffer(self, out_buffer): zresult = lib.ZSTD_decompressStream(self._decompressor._dctx, out_buffer, self._in_buffer) if self._in_buffer.pos == self._in_buffer.size: self._i...
[ "Decompress available input into an output buffer.\n\n Returns True if data in output buffer should be emitted.\n " ]
Please provide a description of the function:def get_c_extension(support_legacy=False, system_zstd=False, name='zstd', warnings_as_errors=False, root=None): actual_root = os.path.abspath(os.path.dirname(__file__)) root = root or actual_root sources = set([os.path.join(actual_root, ...
[ "Obtain a distutils.extension.Extension for the C extension.\n\n ``support_legacy`` controls whether to compile in legacy zstd format support.\n\n ``system_zstd`` controls whether to compile against the system zstd library.\n For this to work, the system zstd library and headers must match what\n python...
Please provide a description of the function:def timer(fn, miniter=3, minwall=3.0): results = [] count = 0 # Ideally a monotonic clock, but doesn't matter too much. wall_begin = time.time() while True: wstart = time.time() start = os.times() fn() end = os.time...
[ "Runs fn() multiple times and returns the results.\n\n Runs for at least ``miniter`` iterations and ``minwall`` wall time.\n " ]
Please provide a description of the function:def timezone(self): if not self._timezone_group and not self._timezone_location: return None if self._timezone_location != "": return "%s/%s" % (self._timezone_group, self._timezone_location) else: return...
[ "The name of the time zone for the location.\n\n A list of time zone names can be obtained from pytz. For example.\n\n >>> from pytz import all_timezones\n >>> for timezone in all_timezones:\n ... print(timezone)\n " ]
Please provide a description of the function:def tz(self): if self.timezone is None: return None try: tz = pytz.timezone(self.timezone) return tz except pytz.UnknownTimeZoneError: raise AstralError("Unknown timezone '%s'" % self.timezone...
[ "Time zone information." ]
Please provide a description of the function:def sun(self, date=None, local=True, use_elevation=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if self.astral is None: self.astral = Astral() ...
[ "Returns dawn, sunrise, noon, sunset and dusk as a dictionary.\n\n :param date: The date for which to calculate the times.\n If no date is specified then the current date will be used.\n :type date: :class:`~datetime.date`\n\n :param local: True = Time to be returned in lo...
Please provide a description of the function:def sunrise(self, date=None, local=True, use_elevation=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if self.astral is None: self.astral = Astral() ...
[ "Return sunrise time.\n\n Calculates the time in the morning when the sun is a 0.833 degrees\n below the horizon. This is to account for refraction.\n\n :param date: The date for which to calculate the sunrise time.\n If no date is specified then the current date will be use...
Please provide a description of the function:def solar_noon(self, date=None, local=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if self.astral is None: self.astral = Astral() if date is N...
[ "Calculates the solar noon (the time when the sun is at its highest\n point.)\n\n :param date: The date for which to calculate the noon time.\n If no date is specified then the current date will be used.\n :type date: :class:`~datetime.date`\n\n :param local: True =...
Please provide a description of the function:def dusk(self, date=None, local=True, use_elevation=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if self.astral is None: self.astral = Astral() ...
[ "Calculates the dusk time (the time in the evening when the sun is a\n certain number of degrees below the horizon. By default this is 6\n degrees but can be changed by setting the\n :attr:`solar_depression` property.)\n\n :param date: The date for which to calculate the dusk time.\n ...
Please provide a description of the function:def solar_midnight(self, date=None, local=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if self.astral is None: self.astral = Astral() if date ...
[ "Calculates the solar midnight (the time when the sun is at its lowest\n point.)\n\n :param date: The date for which to calculate the midnight time.\n If no date is specified then the current date will be used.\n :type date: :class:`~datetime.date`\n\n :param local: ...
Please provide a description of the function:def daylight(self, date=None, local=True, use_elevation=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if self.astral is None: self.astral = Astral() ...
[ "Calculates the daylight time (the time between sunrise and sunset)\n\n :param date: The date for which to calculate daylight.\n If no date is specified then the current date will be used.\n :type date: :class:`~datetime.date`\n\n :param local: True = Time to be returned i...
Please provide a description of the function:def night(self, date=None, local=True, use_elevation=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if self.astral is None: self.astral = Astral() ...
[ "Calculates the night time (the time between astronomical dusk and\n astronomical dawn of the next day)\n\n :param date: The date for which to calculate the start of the night time.\n If no date is specified then the current date will be used.\n :type date: :class:`~datetim...
Please provide a description of the function:def twilight(self, direction=SUN_RISING, date=None, local=True, use_elevation=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if date is None: date = date...
[ "Returns the start and end times of Twilight in the UTC timezone when\n the sun is traversing in the specified direction.\n\n This method defines twilight as being between the time\n when the sun is at -6 degrees and sunrise/sunset.\n\n :param direction: Determines whether the time is f...
Please provide a description of the function:def time_at_elevation(self, elevation, direction=SUN_RISING, date=None, local=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if self.astral is None: self...
[ "Calculate the time when the sun is at the specified elevation.\n\n Note:\n This method uses positive elevations for those above the horizon.\n\n Elevations greater than 90 degrees are converted to a setting sun\n i.e. an elevation of 110 will calculate a setting sun at 70 de...
Please provide a description of the function:def blue_hour(self, direction=SUN_RISING, date=None, local=True, use_elevation=True): if local and self.timezone is None: raise ValueError("Local time requested but Location has no timezone set.") if self.astral is None: sel...
[ "Returns the start and end times of the Blue Hour when the sun is traversing\n in the specified direction.\n\n This method uses the definition from PhotoPills i.e. the\n blue hour is when the sun is between 6 and 4 degrees below the horizon.\n\n :param direction: Determines whether the ...
Please provide a description of the function:def solar_azimuth(self, dateandtime=None): if self.astral is None: self.astral = Astral() if dateandtime is None: dateandtime = datetime.datetime.now(self.tz) elif not dateandtime.tzinfo: dateandtime = se...
[ "Calculates the solar azimuth angle for a specific date/time.\n\n :param dateandtime: The date and time for which to calculate the angle.\n :type dateandtime: :class:`~datetime.datetime`\n\n :returns: The azimuth angle in degrees clockwise from North.\n :rtype: float\n " ]
Please provide a description of the function:def moon_phase(self, date=None, rtype=int): if self.astral is None: self.astral = Astral() if date is None: date = datetime.date.today() return self.astral.moon_phase(date, rtype)
[ "Calculates the moon phase for a specific date.\n\n :param date: The date to calculate the phase for.\n If ommitted the current date is used.\n :type date: :class:`datetime.date`\n\n :returns:\n A number designating the phase\n\n | 0 = New moon\n ...
Please provide a description of the function:def add_locations(self, locations): if isinstance(locations, (str, ustr)): self._add_from_str(locations) elif isinstance(locations, (list, tuple)): self._add_from_list(locations)
[ "Add extra locations to AstralGeocoder.\n\n Extra locations can be\n\n * A single string containing one or more locations separated by a newline.\n * A list of strings\n * A list of lists/tuples that are passed to a :class:`Location` constructor\n " ]
Please provide a description of the function:def _add_from_str(self, s): if sys.version_info[0] < 3 and isinstance(s, str): s = s.decode('utf-8') for line in s.split("\n"): self._parse_line(line)
[ "Add locations from a string" ]
Please provide a description of the function:def _add_from_list(self, l): for item in l: if isinstance(item, (str, ustr)): self._add_from_str(item) elif isinstance(item, (list, tuple)): location = Location(item) self._add_location...
[ "Add locations from a list of either strings or lists or tuples.\n\n Lists of lists and tuples are passed to the Location constructor\n " ]