<s> import os <EOL> import sys <EOL> import collections <EOL> import six <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> def prefix_dict_keys ( dictionary , prefix = '<STR_LIT:_>' ) : <EOL> """<STR_LIT>""" <EOL> result = { } <EOL> for key , value in six . iteritems ( dictionary ) : <EOL> result [ '<STR_LIT>' % ( prefix , key ) ] = value <EOL> return result <EOL> def compare_path_file_name ( file_path_a , file_path_b ) : <EOL> """<STR_LIT>""" <EOL> file_name_a = os . path . basename ( file_path_a ) <EOL> file_name_b = os . path . basename ( file_path_b ) <EOL> return file_name_a < file_name_b <EOL> def strip_shell_chars ( input_str ) : <EOL> """<STR_LIT>""" <EOL> stripped_str = rstrip_last_char ( input_str , '<STR_LIT:\n>' ) <EOL> stripped_str = rstrip_last_char ( stripped_str , '<STR_LIT:\r>' ) <EOL> return stripped_str <EOL> def rstrip_last_char ( input_str , char_to_strip ) : <EOL> """<STR_LIT>""" <EOL> if not input_str : <EOL> return input_str <EOL> if not char_to_strip : <EOL> return input_str <EOL> if input_str . endswith ( char_to_strip ) : <EOL> return input_str [ : - len ( char_to_strip ) ] <EOL> return input_str <EOL> def deep_update ( d , u ) : <EOL> """<STR_LIT>""" <EOL> for k , v in u . iteritems ( ) : <EOL> if isinstance ( v , collections . Mapping ) : <EOL> r = deep_update ( d . get ( k , { } ) , v ) <EOL> d [ k ] = r <EOL> else : <EOL> d [ k ] = u [ k ] <EOL> return d <EOL> def get_normalized_file_path ( file_path ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( sys , '<STR_LIT>' ) : <EOL> file_path = '<STR_LIT>' % ( os . sep , file_path [ - <NUM_LIT:4> : ] ) <EOL> elif file_path [ - <NUM_LIT:4> : ] . lower ( ) in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> file_path = file_path [ : - <NUM_LIT:4> ] + '<STR_LIT>' <EOL> else : <EOL> file_path = file_path <EOL> file_path = os . path . normcase ( file_path ) <EOL> return file_path </s>
