class LegacyMunicipality(LegacyEntity): ''' Legacy entity for municipalities. ''' __table__ = Table( _('municipalities'), LegacyEntity.metadata, Column(_('id'), Integer, nullable=False, primary_key=True), Column(_('state_id'), SmallInteger, ForeignKey(_('states.id'), use_alter=True), nullable=False, index=True), Column(_('name'), String(64), nullable=False, index=True) ) # Columns mapping __columns__ = { _('id'): 'municipality_id', _('state_id'): 'state_id', _('name'): 'municipality_name', }
class Mesoregion(Entity): ''' Entity for mesoregions. ''' __table__ = Table( _('mesoregions'), Entity.metadata, Column(_('id'), SmallInteger, nullable=False, primary_key=True), Column(_('state_id'), SmallInteger, ForeignKey(_('states.id'), use_alter=True), nullable=False, index=True), Column(_('name'), String(64), nullable=False, index=True) ) # Columns mapping __columns__ = { _('id'): 'mesoregion_id', _('state_id'): 'state_id', _('name'): 'mesoregion_name', }
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)
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)
def __init__(self, name, **rules): ''' Constructor. Arguments: name (str): The column name rules (dict): The column rules ''' self.name = name self.localized_name = _(name) self.rules = rules
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)
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)
class State(Entity): ''' Entity for states. ''' __table__ = Table( _('states'), Entity.metadata, Column(_('id'), SmallInteger, nullable=False, primary_key=True), Column(_('name'), String(32), nullable=False, index=True) ) # Columns mapping __columns__ = { _('id'): 'state_id', _('name'): 'state_name', }
class Subdistrict(Entity): ''' Entity for subdistricts. ''' __table__ = Table( _('subdistricts'), Entity.metadata, Column(_('id'), BigInteger, nullable=False, primary_key=True), Column(_('district_id'), Integer, ForeignKey(_('districts.id'), use_alter=True), nullable=False, index=True), Column(_('municipality_id'), Integer, ForeignKey(_('municipalities.id'), use_alter=True), nullable=False, index=True), Column(_('microregion_id'), Integer, ForeignKey(_('microregions.id'), use_alter=True), nullable=False, index=True), Column(_('mesoregion_id'), SmallInteger, ForeignKey(_('mesoregions.id'), use_alter=True), nullable=False, index=True), Column(_('state_id'), SmallInteger, ForeignKey(_('states.id'), use_alter=True), nullable=False, index=True), Column(_('name'), String(64), nullable=False, index=True) ) # Columns mapping __columns__ = { _('id'): 'subdistrict_id', _('district_id'): 'district_id', _('municipality_id'): 'municipality_id', _('microregion_id'): 'microregion_id', _('mesoregion_id'): 'mesoregion_id', _('state_id'): 'state_id', _('name'): 'subdistrict_name', }