def _merge_publicmapping_settings(self, output):
        try:
            cfg = self.data.xpath('//Internationalization')[0]
            output.write("TIME_ZONE = '%s'\n" % cfg.get('timezone'))
            output.write("LANGUAGES = (\n")
            for language in cfg.xpath('Language'):
                output.write("    ('%s', '%s'),\n" % (language.get('code'), language.get('label')))
            output.write(")\n")
            output.write("# Modify to change the language of the application\n")
            if not cfg.get('default') is None:
                output.write("LANGUAGE_CODE = '%s'\n\n" % cfg.get('default'))
            else:
                output.write("LANGUAGE_CODE = '%s'\n\n" % cfg[0].get('code'))

            cfg = self.data.xpath('//Project/Database')[0]
            output.write('\n#\n# Automatically generated settings.\n#\n')

            output.write("DATABASES = {\n")
            output.write("    'default': {\n")
            output.write("        'ENGINE': 'django.contrib.gis.db.backends.postgis',\n")
            output.write("        'NAME': '%s',\n" % cfg.get('name'))
            output.write("        'USER': '%s',\n" % cfg.get('user'))
            output.write("        'PASSWORD': '%s',\n" % cfg.get('password'))
            output.write("        'HOST': '%s',\n" % cfg.get('host'))
            output.write("    }\n")
            output.write("}\n")

            cfg = self.data.xpath('//MapServer')[0]
            output.write("\nMAP_SERVER = '%s'\n" % cfg.get('hostname'))
            protocol = cfg.get('protocol')
            if protocol:
                output.write("MAP_SERVER_PROTOCOL = '%s'\n" % protocol)
            output.write("BASE_MAPS = '%s'\n" % cfg.get('basemaps'))
            output.write("MAP_SERVER_NS = '%s'\n" % cfg.get('ns'))
            output.write("MAP_SERVER_NSHREF = '%s'\n" % cfg.get('nshref'))
            output.write("FEATURE_LIMIT = %d\n" % int(cfg.get('maxfeatures')))
            output.write("MAP_SERVER_USER = '%s'\n" % cfg.get('adminuser'))
            output.write("MAP_SERVER_PASS = '%s'\n" % cfg.get('adminpass'))

            cfg = self.data.xpath('//Project/KeyValueStore')
            if len(cfg) > 0:
                output.write("\nKEY_VALUE_STORE = {\n")
                output.write("    'PASSWORD': '%s',\n" % cfg[0].get('password'))
                output.write("    'HOST': '%s',\n" % cfg[0].get('host'))
                output.write("    'PORT': '%s',\n" % cfg[0].get('port'))
                output.write("    'DB': '%s',\n" % cfg[0].get('db'))
                output.write("}\n")
            else:
                output.write("\nKEY_VALUE_STORE = ''\n")

            cfg = self.data.xpath('//Adjacencies/*')
            if len(cfg) > 0:
                output.write("\nADJACENCY = True\n")
            else:
                output.write("\nADJACENCY = False\n")

            # Specific Settings for Convex Hull Choropleth - This choropleth
            # can only be displayed if convex hull is added to a list of score
            # functions
            cfg = self.data.xpath('//Scoring/ScoreFunctions/ScoreFunction[@id="district_convex"]')
            if len(cfg) > 0:
                output.write("\nCONVEX_CHOROPLETH = True\n")
            else:
                output.write("\nCONVEX_CHOROPLETH = False\n")
            
            cfg = self.data.xpath('//Mailer')[0]
            output.write("\nEMAIL_HOST = '%s'\n" % cfg.get('server'))
            output.write("EMAIL_PORT = %d\n" % int(cfg.get('port')))
            output.write("EMAIL_HOST_USER = '%s'\n" % cfg.get('username'))
            output.write("EMAIL_HOST_PASSWORD = '%s'\n" % cfg.get('password'))
            output.write("EMAIL_SUBJECT_PREFIX = '%s '\n" % cfg.get('prefix'))
            use_tls = cfg.get('use_tls')
            if use_tls:
                output.write("EMAIL_USE_TLS = %s\n" % ((use_tls == 'true'),))
            submission_email = cfg.get('submission_email')
            if submission_email:
                output.write("EMAIL_SUBMISSION = '%s'\n" % submission_email)

            cfg = self.data.xpath('//Project')[0]
            root_dir = cfg.get('root')

            output.write("\nMEDIA_ROOT = '%s/django/publicmapping/site-media/'\n" % root_dir)
            output.write("\nSTATIC_ROOT = '%s/django/publicmapping/static-media/'\n" % root_dir)

            output.write("\nTEMPLATE_DIRS = (\n  '%s/django/publicmapping/templates',\n)\n" % root_dir)
            output.write("\nSLD_ROOT = '%s/sld/'\n" % root_dir)

            output.write("\nSTATICFILES_DIRS = (\n  '%s/django/publicmapping/static/',\n)\n" % root_dir)

            quota = cfg.get('sessionquota')
            if not quota:
                quota = 5
            output.write("\nCONCURRENT_SESSIONS = %d\n" % int(quota))

            timeout = cfg.get('sessiontimeout')
            if not timeout:
                timeout = 15
            output.write("\nSESSION_TIMEOUT = %d\n" % int(timeout))

            # If banner image setting does not exist, defaults to:
            # '/static-media/images/banner-home.png'
            banner = cfg.get('bannerimage')
            if banner:
                output.write("\nBANNER_IMAGE = '%s'\n" % banner)

            # Reporting is optional
            cfg = self.data.xpath('//Reporting')
            if cfg is not None:
                bardcfg = cfg[0].find('BardConfigs/BardConfig')
                calccfg = cfg[0].find('CalculatorReports')
                # BARD
                if bardcfg is not None:
                    cfg = bardcfg

                    output.write("BARD_TRANSFORM = '%s'\n" % cfg.get('transform'))
                    server = cfg.get('server')
                    if server:
                        output.write("BARD_SERVER = '%s'\n" % server)
                    else:
                        output.write("BARD_SERVER = 'http://localhost/reporting'\n")
                    
            cfg = self.data.xpath('//GoogleAnalytics')
            if len(cfg) > 0:
                cfg = cfg[0]
                output.write("\nGA_ACCOUNT = '%s'\n" % cfg.get('account'))
                output.write("GA_DOMAIN = '%s'\n" % cfg.get('domain'))
            else:
                output.write("\nGA_ACCOUNT = None\nGA_DOMAIN = None\n")

            cfg = self.data.xpath('//Upload')
            if len(cfg) > 0:
                cfg = cfg[0]
                output.write("\nMAX_UPLOAD_SIZE = %s * 1024\n" % cfg.get('maxsize'))
            else:
                output.write("\nMAX_UPLOAD_SIZE = 5000 * 1024\n")

            # Fix unassigned parameters
            minpercent = 99
            comparatorsubject = 'poptot'
            cfg = self.data.xpath('//FixUnassigned')
            if len(cfg) > 0:
                cfg = cfg[0]
                minpercent = cfg.get('minpercent') or minpercent
                comparatorsubject = cfg.get('comparatorsubject') or comparatorsubject
            output.write("\nFIX_UNASSIGNED_MIN_PERCENT = %d\n" % int(minpercent))
            output.write("\nFIX_UNASSIGNED_COMPARATOR_SUBJECT = '%s'\n" % comparatorsubject)

            # Undo restrictions
            maxundosduringedit = 0
            maxundosafteredit = 0
            cfg = self.data.xpath('//MaxUndos')
            if len(cfg) > 0:
                cfg = cfg[0]
                maxundosduringedit = cfg.get('duringedit') or 0
                maxundosafteredit = cfg.get('afteredit') or 0
            output.write("\nMAX_UNDOS_DURING_EDIT = %d\n" % int(maxundosduringedit))
            output.write("\nMAX_UNDOS_AFTER_EDIT = %d\n" % int(maxundosafteredit))

            # Leaderboard
            maxranked = 10
            cfg = self.data.xpath('//Leaderboard')
            if len(cfg) > 0:
                cfg = cfg[0]
                maxranked = cfg.get('maxranked') or 10
            output.write("\nLEADERBOARD_MAX_RANKED = %d\n" % int(maxranked))
       
            output.close()

            return True

        except Exception, ex:
            # An error occurred during the processing of the settings file
            logging.warning(traceback.format_exc())

            return False
Invoked by the script installed by setuptools.
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/__init__.py/StoredConfig._merge_publicmapping_settings--crossover with--dataset/ETHPy150Open gmr/tinman/tinman/controller.py/main