mirror of
https://gitlab.com/datalifeit/trytond-stock_lot_cost_price
synced 2023-12-14 05:33:05 +01:00
28 lines
750 B
Python
28 lines
750 B
Python
import netrc
|
|
import os
|
|
try:
|
|
from configparser import ConfigParser, DuplicateSectionError
|
|
except ImportError:
|
|
from ConfigParser import ConfigParser, DuplicateSectionError
|
|
|
|
|
|
def main():
|
|
netrc_ = netrc.netrc(os.path.expanduser('~/.netrc'))
|
|
config = ConfigParser()
|
|
try:
|
|
config.add_section('auth')
|
|
except DuplicateSectionError:
|
|
pass
|
|
hgrc = os.path.expanduser('~/.hgrc')
|
|
config.read(hgrc)
|
|
for host, (login, _, password) in netrc_.hosts.items():
|
|
config.set('auth', host + '.prefix', host)
|
|
config.set('auth', host + '.username', login)
|
|
config.set('auth', host + '.password', password)
|
|
with open(hgrc, 'w') as fp:
|
|
config.write(fp)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|