コード例 #1
0
ファイル: vosi.py プロジェクト: tysen/daiquiri
    def render_tableset(self, tableset, strict=False):
        for schema in tableset:
            self.start('schema')
            self.node('name', {}, schema.get('name'))
            self.node('description', {}, schema.get('description') or '')

            for table in schema.get('tables'):
                if strict:
                    self.start('table')
                else:
                    self.start(
                        'table', {
                            'doi': get_doi_url(table.get('doi')),
                            'size': str(table.get('nrows'))
                        })
                self.node('name', {}, table.get('name'))
                self.node('description', {}, table.get('description') or '')

                for column in table['columns']:
                    self.start('column',
                               {'std': 'true'} if column['std'] else {})
                    self.node('name', {}, column['name'])
                    self.node('description', {},
                              column.get('description') or '')
                    self.node('unit', {}, column.get('unit') or '')
                    self.node('ucd', {}, column.get('ucd') or '')

                    self.render_datatype(column.get('datatype'))
                    for key in ['indexed', 'principal']:
                        if key in column and column.get('key'):
                            self.node('flag', {}, key)

                    self.end('column')

                self.end('table')

            self.end('schema')
コード例 #2
0
def doi_panel(doi, dataset=_('dataset')):
    return {
        'doi_url': get_doi_url(doi),
        'dataset': dataset
    }
コード例 #3
0
def doi_link(doi):
    url = get_doi_url(doi)
    return format_html('<a class="break" href="{}">{}</a>', url, url)
コード例 #4
0
    def get_table_links(self, table):
        table_links = []

        if table.metadata_access_level == ACCESS_LEVEL_PUBLIC and \
                table.schema.metadata_access_level == ACCESS_LEVEL_PUBLIC:
            identifier = self.get_table_identifier(table)

            path = reverse('metadata:table',
                           args=[table.schema.name, table.name])
            access_url = settings.SITE_URL.rstrip('/') + path

            table_links.append({
                'ID':
                identifier,
                'access_url':
                access_url,
                'service_def':
                '',
                'error_message':
                '',
                'description':
                'Documentation for the {} table'.format(table),
                'semantics':
                '#documentation',
                'content_type':
                'application/html',
                'content_length':
                None
            })

            if table.doi:
                table_links.append({
                    'ID':
                    identifier,
                    'access_url':
                    get_doi_url(table.doi),
                    'service_def':
                    '',
                    'error_message':
                    '',
                    'description':
                    'Digital object identifier (DOI) for the {} table'.format(
                        table),
                    'semantics':
                    '#doi',
                    'content_type':
                    'application/html',
                    'content_length':
                    None
                })

            if table.related_identifiers:
                for related_identifier in table.related_identifiers:
                    access_url = related_identifier.get('related_identifier')
                    if access_url is not None:
                        description = DATALINK_RELATION_TYPES.get(related_identifier.get('relation_type'), '') \
                                                             .format('the {} table'.format(table)) \
                                                             .capitalize()

                        table_links.append({
                            'ID': identifier,
                            'access_url': access_url,
                            'service_def': '',
                            'error_message': '',
                            'description': description,
                            'semantics': '#auxiliary',
                            'content_type': 'application/html',
                            'content_length': None
                        })

        return table_links
コード例 #5
0
ファイル: base.py プロジェクト: django-daiquiri/daiquiri
 def get_links(self, sources):
     return [(
         '%(schema_name)s.%(table_name)s' % source,
         'doc',
         get_doi_url(source['doi']) if source['doi'] else source['url']
     ) for source in sources]