Beispiel #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])
Beispiel #2
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)
Beispiel #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)
Beispiel #4
0
    def renderDatasetFormats(self):
        '''
        Renders the available dataset formats.

        Returns:
            str: The available dataset formats
        '''
        grouped_formats = FormatRepository.groupExportableFormatsByType()
        markdown = ''

        for format_type, formats in grouped_formats:
            markdown += '\n'.join([
                Markdown.header(format_type, depth=4),
                Markdown.unorderedList([
                    Markdown.link(_format.info, _format.friendlyName)
                    for _format in formats
                ]) + '\n'
            ])

        return markdown
Beispiel #5
0
    def renderDatasetFormats(self):
        """
        Renders the available dataset formats.

        Returns:
            str: The available dataset formats
        """
        grouped_formats = FormatRepository.groupExportableFormatsByType()
        markdown = ""

        for format_type, formats in grouped_formats:
            markdown += "\n".join(
                [
                    Markdown.header(format_type, depth=4),
                    Markdown.unorderedList([Markdown.link(_format.info, _format.friendlyName) for _format in formats])
                    + "\n",
                ]
            )

        return markdown
Beispiel #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)
Beispiel #7
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)
Beispiel #8
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])