示例#1
0
def _get_report_filename_art8_2012(country, region, article, descriptor):
    d = descriptor.split('.')[0]

    if d in ['D1', 'D4', 'D6']:
        base = 'MSFD8a'
    else:
        base = 'MSFD8b'

    mc = getattr(sql, base + 'Import')
    idcol = base + '_Import_ID'
    filecol = base + '_Import_FileName'
    countrycol = getattr(mc, base + '_Import_ReportingCountry')
    regcol = getattr(mc, base + '_Import_ReportingRegion')

    count, item = db.get_item_by_conditions(mc, idcol, countrycol == country,
                                            regcol == region)

    # TODO: analyse cases when it returns more then one file

    if count != 1:
        logger.warning(
            "Could not find report filename for %s %s %s",
            country,
            region,
            article,
        )

        return None

    return getattr(item, filecol)
示例#2
0
 def get_report_metadata(self):
     """ Returns metadata about the reported information
     """
     t = sql2018.ReportedInformation
     schemas = {
         'Art8': 'ART8_GES',
         'Art9': 'ART9_GES',
         'Art10': 'ART10_Targets',
     }
     count, item = db.get_item_by_conditions(
         t,
         'ReportingDate',
         t.CountryCode == self.country_code,
         t.Schema == schemas[self.article],
         reverse=True,
     )
     return item
示例#3
0
def _get_report_filename_art8esa_2012(country, region, article):
    mc = sql.MSFD8cImport

    count, item = db.get_item_by_conditions(
        mc, 'MSFD8c_Import_ID', mc.MSFD8c_Import_ReportingCountry == country,
        mc.MSFD8c_Import_ReportingRegion == region)

    if count != 1:
        logger.warning(
            "Could not find report filename for %s %s %s",
            country,
            region,
            article,
        )

        return None

    return item.MSFD8c_Import_FileName
示例#4
0
def _get_report_filename_art7_2012_db(country, region, article, descriptor):
    mc = sql_extra.MSCompetentAuthority

    count, item = db.get_item_by_conditions(mc,
                                            'Import_Time',
                                            mc.C_CD == country,
                                            reverse=True)

    if count < 1:
        logger.warning(
            "Could not find report filename for %s %s %s",
            country,
            region,
            article,
        )

        return None

    return item.Import_FileName
示例#5
0
def _get_report_filename_art9_2012(country, region, article, descriptor):
    mc = sql.MSFD9Import

    count, item = db.get_item_by_conditions(
        mc, 'MSFD9_Import_ID', mc.MSFD9_Import_ReportingCountry == country,
        mc.MSFD9_Import_ReportingRegion == region)

    # TODO: analyse cases when it returns more then one file

    if count != 1:
        logger.warning(
            "Could not find report filename for %s %s %s",
            country,
            region,
            article,
        )

        return None

    return item.MSFD9_Import_FileName
示例#6
0
def _get_report_filename_art3_4_2012_db(country, region, article, descriptor):
    """ This method is not used anymore, see _get_report_filename_art3_4_2012
    """
    mc = sql.MSFD4Import

    count, item = db.get_item_by_conditions(
        mc,
        'MSFD4_Import_ID',
        mc.MSFD4_Import_ReportingCountry == country,
        # mc.MSFD8c_Import_ReportingRegion == region
    )

    if count != 1:
        logger.warning(
            "Could not find report filename for %s %s %s",
            country,
            region,
            article,
        )

        return None

    return item.MSFD4_Import_FileName