def assignBranch(self, str_branch_name):#void """ Соединяет курсор с узлом. Если узла нет, создается.""" self._current_node_name = str_branch_name self._branch_cash = {} findex_name = self._get_real_branch_name()+'/'+self._kForwardIndexName sets = dal.get_utf8_template() sets['name'] = findex_name try: os.mkdir(self._get_real_branch_name()) sets['howOpen'] = 'w' dal.list2file(sets, ["{}"]) except OSError as e: print 'Branch is exist' # Загружаем индекс readed_list = dal.file2list(sets) branch_in_json = ' '.join(readed_list) # TODO(zaqwes): долгая операция(несколько секунд), как быть? self._branch_cash = json.loads(branch_in_json)
open_comment_idx.append(i) # Добавление if enable and '#' not in at and at and '"""' not in at: result.append( _kContentMarker+_remove_end_spaces(at)) else: result.append(_remove_end_spaces(at)) return result, open_comment_idx, close_comment_idx if __name__=='__main__': sets = iow.get_utf8_template() sets['name'] = 'bale_mkt.py' mkt_in_list = iow.file2list(sets) mkt_in_list, open_comment_idx, close_comment_idx = _remove_long_comments(mkt_in_list) # Дополнительная маркеровка # Классы, интерфейсы, методы, переменные markered_code = [] for at in mkt_in_list: if _kContentMarker in at: if 'interface' in at: markered_code.append('I:'+at) elif '(' in at: markered_code.append('M:'+at) else: raise "No implement" else:
def read_utf_txt_file(fname): sets = dal.get_utf8_template() sets['name'] = fname return dal.file2list(sets)
def file_as_list(file_name): template = io.get_utf8_template() template['name'] = file_name return io.file2list(template)
def get_file_content(fname): sets = iow.get_utf8_template() sets['name'] = fname source_content = iow.file2list(sets) return source_content
# coding: utf-8 ''' Created on 18.04.2013 @author: кей ''' import dals.os_io.io_wrapper as dal def convert_one_line(msg): copy_line = msg.split(';')[0] if copy_line: name = copy_line.split('.')[-1] print copy_line+' as '+name if __name__=='__main__': sets = dal.get_utf8_template() sets['name'] = 'test_import_to_jy.txt' readed = dal.file2list(sets) map(convert_one_line, readed) print 'Done'
sets['coding'] = 'utf_8' iow.list2file(sets, ['\r# Unrolled:\n']) sets['howOpen'] = 'a' to_json.save_process_result(what_save, sets, raw=False) iow.list2file(sets, ['\r# Packed:\n']) to_json.save_process_result(what_save, sets, raw=True) if __name__ == "__main__": sets = iow.get_utf8_template() sets['name'] = "D:/home/lugansky-igor/tmitter-web-service-win/page/www/sub-pages/sys-settings-new.htm" sets['coding'] = 'cp1251' # branch_name = "settings monitoring system" branch_name = branch_name.replace(' ', '_') readed_list = iow.file2list(sets) # Делим на блоки joined = '\r\n'.join(readed_list) typed_list = joined.split('</h1>') def _process_one_item(item, result_branchs): splitted_lise = item.split('\r\n') # Ищем заголовок item_name = splitted_lise[0].replace('<span style="display:none;">', '').replace('</span>', '') item_name = item_name.replace('\r', '') result_branchs[item_name] = {} # Ищем ids for at in splitted_lise:
@author: Igor ''' import dals.os_io.io_wrapper as dal def printer(msg): print msg if __name__=='__main__': sets = dal.get_utf8_template() path = 'D:/home/lugansky-igor/tmitter-web-service-win/server_side_code/top_service/' fname = path+'copy_top_service_ajax_set_sets.cc' sets['name'] = fname result = [] content = dal.file2list(sets) insert_in_next_line = False for at in content: if 'p["' in at and '!=' in at: result.append( at+' \n// STR_PARAM [Autogenerated]:\n string msg = "Change_to :"+p["'+at.split('"')[1]+'"];') result.append( ' sampler_.journal.PutRecord(msg);') result.append( ' GSNMPJournal->SendWarning(msg, kSnmpOk);') result.append( '// Autogenerated\n') elif 'itmp = a' in at: result.append( at ) insert_in_next_line = True else: if insert_in_next_line: result.append( at+' \n// INT_PARAM [Autogenerated]:\n string msg = "Change_to: "+to_string('+"itmp"+");") result.append( ' sampler_.journal.PutRecord(msg);') result.append( ' GSNMPJournal->SendWarning(msg, kSnmpOk);')