Ejemplo n.º 1
0
class Loader(LoaderBase):
    def _init(self):
        self._model = House
        self._bulk = BulkCreate(House, 'houseguid', 'updatedate')

    def process_row(self, row):
        if row.tag == 'House':
            end_date = self._str_to_date(row.attrib['ENDDATE'])
            if end_date < self._today:
                print('Out of date entry. Skipping...')
                return

            start_date = self._str_to_date(row.attrib['STARTDATE'])
            if start_date > self._today:
                print('Date in future - skipping...')
                return

            related_attrs = dict()
            try:
                related_attrs['aoguid'] = AddrObj.objects.get(
                    pk=row.attrib['AOGUID'])
            except AddrObj.DoesNotExist:
                print('AddrObj with GUID `{0}` not found. Skipping house...'.
                      format(row.attrib['AOGUID']))
                return

            self._bulk.push(row, related_attrs=related_attrs)
Ejemplo n.º 2
0
class Loader(LoaderBase):

    def _init(self):
        self._model = LandMark
        self._bulk = BulkCreate(LandMark, 'landguid', 'updatedate')

    def process_row(self, row):
        if row.tag == 'Landmark':
            end_date = self._str_to_date(row.attrib['ENDDATE'])
            if end_date < self._today:
                print ('Out of date entry. Skipping...')
                return

            start_date = self._str_to_date(row.attrib['STARTDATE'])
            if start_date > self._today:
                print ('Date in future - skipping...')
                return

            related_attrs = dict()
            try:
                related_attrs['aoguid'] = AddrObj.objects.get(pk=row.attrib['AOGUID'])
            except AddrObj.DoesNotExist:
                print ('AddrObj with GUID `{0}` not found. Skipping house...'.format(row.attrib['AOGUID']))
                return

            self._bulk.push(row, related_attrs=related_attrs)
Ejemplo n.º 3
0
class Loader(LoaderBase):

    def _init(self):
        self._model = NormDoc
        self._bulk = BulkCreate(NormDoc, 'normdocid')

    def process_row(self, row):
        if row.tag == 'NormativeDocument':
            self._bulk.push(row)
Ejemplo n.º 4
0
class Loader(LoaderBase):

    def _init(self):
        self._model = SocrBase
        self._bulk = BulkCreate(SocrBase, 'kod_t_st')

    def process_row(self, row):
        if row.tag == 'AddressObjectType':
            self._bulk.push(row)
Ejemplo n.º 5
0
class Loader(LoaderBase):
    def _init(self):
        self._model = AddrObj
        self._bulk = BulkCreate(AddrObj, 'aoguid', 'updatedate')

    def process_row(self, row):
        if row.tag == 'Object':
            # Пропускаем изменённые объекты
            if 'NEXTID' in row.attrib and row.attrib['NEXTID']:
                return

            start_date = self._str_to_date(row.attrib['STARTDATE'])
            if start_date > self._today:
                log.debug('Date in future - skipping...')
                return

            self._bulk.push(row)
Ejemplo n.º 6
0
class Loader(LoaderBase):

    def _init(self):
        self._model = AddrObj
        self._bulk = BulkCreate(AddrObj, 'aoguid', 'updatedate')

    def process_row(self, row):
        if row.tag == 'Object':
            # Пропускаем изменённые объекты
            if 'NEXTID' in row.attrib and row.attrib['NEXTID']:
                return
    
            start_date = self._str_to_date(row.attrib['STARTDATE'])
            if start_date > self._today:
                log.debug('Date in future - skipping...')
                return

            self._bulk.push(row)