def import_legislative_bodies(self, force):
        """
        Create legislative body models out of the configuration.

        @param force: Should the LegislativeBody settings be written if the model already exist?
        @returns: A flag indicating if the import was successful.
        """
        bodies = self.store.filter_legislative_bodies()
        for body in bodies:
            attributes = {
                'name': body.get('id')[:256],
                'max_districts': body.get('maxdistricts'),
                'sort_key': body.get('sort_key'),
                'is_community': body.get('is_community')=='true'
            }

            body_by_region = self.store.filter_nodes('/DistrictBuilder/Regions/Region/LegislativeBodies/LegislativeBody[@ref="%s"]' % body.get('id'))
            if len(body_by_region) != 1:
                logger.info( "Legislative body %s not attributed to any region", attributes['name'])
                continue
            else:
                region_name = body_by_region[0].getparent().getparent().get('id')
            attributes['region'] = Region.objects.get(name=region_name)

            obj, created, changed, message = check_and_update(LegislativeBody, overwrite=force, **attributes)

            for locale in [l[0] for l in settings.LANGUAGES]:
                po = self.poutils[locale]
                po.add_or_update(
                    msgid=u'%s short label' % attributes['name'],
                    msgstr=body.get('short_label') or '%(district_id)s',
                    occurs=[(os.path.abspath(self.store.datafile), body.sourceline,)]
                )
                po.add_or_update(
                    msgid=attributes['name'] % u'%s label',
                    msgstr=body.get('long_label') or '%(district_id)s',
                    occurs=[(os.path.abspath(self.store.datafile), body.sourceline,)]
                )
                po.add_or_update(
                    msgid=u'%s long description' % attributes['name'],
                    msgstr=body.get('name'),
                    occurs=[(os.path.abspath(self.store.datafile), body.sourceline,)]
                )
                po.add_or_update(
                    msgid=u'%s members' % attributes['name'],
                    msgstr=body.get('members'),
                    occurs=[(os.path.abspath(self.store.datafile), body.sourceline,)]
                )

            if changed and not force:
                logger.info(message)
            else:
                logger.debug(message)

            if obj is None:
                continue

            # Add multi-member district configuration
            mmconfig = self.store.get_node('//MultiMemberDistrictConfig[@legislativebodyref="%s"]' % body.get('id'))
            if mmconfig:
                obj.multi_members_allowed = True
                obj.multi_district_label_format = mmconfig.get('multi_district_label_format')[:32]
                obj.min_multi_districts = mmconfig.get('min_multi_districts')
                obj.max_multi_districts = mmconfig.get('max_multi_districts')
                obj.min_multi_district_members = mmconfig.get('min_multi_district_members')
                obj.max_multi_district_members = mmconfig.get('max_multi_district_members')
                obj.min_plan_members = mmconfig.get('min_plan_members')
                obj.max_plan_members = mmconfig.get('max_plan_members')
                logger.debug( 'Multi-member districts enabled for: %s', body.get('name') )
            else:
                obj.multi_members_allowed = False
                obj.multi_district_label_format = ''
                obj.min_multi_districts = 0
                obj.max_multi_districts = 0
                obj.min_multi_district_members = 0
                obj.max_multi_district_members = 0
                obj.min_plan_members = 0
                obj.max_plan_members = 0
                logger.debug( 'Multi-member districts not configured for: %s', body.get('name'))

            obj.save()

        return True
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/config.py/ConfigImporter.import_legislative_bodies/swapped operands of `%`