#NEWLINE# def initGlobalDo( self , _force = False ) : #NEWLINE# #INDENT# _cfgFile = os . path . join ( _force . sublimeRoot , '.do' ) #NEWLINE# if ( not _force ) : #NEWLINE# #INDENT# cCfg = self . readCfg ( _cfgFile ) #NEWLINE# if cCfg : #NEWLINE# #INDENT# return cCfg #NEWLINE# #UNINDENT# #UNINDENT# self . globalInited = True #NEWLINE# cSettings = [ ] #NEWLINE# doSetting = Setting ( ) #NEWLINE# cSettings . append ( doSetting ) #NEWLINE# doSetting . engine = 'file' #NEWLINE# headerCollect = self . defaultHeader #NEWLINE# httpInitFlag = sublime . ok_cancel_dialog ( 'TypeTodo init:\n\n\tStart with new public HTTP storage?' ) #NEWLINE# if httpInitFlag : #NEWLINE# #INDENT# req = urllib2 . Request ( ( ( 'http://' + self . defaultHttpApi ) + '/?=new_rep_public' ) ) #NEWLINE# try : #NEWLINE# #INDENT# cRep = bytes . decode ( urllib2 . urlopen ( req ) . read ( ) ) #NEWLINE# print ( ( 'New TypeTodo repository: ' + cRep ) ) #NEWLINE# sublime . set_timeout ( ( lambda : sublime . status_message ( 'New TypeTodo repository initialized' ) ) , 1000 ) #NEWLINE# cSetting = Setting ( ) #NEWLINE# cSettings . append ( cSetting ) #NEWLINE# cSetting . engine = 'http' #NEWLINE# cSetting . addr = self . defaultHttpApi #NEWLINE# cSetting . base = cRep #NEWLINE# cSetting . login = cSetting . passwh = '' #NEWLINE# headerCollect += ( ( ( ( ( cSetting . engine + ' ' ) + cSetting . addr ) + ' ' ) + cSetting . base ) + '\n' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# sublime . set_timeout ( ( lambda : sublime . error_message ( 'TypeTodo error:\n\n\tcannot init new HTTP repository,\n\tdefault storage mode will be `file`' ) ) , 1000 ) #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# with codecs . open ( _cfgFile , 'w+' , 'UTF-8' ) as f : #NEWLINE# #INDENT# f . write ( headerCollect ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# sublime . set_timeout ( ( lambda : sublime . error_message ( 'TypeTodo error:\n\n\tglobal config cannot be created' ) ) , 1000 ) #NEWLINE# return #NEWLINE# #UNINDENT# doSetting . head = headerCollect #NEWLINE# return cSettings