diff options
author | diSabler <dissy@ya.ru> | 2014-01-25 22:07:18 +0400 |
---|---|---|
committer | diSabler <dissy@ya.ru> | 2014-01-25 22:07:18 +0400 |
commit | e76dde3e04b76f450738d25825d3aac5284414af (patch) | |
tree | 40e1a68aa365351d2d944711ca81435b47bc9088 | |
parent | 42b55d05f8f6712f63d0cc2bd44bc434eba08b60 (diff) |
chg: regexp concat
-rw-r--r-- | kernel.py | 18 | ||||
-rw-r--r-- | plugins/acl.py | 34 | ||||
-rw-r--r-- | plugins/bash.py | 2 | ||||
-rw-r--r-- | plugins/bing.py | 2 | ||||
-rw-r--r-- | plugins/convert.py | 2 | ||||
-rw-r--r-- | plugins/disco.py | 4 | ||||
-rw-r--r-- | plugins/horo.py | 2 | ||||
-rw-r--r-- | plugins/istrue.py | 2 | ||||
-rw-r--r-- | plugins/main.py | 12 | ||||
-rw-r--r-- | plugins/mucfilter.py | 16 | ||||
-rw-r--r-- | plugins/net.py | 8 | ||||
-rw-r--r-- | plugins/psto.py | 2 | ||||
-rw-r--r-- | plugins/sovm.py | 2 | ||||
-rw-r--r-- | plugins/train.py | 2 | ||||
-rw-r--r-- | plugins/turn.py | 4 | ||||
-rw-r--r-- | plugins/www.py | 4 |
16 files changed, 58 insertions, 58 deletions
@@ -574,7 +574,7 @@ def message_exclude_update(): def message_validate(item): if messages_excl: for c in messages_excl: - cn = re.findall(c,' %s ' % item,re.I+re.S+re.U) + cn = re.findall(c,' %s ' % item,re.S|re.I|re.U) for tmp in cn: item = item.replace(tmp,[GT('censor_text')*len(tmp),GT('censor_text')][len(GT('censor_text'))>1]) return item @@ -781,7 +781,7 @@ def get_eval_item(mess,string): return '' def match_for_raw(original,regexp,gr): - orig_drop = orig_reg = re.findall(regexp, original.replace('\n',' '), re.S+re.U+re.I) + orig_drop = orig_reg = re.findall(regexp, original.replace('\n',' '), re.S|re.I|re.U) while '' in orig_drop: orig_drop.remove('') orig_join = ''.join(orig_reg) if orig_join: @@ -1047,7 +1047,7 @@ def messageCB(sess,mess): argz = btext[len(alias[0])+1:] if not argz: ppr = alias[1].replace('%*', '').replace('%{reduce}*', '').replace('%{reduceall}*', '').replace('%{unused}*', '') - ppr = re.sub('\%\{nick2jid\}[0-9\*]','',ppr,flags=re.S+re.I+re.U) + ppr = re.sub('\%\{nick2jid\}[0-9\*]','',ppr,flags=re.S|re.I|re.U) cpar = re.findall('%([0-9]+)', ppr, re.S) if len(cpar): for tmp in cpar: @@ -1059,18 +1059,18 @@ def messageCB(sess,mess): ppr = ppr.replace('%*', argz).replace('%{reduce}*', argz.strip()).replace('%{reduceall}*', reduce_spaces_all(argz)) argz = argz.split() argzbk = list(argz) - n2j = re.findall('\%\{nick2jid\}([0-9])',ppr,flags=re.S+re.I+re.U) + n2j = re.findall('\%\{nick2jid\}([0-9])',ppr,flags=re.S|re.I|re.U) if n2j: for t in n2j: it = int(t) try: curr_nick = get_jid_by_nick(room, argz[it]) except: curr_nick = '' - ppr = re.sub('\%%\{nick2jid\}%s' % t,curr_nick,ppr,flags=re.S+re.I+re.U) + ppr = re.sub('\%%\{nick2jid\}%s' % t,curr_nick,ppr,flags=re.S|re.I|re.U) argzbk = argzbk[:it]+argzbk[it+1:] - n2j = re.findall('\%\{nick2jid\}(\*)',ppr,flags=re.S+re.I+re.U) + n2j = re.findall('\%\{nick2jid\}(\*)',ppr,flags=re.S|re.I|re.U) if n2j: curr_nick = get_jid_by_nick(room, ' '.join(argz)) - ppr = re.sub('\%\{nick2jid\}[0-9\*]',curr_nick,ppr,flags=re.S+re.I+re.U) + ppr = re.sub('\%\{nick2jid\}[0-9\*]',curr_nick,ppr,flags=re.S|re.I|re.U) argz = [] if '%' in ppr: cpar = re.findall('%([0-9]+)', ppr, re.S) @@ -1155,14 +1155,14 @@ def to_censore(text,room): else: cc = ['#'.join(cc[:-1]),cc[-1]] if cc[0]: try: - _ = re.compile(cc[0]) + _ = re.compile(cc[0],re.S|re.I|re.U) ccn.append(cc[0]) if len(cc) > 1: custom_replace[cc[0]] = reduce_spaces_all(cc[1]) except: pass wca = None def_replacer = GT('censor_text') for c in censor+ccn: - cn = re.findall(c,' %s ' % text,re.I+re.S+re.U) + cn = re.findall(c,' %s ' % text,re.S|re.I|re.U) for tmp in cn: t = ''.join(tmp) try: replacer = custom_replace[c] diff --git a/plugins/acl.py b/plugins/acl.py index e531cfa..a0c5571 100644 --- a/plugins/acl.py +++ b/plugins/acl.py @@ -158,7 +158,7 @@ def acl_action(cmd,nick,jid,room,text): cmd = cmd.replace('${NICK}',nick).replace('${JID}',jid).replace('${SERVER}',getServer(jid)) if text and '${EXP}' in cmd and '${/EXP}' in cmd: regex = cmd.split('${EXP}',1)[1].split('${/EXP}',1)[0] - mt = re.findall(regex, text, re.S+re.U+re.I) + mt = re.findall(regex, text, re.S|re.I|re.U) if mt != []: txt = ''.join(mt[0]) else: txt = '' cmd = cmd.split('${EXP}',1)[0] + txt + cmd.split('${/EXP}',1)[1] @@ -180,11 +180,11 @@ def acl_message(room,jid,nick,type,text): if tmp[4] <= time.time() and tmp[4]: cur_execute('delete from acl where jid=%s and action=%s and type=%s and text=%s',(room,tmp[0],tmp[1],tmp[2])) was_match = False if tmp[1] in ['exp','!exp']: - if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),text,re.I+re.S+re.U): was_match = True - elif re.findall(tmp[2].replace('*','*?'),text,re.I+re.S+re.U): was_match = True + if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),text,re.S|re.I|re.U): was_match = True + elif re.findall(tmp[2].replace('*','*?'),text,re.S|re.I|re.U): was_match = True elif tmp[1] in ['cexp','!cexp']: - if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),text,re.S+re.U): was_match = True - elif re.findall(tmp[2].replace('*','*?'),text,re.S+re.U): was_match = True + if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),text,re.S|re.U): was_match = True + elif re.findall(tmp[2].replace('*','*?'),text,re.S|re.U): was_match = True elif tmp[1] in ['sub','!sub']: if tmp[1][0] == '!' and not tmp[2].lower() in text.lower(): was_match = True elif tmp[2].lower() in text.lower(): was_match = True @@ -280,11 +280,11 @@ def acl_selector(a,room,jid,nick,mass,was_joined): if itm: was_match = False if tmp[1] in ['exp','!exp']: - if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.I+re.S+re.U): was_match = True - elif re.findall(tmp[2].replace('*','*?'),itm,re.I+re.S+re.U): was_match = True + if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.S|re.I|re.U): was_match = True + elif re.findall(tmp[2].replace('*','*?'),itm,re.S|re.I|re.U): was_match = True elif tmp[1] in ['cexp','!cexp']: - if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.S+re.U): was_match = True - elif re.findall(tmp[2].replace('*','*?'),itm,re.S+re.U): was_match = True + if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.S|re.U): was_match = True + elif re.findall(tmp[2].replace('*','*?'),itm,re.S|re.U): was_match = True elif tmp[1] in ['sub','!sub']: if tmp[1][0] == '!' and tmp[2].lower() not in itm.lower(): was_match = True elif tmp[2].lower() in itm.lower(): was_match = True @@ -303,11 +303,11 @@ def acl_version_async(a, nick, jid, room, mass, lvl, is_answ): if tmp[0] == 'ver' and (tmp[5] == 9 or lvl == tmp[5]): was_match = False if tmp[1] in ['exp','!exp']: - if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.I+re.S+re.U): was_match = True - elif re.findall(tmp[2].replace('*','*?'),itm,re.I+re.S+re.U): was_match = True + if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.S|re.I|re.U): was_match = True + elif re.findall(tmp[2].replace('*','*?'),itm,re.S|re.I|re.U): was_match = True elif tmp[1] in ['cexp','!cexp']: - if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.S+re.U): was_match = True - elif re.findall(tmp[2].replace('*','*?'),itm,re.S+re.U): was_match = True + if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.S|re.U): was_match = True + elif re.findall(tmp[2].replace('*','*?'),itm,re.S|re.U): was_match = True elif tmp[1] in ['sub','!sub']: if tmp[1][0] == '!' and tmp[2].lower() not in itm.lower(): was_match = True elif tmp[2].lower() in itm.lower(): was_match = True @@ -348,11 +348,11 @@ def acl_vcard_async(a, nick, jid, room, mass, lvl, is_answ): if tmp[0] == 'vcard' and (tmp[5] == 9 or lvl == tmp[5]): was_match = False if tmp[1] in ['exp','!exp']: - if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.I+re.S+re.U): was_match = True - elif re.findall(tmp[2].replace('*','*?'),itm,re.I+re.S+re.U): was_match = True + if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.S|re.I|re.U): was_match = True + elif re.findall(tmp[2].replace('*','*?'),itm,re.S|re.I|re.U): was_match = True elif tmp[1] in ['cexp','!cexp']: - if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.S+re.U): was_match = True - elif re.findall(tmp[2].replace('*','*?'),itm,re.S+re.U): was_match = True + if tmp[1][0] == '!' and not re.findall(tmp[2].replace('*','*?'),itm,re.S|re.U): was_match = True + elif re.findall(tmp[2].replace('*','*?'),itm,re.S|re.U): was_match = True elif tmp[1] in ['sub','!sub']: if tmp[1][0] == '!' and tmp[2].lower() not in itm.lower(): was_match = True elif tmp[2].lower() in itm.lower(): was_match = True diff --git a/plugins/bash.py b/plugins/bash.py index fa3c01a..ece14e4 100644 --- a/plugins/bash.py +++ b/plugins/bash.py @@ -27,7 +27,7 @@ def bash_org_ru(type, jid, nick, text): elif re.match('\d+$', text): url = 'http://bash.org.ru/quote/%s' % text else: url = 'http://bash.org.ru/?text=%s' % urllib.quote(text.encode('cp1251')) body = html_encode(load_page(url)) - body = re.findall('<span class="date">(.*?)</span>.*?class="id">(.*?)</a>.*?<div class="text">(.*?)</div>',body,re.S+re.I+re.U) + body = re.findall('<span class="date">(.*?)</span>.*?class="id">(.*?)</a>.*?<div class="text">(.*?)</div>',body,re.S|re.I|re.U) try: msg = rss_del_nn(rss_replace('%s %s\n%s' % body[0])) except: msg = L('Quote not found!','%s/%s'%(jid,nick)) send_msg(type, jid, nick, msg) diff --git a/plugins/bing.py b/plugins/bing.py index 4757a68..207c7fc 100644 --- a/plugins/bing.py +++ b/plugins/bing.py @@ -63,7 +63,7 @@ def bing_translate(type, jid, nick, text): 'text':tr_text.encode("utf-8"),\ 'from':lfrom,\ 'to':lto})) - try: msg = re.findall('responseData\(\"(.*?)\"\)\;$',unicode(translate_results),re.S+re.I+re.U)[0] + try: msg = re.findall('responseData\(\"(.*?)\"\)\;$',unicode(translate_results),re.S|re.I|re.U)[0] except: msg = L('I can\'t translate it!','%s/%s'%(jid,nick)) else: msg = L('Incorrect language settings for translate. bt list - available languages.','%s/%s'%(jid,nick)) else: msg = L('Command\'s format: bt [from] to text','%s/%s'%(jid,nick)) diff --git a/plugins/convert.py b/plugins/convert.py index 6275adb..5d12ca6 100644 --- a/plugins/convert.py +++ b/plugins/convert.py @@ -53,7 +53,7 @@ def currency_converter(type, jid, nick, text): body = html_encode(load_page(url)) try: curr = body.split('<select name="tid_from" class="n">')[1].split('</select>')[0] - curr_list = dict(re.findall('<option value="(.*?)".*?>(.*?)</option>',curr,re.S+re.I+re.U)) + curr_list = dict(re.findall('<option value="(.*?)".*?>(.*?)</option>',curr,re.S|re.I|re.U)) except: curr_list = {} try: body = body.split('<table id="rTable" class="table">',1)[1] except: body = '' diff --git a/plugins/disco.py b/plugins/disco.py index e7edc05..352445f 100644 --- a/plugins/disco.py +++ b/plugins/disco.py @@ -22,7 +22,7 @@ # --------------------------------------------------------------------------- # whereis_answers = {} -whereis_regx = re.compile('<item .*?name=[\'"](.*?)[\'"]',re.S+re.U+re.I) +whereis_regx = re.compile('<item .*?name=[\'"](.*?)[\'"]',re.S|re.I|re.U) whereis_lock = None disco_excl = [] @@ -731,7 +731,7 @@ def disco_exclude_update(): def disco_validate(item): for c in disco_excl: - if re.findall(c,' %s ' % item,re.I+re.S+re.U): return None + if re.findall(c,' %s ' % item,re.S|re.I|re.U): return None return item def smart_sort(item): diff --git a/plugins/horo.py b/plugins/horo.py index b67dc8b..ca64b93 100644 --- a/plugins/horo.py +++ b/plugins/horo.py @@ -39,7 +39,7 @@ def handler_horoscope(type, jid, nick, text): if param in [L(t) for t in horodb] or param in horodb: if param not in horodb: param = dict([[L(t),t] for t in horodb])[param] body = html_encode(load_page('http://horo.mail.ru/prediction/%s/today' % param)) - try: msg = unhtml_hard(re.findall('<div id="tm_today">(.+?)<div class="mb2">',body,re.S+re.I+re.U)[0].strip()) + try: msg = unhtml_hard(re.findall('<div id="tm_today">(.+?)<div class="mb2">',body,re.S|re.I|re.U)[0].strip()) except: msg = L('Unknown error!','%s/%s'%(jid,nick)) if type=='groupchat': send_msg('chat', jid, nick, msg) diff --git a/plugins/istrue.py b/plugins/istrue.py index 3e7380e..3254247 100644 --- a/plugins/istrue.py +++ b/plugins/istrue.py @@ -45,7 +45,7 @@ def is_valid(type, jid, nick, text): else: msg += L('Equally','%s/%s'%(jid,nick)) def repl(t): return '[%s]' % t.group() - msg += ' - %s' % re.sub([u'([а-яё]+)','([a-z]+)'][hl==1],repl,text,flags=re.S+re.U+re.I) + msg += ' - %s' % re.sub([u'([а-яё]+)','([a-z]+)'][hl==1],repl,text,flags=re.S|re.I|re.U) send_msg(type, jid, nick, msg) diff --git a/plugins/main.py b/plugins/main.py index b68bd6e..83175bb 100644 --- a/plugins/main.py +++ b/plugins/main.py @@ -237,16 +237,16 @@ def atempt_to_shutdown_with_reason(text,sleep_time,exit_type,critical): def deidna(text): def repl(t): return t.group().lower().decode('idna') - return re.sub(r'(xn--[-0-9a-z_]*)',repl,text,flags=re.S+re.U+re.I) + return re.sub(r'(xn--[-0-9a-z_]*)',repl,text,flags=re.S|re.I|re.U) def enidna(text): - idn = re.findall(u'http[s]?://([-0-9a-zа-я._]*)',text,flags=re.S+re.U+re.I) + idn = re.findall(u'http[s]?://([-0-9a-zа-я._]*)',text,flags=re.S|re.I|re.U) if idn: text = text.replace(idn[0],idn[0].lower().encode('idna')) return text.encode('utf-8') def enidna_raw(text): def repl(t): return t.group().lower().encode('idna') - return re.sub(u'([а-я][-0-9а-я_]*)',repl,text,flags=re.S+re.U+re.I) + return re.sub(u'([а-я][-0-9а-я_]*)',repl,text,flags=re.S|re.I|re.U) def get_level(cjid, cnick): access_mode = -2 @@ -304,7 +304,7 @@ def show_syslogs_search(type, jid, nick, text): matches = [] for t in files: if not value or (value and re.findall(value,t.split('.')[0])): - m = [f for f in readfile(slog_folder % t).decode('utf-8').split('\n') if ' [9] syslogs_search' not in f and re.findall(text,f,re.S+re.I+re.U)] + m = [f for f in readfile(slog_folder % t).decode('utf-8').split('\n') if ' [9] syslogs_search' not in f and re.findall(text,f,re.S|re.I|re.U)] if m: if value: matches.append('*** %s%s%s%s-%s%s-%s%s ***' % tuple(t.split('.')[0])) matches += m @@ -436,9 +436,9 @@ def status(type, jid, nick, text): send_msg(type, jid, nick, msg) def replacer(msg): - def repl(t): return '%s\n' % re.findall('<div.*?>(.*?)</div>',t.group(0),re.S+re.U+re.I)[0] + def repl(t): return '%s\n' % re.findall('<div.*?>(.*?)</div>',t.group(0),re.S|re.I|re.U)[0] msg = rss_replace(msg) - msg = re.sub(r'(<div.*?>).*?(</div>)',repl,msg,flags=re.S+re.U+re.I) + msg = re.sub(r'(<div.*?>).*?(</div>)',repl,msg,flags=re.S|re.I|re.U) for tmp in [['<br/>','\n'],['<br />','\n']]: msg = msg.replace(*tmp) msg = rss_del_html(msg) msg = rss_replace(msg) diff --git a/plugins/mucfilter.py b/plugins/mucfilter.py index a330b22..8becb5f 100644 --- a/plugins/mucfilter.py +++ b/plugins/mucfilter.py @@ -141,7 +141,7 @@ def muc_filter_set(iq,id,room,acclvl,query,towh,al): if not mute and msg and get_config(gr,'muc_filter_adblock') != 'off': f = [] for reg in adblock_regexp: - tmp = re.findall(reg,body,re.I+re.S+re.U) + tmp = re.findall(reg,body,re.S|re.I|re.U) if tmp: f = f + tmp if f: act = get_config(gr,'muc_filter_adblock') @@ -159,7 +159,7 @@ def muc_filter_set(iq,id,room,acclvl,query,towh,al): if rawbody: f = [] for reg in adblock_regexp: - tmp = re.findall(reg,rawbody,re.I+re.S+re.U) + tmp = re.findall(reg,rawbody,re.S|re.I|re.U) if tmp: f = f + tmp if f: act = get_config(gr,'muc_filter_adblock_raw') @@ -430,8 +430,8 @@ def muc_filter_set(iq,id,room,acclvl,query,towh,al): try: re.compile(bl_nick) except: bl_nick = None is_bl = None - if bl_jid and re.findall(bl_jid,jid,re.S+re.U+re.I): is_bl = True - if not nick or (not is_bl and bl_nick and re.findall(bl_nick,nick,re.S+re.U+re.I)): is_bl = True + if bl_jid and re.findall(bl_jid,jid,re.S|re.I|re.U): is_bl = True + if not nick or (not is_bl and bl_nick and re.findall(bl_nick,nick,re.S|re.I|re.U)): is_bl = True if is_bl: muc_pprint('MUC-Filter blacklist: %s/%s %s' % (gr,nick,jid),'brown') msg,mute = unicode(xmpp.Node('presence', {'from': tojid, 'type': 'error', 'to':jid}, payload = ['replace_it',xmpp.Node('error', {'type': 'auth','code':'403'}, payload=[xmpp.Node('forbidden',{'xmlns':'urn:ietf:params:xml:ns:xmpp-stanzas'},[]),xmpp.Node('text',{'xmlns':'urn:ietf:params:xml:ns:xmpp-stanzas'},[L('Deny by blacklist!',rn)])])])).replace('replace_it',get_tag(msg,'presence')),True @@ -448,8 +448,8 @@ def muc_filter_set(iq,id,room,acclvl,query,towh,al): if not mute and msg and get_config(gr,'muc_filter_adblock_prs') != 'off': fs,fn = [],[] for reg in adblock_regexp: - tmps = [None,re.findall(reg,status,re.I+re.S+re.U)][status != ''] - tmpn = [None,re.findall(reg,nick,re.I+re.S+re.U)][nick != ''] + tmps = [None,re.findall(reg,status,re.S|re.I|re.U)][status != ''] + tmpn = [None,re.findall(reg,nick,re.S|re.I|re.U)][nick != ''] if tmps: fs = fs + tmps if tmpn: fn = fn + tmpn if fs: @@ -479,8 +479,8 @@ def muc_filter_set(iq,id,room,acclvl,query,towh,al): rawnick = match_for_raw(nick,u'[a-zа-я0-9@.]*',gr) fs,fn = [],[] for reg in adblock_regexp: - tmps = [None,re.findall(reg,rawstatus,re.I+re.S+re.U)][status != ''] - tmpn = [None,re.findall(reg,rawnick,re.I+re.S+re.U)][nick != ''] + tmps = [None,re.findall(reg,rawstatus,re.S|re.I|re.U)][status != ''] + tmpn = [None,re.findall(reg,rawnick,re.S|re.I|re.U)][nick != ''] if tmps: fs = fs + tmps if tmpn: fn = fn + tmpn if rawstatus and fs: diff --git a/plugins/net.py b/plugins/net.py index f1824c8..4012e1d 100644 --- a/plugins/net.py +++ b/plugins/net.py @@ -25,7 +25,7 @@ def vendor_by_mac(type, jid, nick, text): text = text.strip().replace('-','').replace(':','').replace(' ','')[:6].upper() if text and len(text) == 6: result = html_encode(load_page('http://standards.ieee.org/cgi-bin/ouisearch?%s' % text)) - r = re.findall('\(hex\)(.*?)\n',result,re.S+re.I) + r = re.findall('\(hex\)(.*?)\n',result,re.S|re.I) if 'Sorry!' in result and not r: msg = L('Not found!','%s/%s'%(jid,nick)) else: msg = r[0].strip().upper() else: msg = L('What?','%s/%s'%(jid,nick)) @@ -80,12 +80,12 @@ def srv_host(type, jid, nick, text): def srv_raw_check(type, jid, nick, text): text = enidna_raw(text) - text = ''.join(re.findall(u'[-a-z0-9\.\_\?\#\=\@\%\ \+]+',text,re.S+re.I)[0]) + text = ''.join(re.findall(u'[-a-z0-9\.\_\?\#\=\@\%\ \+]+',text,re.S|re.I)[0]) send_msg(type, jid, nick, deidna(shell_execute(text,'%s/%s'%(jid,nick)))) def chkserver(type, jid, nick, text): for a in ':;&/|\\\n\t\r': text = text.replace(a,' ') - t = re.findall(u'[-a-zа-я0-9._?#=@%]+',text,re.S+re.I) + t = re.findall(u'[-a-zа-я0-9._?#=@%]+',text,re.S|re.I|re.U) if len(t) >= 2: port = [] for a in t: @@ -95,7 +95,7 @@ def chkserver(type, jid, nick, text): t = t[0] port.sort() msg = shell_execute('nmap %s -p%s -P0 -T5' % (t.encode('idna'),','.join(port)),'%s/%s'%(jid,nick)) - try: msg = '%s\n%s' % (t.encode('idna'),reduce_spaces_all(re.findall('SERVICE(.*)Nmap',msg,re.S+re.U)[0][1:-2])) + try: msg = '%s\n%s' % (t.encode('idna'),reduce_spaces_all(re.findall('SERVICE(.*)Nmap',msg,re.S|re.U)[0][1:-2])) except: try: msg = '' diff --git a/plugins/psto.py b/plugins/psto.py index 58a6f65..bc90f29 100644 --- a/plugins/psto.py +++ b/plugins/psto.py @@ -49,7 +49,7 @@ def psto_catch(room,jid,nick,type,text): try: psto_idn, text = text.split(' ',1)[0][2:],text[1:] (type,jid,nick,psto_comm) = psto_id.pop(psto_idn).split('\n') - splitter = re.findall('http\:\/\/[-a-z0-9]+?\.psto\.net\/%s' % psto_idn, text, re.S+re.I+re.U)[0] + splitter = re.findall('http\:\/\/[-a-z0-9]+?\.psto\.net\/%s' % psto_idn, text, re.S|re.I|re.U)[0] while '\n\n' in text: text = text.replace('\n\n','\n') while '\n ' in text: text = text.replace('\n ','\n') if psto_comm: diff --git a/plugins/sovm.py b/plugins/sovm.py index 1ea0f20..4b90207 100644 --- a/plugins/sovm.py +++ b/plugins/sovm.py @@ -31,7 +31,7 @@ def sovm(type, jid, nick, text): body = html_encode(load_page('http://astro-goroskop.ru/sovmestimosti/%s.html' % znak)).replace('\n',' ') if '-' in znak: regexp = 'class="float_img" alt="(.*?)" />(.*?)<script' else: regexp = 'class="float_img" alt="(.*?)" />(.*?)<br /><br />' - body = re.findall(regexp,body,re.S+re.I+re.U) + body = re.findall(regexp,body,re.S|re.I|re.U) if body and len(body[0]) == 2: msg ='\n'.join(t.strip().replace('<br /> <br />','') for t in body[0]) else: msg = L('Error!','%s/%s'%(jid,nick)) else: msg = L('Sign not found!','%s/%s'%(jid,nick)) diff --git a/plugins/train.py b/plugins/train.py index a40c02c..51a9249 100644 --- a/plugins/train.py +++ b/plugins/train.py @@ -27,7 +27,7 @@ def train(type, jid, nick, text): url = 'http://rasp.yandex.ru/search/train/?fromName=%s&toName=%s' % (from_to[0], from_to[1]) data = html_encode(load_page(url)) data = data.split('<div class="b-timetable__tripname">',3)[1] - res = re.findall(u'<a class="b-link" href="/thread/.+?><strong>(.+?)</strong> <span class="g-nowrap">(.+?)</span>.+?<span class="g-nowrap"></span>.*?<span class="g-nowrap">(.+?)</span></a>.+?<strong>(.+?)</strong>.+?<strong>(.+?)</strong>.+?<div class="b-timetable__pathtime">(.+?)</div>', data, re.I+re.S+re.U) + res = re.findall(u'<a class="b-link" href="/thread/.+?><strong>(.+?)</strong> <span class="g-nowrap">(.+?)</span>.+?<span class="g-nowrap"></span>.*?<span class="g-nowrap">(.+?)</span></a>.+?<strong>(.+?)</strong>.+?<strong>(.+?)</strong>.+?<div class="b-timetable__pathtime">(.+?)</div>', data, re.S|re.I|re.U) if res.count(res[0]) > 1: res = res[:res.index(res[0], 1)] msg = '\n'.join(['%s\t%s-%s\t\t%s-%s\t(%s)' % _ for _ in res]) if not msg.strip() or 'b-pseudo-link js-transfers-trigger' in data: msg = L('What?','%s/%s'%(jid,nick)) diff --git a/plugins/turn.py b/plugins/turn.py index b205118..8247cd1 100644 --- a/plugins/turn.py +++ b/plugins/turn.py @@ -40,7 +40,7 @@ def turner_raw(text,jid,nick): elif ': ' in to_turn: msg, to_turn = '%s:' % to_turn.split(': ',1)[0], to_turn.split(': ',1)[1] else: msg = '' for tt in re.findall('\s+[^\s]*', ' ' + to_turn,re.I+re.U): - if re.findall('\s+(((svn|http[s]?|ftp)(://))|(magnet:\?))',tt,re.I+re.S+re.U): msg += tt + if re.findall('\s+(((svn|http[s]?|ftp)(://))|(magnet:\?))',tt,re.S|re.I|re.U): msg += tt else: msg += ''.join([ltab[rtab.find(x)] if x in rtab else x for x in tt]) msg = msg.strip() if get_config(getRoom(jid),'censor'): msg = to_censore(msg,jid) @@ -84,7 +84,7 @@ def autoturn(room,jid,nick,type,text): count_two = 0 if not sum([int(ord(t)>127) for t in tmp]): for tt in re.findall('\s+[^\s]*', ' ' + tmp): - if not re.findall('(svn|http[s]?|ftp)(://)',tt,re.S+re.U) and not re.findall(u'\s+[A-ZА-Я\d\']{2,}$',tt,re.U): count_two += sum([1 for k in two_en if k in tt]) + if not re.findall('(svn|http[s]?|ftp)(://)',tt,re.S|re.U) and not re.findall(u'\s+[A-ZА-Я\d\']{2,}$',tt,re.U): count_two += sum([1 for k in two_en if k in tt]) if len(tmp.split()) < count_two - 1: to_turn = turner_raw(text,room,nick) if to_turn and to_turn != text: diff --git a/plugins/www.py b/plugins/www.py index 16bc96b..a6ff511 100644 --- a/plugins/www.py +++ b/plugins/www.py @@ -86,7 +86,7 @@ def netheader(type, jid, nick, text): body = '%s\n%s' % (text,'\n'.join(res)) if regex: try: - mt = re.findall(regex, body, re.S+re.U+re.I) + mt = re.findall(regex, body, re.S|re.I|re.U) if mt != []: body = ''.join(mt[0]) else: body = L('RegExp not found!','%s/%s'%(jid,nick)) except: body = L('Error in RegExp!','%s/%s'%(jid,nick)) @@ -113,7 +113,7 @@ def netwww(type, jid, nick, text): page = remove_sub_space(html_encode(load_page(text))) if regex: try: - mt = re.findall(regex, page, re.S+re.U+re.I) + mt = re.findall(regex, page, re.S|re.I|re.U) if mt != []: if n: msg = unhtml_hard('\n'.join([''.join(t) for t in mt[:n]])) |