<s> '''<STR_LIT:U+0020>''' <EOL> from __future__ import print_function <EOL> import os <EOL> import copy <EOL> import pprint <EOL> import subprocess <EOL> import sys <EOL> _DEBUG = os . getenv ( '<STR_LIT>' , None ) is not None <EOL> ARGS_OPTS = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:-c>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> def debug ( output ) : <EOL> if _DEBUG : <EOL> sys . stderr . write ( output + '<STR_LIT:\n>' ) <EOL> def parse ( content , assoc , is_group = False ) : <EOL> for line in content . split ( '<STR_LIT:\n>' ) : <EOL> line = line . split ( '<STR_LIT:#>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> fields = line . strip ( ) . split ( '<STR_LIT::>' ) <EOL> if len ( fields ) >= <NUM_LIT:4> : <EOL> if is_group : <EOL> val = ( fields [ <NUM_LIT:2> ] , '<STR_LIT>' ) <EOL> else : <EOL> val = ( fields [ <NUM_LIT:2> ] , fields [ <NUM_LIT:3> ] ) <EOL> if fields [ <NUM_LIT:0> ] in assoc : <EOL> if assoc [ fields [ <NUM_LIT:0> ] ] != val : <EOL> raise KeyError ( '<STR_LIT>' % <EOL> ( fields [ <NUM_LIT:0> ] , assoc [ fields [ <NUM_LIT:0> ] ] , val ) ) <EOL> assoc [ fields [ <NUM_LIT:0> ] ] = val <EOL> return assoc <EOL> def get_index ( array , key , default = None ) : <EOL> try : <EOL> return array . index ( key ) <EOL> except ValueError : <EOL> return default <EOL> def call_addgroup ( name ) : <EOL> subprocess . call ( [ '<STR_LIT>' , name ] ) <EOL> def parse_cmdline ( args , uids , gids , first = <NUM_LIT:100> , last = <NUM_LIT> , last_user = <NUM_LIT> ) : <EOL> args0 = args [ <NUM_LIT:0> ] . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> def insert ( ids , key , idx , opt ) : <EOL> index = get_index ( args , opt ) or get_index ( args , '<STR_LIT:->' + opt [ <NUM_LIT:2> ] ) <EOL> if key in ids : <EOL> val = ids [ key ] [ idx ] <EOL> elif key in [ x for v in ids . values ( ) for x in v ] : <EOL> val = key <EOL> else : <EOL> raise KeyError ( '<STR_LIT>' % <EOL> ( key , opt , str ( ids . values ( ) ) ) ) <EOL> debug ( '<STR_LIT>' % <EOL> ( opt , str ( index ) , key , val ) ) <EOL> if index : <EOL> args [ index + <NUM_LIT:1> ] = val <EOL> else : <EOL> args . insert ( <NUM_LIT:1> , val ) <EOL> args . insert ( <NUM_LIT:1> , opt ) <EOL> args_opts = copy . deepcopy ( ARGS_OPTS ) <EOL> if args0 == '<STR_LIT>' : <EOL> args_opts . remove ( '<STR_LIT>' ) <EOL> arg1 = None <EOL> for ai in range ( <NUM_LIT:1> , len ( args ) ) : <EOL> if args [ ai ] [ <NUM_LIT:0> ] != '<STR_LIT:->' and ( args [ ai - <NUM_LIT:1> ] not in args_opts or args [ ai - <NUM_LIT:1> ] == args [ <NUM_LIT:0> ] ) : <EOL> arg1 = args [ ai ] <EOL> break <EOL> if not arg1 : <EOL> raise KeyError ( '<STR_LIT>' % str ( args ) ) <EOL> if args0 == '<STR_LIT>' or args0 == '<STR_LIT>' : <EOL> idx = get_index ( args , '<STR_LIT>' ) or get_index ( args , '<STR_LIT>' ) <EOL> if idx : <EOL> insert ( gids , args [ idx + <NUM_LIT:1> ] , <NUM_LIT:0> , '<STR_LIT>' ) <EOL> else : <EOL> call_addgroup ( arg1 ) <EOL> insert ( uids , arg1 , <NUM_LIT:1> , '<STR_LIT>' ) <EOL> insert ( uids , arg1 , <NUM_LIT:0> , '<STR_LIT>' ) <EOL> elif args0 == '<STR_LIT>' or args0 == '<STR_LIT>' : <EOL> insert ( gids , arg1 , <NUM_LIT:0> , '<STR_LIT>' ) <EOL> args [ <NUM_LIT:0> ] = args [ <NUM_LIT:0> ] + '<STR_LIT>' <EOL> return args <EOL> def main ( ) : <EOL> uids = { } <EOL> gids = { } <EOL> debug ( '<STR_LIT>' % str ( sys . argv ) ) <EOL> IDS = '<STR_LIT>' <EOL> try : <EOL> exec ( open ( IDS ) . read ( ) ) <EOL> except IOError : <EOL> pass <EOL> parse ( open ( '<STR_LIT>' ) . read ( ) , uids ) <EOL> parse ( open ( '<STR_LIT>' ) . read ( ) , gids , True ) <EOL> parse_cmdline ( sys . argv , uids , gids ) <EOL> debug ( '<STR_LIT>' % str ( sys . argv ) ) <EOL> ret = subprocess . call ( sys . argv ) <EOL> if ret != <NUM_LIT:0> : <EOL> sys . exit ( ret ) <EOL> parse ( open ( '<STR_LIT>' ) . read ( ) , uids ) <EOL> parse ( open ( '<STR_LIT>' ) . read ( ) , gids , True ) <EOL> out = open ( IDS , '<STR_LIT:w>' ) <EOL> print ( '<STR_LIT>' , file = out , end = '<STR_LIT>' ) <EOL> pprint . pprint ( uids , out ) <EOL> print ( '<STR_LIT>' , file = out , end = '<STR_LIT>' ) <EOL> pprint . pprint ( gids , out ) <EOL> out . close ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> if sys . argv [ <NUM_LIT:0> ] . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> uids = { } <EOL> gids = { } <EOL> try : <EOL> exec ( open ( sys . argv [ <NUM_LIT:3> ] ) . read ( ) ) <EOL> except IOError : <EOL> pass <EOL> parse ( open ( sys . argv [ <NUM_LIT:1> ] ) . read ( ) , uids ) <EOL> parse ( open ( sys . argv [ <NUM_LIT:2> ] ) . read ( ) , gids , True ) <EOL> out = open ( sys . argv [ <NUM_LIT:3> ] , '<STR_LIT:w>' ) <EOL> print ( '<STR_LIT>' , file = out , end = '<STR_LIT>' ) <EOL> pprint . pprint ( uids , out ) <EOL> print ( '<STR_LIT>' , file = out , end = '<STR_LIT>' ) <EOL> pprint . pprint ( gids , out ) <EOL> out . close ( ) <EOL> else : <EOL> main ( ) </s>
