2022-04-17 17:25:35 +08:00
|
|
|
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)
|
2022-04-20 22:48:23 +08:00
|
|
|
with open('../utils/test.ini', 'w') as config_file:
|
2022-04-17 17:25:35 +08:00
|
|
|
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'
|
|
|
|
|
2022-04-20 22:48:23 +08:00
|
|
|
with open('../utils/test.ini', 'w') as config_file:
|
2022-04-17 17:25:35 +08:00
|
|
|
config.write(config_file)
|