def configure(self): ''' Defines the command arguments. ''' datasets = DatabaseRepository.listYears() raw_formats = FormatRepository.listExportableFormatNames() minifiable_formats = FormatRepository.listMinifiableFormatNames() self.addArgument('-d', '--datasets', metavar='DATASET', nargs='*', default=datasets, help=('Datasets to build.\n' 'Defaults to all available: {}' \ .format(', '.join(datasets)))) self.addArgument('-r', '--raw', metavar='FORMAT', nargs='*', default=raw_formats, help=('Raw formats to build the dataset.\n' 'Defaults to all available: {}' \ .format(', '.join(raw_formats)))) self.addArgument('-m', '--min', metavar='FORMAT', nargs='*', default=minifiable_formats, help=('Minifiable formats to build the dataset.\n' 'Defaults to all available: {}' \ .format(', '.join(minifiable_formats))))
def getDatasetsByLocale(locale): ''' Returns the datasets available for a given localization. Arguments: locale (str): The localization name Returns: collections.OrderedDict: The localization datasets ''' data = OrderedDict() for dataset in DatabaseRepository.listYears(): dataset_file = DATA_DIR / locale / dataset / 'places.json' if dataset_file.exists(): data[dataset] = json.load(File(dataset_file)) return data
def getDatasetsByLocale(locale): """ Returns the datasets available for a given localization. Arguments: locale (str): The localization name Returns: collections.OrderedDict: The localization datasets """ data = OrderedDict() for dataset in DatabaseRepository.listYears(): dataset_file = DATA_DIR / locale / dataset / "places.json" if dataset_file.exists(): data[dataset] = json.load(File(dataset_file)) return data