1 |
douglas |
596 |
#!/usr/bin/env python |
2 |
|
|
# CCS Computer Science |
3 |
|
|
# |
4 |
|
|
# Douglas Thrift |
5 |
|
|
# |
6 |
|
|
# $Id$ |
7 |
|
|
|
8 |
|
|
from __future__ import with_statement |
9 |
|
|
|
10 |
|
|
try: |
11 |
|
|
from _users import users |
12 |
|
|
except ImportError: |
13 |
|
|
users = set() |
14 |
|
|
|
15 |
|
|
if __name__ == '__main__': |
16 |
|
|
for file in ('/etc/passwd', '/etc/group'): |
17 |
|
|
with open(file, 'rb') as file: |
18 |
|
|
for line in file: |
19 |
|
|
if line.startswith('#'): |
20 |
|
|
continue |
21 |
|
|
|
22 |
|
|
users.update(line.split(':', 1)[:1]) |
23 |
|
|
|
24 |
|
|
with open('_users.py', 'wb') as file: |
25 |
|
|
file.write('users = set((\n') |
26 |
|
|
|
27 |
|
|
for user in sorted(users): |
28 |
|
|
file.write('\t%s,\n' % repr(user)) |
29 |
|
|
|
30 |
|
|
file.write('))\n') |