# coding: utf-8 ''' Created on 5 дек. 2017 г. @author: AdvancedDim ''' # import io # import re # import xml.etree.ElementTree as ET # import collections # import tempfile # from bs4 import BeautifulSoup # from java.text import SimpleDateFormat # # # def upload(): # root = ET.parse('D:/Programs/ARONIN_ASK_MB/XML/00750.xml') # # namespaces = { # 'w': 'http://schemas.microsoft.com/office/word/2003/wordml', # 'o': 'urn:schemas-microsoft-com:office:office', # 'aml': 'http://schemas.microsoft.com/aml/2001/core', # 'wpc': 'http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas', # 'dt': 'uuid:C2F41010-65B3-11d1-A29F-00AA00C14882', # 'wx': 'http://schemas.microsoft.com/office/word/2003/auxHint', # 'wne': 'http://schemas.microsoft.com/office/word/2006/wordml', # 'wsp': 'http://schemas.microsoft.com/office/word/2003/wordml/sp2', # 'sl': 'http://schemas.microsoft.com/schemaLibrary/2003/core', # 'mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006'} # # qti = {} # elem = [] # key = None # q = re.compile(u"(?:@(\d*)\.){1}(?:@(?:(\d*)\.(\d*))){1}(?:@([А-Я])){1}") # a = re.compile(u"([А-Я])\. *\s*(.+)") # c = re.compile(u'([\S\ ]+)') # # m = r.search(val) # # # # for child in root.findall('.//w:t', namespaces): # # # How to make decisions based on attributes even in 2.6: # # s = child.text # # if s[0]=='@': # # if key: # # qti[key] = elem # # key = s # # elem = [] # # else: # # elem.append(s) # # f = io.open('D:/Programs/ARONIN_ASK_MB/XML/00750.txt', 'r', encoding="cp1251") # lineList = f.readlines() # for s in lineList: # item = c.match(s) # if item: # s = item.groups()[0] # if s[0]=='@': # if key: # qti[key] = elem # key = s # elem = [] # else: # elem.append(s) # # od = collections.OrderedDict(sorted(qti.items())) # # for k,v in od.items(): # # if k==u"@09.@0321.01@Г@@": # print q.search(k).groups() # print v[0].replace('@', '') # # print v[1:] # for i in v[1:]: # # print i # m = a.search(i) # if m: # print m.groups()[0], m.groups()[1] # # f.close() # # # def cleanString(s): # text = u'' # ss = s.replace(u' ', '') # # print u"ss = [" + ss + u"]" # if ss: # pattern = re.compile(r'[\t\n\r\f\v]+') # text = re.sub(pattern, '', s) # text = (u' '.join(text.split())).strip() # return text # # def upload2(): # file = io.open('D:\Data\Ланселот\Сетевое обучение\Московский врач\Тесты NEW\Группы пользователей\Шаблон.htm', 'r', encoding="cp1251") # # html = BeautifulSoup(file, 'html5lib') # tables = html('table') # # options_table = tables[0] # options_rows = options_table('tr') # # test = { # 'speciality': u'', # 'control_date': u''} # # matching_numbers = { # 1: 'speciality', # 2: 'control_date'} # # for i, row in enumerate(options_rows): # index = i + 1 # td = row('td') # param = cleanString(' '.join(td[2].stripped_strings)) # if not param: # print u'Отсутствует параметр №{}'.format(i) # else: # try: # test[matching_numbers[index]] = param # except: # pass # # groups = list() # group = dict() # groups_table = tables[1] # groups_rows = groups_table('tr') # # for row in groups_rows: # td = row('td') # td1 = cleanString(u' '.join(td[0].stripped_strings)) # if td1 == u'Время': # if group: # groups.append(group) # group = dict() # group['persons'] = [] # time = cleanString(u' '.join(td[1].stripped_strings)) # group['name'] = u'{}, {} {}'.format(test['speciality'], test['control_date'], time) # group['time'] = time # elif td1: # person = dict() # person['surname'] = cleanString(u' '.join(td[1].stripped_strings)) # person['name'] = cleanString(u' '.join(td[2].stripped_strings)) # person['patronymic'] = cleanString(u' '.join(td[3].stripped_strings)) # person['phone'] = cleanString(u' '.join(td[4].stripped_strings)) # if group: # group['persons'].append(person) # elif group: # groups.append(group) # group = dict() # # if group: # groups.append(group) # group = dict() # test['groups'] = groups # # return test # # if __name__ == "__main__": # test = upload2() # print test # record = '12.' # print record.find('.') # # c = record.split('.') # # print c # people = [{'a': 1, 'b': 2}, {'a': 2, 'b': 3},{'a': 4, 'b': 7}] # name_indexer = dict((str(p['a']), p['b']) for p in people) # print name_indexer # # p = [1,2,3,4,5] # print p.count(1), p.count(10) import sys import os, sys non_symbolic=os.path.realpath(sys.argv[0]) program_filepath=os.path.join(sys.path[0], os.path.basename(non_symbolic)) # ... print program_filepath # sys.path.append('D:\\AAAAAAAAAAAAAA') # sys.path.insert(0, "./../../score") # # print sys.path