<s> import sys , re , os <EOL> tags = [ ] <EOL> def main ( ) : <EOL> args = sys . argv [ <NUM_LIT:1> : ] <EOL> for filename in args : <EOL> treat_file ( filename ) <EOL> if tags : <EOL> fp = open ( '<STR_LIT>' , '<STR_LIT:w>' ) <EOL> tags . sort ( ) <EOL> for s in tags : fp . write ( s ) <EOL> expr = '<STR_LIT>' <EOL> matcher = re . compile ( expr ) <EOL> def treat_file ( filename ) : <EOL> try : <EOL> fp = open ( filename , '<STR_LIT:r>' ) <EOL> except : <EOL> sys . stderr . write ( '<STR_LIT>' % filename ) <EOL> return <EOL> base = os . path . basename ( filename ) <EOL> if base [ - <NUM_LIT:3> : ] == '<STR_LIT>' : <EOL> base = base [ : - <NUM_LIT:3> ] <EOL> s = base + '<STR_LIT:\t>' + filename + '<STR_LIT:\t>' + '<STR_LIT>' <EOL> tags . append ( s ) <EOL> while <NUM_LIT:1> : <EOL> line = fp . readline ( ) <EOL> if not line : <EOL> break <EOL> m = matcher . match ( line ) <EOL> if m : <EOL> content = m . group ( <NUM_LIT:0> ) <EOL> name = m . group ( <NUM_LIT:2> ) <EOL> s = name + '<STR_LIT:\t>' + filename + '<STR_LIT>' + content + '<STR_LIT>' <EOL> tags . append ( s ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
