Saves conf to configuration filename
(conf, filename)
| 3563 | logger.debug(debugMsg) |
| 3564 | |
| 3565 | def saveConfig(conf, filename): |
| 3566 | """ |
| 3567 | Saves conf to configuration filename |
| 3568 | """ |
| 3569 | |
| 3570 | config = UnicodeRawConfigParser() |
| 3571 | userOpts = {} |
| 3572 | |
| 3573 | for family in optDict: |
| 3574 | userOpts[family] = [] |
| 3575 | |
| 3576 | for option, value in conf.items(): |
| 3577 | for family, optionData in optDict.items(): |
| 3578 | if option in optionData: |
| 3579 | userOpts[family].append((option, value, optionData[option])) |
| 3580 | |
| 3581 | for family, optionData in userOpts.items(): |
| 3582 | config.add_section(family) |
| 3583 | |
| 3584 | optionData.sort() |
| 3585 | |
| 3586 | for option, value, datatype in optionData: |
| 3587 | if datatype and isListLike(datatype): |
| 3588 | datatype = datatype[0] |
| 3589 | |
| 3590 | if option in IGNORE_SAVE_OPTIONS: |
| 3591 | continue |
| 3592 | |
| 3593 | if value is None: |
| 3594 | if datatype == OPTION_TYPE.BOOLEAN: |
| 3595 | value = "False" |
| 3596 | elif datatype in (OPTION_TYPE.INTEGER, OPTION_TYPE.FLOAT): |
| 3597 | if option in defaults: |
| 3598 | value = str(defaults[option]) |
| 3599 | else: |
| 3600 | value = '0' |
| 3601 | elif datatype == OPTION_TYPE.STRING: |
| 3602 | value = "" |
| 3603 | |
| 3604 | if isinstance(value, six.string_types): |
| 3605 | value = value.replace("\n", "\n ") |
| 3606 | |
| 3607 | config.set(family, option, value) |
| 3608 | |
| 3609 | with openFile(filename, "wb") as f: |
| 3610 | try: |
| 3611 | config.write(f) |
| 3612 | except IOError as ex: |
| 3613 | errMsg = "something went wrong while trying " |
| 3614 | errMsg += "to write to the configuration file '%s' ('%s')" % (filename, getSafeExString(ex)) |
| 3615 | raise SqlmapSystemException(errMsg) |
| 3616 | |
| 3617 | def initTechnique(technique=None): |
| 3618 | """ |
no test coverage detected
searching dependent graphs…