<s> import csv <EOL> import os <EOL> from utils . msg_util import * <EOL> class UserMapHelper : <EOL> def __init__ ( self , user_map_fname ) : <EOL> self . user_map_fname = user_map_fname <EOL> self . map_lookup = { } <EOL> self . load_map_lookup ( ) <EOL> def get_key_count ( self ) : <EOL> return len ( self . map_lookup ) <EOL> def load_map_lookup ( self ) : <EOL> if not os . path . isfile ( self . user_map_fname ) : <EOL> msgx ( '<STR_LIT>' % self . user_map_fname ) <EOL> with open ( self . user_map_fname , '<STR_LIT>' ) as csvfile : <EOL> map_reader = csv . reader ( csvfile , delimiter = '<STR_LIT:U+002C>' ) <EOL> row_num = <NUM_LIT:0> <EOL> for row in map_reader : <EOL> row_num += <NUM_LIT:1> <EOL> if row_num == <NUM_LIT:1> : continue <EOL> if len ( row ) == <NUM_LIT:0> : continue <EOL> if row [ <NUM_LIT:0> ] . startswith ( '<STR_LIT:#>' ) : continue <EOL> if len ( row ) == <NUM_LIT:2> : <EOL> if row [ <NUM_LIT:1> ] . strip ( ) : <EOL> self . map_lookup [ row [ <NUM_LIT:0> ] . strip ( ) ] = row [ <NUM_LIT:1> ] . strip ( ) <EOL> msgt ( '<STR_LIT>' % len ( self . map_lookup ) ) <EOL> for k , v in self . map_lookup . items ( ) : <EOL> msg ( '<STR_LIT>' % ( k , v ) ) <EOL> def get_github_user ( self , redmine_name , with_github_at = True ) : <EOL> if not redmine_name : <EOL> return None <EOL> github_name = self . map_lookup . get ( redmine_name . strip ( ) , None ) <EOL> if github_name is None : <EOL> return None <EOL> if with_github_at : <EOL> return '<STR_LIT:@>' + github_name <EOL> return github_name </s>
