def store_conf(self, data, conf=None, mode='srv'):
        mconf = None
        if not conf:
            mconf = self.conf
        else:
            mconf = conf
            if mconf != self.conf and not mconf.startswith('/'):
                mconf = os.path.join(self.root, mconf)
        if not mconf:
            return [[1, 'Sorry, no configuration file defined']]

        dirname = os.path.dirname(mconf)
        if not os.path.exists(dirname):
            try:
                os.makedirs(dirname)
            except OSError as e:
                return [[1, str(e)]]

        if self.clientconfdir in dirname:
            ref = '{}.bui.init.back~'.format(mconf)
            bak = '{}.bak~'.format(mconf)
        else:
            ref = '{}.bui.init.back'.format(mconf)
            bak = '{}.bak'.format(mconf)
        if not os.path.isfile(ref) and os.path.isfile(mconf):
            try:
                shutil.copy(mconf, ref)
            except Exception as e:
                return [[2, str(e)]]
        elif os.path.isfile(mconf):
            try:
                shutil.copy(mconf, bak)
            except Exception as e:
                return [[2, str(e)]]

        errs = []
        for key in data.keys():
            if key in self.files:
                d = data.get(key)
                if not os.path.isfile(d):
                    typ = 'strings'
                    if key in getattr(self, 'multi_{}'.format(mode)):
                        typ = 'multis'
                    elif key in getattr(self, 'boolean_{}'.format(mode)):
                        typ = 'bools'
                    elif key in getattr(self, 'integer_{}'.format(mode)):
                        typ = 'integers'
                    # highlight the wrong parameters
                    errs.append([
                        2,
                        "Sorry, the file '{}' does not exist".format(d),
                        key,
                        typ
                    ])
        if errs:
            return errs

        orig = []
        try:
            with codecs.open(mconf, 'r', 'utf-8') as ff:
                orig = [x.rstrip('\n') for x in ff.readlines()]
        except:
            pass

        oldkeys = [self._get_line_key(x) for x in orig]
        newkeys = list(set(data.viewkeys()) - set(oldkeys))

        already_multi = []
        already_file = []
        written = []

        try:
            with codecs.open(mconf, 'w', 'utf-8') as f:
                # f.write('# Auto-generated configuration using Burp-UI\n')
                for line in orig:
                    if (self._line_removed(line, data.viewkeys()) and
                            not self._line_is_comment(line) and
                            not self._line_is_file_include(line)):
                        # The line was removed, we comment it
                        f.write('#{}\n'.format(line))
                    elif self._line_is_file_include(line):
                        # The line is a file inclusion, we check if the line
                        # was already present
                        ori = self._include_get_file(line)
                        if ori in data.getlist('includes_ori'):
                            idx = data.getlist('includes_ori').index(ori)
                            file = data.getlist('includes')[idx]
                            self._write_key(f, '.', file)
                            already_file.append(file)
                        else:
                            f.write('#{}\n'.format(line))
                    elif self._get_line_key(line, False) in data.viewkeys():
                        # The line is still present or has been un-commented,
                        # rewrite it with eventual changes
                        key = self._get_line_key(line, False)
                        if key not in already_multi:
                            self._write_key(f, key, data)
                        if key in getattr(self, 'multi_{}'.format(mode)):
                            already_multi.append(key)
                        written.append(key)
                    else:
                        # The line was empty or a comment...
                        f.write('{}\n'.format(line))
                # Write the new keys
                for key in newkeys:
                    if (key not in written and
                            key not in ['includes', 'includes_ori']):
                        self._write_key(f, key, data)
                # Write the rest of file inclusions
                for file in data.getlist('includes'):
                    if file not in already_file:
                        self._write_key(f, '.', file)
        except Exception as e:
            return [[2, str(e)]]

        return [[0, 'Configuration successfully saved.']]
See :func:`burpui.misc.parser.interface.BUIparser.store_conf`
dataset/ETHPy150Open ziirish/burp-ui/burpui/misc/parser/burp1.py/Parser.store_conf