Beispiel #1
0
 def save_to_file(self):
     path = UtilsConfig.get_stock_list_path(self.list_name)
     if path is not None:
         try:
             f = open(path, 'w', encoding=UtilsConfig.get_encoding())
         except:
             f = open(path, 'w')
         for key, line in self.infolist.items():
             assert(isinstance(line, StockSuperiorInfo))
             f.write('{} {} {}\n'.format(line.update_date, line.code, line.code_name))
         f.close()
         return True
     else:
         print('save file {} failed.'.format(self.list_name))
         return False
Beispiel #2
0
 def load_from_file(self):
     path = UtilsConfig.get_stock_list_path(self.list_name)
     if path is not None and os.path.isfile(path):
         try:
             f = open(path, 'r', encoding=UtilsConfig.get_encoding())
         except:
             f = open(path, 'r')
         for line in f.readlines():
             info = StockIndustryInfo(*line.split())
             self.infolist[info.key] = info
         f.close()
         return True
     else:
         print('load file {} failed.'.format(self.list_name))
         return False
Beispiel #3
0
 def save_to_file(self, file_name='default.list'):
     path = UtilsConfig.get_stock_list_path(file_name)
     if path is not None:
         try:
             f = open(path, 'w', encoding=UtilsConfig.get_encoding())
         except:
             f = open(path, 'w')
         for key, line in self.infolist.items():
             assert(isinstance(line, StockBasicInfo))
             f.write('{} {} {} {} {} {}\n'.format(line.code, line.code_name, line.ipoDate, line.outDate,
                     line.type.numerator, line.status.numerator))
         f.close()
         return True
     else:
         print('save file {} failed.'.format(file_name))
         return False