Exemplo n.º 1
0
    def renderDatasetFiles(self):
        """
        Renders the dataset files info.

        Returns:
            str: The dataset files info
        """
        headers = ["File", "Format", "Size", "Savings"]
        alignment = ["<", "^", ">", ">"]
        data = []

        for dataset_file in self._dataset_dir.files(pattern="places*"):
            raw_file = File(self._dataset_dir.parent / dataset_file.name)
            dataset_format = "-"

            if dataset_file.format:
                dataset_format = Markdown.link(dataset_file.format.info, dataset_file.format.friendlyName)

            dataset_info = [Markdown.code(dataset_file.name), dataset_format, "{:9,d}".format(dataset_file.size)]

            if raw_file.exists():
                savings = Number.percentDifference(dataset_file.size, raw_file.size)
                dataset_info.append("{:>6.1f}%".format(savings))

            data.append(dataset_info)

        if "minified" in self._dataset_dir:
            return Markdown.table([headers] + data, alignment)

        return Markdown.table([headers[:3]] + [row[:3] for row in data], alignment[:3])
Exemplo n.º 2
0
    def renderDatasetFiles(self):
        '''
        Renders the dataset files info.

        Returns:
            str: The dataset files info
        '''
        headers = ['File', 'Format', 'Size', 'Savings']
        alignment = ['<', '^', '>', '>']
        data = []

        for dataset_file in self._dataset_dir.files(pattern='places*'):
            raw_file = File(self._dataset_dir.parent / dataset_file.name)
            dataset_format = '-'

            if dataset_file.format:
                dataset_format = Markdown.link(
                    dataset_file.format.info, dataset_file.format.friendlyName)

            dataset_info = [
                Markdown.code(dataset_file.name),
                dataset_format,
                '{:9,d}'.format(dataset_file.size),
            ]

            if raw_file.exists():
                savings = Number.percentDifference(dataset_file.size,
                                                   raw_file.size)
                dataset_info.append('{:>6.1f}%'.format(savings))

            data.append(dataset_info)

        if 'minified' in self._dataset_dir:
            return Markdown.table([headers] + data, alignment)

        return Markdown.table([headers[:3]] + [row[:3] for row in data],
                              alignment[:3])
Exemplo n.º 3
0
    def renderDatasetRecords(self):
        '''
        Renders the dataset records counts.

        Returns:
            str: The dataset records counts
        '''
        headers = ['Table', 'Records']
        alignment = ['>', '>']
        datasets = DatasetUtils.getDatasetsByLocale(self._locale)
        data = [[
            Markdown.code(_(entity.table)),
            '{:,d}'.format(len(datasets[self._dataset.year][_(entity.table)]))
        ] for entity in Entities
                if _(entity.table) in datasets[self._dataset.year]]

        return Markdown.table([headers] + data, alignment)
Exemplo n.º 4
0
    def renderDatasetRecords(self):
        """
        Renders the dataset records counts.

        Returns:
            str: The dataset records counts
        """
        headers = ["Table", "Records"]
        alignment = [">", ">"]
        datasets = DatasetUtils.getDatasetsByLocale(self._locale)
        data = [
            [Markdown.code(_(entity.table)), "{:,d}".format(len(datasets[self._dataset.year][_(entity.table)]))]
            for entity in Entities
            if _(entity.table) in datasets[self._dataset.year]
        ]

        return Markdown.table([headers] + data, alignment)
Exemplo n.º 5
0
    def renderDatasetRecords(self):
        """
        Renders the available dataset records counts.

        Returns:
            str: The available dataset records counts
        """
        headers = ["Dataset"] + [Markdown.code(entity.table) for entity in Entities]
        alignment = [">"] * 7
        datasets = DatasetUtils.getDatasetsByLocale("pt")
        data = [
            [Markdown.bold(dataset)]
            + [
                "{:,d}".format(len(datasets[dataset][_(entity.table)])) if _(entity.table) in datasets[dataset] else "-"
                for entity in Entities
            ]
            for dataset in datasets
        ]

        return Markdown.table([headers] + data, alignment)
Exemplo n.º 6
0
    def renderDatasetRecords(self):
        '''
        Renders the available dataset records counts.

        Returns:
            str: The available dataset records counts
        '''
        headers = ['Dataset'
                   ] + [Markdown.code(entity.table) for entity in Entities]
        alignment = ['>'] * 7
        datasets = DatasetUtils.getDatasetsByLocale('pt')
        data = [
            [Markdown.bold(dataset)] + [
                '{:,d}'.format(len(datasets[dataset][_(entity.table)])) \
                    if _(entity.table) in datasets[dataset] else '-'
                for entity in Entities
            ]
            for dataset in datasets
        ]

        return Markdown.table([headers] + data, alignment)