1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-01-22 12:34:17 +00:00

py-i2phosts-builder: use validate_config()

This commit is contained in:
Hidden Z 2010-11-02 16:28:01 +00:00
parent c3a218978a
commit 7351534f88

View File

@ -18,7 +18,11 @@ parser.add_argument('-d', '--debug', action='store_true',
args = parser.parse_args()
# read config
config = configobj.ConfigObj(args.config_file, file_error=True)
spec = '''
hostsfile = string(default=None)
'''
spec = spec.split('\n')
config = configobj.ConfigObj(args.config_file, configspec=spec, file_error=True)
if 'include' in config:
config_included = configobj.ConfigObj(config['include'])
config.merge(config_included)
@ -32,6 +36,10 @@ else:
sys.path.insert(1, DJANGO_PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
from web.postkey.models import i2phost
from web.lib.utils import validate_config
# validate config
validate_config(config)
# result hosts.txt
if 'hostsfile' in config: