from click import echo, style from dateutil import tz from typing import Iterable from datacube.index._api import Index from datacube.model import DatasetType, Dataset from datacube.ui import click as ui from digitalearthau import paths, uiutil TRASH_OPTIONS = ui.compose( click.option( '--min-trash-age-hours', type=int, default=72, help= "Only trash locations that were archive at least this many hours ago." ), click.option('--dry-run', is_flag=True, help="Don't make any changes (ie. don't trash anything)"), ) @click.group(help='Find and trash archived locations.') @ui.global_cli_options def main(): pass @main.command('indexed') @TRASH_OPTIONS
save_tasks_option = click.option('--save-tasks', 'output_tasks_file', help='Save tasks to the specified file', type=click.Path(exists=False)) #: pylint: disable=invalid-name queue_size_option = click.option('--queue-size', help='Number of tasks to queue at the start', type=click.IntRange(1, 100000), default=3200) #: pylint: disable=invalid-name task_app_options = dc_ui.compose( app_config_option, load_tasks_option, save_tasks_option, dc_ui.config_option, dc_ui.verbose_option, dc_ui.log_queries_option, dc_ui.executor_cli_options, ) def _cell_list_from_file(filename): cell_matcher = re.compile(r'(-?\d+)(?:\s*(?:,|_|\s)\s*)(-?\d+)') with open(filename) as cell_file: for line in cell_file: match = cell_matcher.match(line) if match: yield tuple(int(i) for i in match.groups())
#: pylint: disable=invalid-name app_config_option = click.option('--app-config', help='App configuration file', type=click.Path(exists=True, readable=True, writable=False, dir_okay=False)) #: pylint: disable=invalid-name load_tasks_option = click.option('--load-tasks', help='Load tasks from the specified file', type=click.Path(exists=True, readable=True, writable=False, dir_okay=False)) #: pylint: disable=invalid-name save_tasks_option = click.option('--save-tasks', help='Save tasks to the specified file', type=click.Path(exists=False)) #: pylint: disable=invalid-name task_app_options = dc_ui.compose( app_config_option, load_tasks_option, save_tasks_option, dc_ui.config_option, dc_ui.verbose_option, dc_ui.log_queries_option, dc_ui.executor_cli_options, ) def task_app(make_config, make_tasks): """ Create a `Task App` from a function Decorates a function :param make_config: callable(index, config, **query) :param make_tasks: callable(index, config, **kwargs) :return: """