コード例 #1
0
 def mapGeometricians(self, line, plone_object):
     title_words = [word for word in self.getData('Titre').lower().split()]
     for word in title_words:
         if word not in ['géometre', 'géomètre']:
             return
     name = self.getData('Nom')
     firstname = self.getData('Prenom')
     raw_name = firstname + name
     name = cleanAndSplitWord(name)
     firstname = cleanAndSplitWord(firstname)
     names = name + firstname
     geometrician = self.catalog(portal_type='Geometrician', Title=names)
     if not geometrician:
         geometrician = self.catalog(portal_type='Geometrician', Title=name)
     if len(geometrician) == 1:
         return geometrician[0].getObject()
     self.logError(self, line, 'no geometricians found or too much geometricians found',
                   {
                       'raw_name': raw_name,
                       'title': self.getData('Titre'),
                       'name': name,
                       'firstname': firstname,
                       'search_result': len(geometrician)
                   })
     return []
コード例 #2
0
    def mapWorklocations(self, line):
        num = self.getData('AdresseTravauxNumero')
        noisy_words = set(
            ('d', 'du', 'de', 'des', 'le', 'la', 'les', 'à', ',', 'rues',
             'terrain', 'terrains', 'garage', 'magasin', 'entrepôt'))
        raw_street = self.getData('AdresseTravauxRue')
        # remove string in () and []
        raw_street = re.sub("[\(\[].*?[\)\]]", "", raw_street)
        street = cleanAndSplitWord(raw_street)
        street_keywords = [
            word for word in street
            if word not in noisy_words and len(word) > 1
        ]
        if len(street_keywords) and street_keywords[-1] == 'or':
            street_keywords = street_keywords[:-1]

        locality = self.getData('AdresseTravauxVille')
        street_keywords.extend(cleanAndSplitWord(locality))

        brains = self.catalog(portal_type='Street', Title=street_keywords)
        if len(brains) == 1:
            return ({'street': brains[0].UID, 'number': num}, )
        if street:
            self.logError(
                self, line, 'Couldnt find street or found too much streets', {
                    'address': '%s, %s, %s ' % (num, raw_street, locality),
                    'street': street_keywords,
                    'search result': len(brains)
                })
        return {}
コード例 #3
0
    def mapWorklocations(self, line):
        num = self.getData('BIENNUM')
        noisy_words = set(
            ('d', 'du', 'de', 'des', 'le', 'la', 'les', 'à', ',', 'rues',
             'terrain', 'terrains', 'garage', 'magasin', 'entrepôt'))
        raw_street = self.getData('BIENADR')
        if raw_street.endswith(')'):
            raw_street = raw_street[:-5]
        street = cleanAndSplitWord(raw_street)
        street_keywords = [
            word for word in street
            if word not in noisy_words and len(word) > 1
        ]
        if len(street_keywords) and street_keywords[-1] == 'or':
            street_keywords = street_keywords[:-1]

        locality = self.getData('BIENCOM')
        street_keywords.extend(cleanAndSplitWord(locality))

        brains = self.catalog(portal_type='Street', Title=street_keywords)
        if len(brains) == 1:
            return ({'street': brains[0].UID, 'number': num}, )
        if street:
            self.logError(
                self, line, 'Couldnt find street or found too much streets', {
                    'address': '%s, %s, %s ' % (num, raw_street, locality),
                    'street': street_keywords,
                    'search result': len(brains)
                })
        return {}
コード例 #4
0
 def mapGeometricians(self, line, plone_object):
     title_words = [word for word in self.getData('Titre').lower().split()]
     for word in title_words:
         if word not in ['géometre', 'géomètre']:
             return
     name = self.getData('Nom')
     firstname = self.getData('Prenom')
     raw_name = firstname + name
     name = cleanAndSplitWord(name)
     firstname = cleanAndSplitWord(firstname)
     names = name + firstname
     geometrician = self.catalog(portal_type='Geometrician', Title=names)
     if not geometrician:
         geometrician = self.catalog(portal_type='Geometrician', Title=name)
     if len(geometrician) == 1:
         return geometrician[0].getObject()
     self.logError(self, line, 'no geometricians found or too much geometricians found',
                   {
                       'raw_name': raw_name,
                       'title': self.getData('Titre'),
                       'name': name,
                       'firstname': firstname,
                       'search_result': len(geometrician)
                   })
     return []
コード例 #5
0
    def mapWorklocations(self, line):
        num = self.getData('NUM')
        noisy_words = set(
            ('d', 'du', 'de', 'des', 'le', 'la', 'les', 'à', ',', 'rues'))
        raw_street = self.getData('SITUATION DU BIEN -PARCELLE - RUE').split(
            ',')[0]
        street = cleanAndSplitWord(raw_street)
        street_keywords = [
            word for word in street
            if word not in noisy_words and len(word) > 1
        ]
        street_keywords.extend(cleanAndSplitWord(self.getData('CODE')))
        street_keywords.extend(cleanAndSplitWord(self.getData('LOCALITE')))
        brains = self.catalog(portal_type='Street', Title=street_keywords)
        if len(brains) == 1:
            return ({'street': brains[0].UID, 'number': num}, )

        street_keywords = street_keywords[1:]
        brains = self.catalog(portal_type='Street', Title=street_keywords)
        if len(brains) == 1:
            return ({'street': brains[0].UID, 'number': num}, )
        if street:
            self.logError(
                self, line, 'Couldnt find street or found too much streets', {
                    'address': raw_street,
                    'street': street_keywords,
                    'search result': len(brains)
                })
        return {}
コード例 #6
0
    def mapArchitects(self, line, plone_object):
        archi_id = self.getData('Num Architecte')
        if not archi_id:
            return []
        archi_map = self.getValueMapping('architects_id_map')
        try:
            archi_title = archi_map[archi_id]
        except KeyError:
            return []

        if not archi_title:
            return []
        fullname = cleanAndSplitWord(archi_title)
        if not fullname:
            return []
        architects = self.catalog(portal_type='Architect', Title=fullname)
        if len(architects) == 1:
            return architects[0].getObject()
        self.logError(
            self, line, 'No architects found or too much architects found', {
                'raw_name': archi_id,
                'name': fullname,
                'search_result': len(architects)
            })
        return []
コード例 #7
0
 def tokenizeReference(self, reference):
     reference = cleanAndSplitWord(reference)
     # we do not use 'partie' in parcel search
     reference = [
         part.upper() for part in reference if part not in ['pie', 'pi']
     ]
     return reference
コード例 #8
0
    def create(self, kwargs, container, line):
        searchview = self.site.restrictedTraverse('searchparcels')

        for k, v in kwargs.iteritems():
            searchview.context.REQUEST[k] = v
        #check if we can find a parcel in the db cadastre with these infos
        found = searchview.findParcel(**kwargs)
        if not found:
            found = searchview.findParcel(browseoldparcels=True, **kwargs)
        if len(found) == 1:
            kwargs['divisionCode'] = kwargs['division']
            kwargs['division'] = kwargs['division']
        else:
            self.logError(
                self, 'Too much parcels found or not enough parcels found', {
                    'kwargs': kwargs,
                    'search result': len(found)
                })
        kwargs['id'] = ''.join(
            [''.join(cleanAndSplitWord(ref)) for ref in kwargs.values()])
        kwargs['id'] = normalizeString(kwargs['id'].replace('/', ''))
        if kwargs['id'] in container.objectIds():
            return None
        return super(ParcelFactory, self).create(kwargs,
                                                 container=container,
                                                 line=line)
コード例 #9
0
    def mapWorklocations(self, line):
        noisy_words = set(
            ('d', 'du', 'de', 'des', 'le', 'la', 'les', 'à', ',', 'rues',
             'terrain', 'terrains', 'garage', 'magasin', 'entrepôt'))
        raw_street = self.getData('Lieu de construction')
        num = ''.join(ele for ele in raw_street if ele.isdigit())
        # remove string in () and []
        raw_street = re.sub("[\(\[].*?[\)\]]", "", raw_street)
        street = cleanAndSplitWord(raw_street)
        street_keywords = [
            word for word in street
            if word not in noisy_words and len(word) > 1
        ]
        if len(street_keywords) and street_keywords[-1] == 'or':
            street_keywords = street_keywords[:-1]

        brains = self.catalog(portal_type='Street', Title=street_keywords)
        if len(brains) == 1:
            return ({'street': brains[0].UID, 'number': num}, )
        if street:
            self.logError(
                self, line, 'Couldnt find street or found too much streets', {
                    'address': '%s' % (raw_street),
                    'street': street_keywords,
                    'search result': len(brains)
                })
        return {}
コード例 #10
0
 def mapArchitects(self, line, plone_object):
     # archi_name = '%s %s %s' % (self.getData('Nom Architecte'), self.getData('Prenom Architecte'), self.getData('Societe Architecte'))
     archi_name = ' %s %s' % (self.getData('Prenom Architecte'),
                              self.getData('Societe Architecte'))
     fullname = cleanAndSplitWord(archi_name)
     if not fullname:
         return []
     noisy_words = [
         'monsieur', 'madame', 'architecte', '&', ',', '.', 'or', 'mr',
         'mme', '/'
     ]
     name_keywords = [
         word.lower() for word in fullname
         if word.lower() not in noisy_words
     ]
     architects = self.catalog(portal_type='Architect', Title=name_keywords)
     if len(architects) == 0:
         Utils.createArchitect(archi_name)
         architects = self.catalog(portal_type='Architect',
                                   Title=name_keywords)
     if len(architects) == 1:
         return architects[0].getObject()
     self.logError(
         self, line, 'No architects found or too much architects found', {
             'raw_name': archi_name,
             'name': name_keywords,
             'search_result': len(architects)
         })
     return []
コード例 #11
0
 def tokenizeReference(self, reference):
     reference = ''.join(cleanAndSplitWord(reference)).upper()
     # we do not use 'partie' in parcel search
     regex = '\W*(?P<radical>\d+)?\s*(?P<bis>/\s*\d+)?\W*(?P<exposant>[a-zA-Z](?![a-zA-Z]))?\W*(?P<puissance>\d+)?\W*(?P<partie>pie)?\W*'
     parsed_abbr = re.match(regex, reference).groups()
     reference = [part for part in parsed_abbr if part]
     return reference
コード例 #12
0
def convertDate(mapper, line, date):
    date = cleanAndSplitWord(date)
    if len(date) > 1:
        mapper.logError(mapper, line, 'More dates found')
    date = date and date[0] or date
    try:
        return date and DateTime(date) or None
    except:
        mapper.logError(mapper, line, 'Wrong date format', {'date': date})
コード例 #13
0
ファイル: mappers.py プロジェクト: IMIO/mons.urban.dataimport
def convertDate(mapper, line, date):
    date = cleanAndSplitWord(date)
    if len(date) > 1:
        mapper.logError(mapper, line, 'More dates found')
    date = date and date[0] or date
    try:
        return date and DateTime(date) or None
    except:
        mapper.logError(mapper, line, 'Wrong date format', {'date': date})
コード例 #14
0
    def mapWorklocations(self, line):
        num = self.getData('C_Num')
        noisy_words = set(('d', 'du', 'de', 'des', 'le', 'la', 'les', 'à', ',', 'rues', 'terrain', 'terrains', 'garage', 'magasin', 'entrepôt'))
        raw_street = self.getData('C_Adres')
        if raw_street.endswith(')'):
            raw_street = raw_street[:-5]
        street = cleanAndSplitWord(raw_street)
        street_keywords = [word for word in street if word not in noisy_words and len(word) > 1]
        if len(street_keywords) and street_keywords[-1] == 'or':
            street_keywords = street_keywords[:-1]

        locality = '%s %s' % (self.getData('C_Code'), self.getData('C_Loc'))
        street_keywords.extend(cleanAndSplitWord(locality))
        brains = self.catalog(portal_type='Street', Title=street_keywords)
        if len(brains) == 1:
            return ({'street': brains[0].UID, 'number': num},)
        if street:
            self.logError(self, line, 'Couldnt find street or found too much streets', {
                'address': '%s, %s %s' % (num, raw_street, locality),
                'street': street_keywords,
                'search result': len(brains)
            })
        return {}
コード例 #15
0
ファイル: mappers.py プロジェクト: IMIO/mons.urban.dataimport
 def mapArchitects(self, line, plone_object):
     title = self.getData('TITRE')
     # we consider the applicant as an architect only if his/her title says so
     if 'arch' not in title.lower():
         return
     archi_name = self.getData('NOM DEMANDEUR') + self.getData('PRENOM')
     fullname = cleanAndSplitWord(archi_name)
     if not fullname:
         return []
     name_keywords = [word.lower() for word in fullname]
     architects = self.catalog(portal_type='Architect', Title=name_keywords)
     if len(architects) == 1:
         return architects[0].getObject()
     self.logError(self, line, 'No architects found or too much architects found', {'name': name_keywords, 'search_result': len(architects)})
     return []
コード例 #16
0
ファイル: mappers.py プロジェクト: IMIO/mons.urban.dataimport
    def mapWorklocations(self, line):
        num = self.getData('NUM')
        noisy_words = set(('d', 'du', 'de', 'des', 'le', 'la', 'les', 'à', ',', 'rues'))
        raw_street = self.getData('SITUATION DU BIEN -PARCELLE - RUE').split(',')[0]
        street = cleanAndSplitWord(raw_street)
        street_keywords = [word for word in street if word not in noisy_words and len(word) > 1]
        street_keywords.extend(cleanAndSplitWord(self.getData('CODE')))
        street_keywords.extend(cleanAndSplitWord(self.getData('LOCALITE')))
        brains = self.catalog(portal_type='Street', Title=street_keywords)
        if len(brains) == 1:
            return ({'street': brains[0].UID, 'number': num},)

        street_keywords = street_keywords[1:]
        brains = self.catalog(portal_type='Street', Title=street_keywords)
        if len(brains) == 1:
            return ({'street': brains[0].UID, 'number': num},)
        if street:
            self.logError(
                self,
                line,
                'Couldnt find street or found too much streets',
                {'address': raw_street, 'street': street_keywords, 'search result': len(brains)}
            )
        return {}
コード例 #17
0
 def mapArchitects(self, line, plone_object):
     archi_name = self.getData("architecte")
     fullname = cleanAndSplitWord(archi_name)
     if not fullname:
         return []
     noisy_words = ["monsieur", "madame", "architecte", "&", ",", ".", "or", "mr", "mme", "/"]
     name_keywords = [word.lower() for word in fullname if word.lower() not in noisy_words and len(word) > 2]
     architects = self.catalog(portal_type="Architect", Title=name_keywords)
     if len(architects) == 1:
         return architects[0].getObject()
     self.logError(
         self,
         line,
         "No architects found or too much architects found",
         {"raw_name": archi_name, "name": name_keywords, "search_result": len(architects)},
     )
     return []
コード例 #18
0
 def mapNotarycontact(self, line, plone_object):
     notaire_name = self.getData('NOM')  # self.getData('notaire')
     fullname = cleanAndSplitWord(notaire_name)
     if not fullname:
         return []
     noisy_words = ['monsieur', 'madame', 'notaire', '&', ',', '.', 'or', 'mr', 'mme', '/']
     name_keywords = [word.lower() for word in fullname if word.lower() not in noisy_words and len(word) > 2]
     notaries = self.catalog(portal_type='Notary', Title=name_keywords)
     if len(notaries) == 1:
         return notaries[0].getObject()
     self.logError(self, line, 'No notaries found or too much notaries found',
                   {
                       'raw_name': notaire_name,
                       'name': name_keywords,
                       'search_result': len(notaries)
                   })
     return []
コード例 #19
0
 def mapArchitects(self, line, plone_object):
     archi_name = self.getData('NomArchitecte')
     fullname = cleanAndSplitWord(archi_name)
     if not fullname:
         return []
     noisy_words = ['monsieur', 'madame', 'architecte', '&', ',', '.', 'or', 'mr', 'mme', '/']
     name_keywords = [word.lower() for word in fullname if word.lower() not in noisy_words]
     architects = self.catalog(portal_type='Architect', Title=name_keywords)
     if len(architects) == 1:
         return architects[0].getObject()
     self.logError(self, line, 'No architects found or too much architects found',
                   {
                       'raw_name': archi_name,
                       'name': name_keywords,
                       'search_result': len(architects)
                   })
     return []
コード例 #20
0
ファイル: mappers.py プロジェクト: IMIO/mons.urban.dataimport
    def create(self, kwargs, container, line):
        searchview = self.site.restrictedTraverse('searchparcels')

        for k, v in kwargs.iteritems():
            searchview.context.REQUEST[k] = v
        #check if we can find a parcel in the db cadastre with these infos
        found = searchview.findParcel(**kwargs)
        if not found:
            found = searchview.findParcel(browseoldparcels=True, **kwargs)
        if len(found) == 1:
            kwargs['divisionCode'] = kwargs['division']
            kwargs['division'] = kwargs['division']
        else:
            self.logError(self, 'Too much parcels found or not enough parcels found', {'kwargs': kwargs, 'search result': len(found)})
        kwargs['id'] = ''.join([''.join(cleanAndSplitWord(ref)) for ref in kwargs.values()])
        kwargs['id'] = normalizeString(kwargs['id'].replace('/', ''))
        if kwargs['id'] in container.objectIds():
            return None
        return super(ParcelFactory, self).create(kwargs, container=container, line=line)
コード例 #21
0
 def mapArchitects(self, line, plone_object):
     title = self.getData('TITRE')
     # we consider the applicant as an architect only if his/her title says so
     if 'arch' not in title.lower():
         return
     archi_name = self.getData('NOM DEMANDEUR') + self.getData('PRENOM')
     fullname = cleanAndSplitWord(archi_name)
     if not fullname:
         return []
     name_keywords = [word.lower() for word in fullname]
     architects = self.catalog(portal_type='Architect', Title=name_keywords)
     if len(architects) == 1:
         return architects[0].getObject()
     self.logError(self, line,
                   'No architects found or too much architects found', {
                       'name': name_keywords,
                       'search_result': len(architects)
                   })
     return []
コード例 #22
0
 def mapWorklocations(self, line):
     locality = self.getData("lieu")
     raw_street = self.getData("ruelieu") or u""
     regex = "([^\d,]+\s*)+,?\s*(.*)"
     parsed_street = re.search(regex, raw_street)
     if parsed_street:
         street, num = parsed_street.groups()
         street_keywords = cleanAndSplitWord(street + " " + locality)
         street_keywords = [word for word in street_keywords if len(word) > 1]
         brains = self.catalog(portal_type="Street", Title=street_keywords, review_state="enabled")
         if len(brains) == 1:
             return ({"street": brains[0].UID, "number": num or ""},)
         if street:
             self.logError(
                 self,
                 line,
                 "Couldnt find street or found too much streets",
                 {"address": "%s" % raw_street, "street": street_keywords, "search result": len(brains)},
             )
     else:
         self.logError(self, line, "Couldnt parse street and number", {"address": "%s" % raw_street})
     return ({},)
コード例 #23
0
 def mapWorklocations(self, line):
     locality = self.getData('localitebien')
     raw_street = self.getData('ruebien') or u''
     regex = '([^\d,]+\s*)+,?\s*(.*)'
     parsed_street = re.search(regex, raw_street)
     if parsed_street:
         street, num = parsed_street.groups()
         street_keywords = cleanAndSplitWord(street + ' ' + locality)
         street_keywords = [word for word in street_keywords if len(word) > 1]
         brains = self.catalog(portal_type='Street', Title=street_keywords, review_state='enabled')
         if len(brains) == 1:
             return ({'street': brains[0].UID, 'number': num or ''},)
         if street:
             self.logError(self, line, 'Couldnt find street or found too much streets', {
                 'address': '%s' % raw_street,
                 'street': street_keywords,
                 'search result': len(brains)
             })
     else:
         self.logError(self, line, 'Couldnt parse street and number', {
             'address': '%s' % raw_street.encode('utf-8'),
         })
     return ({},)
コード例 #24
0
ファイル: mappers.py プロジェクト: IMIO/mons.urban.dataimport
 def tokenizeReference(self, reference):
     reference = cleanAndSplitWord(reference)
     # we do not use 'partie' in parcel search
     reference = [part.upper() for part in reference if part not in ['pie', 'pi']]
     return reference