31 lines
No EOL
703 B
Python
31 lines
No EOL
703 B
Python
import configparser
|
|
|
|
cfg_data = '''
|
|
[info]
|
|
users_dir= /home
|
|
name= $USER
|
|
home_dir= %(users_dir)s/%(name)s
|
|
'''
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.read_string(cfg_data)
|
|
|
|
users_dir = config['info']['users_dir']
|
|
name = config['info']['name']
|
|
home_dir = config['info']['home_dir']
|
|
|
|
print(users_dir)
|
|
print(name)
|
|
print(home_dir)
|
|
with open('../utils/test.ini', 'w') as config_file:
|
|
config.write(config_file)
|
|
|
|
config.add_section('Accounts')
|
|
config['Accounts']['baseUrl'] = 'https://cloud.liyp.cc'
|
|
config['Accounts']['name'] = 'admin'
|
|
config['Accounts']['type'] = 'NextCloud'
|
|
config['Accounts']['username'] = 'admin'
|
|
|
|
with open('../utils/test.ini', 'w') as config_file:
|
|
config.write(config_file) |