python - PyYAML Basic config file writeback -
i'm new python, , i'm looking basic things pyyaml. want take yaml file:
#lets test out logfile config --- filepath: c:\users\me\documents\python\yaml_test1\ filename: logfile_ log_no: 1
now i'm shooting way control path logfile, root name of log, , number log we're on appended filename (to rollover new log when hit kb file size).
import yaml import os rootdir = os.getcwd() c_filename = rootdir + "\\config.yml" c_filein = open(c_filename,'r+') conf = yaml.load(c_filein) = conf['log_no'] += 1 print conf['log_no'] = print yaml.dump(conf['log_no']) yaml.dump(conf,c_filein) c_filein.close()
my problem dumping file dumps full (though updated) yaml file, @ end of config. suggestions?
ninja edit: i'm open , suggestions, it's use other yaml. reading , wanted give shot.
so i'm going close since have found configparser module looking rotating logfile
Comments
Post a Comment