ソースを参照

코드 스타일 수정 및 파일 위치 변경

ect (or 2du) 8 年 前
コミット
fe2744a6aa

ファイルの差分が大きいため隠しています
+ 173 - 173
app.py


+ 1 - 1
back_reset.py

@@ -15,7 +15,7 @@ def go_namu(data):
         print(end[0])
         namumark(conn, end[0], end[1], 1, 0, 0)
 
-if(__name__=='__main__'):
+if __name__=='__main__':
     curs.execute("select title, data from data")
     data = curs.fetchall()
     print(int(len(data) / 4))

+ 149 - 149
func.py

@@ -15,7 +15,7 @@ import os
 
 from set_mark.macro import get_time
 from set_mark.macro import ip_check
-from set_mark.mark import *
+from mark import *
 from set_mark.link import url_pas
 from set_mark.link import sha224
 
@@ -23,40 +23,40 @@ def captcha_get(conn):
     curs = conn.cursor()
 
     data = ''
-    if(custom(conn)[2] == 0):
+    if custom(conn)[2] == 0:
         curs.execute('select data from other where name = "recaptcha"')
         recaptcha = curs.fetchall()
-        if(recaptcha and recaptcha[0][0] != ''):
+        if recaptcha and recaptcha[0][0] != '':
             curs.execute('select data from other where name = "sec_re"')
             sec_re = curs.fetchall()
-            if(sec_re and sec_re[0][0] != ''):
+            if sec_re and sec_re[0][0] != '':
                 data += recaptcha[0][0] + '<hr>'
 
-    return(data)
+    return data
 
 def captcha_post(test, conn, num = 1):
     curs = conn.cursor()
 
-    if(num == 1):
-        if(custom(conn)[2] == 0 and captcha_get(conn) != ''):
+    if num == 1:
+        if custom(conn)[2] == 0 and captcha_get(conn) != '':
             curs.execute('select data from other where name = "sec_re"')
             sec_re = curs.fetchall()
-            if(sec_re and sec_re[0][0] != ''):
+            if sec_re and sec_re[0][0] != '':
                 data = requests.get('https://www.google.com/recaptcha/api/siteverify', params = { 'secret' : sec_re, 'response' : test })
 
-                if(not data):
-                    return(0)
+                if not data:
+                    return 0
                 else:
                     json_data = data.json()
 
-                    if(data.status_code == 200 and json_data['success'] == True):
-                        return(0)
+                    if data.status_code == 200 and json_data['success'] == True:
+                        return 0
                     else:
-                        return(1)
+                        return 1
             else:
-                return(0)
+                return 0
         else:
-            return(0)
+            return 0
     else:
         pass
 
@@ -66,14 +66,14 @@ def ip_warring(conn):
     if(custom(conn)[2] == 0):    
         curs.execute('select data from other where name = "no_login_warring"')
         data = curs.fetchall()
-        if(data and data[0][0] != ''):
+        if data and data[0][0] != '':
             text_data = '<span>' + data[0][0] + '</span><hr>'
         else:
             text_data = '<span>비 로그인 상태입니다. 비 로그인으로 진행 시 아이피가 기록됩니다.</span><hr>'
     else:
         text_data = ''
 
-    return(text_data)
+    return text_data
 
 def skin_check(conn):
     curs = conn.cursor()
@@ -81,8 +81,8 @@ def skin_check(conn):
     try:
         curs.execute('select data from other where name = "skin"')
         skin_exist = curs.fetchall()
-        if(skin_exist):
-            if(os.path.exists(os.path.abspath('./views/' + skin_exist[0][0] + '/index.tpl')) == 1):
+        if skin_exist:
+            if os.path.exists(os.path.abspath('./views/' + skin_exist[0][0] + '/index.tpl')) == 1:
                 skin = './views/' + skin_exist[0][0] + '/'
     except:
         pass
@@ -91,34 +91,34 @@ def skin_check(conn):
 
 def next_fix(link, num, page, end = 50):
     list_data = ''
-    if(num == 1):
-        if(len(page) == end):
+    if num == 1:
+        if len(page) == end:
             list_data += '<hr><a href="' + link + str(num + 1) + '">(이후)</a>'
-    elif(len(page) != end):
+    elif len(page) != end:
         list_data += '<hr><a href="' + link + str(num - 1) + '">(이전)</a>'
     else:
         list_data += '<hr><a href="' + link + str(num - 1) + '">(이전)</a> <a href="' + link + str(num + 1) + '">(이후)</a>'
 
-    return(list_data)
+    return list_data
 
 def other2(origin):
-    return(origin + ['제거 되었음. 스킨 업데이트 필요함.'])    
+    return origin + ['제거 되었음. 스킨 업데이트 필요함.']    
 
 def wiki_set(conn, num):
     curs = conn.cursor()
-    if(num == 1):
+    if num == 1:
         data_list = []
 
         curs.execute('select data from other where name = ?', ['name'])
         db_data = curs.fetchall()
-        if(db_data and db_data[0][0] != ''):
+        if db_data and db_data[0][0] != '':
             data_list += [db_data[0][0]]
         else:
             data_list += ['무명위키']
 
         curs.execute('select data from other where name = "license"')
         db_data = curs.fetchall()
-        if(db_data and db_data[0][0] != ''):
+        if db_data and db_data[0][0] != '':
             data_list += [db_data[0][0]]
         else:
             data_list += ['CC 0']
@@ -127,83 +127,83 @@ def wiki_set(conn, num):
 
         curs.execute('select data from other where name = "logo"')
         db_data = curs.fetchall()
-        if(db_data and db_data[0][0] != ''):
+        if db_data and db_data[0][0] != '':
             data_list += [db_data[0][0]]
         else:
             data_list += [data_list[0]]
             
         curs.execute("select data from other where name = 'head'")
         db_data = curs.fetchall()
-        if(db_data and db_data[0][0] != ''):
+        if db_data and db_data[0][0] != '':
             data_list += [db_data[0][0]]
         else:
             data_list += ['']
 
-        return(data_list)
+        return data_list
 
-    if(num == 2):
+    if num == 2:
         var_data = '위키:대문'
         curs.execute('select data from other where name = "frontpage"')
-    elif(num == 3):
+    elif num == 3:
         var_data = '2'
         curs.execute('select data from other where name = "upload"')
     
     db_data = curs.fetchall()
-    if(db_data and db_data[0][0] != ''):
-        return(db_data[0][0])
+    if db_data and db_data[0][0] != '':
+        return db_data[0][0]
     else:
-        return(var_data)
+        return var_data
 
 def diff(seqm):
     output = []
     for opcode, a0, a1, b0, b1 in seqm.get_opcodes():
-        if(opcode == 'equal'):
+        if opcode == 'equal':
             output += [seqm.a[a0:a1]]
-        elif(opcode == 'insert'):
+        elif opcode == 'insert':
             output += ["<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span>"]
-        elif(opcode == 'delete'):
+        elif opcode == 'delete':
             output += ["<span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>"]
-        elif(opcode == 'replace'):
+        elif opcode == 'replace':
             output += ["<span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>"]
             output += ["<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span>"]
             
-    return(''.join(output))
+    return ''.join(output)
            
 def admin_check(conn, num, what):
     ip = ip_check() 
     curs = conn.cursor()
     curs.execute("select acl from user where id = ?", [ip])
     user = curs.fetchall()
-    if(user):
+    if user:
         reset = 0
-        while(1):
-            if(num == 1 and reset == 0):
+        while 1:
+            if num == 1 and reset == 0:
                 check = 'ban'
-            elif(num == 2 and reset == 0):
+            elif num == 2 and reset == 0:
                 check = 'mdel'
-            elif(num == 3 and reset == 0):
+            elif num == 3 and reset == 0:
                 check = 'toron'
-            elif(num == 4 and reset == 0):
+            elif num == 4 and reset == 0:
                 check = 'check'
-            elif(num == 5 and reset == 0):
+            elif num == 5 and reset == 0:
                 check = 'acl'
-            elif(num == 6 and reset == 0):
+            elif num == 6 and reset == 0:
                 check = 'hidel'
-            elif(num == 7 and reset == 0):
+            elif num == 7 and reset == 0:
                 check = 'give'
             else:
                 check = 'owner'
 
             curs.execute('select name from alist where name = ? and acl = ?', [user[0][0], check])
             acl_data = curs.fetchall()
-            if(acl_data):
-                if(what):
+            if acl_data:
+                if what:
                     curs.execute("insert into re_admin (who, what, time) values (?, ?, ?)", [ip, what, get_time()])
                     conn.commit()
 
-                return(1)
+                return 1
             else:
-                if(reset == 0):
+                if reset == 0:
                     reset = 1
                 else:
                     break
@@ -211,13 +211,13 @@ def admin_check(conn, num, what):
 def ip_pas(conn, raw_ip):
     hide = 0
     curs = conn.cursor()
-    if(re.search("(\.|:)", raw_ip)):
+    if re.search("(\.|:)", raw_ip):
         if(not re.search("^도구:", raw_ip)):    
             curs.execute("select data from other where name = 'ip_view'")
             d = curs.fetchall()
-            if(d and d[0][0] != ''):
+            if d and d[0][0] != '':
                 ip = '<span style="font-size: 75%;">' + hashlib.md5(bytes(raw_ip, 'utf-8')).hexdigest() + '</span>'
-                if(not admin_check(conn, 'ban', None)):
+                if not admin_check(conn, 'ban', None):
                     hide = 1
             else:
                 ip = raw_ip
@@ -226,106 +226,106 @@ def ip_pas(conn, raw_ip):
             hide = 1
     else:
         curs.execute("select title from data where title = ?", ['사용자:' + raw_ip])
-        if(curs.fetchall()):
+        if curs.fetchall():
             ip = '<a href="/w/' + url_pas('사용자:' + raw_ip) + '">' + raw_ip + '</a>'
         else:
             ip = '<a class="not_thing" href="/w/' + url_pas('사용자:' + raw_ip) + '">' + raw_ip + '</a>'
          
-    if(hide == 0):
+    if hide == 0:
         ip += ' <a href="/record/' + url_pas(raw_ip) + '">(기록)</a>'
 
-    return(ip)
+    return ip
 
 def custom(conn):
     curs = conn.cursor()
-    if('MyMaiToNight' in session):
+    if 'MyMaiToNight' in session:
         user_head = session['MyMaiToNight']
     else:
         user_head = ''
 
-    if('Now' in session and session['Now'] == 1):
+    if 'Now' in session and session['Now'] == 1:
         curs.execute('select name from alarm where name = ? limit 1', [ip_check()])
-        if(curs.fetchall()):
+        if curs.fetchall():
             user_icon = 2
         else:
             user_icon = 1
     else:
         user_icon = 0
 
-    return(['', '', user_icon, user_head])
+    return ['', '', user_icon, user_head]
 
 def acl_check(conn, name):
     ip = ip_check()
     curs = conn.cursor()
-    if(ban_check(conn) == 1):
-        return(1)
+    if ban_check(conn) == 1:
+        return 1
 
     acl_c = re.search("^사용자:([^/]*)", name)
-    if(acl_c):
+    if acl_c:
         acl_n = acl_c.groups()
 
-        if(admin_check(conn, 5, None) == 1):
-            return(0)
+        if admin_check(conn, 5, None) == 1:
+            return 0
 
         curs.execute("select dec from acl where title = ?", ['사용자:' + acl_n[0]])
         acl_d = curs.fetchall()
-        if(acl_d):
-            if(acl_d[0][0] == 'all'):
-                return(0)
+        if acl_d:
+            if acl_d[0][0] == 'all':
+                return 0
 
-            if(acl_d[0][0] == 'user' and not re.search("(\.|:)", ip)):
-                return(0)
+            if acl_d[0][0] == 'user' and not re.search("(\.|:)", ip):
+                return 0
 
-            if(not ip == acl_n[0] or re.search("(\.|:)", ip)):
-                return(1)
+            if not ip == acl_n[0] or re.search("(\.|:)", ip):
+                return 1
         
-        if(ip == acl_n[0] and not re.search("(\.|:)", ip) and not re.search("(\.|:)", acl_n[0])):
-            return(0)
+        if ip == acl_n[0] and not re.search("(\.|:)", ip) and not re.search("(\.|:)", acl_n[0]):
+            return 0
         else:
-            return(1)
+            return 1
 
     file_c = re.search("^파일:(.*)", name)
-    if(file_c and admin_check(conn, 5, 'edit (' + name + ')') != 1):
-        return(1)
+    if file_c and admin_check(conn, 5, 'edit (' + name + ')') != 1:
+        return 1
 
     curs.execute("select acl from user where id = ?", [ip])
     user_d = curs.fetchall()
 
     curs.execute("select dec from acl where title = ?", [name])
     acl_d = curs.fetchall()
-    if(acl_d):
-        if(acl_d[0][0] == 'user'):
-            if(not user_d):
-                return(1)
+    if acl_d:
+        if acl_d[0][0] == 'user':
+            if not user_d:
+                return 1
 
-        if(acl_d[0][0] == 'admin'):
-            if(not user_d):
-                return(1)
+        if acl_d[0][0] == 'admin':
+            if not user_d:
+                return 1
 
-            if(not admin_check(conn, 5, 'edit (' + name + ')') == 1):
-                return(1)
+            if not admin_check(conn, 5, 'edit (' + name + ')') == 1:
+                return 1
 
     curs.execute('select data from other where name = "edit"')
     set_d = curs.fetchall()
-    if(set_d):
-        if(set_d[0][0] == 'user'):
-            if(not user_d):
-                return(1)
+    if set_d:
+        if set_d[0][0] == 'user':
+            if not user_d:
+                return 1
 
-        if(set_d[0][0] == 'admin'):
-            if(not user_d):
-                return(1)
+        if set_d[0][0] == 'admin':
+            if not user_d:
+                return 1
 
-            if(not admin_check(conn, 5, None) == 1):
-                return(1)
+            if not admin_check(conn, 5, None) == 1:
+                return 1
 
-    return(0)
+    return 0
 
 def ban_check(conn):
     ip = ip_check()
     curs = conn.cursor()
     band = re.search("^([0-9]{1,3}\.[0-9]{1,3})", ip)
-    if(band):
+    if band:
         band_it = band.groups()
     else:
         band_it = ['Not']
@@ -335,28 +335,28 @@ def ban_check(conn):
 
     curs.execute("select block from ban where block = ?", [ip])
     ban_d = curs.fetchall()
-    if(band_d or ban_d):
-        return(1)
+    if band_d or ban_d:
+        return 1
     
-    return(0)
+    return 0
         
 def topic_check(conn, name, sub):
     ip = ip_check()
     curs = conn.cursor()
-    if(ban_check(conn) == 1):
-        return(1)
+    if ban_check(conn) == 1:
+        return 1
 
     curs.execute("select title from stop where title = ? and sub = ?", [name, sub])
     topic_s = curs.fetchall()
-    if(topic_s):
-        return(1)
+    if topic_s:
+        return 1
 
-    return(0)
+    return 0
 
 def rd_plus(conn, title, sub, date):
     curs = conn.cursor()
     curs.execute("select title from rd where title = ? and sub = ?", [title, sub])
-    if(curs.fetchall()):
+    if curs.fetchall():
         curs.execute("update rd set date = ? where title = ? and sub = ?", [date, title, sub])
     else:
         curs.execute("insert into rd (title, sub, date) values (?, ?, ?)", [title, sub, date])
@@ -365,52 +365,52 @@ def history_plus(conn, title, data, date, ip, send, leng):
     curs = conn.cursor()
     curs.execute("select id from history where title = ? order by id + 0 desc limit 1", [title])
     d = curs.fetchall()
-    if(d):
+    if d:
         curs.execute("insert into history (id, title, data, date, ip, send, leng) values (?, ?, ?, ?, ?, ?, ?)", [str(int(d[0][0]) + 1), title, data, date, ip, send, leng])
     else:
         curs.execute("insert into history (id, title, data, date, ip, send, leng) values ('1', ?, ?, ?, ?, ?, ?)", [title, data, date, ip, send + ' (새 문서)', leng])
 
 def leng_check(a, b):
-    if(a < b):
+    if a < b:
         c = b - a
         c = '+' + str(c)
-    elif(b < a):
+    elif b < a:
         c = a - b
         c = '-' + str(c)
     else:
         c = '0'
         
-    return(c)
+    return c
 
 def redirect(data):
-    return('<meta http-equiv="refresh" content="0; url=' + data + '">')
+    return '<meta http-equiv="refresh" content="0; url=' + data + '">'
 
 def re_error(conn, data):
     curs = conn.cursor()
-    if(data == '/ban'):
+    if data == '/ban':
         ip = ip_check()
         end = '|| 사유 || 권한이 맞지 않는 상태 입니다. ||'
-        if(ban_check(conn) == 1):
+        if ban_check(conn) == 1:
             curs.execute("select end, why from ban where block = ?", [ip])
             d = curs.fetchall()
-            if(not d):
+            if not d:
                 m = re.search("^([0-9]{1,3}\.[0-9]{1,3})", ip)
-                if(m):
+                if m:
                     curs.execute("select end, why from ban where block = ? and band = 'O'", [m.groups()[0]])
                     d = curs.fetchall()
             
-            if(d):
+            if d:
                 end = '|| 상태 ||'
-                if(d[0][0]):
+                if d[0][0]:
                     now = int(re.sub('(:|-| )', '', get_time()))
                     day = re.sub('\-', '', d[0][0])              
                               
-                    if(re.search(':', day)):
+                    if re.search(':', day):
                         day = re.sub('( |:)', '', day)
                     else:
                         day += '000000'
                     
-                    if(now >= int(day)):
+                    if now >= int(day):
                         curs.execute("delete from ban where block = ?", [ip])
                         conn.commit()
                         
@@ -422,7 +422,7 @@ def re_error(conn, data):
                 
                 end += '||'
 
-                if(d[0][1] != ''):
+                if d[0][1] != '':
                     end += '\r\n|| 사유 || ' + d[0][1] + ' ||'
 
         return(html_minify(template('index', 
@@ -432,85 +432,85 @@ def re_error(conn, data):
         )))
 
     d = re.search('\/error\/([0-9]+)', data)
-    if(d):
+    if d:
         num = int(d.groups()[0])
-        if(num == 1):
+        if num == 1:
             title = '권한 오류'
             data = '비 로그인 상태 입니다.'
-        elif(num == 2):
+        elif num == 2:
             title = '권한 오류'
             data = '이 계정이 없습니다.'
-        elif(num == 3):
+        elif num == 3:
             title = '권한 오류'
             data = '권한이 모자랍니다.'
-        elif(num == 4):
+        elif num == 4:
             title = '권한 오류'
             data = '관리자는 차단, 검사 할 수 없습니다.'
-        elif(num == 5):
+        elif num == 5:
             title = '사용자 오류'
             data = '그런 계정이 없습니다.'
-        elif(num == 6):
+        elif num == 6:
             title = '가입 오류'
             data = '동일한 아이디의 사용자가 있습니다.'
-        elif(num == 7):
+        elif num == 7:
             title = '가입 오류'
             data = '아이디는 20글자보다 짧아야 합니다.'
-        elif(num == 8):
+        elif num == 8:
             title = '가입 오류'
             data = '아이디에는 한글과 알파벳과 공백만 허용 됩니다.'
-        elif(num == 9):
+        elif num == 9:
             title = '파일 올리기 오류'
             data = '파일이 없습니다.'
-        elif(num == 10):
+        elif num == 10:
             title = '변경 오류'
             data = '비밀번호가 다릅니다.'
-        elif(num == 11):
+        elif num == 11:
             title = '로그인 오류'
             data = '이미 로그인 되어 있습니다.'
-        elif(num == 12):
+        elif num == 12:
             title = '편집 오류'
             data = '누군가 먼저 편집 했습니다.'
-        elif(num == 13):
+        elif num == 13:
             title = '리캡차 오류'
             data = '리캡차를 통과하세요.'
-        elif(num == 14):
+        elif num == 14:
             title = '파일 올리기 오류'
             data = 'jpg, gif, jpeg, png, webp만 가능 합니다.'
-        elif(num == 15):
+        elif num == 15:
             title = '편집 오류'
             data = '편집 기록은 500자를 넘을 수 없습니다.'
-        elif(num == 16):
+        elif num == 16:
             title = '파일 올리기 오류'
             data = '동일한 이름의 파일이 있습니다.'
-        elif(num == 17):
+        elif num == 17:
             title = '파일 올리기 오류'
             data = '파일 용량은 ' + wiki_set(conn, 3) + 'MB를 넘길 수 없습니다.'
-        elif(num == 18):
+        elif num == 18:
             title = '편집 오류'
             data = '내용이 원래 문서와 동일 합니다.'
-        elif(num == 19):
+        elif num == 19:
             title = '이동 오류'
             data = '이동 하려는 곳에 문서가 이미 있습니다.'
-        elif(num == 20):
+        elif num == 20:
             title = '비밀번호 오류'
             data = '재 확인이랑 비밀번호가 다릅니다.'
-        elif(num == 21):
+        elif num == 21:
             title = '편집 오류'
             data = '편집 필터에 의해 검열 되었습니다.'
-        elif(num == 22):
+        elif num == 22:
             title = '파일 올리기 오류'
             data = '파일 이름은 알파벳, 한글, 띄어쓰기, 언더바, 빼기표만 허용 됩니다.'
         else:
             title = '정체 불명의 오류'
             data = '???'
 
-        if(title):
+        if title:
             return(html_minify(template('index', 
                 imp = [title, wiki_set(conn, 1), custom(conn), other2([0, 0])],
                 data = namumark(conn, "", "[목차(없음)]\r\n== 오류 발생 ==\r\n" + data, 0, 0, 0),
                 menu = 0
             )))
         else:
-            return(redirect('/'))
+            return redirect('/')
     else:
-        return(redirect('/'))
+        return redirect('/')

+ 32 - 32
set_mark/mark.py → mark.py

@@ -1,17 +1,17 @@
-from . import start
-from . import mid_pas
-from . import html_pas
-from . import include_pas
-from . import macro
-from . import redirect_pas
-from . import blockquote
-from . import toc_pas
-from . import text_help
-from . import link
-from . import indent
-from . import footnote
-from . import table
-from . import end
+from set_mark.start import start
+from set_mark.mid_pas import mid_pas
+from set_mark.html_pas import html_pas
+from set_mark.include_pas import include_pas
+from set_mark.macro import macro
+from set_mark.redirect_pas import redirect_pas
+from set_mark.blockquote import blockquote
+from set_mark.toc_pas import toc_pas
+from set_mark.text_help import text_help
+from set_mark.link import link
+from set_mark.indent import indent
+from set_mark.footnote import footnote
+from set_mark.table import table
+from set_mark.end import end
 import re
 import html
 import sqlite3
@@ -27,51 +27,51 @@ def send_p(d):
 
     d = re.sub('&lt;a href="(?:[^"]*)"&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', '<a href="' + url_pas('\g<in>') + '">\g<in></a>', d)  
 
-    return(d)
+    return d
 
 def url_pas(data):
-    return(parse.quote(data).replace('/','%2F'))
+    return parse.quote(data).replace('/','%2F')
     
 async def plusing(conn, name, link, backtype):
     curs = conn.cursor()
     curs.execute("select title from back where title = ? and link = ? and type = ?", [link, name, backtype])
-    if(not curs.fetchall()):
+    if not curs.fetchall():
         curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
 
 def namumark(conn, title, data, num, in_c, toc_y):  
-    data = start.start(data)
-    data = html_pas.html_pas(data)
+    data = start(data)
+    data = html_pas(data)
     
     fol_num = 0
-    a = mid_pas.mid_pas(data, fol_num, 0, in_c, toc_y)
+    a = mid_pas(data, fol_num, 0, in_c, toc_y)
     data = a[0]
     fol_num = a[1]
 
-    a = include_pas.include_pas(conn, data, title, in_c, num, toc_y, fol_num)
+    a = include_pas(conn, data, title, in_c, num, toc_y, fol_num)
     data = a[0]
     category = a[1]
     fol_num = a[2]
     backlink = a[3]
     
     data = re.sub("\r\n##\s?([^\n]*)\r\n", "\r\n", data)    
-    a = redirect_pas.redirect_pas(data, title, backlink)
+    a = redirect_pas(data, title, backlink)
     data = a[0]
     backlink = a[1]
     
-    data = blockquote.blockquote(data)
-    data = toc_pas.toc_pas(data, title, num, toc_y)
-    data = text_help.text_help(data)
-    data = macro.macro(data)
+    data = blockquote(data)
+    data = toc_pas(data, title, num, toc_y)
+    data = text_help(data)
+    data = macro(data)
     
-    a = link.link(conn, title, data, num, category, backlink)
+    a = link(conn, title, data, num, category, backlink)
     data = a[0]
     category = a[1]
     backlink = a[2]
     
-    data = indent.indent(data)
-    data = footnote.footnote(data, fol_num)
-    data = table.table(data)
-    data = end.end(data, category)
+    data = indent(data)
+    data = footnote(data, fol_num)
+    data = table(data)
+    data = end(data, category)
     
     if(num == 1):        
         asyncio.set_event_loop(asyncio.new_event_loop())
@@ -81,4 +81,4 @@ def namumark(conn, title, data, num, in_c, toc_y):
         loop.close()
         conn.commit()
         
-    return(data)
+    return data

+ 1 - 1
requirements.txt

@@ -4,4 +4,4 @@ tornado >= 4.5.2
 bcrypt >= 3.1.3
 requests >= 2.13.0
 flask >= 0.12.2
-Flask-Reggie >= 0.0.2
+flask-Reggie >= 0.0.2

+ 0 - 0
set_mark/__init__.py


+ 3 - 3
set_mark/blockquote.py

@@ -1,9 +1,9 @@
 import re
 
 def blockquote(data):
-    while(1):
+    while 1:
         m = re.search("\n&gt;\s?((?:[^\n]*)(?:(?:(?:(?:\n&gt;\s?)(?:[^\n]*))+)?))", data)
-        if(m):
+        if m:
             result = m.groups()
             blockquote = result[0]
             blockquote = re.sub("\n&gt;\s?", "\n", blockquote)
@@ -11,4 +11,4 @@ def blockquote(data):
         else:
             break
 
-    return(data)
+    return data

+ 2 - 2
set_mark/end.py

@@ -1,7 +1,7 @@
 import re
 
 def end(data, category):    
-    if(category):
+    if category:
         data += '<div style="margin-top: 30px;" id="cate">분류: ' + category + '</div>'
             
     data = re.sub("\r\n(?P<in><h[0-6])", "\g<in>", data)
@@ -19,4 +19,4 @@ def end(data, category):
     data = re.sub('^<div style="margin-top: 30px;" id="cate">', '<div id="cate">', data)        
     data = re.sub('&amp;#92;', '&#92;', data)
 
-    return(data)
+    return data

+ 9 - 9
set_mark/footnote.py

@@ -5,17 +5,17 @@ def footnote(data, fol_num):
     tou = "<hr style='margin-top: 30px;' id='footnote'><div><br>"
     namu = []
     pop_re = re.compile('(?:\[\*([^\s]*)(?:\s((?:(?!\[|\]).)*))?\]|(\[각주\]))')
-    while(1):
+    while 1:
         b = pop_re.search(data)
-        if(b):
+        if b:
             results = b.groups()
             try:
-                if(not results[1] and results[0]):
+                if not results[1] and results[0]:
                     i = 0
                     
-                    while(1):
+                    while 1:
                         try:
-                            if(namu[i] == results[0]):
+                            if namu[i] == results[0]:
                                 none_this = 0
                                 break
                             else:
@@ -24,7 +24,7 @@ def footnote(data, fol_num):
                             none_this = 1
                             break
                             
-                    if(none_this == 0):
+                    if none_this == 0:
                         data = pop_re.sub("<sup><a href='javascript:void(0);' onclick='folding(" + str(fol_num) + ");' id='rfn-" + str(a) + "'>[" + results[0] + "]</a></sup>" + \
                                         "<div class='popup' style='display: none;' id='folding_" + str(fol_num) + "'><a onclick='folding(" + str(fol_num) + ");'" + \
                                         " href='#fn-" + str(a) + "'>#d#" + results[0] + "#/d#</a> <a href='javascript:void(0);' onclick='folding(" + str(fol_num) + ");'>[X]</a> " + \
@@ -53,7 +53,7 @@ def footnote(data, fol_num):
             except:
                 tou += '</div>'
 
-                if(tou == "<hr style='margin-top: 30px;' id='footnote'><div><br></div>"):
+                if tou == "<hr style='margin-top: 30px;' id='footnote'><div><br></div>":
                     tou = ""
                 else:
                     tou = re.sub('#d#(?P<in>(?:(?!#\/d#).)*)#\/d#', '[\g<in>]', tou)
@@ -63,7 +63,7 @@ def footnote(data, fol_num):
         else:
             tou += '</div>'
 
-            if(tou == "<hr style='margin-top: 30px;' id='footnote'><div><br></div>"):
+            if tou == "<hr style='margin-top: 30px;' id='footnote'><div><br></div>":
                 tou = ""
             else:
                 tou = re.sub('#d#(?P<in>(?:(?!#\/d#).)*)#\/d#', '[\g<in>]', tou)
@@ -76,4 +76,4 @@ def footnote(data, fol_num):
     data = re.sub("(?:(?:<br>| |\r|\n)+)$", "", data)
     data += tou
     
-    return(data)
+    return data

+ 7 - 7
set_mark/html_pas.py

@@ -7,15 +7,15 @@ def html_pas(data):
 
     d_list = re.findall('<(\/)?([^> ]+)( (?:[^>]+)?)?>', data)
     for i_list in d_list:
-        if(i_list[0] == ''):
-            if(i_list[1] in ['div', 'span', 'embed', 'iframe']):
-                if(re.search('<\/' + i_list[1] + '>', data)):
+        if i_list[0] == '':
+            if i_list[1] in ['div', 'span', 'embed', 'iframe']:
+                if re.search('<\/' + i_list[1] + '>', data):
                     src = re.search('src=([^ ]*)', i_list[2])
-                    if(src):
+                    if src:
                         v_src = re.search('http(?:s)?:\/\/([^/\'" ]*)', src.groups()[0])
                         data_list = ["www.youtube.com", "serviceapi.nmv.naver.com", "tv.kakao.com", "www.google.com", "serviceapi.rmcnmv.naver.com"]
-                        if(v_src):
-                            if(not v_src.groups()[0] in data_list):
+                        if v_src:
+                            if not v_src.groups()[0] in data_list:
                                 ot = re.sub('src=([^ ]*)', '', i_list[2])
                             else:
                                 ot = i_list[2]
@@ -35,4 +35,4 @@ def html_pas(data):
     for d_end in end:
         data = re.sub('%H%((?:(?!%/H%).)*)%/H%', '<' + re.sub('&quot;', '"', re.sub('&#x27;', "'", d_end)) + '>', data, 1)
 
-    return(data)
+    return data

+ 8 - 8
set_mark/include_pas.py

@@ -7,7 +7,7 @@ from urllib import parse
 import re
 
 def url_pas(data):
-    return(parse.quote(data).replace('/','%2F'))
+    return parse.quote(data).replace('/','%2F')
     
 def include_pas(conn, data, title, in_c, num, toc_y, fol_num):
     curs = conn.cursor()
@@ -18,7 +18,7 @@ def include_pas(conn, data, title, in_c, num, toc_y, fol_num):
     include = re.compile("\[include\(((?:(?!\)\]|,).)*)((?:(?:,\s?(?:(?!\)\]).)*))+)?\)\]((?:(?!\n))*)")
     m = include.findall(data)
     for results in m:
-        if(results[0] == title):
+        if results[0] == title:
             data = include.sub("<b>" + results[0] + "</b>", data, 1)
         else:
             backlink += [[title, results[0], 'include']]
@@ -39,11 +39,11 @@ def include_pas(conn, data, title, in_c, num, toc_y, fol_num):
                 category = var_d2[1]
                 fol_num = var_d[1]
                 
-                if(results[1]):
+                if results[1]:
                     a = results[1]
-                    while(1):
+                    while 1:
                         g = re.search("([^= ,]*)\=([^,]*)", a)
-                        if(g):
+                        if g:
                             result = g.groups()
                             in_data = re.sub("@" + result[0] + "@", result[1], in_data)
                             a = re.sub("([^= ,]*)\=([^,]*)", "", a, 1)
@@ -52,10 +52,10 @@ def include_pas(conn, data, title, in_c, num, toc_y, fol_num):
 
                 in_data = toc_pas.toc_pas(in_data, results[0], num, toc_y)
                             
-                if(results[2]):
+                if results[2]:
                     test = '<br>'
                 else:
-                    if(re.search('\|\|', in_data)):
+                    if re.search('\|\|', in_data):
                         test = '\n'
                     else:
                         test = ''
@@ -64,4 +64,4 @@ def include_pas(conn, data, title, in_c, num, toc_y, fol_num):
             else:
                 data = include.sub("<a class=\"not_thing\" href=\"/w/" + url_pas(results[0]) + "\">" + results[0] + "</a>", data, 1)
 
-    return([data, category, fol_num, backlink])
+    return [data, category, fol_num, backlink]

+ 9 - 9
set_mark/indent.py

@@ -1,17 +1,17 @@
 import re
 
 def indent(data):
-    while(1):
+    while 1:
         m = re.search("(\n(?:(?:( *)\* (?:[^\n]*))\n?)+)", data)
-        if(m):
+        if m:
             result = m.groups()
             end = str(result[0])
 
-            while(1):
+            while 1:
                 isspace = re.search("\n( *)\* ([^\n]*)", end)
-                if(isspace):
+                if isspace:
                     spacebar = isspace.groups()
-                    if(len(spacebar[0]) == 0):
+                    if len(spacebar[0]) == 0:
                         up = 20
                     else:
                         up = len(spacebar[0]) * 20
@@ -25,17 +25,17 @@ def indent(data):
         else:
             break
 
-    while(1):
+    while 1:
         b = re.search("(<\/h[0-9]>|\n)( +)", data)
-        if(b):
+        if b:
             result = b.groups()
             up = re.sub(' ', '<span id="in"></span>', result[1])
 
-            if(re.search('<\/h[0-9]>', result[0])):
+            if re.search('<\/h[0-9]>', result[0]):
                 data = re.sub("(?P<in>\/h[0-9]>)( +)", '\g<in>' + up, data, 1)
             else:
                 data = re.sub("(?:\n)( +)", '<br>' + up, data, 1)
         else:
             break
             
-    return(data)
+    return data

+ 31 - 31
set_mark/link.py

@@ -4,10 +4,10 @@ from urllib import parse
 import hashlib
 
 def url_pas(data):
-    return(parse.quote(data).replace('/','%2F'))
+    return parse.quote(data).replace('/','%2F')
 
 def sha224(data):
-    return(hashlib.sha224(bytes(data, 'utf-8')).hexdigest())
+    return hashlib.sha224(bytes(data, 'utf-8')).hexdigest()
 
 def link(conn, title, data, num, category, backlink):
     curs = conn.cursor()
@@ -15,12 +15,12 @@ def link(conn, title, data, num, category, backlink):
     
     m = re.findall("\[\[(분류:(?:(?:(?!\]\]|#).)+))((?:#(?:(?:(?!#|\]\]).)+))+)?\]\]", data)
     for g in m:
-        if(title != g[0]):
-            if(num == 1):
+        if title != g[0]:
+            if num == 1:
                 backlink += [[title, g[0], 'cat']]
                 
             curs.execute("select title from data where title = ?", [g[0]])
-            if(curs.fetchall()):
+            if curs.fetchall():
                 red = ""
             else:
                 red = 'class="not_thing"'
@@ -29,8 +29,8 @@ def link(conn, title, data, num, category, backlink):
                 category += ' / '                
 
             style = ''
-            if(g[1]):
-                if(re.search('#blur', g[1])):
+            if g[1]:
+                if re.search('#blur', g[1]):
                     style = ' style="filter: blur(3px);" onmouseover="this.style.filter=\'none\';" onmouseout="this.style.filter=\'blur(3px)\';"'
                 
             category += '<a ' + red + ' ' + style + '" href="/w/' + url_pas(g[0]) + '">' + re.sub("분류:", "", g[0]) + '</a>'
@@ -39,7 +39,7 @@ def link(conn, title, data, num, category, backlink):
     
     test = re.findall('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', data)
     for wiki in test:
-        if(wiki[1]):
+        if wiki[1]:
             out = wiki[1]
         else:
             out = wiki[0]
@@ -51,14 +51,14 @@ def link(conn, title, data, num, category, backlink):
     a = re.findall('\[\[\.\.\/(\|(?:(?!]]).)+)?]]', data)
     for i in a:
         b = re.search('(.*)\/', title)
-        if(b):
+        if b:
             m = b.groups()
-            if(i):
+            if i:
                 data = re.sub('\[\[\.\.\/(\|((?!]]).)+)?]]', '[[' + m[0] + i + ']]', data, 1)
             else:
                 data = re.sub('\[\[\.\.\/(\|((?!]]).)+)?]]', '[[' + m[0] + ']]', data, 1)
         else:
-            if(i):
+            if i:
                 data = re.sub('\[\[\.\.\/(\|((?!]]).)+)?]]', '[[' + title + i + ']]', data, 1)
             else:
                 data = re.sub('\[\[\.\.\/(\|((?!]]).)+)?]]', '[[' + title + ']]', data, 1)
@@ -66,11 +66,11 @@ def link(conn, title, data, num, category, backlink):
     data = re.sub('\[\[(?P<in>\/(?:(?!]]|\|).)+)(?P<out>\|(?:(?:(?!]]).)+))?]]', '[[' + title + '\g<in>\g<out>]]', data)
                 
     link = re.compile('\[\[((?:(?!\[\[|\]\]|\|).)*)(?:\|((?:(?!\[\[|\]\]).)*))?\]\]')
-    while(1):
+    while 1:
         l_d = link.search(data)
-        if(l_d):
+        if l_d:
             d = l_d.groups()
-            if(re.search('^(?:파일|외부):', d[0])):
+            if re.search('^(?:파일|외부):', d[0]):
                 width = ''
                 height = ''
                 align = ''
@@ -78,30 +78,30 @@ def link(conn, title, data, num, category, backlink):
                 
                 try:        
                     w_d = re.search('width=([0-9]+(?:[a-z%]+)?)', d[1])
-                    if(w_d):
+                    if w_d:
                         width = 'width="' + w_d.groups()[0] + '" '
                     
                     h_d = re.search('height=([0-9]+(?:[a-z%]+)?)', d[1])
-                    if(h_d):
+                    if h_d:
                         height = 'height="' + h_d.groups()[0] + '" '
                         
                     a_d = re.search('align=(center|right)', d[1])
-                    if(a_d):
+                    if a_d:
                         span[0] = '<span style="display: block; text-align: ' + a_d.groups()[0] + ';">'
                         span[1] = '</span>'
                 except:
                     pass
                     
                 f_d = re.search('^파일:([^.]+)\.(.+)$', d[0])
-                if(f_d):
-                    if(not re.search("^파일:([^\n]*)", title)):
-                        if(num == 1):
+                if f_d:
+                    if not re.search("^파일:([^\n]*)", title):
+                        if num == 1:
                             backlink += [[title, d[0], 'file']]
 
                     file_name = f_d.groups()
 
                     curs.execute("select title from data where title = ?", ['파일:' + file_name[0] + '.' + file_name[1]])
-                    if(not curs.fetchall()):
+                    if not curs.fetchall():
                         img = '<a class="not_thing" href="/w/' + url_pas('파일:' + file_name[0] + '.' + file_name[1]) + '">파일:' + file_name[0] + '.' + file_name[1] + '</a>'
                     else:
                         img = span[0] + '<img src="/image/' + sha224(file_name[0]) + '.' + file_name[1] + '" ' + width + height + '>' + span[1]
@@ -111,10 +111,10 @@ def link(conn, title, data, num, category, backlink):
                     img = span[0] + '<img src="' + re.sub('^외부:', '', d[0]) + '" ' + width + height + '>' + span[1]
                     data = link.sub(img, data, 1)
                                     
-            elif(re.search('^https?:\/\/', re.sub('<([^>]*)>', '', d[0]))):
+            elif re.search('^https?:\/\/', re.sub('<([^>]*)>', '', d[0])):
                 view = d[0]
                 try:
-                    if(re.search('(.+)', d[1])):
+                    if re.search('(.+)', d[1]):
                         view = d[1]
                 except:
                     pass
@@ -123,34 +123,34 @@ def link(conn, title, data, num, category, backlink):
             else:
                 view = d[0].replace('\\\\', '<slash>').replace('\\', '').replace('<slash>', '\\')
                 try:
-                    if(re.search('(.+)', d[1])):
+                    if re.search('(.+)', d[1]):
                         view = d[1].replace('\\\\', '<slash>').replace('\\', '').replace('<slash>', '\\')
                 except:
                     pass        
                     
                 sh = ''
                 s_d = re.search('#((?:(?!x27;|#).)+)$', d[0])
-                if(s_d):
+                if s_d:
                     href = re.sub('#((?:(?!x27;|#).)+)$', '', d[0])
                     sh = '#' + s_d.groups()[0]
                 else:
                     href = d[0]
                     
-                if(d[0] == title):
+                if d[0] == title:
                     data = link.sub('<b>' + view + '</b>', data, 1)
-                elif(re.search('^#', d[0])):
+                elif re.search('^#', d[0]):
                     data = link.sub('<a title="' + sh + '" href="' + sh + '">' + view + '</a>', data, 1)
                 else:                    
                     a = re.sub('<([^>]*)>', '', href.replace('&#x27;', "'").replace('&quot;', '"').replace('\\\\', '<slash>').replace('\\', '').replace('<slash>', '\\'))
                     
-                    if(num == 1):
+                    if num == 1:
                         backlink += [[title, a, '']]
                     
                     curs.execute("select title from data where title = ?", [a])
-                    if(not curs.fetchall()):
+                    if not curs.fetchall():
                         no = 'class="not_thing"'
                         
-                        if(num == 1):
+                        if num == 1:
                             backlink += [[title, a, 'no']]
                     else:
                         no = ''
@@ -161,4 +161,4 @@ def link(conn, title, data, num, category, backlink):
             
     data = data.replace('\\', '&#92;')
 
-    return([data, category, backlink])
+    return [data, category, backlink]

+ 19 - 19
set_mark/macro.py

@@ -10,27 +10,27 @@ def get_time():
     now = time.localtime()
     date = "%04d-%02d-%02d %02d:%02d:%02d" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec)
 
-    return(date)
+    return date
     
 def ip_check():
-    if(('Now' and 'DREAMER') in session and session['Now'] == 1):
+    if ('Now' and 'DREAMER') in session and session['Now'] == 1:
         ip = session['DREAMER']
     else:
         ip = request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
 
-    return(str(ip))
+    return str(ip)
 
 def savemark(data):
     data = re.sub("\[date\(now\)\]", get_time(), data)
     
-    if(not re.search("\.", ip_check())):
+    if not re.search("\.", ip_check()):
         name = '[[사용자:' + ip_check() + '|' + ip_check() + ']]'
     else:
         name = ip_check()
         
     data = re.sub("\[name\]", name, data)
 
-    return(data)
+    return data
 
 def macro(data):      
     data = savemark(data)
@@ -39,42 +39,42 @@ def macro(data):
     data = re.sub('\[ruby\((?P<in>[^\,]*)\,\s?(?P<out>[^\)]*)\)\]', '<ruby>\g<in><rp>(</rp><rt>\g<out></rt><rp>)</rp></ruby>', data)
     data = re.sub("\[br\]", '<br>', data)
     
-    while(1):
+    while 1:
         com = re.compile("\[(youtube|kakaotv)\(([^, )]*)(,[^)]*)?\)\]")
         m = com.search(data)
-        if(m):
+        if m:
             src = ''
             width = '560'
             height = '315'
             time = '0'
             
             result = m.groups()
-            if(result[1]):
+            if result[1]:
                 yudt = re.search('(?:\?v=(.*)|\/([^/?]*)|^([a-zA-Z0-9\-_]*))$', result[1])
-                if(yudt):
-                    if(yudt.groups()[0]):
+                if yudt:
+                    if yudt.groups()[0]:
                         src = yudt.groups()[0]
-                    elif(yudt.groups()[1]):
+                    elif yudt.groups()[1]:
                         src = yudt.groups()[1]
-                    elif(yudt.groups()[2]):
+                    elif yudt.groups()[2]:
                         src = yudt.groups()[2]
                 else:
                     src = ''
                     
-            if(result[2]):
+            if result[2]:
                 mdata = re.search('width=([0-9%]*)', result[2])
-                if(mdata):
+                if mdata:
                     width = mdata.groups()[0]
                 
                 mdata = re.search('height=([0-9%]*)', result[2])
-                if(mdata):
+                if mdata:
                     height = mdata.groups()[0]
                     
                 mdata = re.search('start=([0-9]*)', result[2])
-                if(mdata):
+                if mdata:
                     time = mdata.groups()[0]
 
-            if(result[0] == 'youtube'):
+            if result[0] == 'youtube':
                 data = com.sub('<iframe width="' + width + '" height="' + height + '" src="https://www.youtube.com/embed/' + src + '?start=' + time + '" frameborder="0" allowfullscreen></iframe><br>', data, 1)
             else:
                 data = com.sub('<iframe width="' + width + '" height="' + height + '" src="https://tv.kakao.com/embed/player/cliplink/' + src + '?service=kakao_tv&start=' + time + '" allowfullscreen frameborder="0" scrolling="no"></iframe><br>', data, 1)
@@ -101,11 +101,11 @@ def macro(data):
         will = datetime.datetime.strptime(dday, '%Y-%m-%d')
         e_data = old - will
 
-        if(re.search('^-', str(e_data.days))):
+        if re.search('^-', str(e_data.days)):
             e_day = str(e_data.days)
         else:
             e_day = '+' + str(e_data.days)
 
         data = re.sub('\[dday\(([0-9]{4}-[0-9]{2}-[0-9]{2})\)\]', e_day, data, 1)
         
-    return(data)
+    return data

+ 22 - 22
set_mark/mid_pas.py

@@ -2,26 +2,26 @@ import re
 
 def mid_pas(data, fol_num, include, in_c, toc_y):
     p = re.compile('{{{((?:(?:(?:\+|-)[0-5])|(?:#|@)(?:(?:[0-9a-f-A-F]{3}){1,2}|(?:\w+))|(?:#!(?:html|wiki|noin|folding|syntax)))(?:(?!{{{|}}}).)+)}}}', re.DOTALL)
-    while(1):
+    while 1:
         m = p.search(data)
-        if(m):
+        if m:
             data = p.sub('###' + m.groups()[0] + '/###', data, 1)
         else:
             break
 
     com = re.compile("{{{((?:(?!{{{|}}}).)*)}}}", re.DOTALL)
-    while(1):
+    while 1:
         m = com.search(data)
-        if(m):
+        if m:
             data = com.sub('<code>' + m.groups()[0] + '</code>', data, 1)
         else:
             break
 
     com3 = re.compile('###((?:(?!\/###).)+)\/###', re.DOTALL)
     m = com3.search(data)
-    while(1):
+    while 1:
         m = com3.search(data)
-        if(m):
+        if m:
             data = com3.sub('{{{' + m.groups()[0] + '}}}', data, 1)
         else:
             break
@@ -33,9 +33,9 @@ def mid_pas(data, fol_num, include, in_c, toc_y):
         mid_data = re.sub("(?P<in>.)", "#no#\g<in>#/no#", mid_data)
         data = com2.sub(mid_data, data, 1)
 
-    while(1):
+    while 1:
         is_it = com.search(data)
-        if(is_it):
+        if is_it:
             it_d = is_it.groups()[0]
 
             big_a = re.compile("^\+([1-5]) (.*)$", re.DOTALL)
@@ -71,32 +71,32 @@ def mid_pas(data, fol_num, include, in_c, toc_y):
             syn_a = re.compile("^#!syntax ((?:(?!\n).)*)\n(.*)$", re.DOTALL)
             syn = syn_a.search(it_d)
 
-            if(big):
+            if big:
                 big_d = big.groups()
                 data = com.sub('<span style="font-size: ' + str(int(big_d[0]) * 20 + 100) + '%;">' + big_d[1] + '</span>', data, 1)
-            elif(small):
+            elif small:
                 sm_d = small.groups()
                 data = com.sub('<span style="font-size: ' + str(100 - int(sm_d[0]) * 10) + '%;">' + sm_d[1] + '</span>', data, 1)
-            elif(color_2):
+            elif color_2:
                 c_d_2 = color_2.groups()
                 data = com.sub('<span style="color: ' + c_d_2[0] + '">' + c_d_2[1] + '</span>', data, 1)
-            elif(color_3):
+            elif color_3:
                 c_d_3 = color_3.groups()
                 data = com.sub('<span style="color: ' + c_d_3[0] + '">' + c_d_3[1] + '</span>', data, 1)
-            elif(back):
+            elif back:
                 back_d_1 = back.groups()
                 data = com.sub('<span style="background: #' + back_d_1[0] + '">' + back_d_1[1] + '</span>', data, 1)
-            elif(back_3):
+            elif back_3:
                 back_d_3 = back_3.groups()
                 data = com.sub('<span style="background: ' + back_d_3[0] + '">' + back_d_3[1] + '</span>', data, 1)
-            elif(div):
+            elif div:
                 div_d = div.groups()
                 data = com.sub('<div style="' + div_d[0] + '">' + div_d[1] + '</div>', data, 1)
-            elif(html_d):
+            elif html_d:
                 data = com.sub(html_d.groups()[0], data, 1)
-            elif(fol):
+            elif fol:
                 fol_d = fol.groups()
-                if(toc_y != 0):
+                if toc_y != 0:
                     data = com.sub("<div>" + fol_d[0] + " <div id='folding_" + str(fol_num + 1) + "' style='display: inline-block;'>[<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + \
                                     "); folding(" + str(fol_num + 2) + "); folding(" + str(fol_num) + ");'>펼치기</a>]</div><div id='folding_" + str(fol_num + 2) + \
                                     "' style='display: none;'>[<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + "); folding(" + str(fol_num + 2) + \
@@ -106,13 +106,13 @@ def mid_pas(data, fol_num, include, in_c, toc_y):
                 else:
                     data = com.sub("<div>" + fol_d[0] + "<br><br>" + fol_d[1] + "</div>", data, 1)
                 
-            elif(syn):
+            elif syn:
                 syn_d = syn.groups()
                 tax_d = syn_d[1].replace(' ', '<space>')
                 tax_d = tax_d.replace('\r\n', '<isbr>')
                 data = com.sub('<pre id="syntax"><code class="' + syn_d[0] + '"><code>' + tax_d + '</code></code></pre>', data, 1)
-            elif(include_out):
-                if((include or in_c) == 1):
+            elif include_out:
+                if (include or in_c) == 1:
                     data = com.sub("", data, 1)
                 else:
                     data = com.sub(include_out.groups()[0], data, 1)
@@ -128,4 +128,4 @@ def mid_pas(data, fol_num, include, in_c, toc_y):
         mid_data = re.sub("(?P<in>.)", "#no#\g<in>#/no#", mid_data)
         data = com2.sub(mid_data, data, 1)
             
-    return([data, fol_num])
+    return [data, fol_num]

+ 3 - 3
set_mark/redirect_pas.py

@@ -2,7 +2,7 @@ import re
 from urllib import parse
 
 def url_pas(data):
-    return(parse.quote(data).replace('/','%2F'))
+    return parse.quote(data).replace('/','%2F')
 
 def redirect_pas(data, title, backlink):    
     d_re = re.findall('\r\n#(?:redirect|넘겨주기) ((?:(?!\r|\n|%0D).)+)', data)
@@ -11,7 +11,7 @@ def redirect_pas(data, title, backlink):
             
         sh = ''
         s_d = re.search('#((?:(?!x27;|#).)+)$', d)
-        if(s_d):
+        if s_d:
             href = re.sub('#((?:(?!x27;|#).)+)$', '', d)
             sh = '#' + s_d.groups()[0]
         else:
@@ -21,4 +21,4 @@ def redirect_pas(data, title, backlink):
         backlink += [[title, a, 'redirect']]
         data = re.sub('\r\n#(?:redirect|넘겨주기) ((?:(?!\r|\n|%0D).)+)', '<meta http-equiv="refresh" content="0;url=/w/' + url_pas(a) + '?froms=' + url_pas(title) + sh + '" />', data, 1)
         
-    return([data, backlink])
+    return [data, backlink]

+ 1 - 1
set_mark/start.py

@@ -6,4 +6,4 @@ def start(data):
     data = re.sub("\n", "\r\n", re.sub("\r\n", "\n", data))
     data = '\r\n' + data + '\r\n'
         
-    return(data)
+    return data

+ 55 - 55
set_mark/table.py

@@ -11,97 +11,97 @@ def table_p(d, d2, d3, num = 0):
     table_w = re.search("&lt;table\s?width=((?:(?!&gt;).)*)&gt;", d)
     table_h = re.search("&lt;table\s?height=((?:(?!&gt;).)*)&gt;", d)
     table_a = re.search("&lt;table\s?align=((?:(?!&gt;).)*)&gt;", d)
-    if(table_w):
+    if table_w:
         alltable += 'width: ' + table_w.groups()[0] + ';'
-    if(table_h):
+    if table_h:
         alltable += 'height: ' + table_h.groups()[0] + ';'
-    if(table_a):
-        if(table_a.groups()[0] == 'right'):
+    if table_a:
+        if table_a.groups()[0] == 'right':
             alltable += 'float: right;'
-        elif(table_a.groups()[0] == 'center'):
+        elif table_a.groups()[0] == 'center':
             alltable += 'margin: auto;'
             
     table_t_a = re.search("&lt;table\s?textalign=((?:(?!&gt;).)*)&gt;", d)
-    if(table_t_a):
+    if table_t_a:
         num = 1
-        if(table_t_a.groups()[0] == 'right'):
+        if table_t_a.groups()[0] == 'right':
             alltable += 'text-align: right;'
-        elif(table_t_a.groups()[0] == 'center'):
+        elif table_t_a.groups()[0] == 'center':
             alltable += 'text-align: center;'
 
     row_t_a = re.search("&lt;row\s?textalign=((?:(?!&gt;).)*)&gt;", d)
-    if(row_t_a):
-        if(row_t_a.groups()[0] == 'right'):
+    if row_t_a:
+        if row_t_a.groups()[0] == 'right':
             rowstyle += 'text-align: right;'
-        elif(row_t_a.groups()[0] == 'center'):
+        elif row_t_a.groups()[0] == 'center':
             rowstyle += 'text-align: center;'
         else:
             rowstyle += 'text-align: left;'
     
     table_cel = re.search("&lt;-((?:(?!&gt;).)*)&gt;", d)
-    if(table_cel):
+    if table_cel:
         cel = 'colspan="' + table_cel.groups()[0] + '"'
     else:
         cel = 'colspan="' + str(round(len(d2) / 2)) + '"'   
 
     table_row = re.search("&lt;\|((?:(?!&gt;).)*)&gt;", d)
-    if(table_row):
+    if table_row:
         row = 'rowspan="' + table_row.groups()[0] + '"'
 
     row_bgcolor_2 = re.search("&lt;rowbgcolor=(#(?:[0-9a-f-A-F]{3}){1,2})&gt;", d)
     row_bgcolor_3 = re.search("&lt;rowbgcolor=(\w+)&gt;", d)
-    if(row_bgcolor_2):
+    if row_bgcolor_2:
         rowstyle += 'background: ' + row_bgcolor_2.groups()[0] + ';'
-    elif(row_bgcolor_3):
+    elif row_bgcolor_3:
         rowstyle += 'background: ' + row_bgcolor_3.groups()[0] + ';'
         
     table_border_2 = re.search("&lt;table\s?bordercolor=(#(?:[0-9a-f-A-F]{3}){1,2})&gt;", d)
     table_border_3 = re.search("&lt;table\s?bordercolor=(\w+)&gt;", d)
-    if(table_border_2):
+    if table_border_2:
         alltable += 'border: ' + table_border_2.groups()[0] + ' 2px solid;'
-    elif(table_border_3):
+    elif table_border_3:
         alltable += 'border: ' + table_border_3.groups()[0] + ' 2px solid;'
         
     table_bgcolor_2 = re.search("&lt;table\s?bgcolor=(#(?:[0-9a-f-A-F]{3}){1,2})&gt;", d)
     table_bgcolor_3 = re.search("&lt;table\s?bgcolor=(\w+)&gt;", d)
-    if(table_bgcolor_2):
+    if table_bgcolor_2:
         alltable += 'background: ' + table_bgcolor_2.groups()[0] + ';'
-    elif(table_bgcolor_3):
+    elif table_bgcolor_3:
         alltable += 'background: ' + table_bgcolor_3.groups()[0] + ';'
         
     bgcolor_2 = re.search("&lt;(?:bgcolor=)?(#(?:[0-9a-f-A-F]{3}){1,2})&gt;", d)
     bgcolor_3 = re.search("&lt;(?:bgcolor=)?(\w+)&gt;", d)
-    if(bgcolor_2):
+    if bgcolor_2:
         celstyle += 'background: ' + bgcolor_2.groups()[0] + ';'
-    elif(bgcolor_3):
+    elif bgcolor_3:
         celstyle += 'background: ' + bgcolor_3.groups()[0] + ';'
         
     n_width = re.search("&lt;width=((?:(?!&gt;).)*)&gt;", d)
     n_height = re.search("&lt;height=((?:(?!&gt;).)*)&gt;", d)
-    if(n_width):
+    if n_width:
         celstyle += 'width: ' + n_width.groups()[0] + ';'
-    if(n_height):
+    if n_height:
         celstyle += 'height: ' + n_height.groups()[0] + ';'
         
     text_right = re.search("&lt;\)&gt;", d)
     text_center = re.search("&lt;:&gt;", d)
     text_left = re.search("&lt;\(&gt;",  d)
-    if(text_right):
+    if text_right:
         celstyle += 'text-align: right;'
-    elif(text_center):
+    elif text_center:
         celstyle += 'text-align: center;'
-    elif(text_left):
+    elif text_left:
         celstyle += 'text-align: left;'
-    elif(num == 0):
-        if(re.search('^ (.*) $', d3)):
+    elif num == 0:
+        if re.search('^ (.*) $', d3):
             celstyle += 'text-align: center;'
-        elif(re.search('^ (.*)$', d3)):
+        elif re.search('^ (.*)$', d3):
             celstyle += 'text-align: right;'
-        elif(re.search('^(.*) $', d3)):
+        elif re.search('^(.*) $', d3):
             celstyle += 'text-align: left;'
 
     text_class = re.search("&lt;table\s?class=((?:(?!&gt;).)+)&gt;", d)
-    if(text_class):
+    if text_class:
         d = text_class.groups()
         table_class += d[0]
         
@@ -110,14 +110,14 @@ def table_p(d, d2, d3, num = 0):
     rowstyle += '"'
     table_class += '"'
 
-    return([alltable, rowstyle, celstyle, row, cel, table_class, num])
+    return [alltable, rowstyle, celstyle, row, cel, table_class, num]
 
 def table(data):
     data = re.sub("(?:\|\|\r\n)", "#table#<tablenobr>", data)
         
-    while(1):
+    while 1:
         y = re.search("(\|\|(?:(?:(?:(?:(?!\|\|).)*)(?:\n?))+))", data)
-        if(y):
+        if y:
             a = y.groups()
             
             mid_data = re.sub("\|\|", "#table#", a[0])
@@ -130,14 +130,14 @@ def table(data):
     data = re.sub("#table#", "||", data)
     data = re.sub("<tablenobr>", "\r\n", data)
     
-    while(1):
+    while 1:
         m = re.search("(\|\|(?:(?:(?:.*)\n?)\|\|)+)", data)
-        if(m):
+        if m:
             results = m.groups()
             table = results[0]
-            while(1):
+            while 1:
                 a = re.search("^(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)((?:(?!\|\||<\/td>).)*)", table)
-                if(a):
+                if a:
                     row = ''
                     cel = ''
                     celstyle = ''
@@ -147,7 +147,7 @@ def table(data):
                     num = 0
 
                     result = a.groups()
-                    if(result[1]):
+                    if result[1]:
                         table_d = table_p(result[1], result[0], result[2])
                         alltable = table_d[0]
                         rowstyle = table_d[1]
@@ -162,11 +162,11 @@ def table(data):
                     else:
                         cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
 
-                        if(re.search('^ (.*) $', result[2])):
+                        if re.search('^ (.*) $', result[2]):
                             celstyle += 'text-align: center;'
-                        elif(re.search('^ (.*)$', result[2])):
+                        elif re.search('^ (.*)$', result[2]):
                             celstyle += 'text-align: right;'
-                        elif(re.search('^(.*) $', result[2])):
+                        elif re.search('^(.*) $', result[2]):
                             celstyle += 'text-align: left;'
 
                         table = re.sub("^(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "<table><tbody><tr><td " + cel + " style='" + celstyle + "'>", table, 1)
@@ -175,9 +175,9 @@ def table(data):
                     
             table = re.sub("\|\|$", "</td></tr></tbody></table>", table)
             
-            while(1):
+            while 1:
                 b = re.search("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)((?:(?!\|\||<\/td>).)*)", table)
-                if(b):
+                if b:
                     row = ''
                     cel = ''
                     celstyle = ''
@@ -185,7 +185,7 @@ def table(data):
                     table_d = ''
 
                     result = b.groups()
-                    if(result[1]):
+                    if result[1]:
                         table_d = table_p(result[1], result[0], result[2], num)
                         rowstyle = table_d[1]
                         celstyle = table_d[2]
@@ -196,27 +196,27 @@ def table(data):
                     else:
                         cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
 
-                        if(re.search('^ (.*) $', result[2])):
+                        if re.search('^ (.*) $', result[2]):
                             celstyle += 'text-align: center;'
-                        elif(re.search('^ (.*)$', result[2])):
+                        elif re.search('^ (.*)$', result[2]):
                             celstyle += 'text-align: right;'
-                        elif(re.search('^(.*) $', result[2])):
+                        elif re.search('^(.*) $', result[2]):
                             celstyle += 'text-align: left;'
 
                         table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "</td></tr><tr><td " + cel + " style='" + celstyle + "'>", table, 1)
                 else:
                     break
 
-            while(1):
+            while 1:
                 c = re.search("(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)((?:(?!\|\||<\/td>).)*)", table)
-                if(c):
+                if c:
                     row = ''
                     cel = ''
                     celstyle = ''
                     table_d = ''
 
                     result = c.groups()
-                    if(result[1]):
+                    if result[1]:
                         table_d = table_p(result[1], result[0], result[2], num)
                         celstyle = table_d[2]
                         row = table_d[3]
@@ -226,11 +226,11 @@ def table(data):
                     else:
                         cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
 
-                        if(re.search('^ (.*) $', result[2])):
+                        if re.search('^ (.*) $', result[2]):
                             celstyle += 'text-align: center;'
-                        elif(re.search('^ (.*)$', result[2])):
+                        elif re.search('^ (.*)$', result[2]):
                             celstyle += 'text-align: right;'
-                        elif(re.search('^(.*) $', result[2])):
+                        elif re.search('^(.*) $', result[2]):
                             celstyle += 'text-align: left;'
 
                         table = re.sub("(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "</td><td " + cel + " style='" + celstyle + "'>", table, 1)
@@ -241,4 +241,4 @@ def table(data):
         else:
             break
         
-    return(data)
+    return data

+ 1 - 1
set_mark/text_help.py

@@ -11,4 +11,4 @@ def text_help(data):
     data = re.sub('{{\|(?P<in>(?:(?:(?:(?!\|}}).)*)(?:\n?))+)\|}}', '<table><tbody><tr><td>\g<in></td></tr></tbody></table>', data)
     data = re.sub("-{4,11}", "<hr>", data)
         
-    return(data)
+    return data

+ 11 - 11
set_mark/toc_pas.py

@@ -2,11 +2,11 @@ import re
 from urllib import parse
 
 def url_pas(data):
-    return(parse.quote(data).replace('/','%2F'))
+    return parse.quote(data).replace('/','%2F')
 
 def toc_pas(data, title, num, toc_y):
-    if(not re.search('\[목차\]', data)):
-        if(not re.search('\[목차\(없음\)\]', data)):
+    if not re.search('\[목차\]', data):
+        if not re.search('\[목차\(없음\)\]', data):
             data = re.sub("(?P<in>(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n)", "[목차]\n\g<in>", data, 1)
         else:
             data = re.sub("\[목차\(없음\)\]", "", data)
@@ -19,13 +19,13 @@ def toc_pas(data, title, num, toc_y):
     toc_d = -1
     span = ''
     rtoc = '<div id="toc"><span id="toc-name">목차</span><br><br>'
-    while(1):
+    while 1:
         i[0] += 1
         m = re.search('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\r\n', data)
-        if(m):
+        if m:
             result = m.groups()
             wiki = len(result[0])
-            if(last < wiki):
+            if last < wiki:
                 last = wiki
             else:
                 last = wiki
@@ -42,15 +42,15 @@ def toc_pas(data, title, num, toc_y):
             toc = re.sub("#\.", '.', toc)
             toc = re.sub("\.$", '', toc)
 
-            if(toc_c == -1):
+            if toc_c == -1:
                 margin = ''
                 toc_c = toc.count('.')
             else:
                 toc_d = toc.count('.')
-                if(toc_c == toc_d):
+                if toc_c == toc_d:
                     margin = 'style="margin-top: 30px;"'
                 else:
-                    if(toc_d < toc_c):
+                    if toc_d < toc_c:
                         margin = 'style="margin-top: 30px;"'
                     else:
                         margin = 'style="margin-top: 15px;"'
@@ -67,7 +67,7 @@ def toc_pas(data, title, num, toc_y):
             c = re.sub("\[\[(([^|]*)\|)?(?P<in>[^\]]*)\]\]", "\g<in>", c)
 
             edit_d = ''
-            if(toc_y == 1):
+            if toc_y == 1:
                 edit_d = ' <span style="font-size: 12px;"><a href="/edit/' + url_pas(title) + '?section=' + str(i[0]) + '">(편집)</a></span>'
 
             data = re.sub('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n', '<tablenobr><h' + str(wiki) + ' id="' + c + '" ' + margin + '><a href="#toc" id="s-' + toc + '">' \
@@ -80,4 +80,4 @@ def toc_pas(data, title, num, toc_y):
     
     data = re.sub("\[목차\]", rtoc, data)
 
-    return(data)
+    return data

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません