rpm-ostree/scripts/rpmostree-passwd2json.py
Jonathan Lebon 206ae24d4e tests: Bump to Python 3 only
This bumps the requirement on the controlling host to Python 3 only.
It also bumps the requirement on the target host to Python 3 as well
since FCOS doesn't ship Python 2 right now.

Though we'll need to eventually drop all Python usage anyway, but at
least let's get tests passing on FCOS first. (See related previous
patch).

Closes: #1828
Approved by: cgwalters
2019-05-08 19:02:32 +00:00

24 lines
570 B
Python
Executable File

#!/usr/bin/python3
import os
import sys
out = """\
"check-passwd": { "type": "data",\n\
"entries": { """
prefix_len = len(' "entries": { ')
done = False
for fname in sys.argv[1:]:
for line in open(fname):
(user,xpass,uid,gid,x) = line.split(':', 4)
if done:
out += ',\n'
out += ' ' * prefix_len
done = True
if uid == gid:
out += '"%s": %s' % (user, uid)
else:
out += '"%s": [%s, %s]' % (user, uid, gid)
out += ' } },'
print(out)