<s> import sys , os , stat <EOL> import pythoncom <EOL> from win32com . shell import shell , shellcon <EOL> import commctrl <EOL> import winerror <EOL> from win32com . server . util import wrap <EOL> from pywintypes import IID <EOL> IPersist_Methods = [ "<STR_LIT>" ] <EOL> IColumnProvider_Methods = IPersist_Methods + [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> class ColumnProvider : <EOL> _reg_progid_ = "<STR_LIT>" <EOL> _reg_desc_ = "<STR_LIT>" <EOL> _reg_clsid_ = IID ( "<STR_LIT>" ) <EOL> _com_interfaces_ = [ pythoncom . IID_IPersist , <EOL> shell . IID_IColumnProvider , <EOL> ] <EOL> _public_methods_ = IColumnProvider_Methods <EOL> def GetClassID ( self ) : <EOL> return self . _reg_clsid_ <EOL> def Initialize ( self , colInit ) : <EOL> flags , reserved , name = colInit <EOL> print "<STR_LIT>" , name <EOL> def GetColumnInfo ( self , index ) : <EOL> if index in [ <NUM_LIT:0> , <NUM_LIT:1> ] : <EOL> if index == <NUM_LIT:0> : <EOL> ext = "<STR_LIT>" <EOL> else : <EOL> ext = "<STR_LIT>" <EOL> title = ext + "<STR_LIT>" <EOL> description = "<STR_LIT>" % ext <EOL> col_id = ( self . _reg_clsid_ , <EOL> index ) <EOL> col_info = ( <EOL> col_id , <EOL> pythoncom . VT_I4 , <EOL> commctrl . LVCFMT_RIGHT , <EOL> <NUM_LIT:20> , <EOL> shellcon . SHCOLSTATE_TYPE_INT | shellcon . SHCOLSTATE_SECONDARYUI , <EOL> title , <EOL> description ) <EOL> return col_info <EOL> return None <EOL> def GetItemData ( self , colid , colData ) : <EOL> fmt_id , pid = colid <EOL> fmt_id == self . _reg_clsid_ <EOL> flags , attr , reserved , ext , name = colData <EOL> if ext . lower ( ) not in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> return None <EOL> if pid == <NUM_LIT:0> : <EOL> ext = "<STR_LIT>" <EOL> else : <EOL> ext = "<STR_LIT>" <EOL> check_file = os . path . splitext ( name ) [ <NUM_LIT:0> ] + ext <EOL> try : <EOL> st = os . stat ( check_file ) <EOL> return st [ stat . ST_SIZE ] <EOL> except OSError : <EOL> return None <EOL> def DllRegisterServer ( ) : <EOL> import _winreg <EOL> key = _winreg . CreateKey ( _winreg . HKEY_CLASSES_ROOT , <EOL> "<STR_LIT>" + str ( ColumnProvider . _reg_clsid_ ) ) <EOL> _winreg . SetValueEx ( key , None , <NUM_LIT:0> , _winreg . REG_SZ , ColumnProvider . _reg_desc_ ) <EOL> print ColumnProvider . _reg_desc_ , "<STR_LIT>" <EOL> def DllUnregisterServer ( ) : <EOL> import _winreg <EOL> try : <EOL> key = _winreg . DeleteKey ( _winreg . HKEY_CLASSES_ROOT , <EOL> "<STR_LIT>" + str ( ColumnProvider . _reg_clsid_ ) ) <EOL> except WindowsError , details : <EOL> import errno <EOL> if details . errno != errno . ENOENT : <EOL> raise <EOL> print ColumnProvider . _reg_desc_ , "<STR_LIT>" <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from win32com . server import register <EOL> register . UseCommandLine ( ColumnProvider , <EOL> finalize_register = DllRegisterServer , <EOL> finalize_unregister = DllUnregisterServer ) </s>
