Răsfoiți Sursa

파서 버그 수정

Surplus_Up (2DU) 6 ani în urmă
părinte
comite
125d833ec9
3 a modificat fișierele cu 23 adăugiri și 13 ștergeri
  1. 13 10
      emergency_tool.py
  2. 8 1
      route/tool/mark.py
  3. 2 2
      route/tool/set_mark/namumark.py

+ 13 - 10
emergency_tool.py

@@ -230,17 +230,20 @@ if what_i_do == '1':
         go_num = 100
 
     num = 0
-    while 1:
-        curs.execute(db_change("select title, data from data d where not exists (select title from back where link = d.title) limit 1"))
-        data = curs.fetchall()
-        if data:
-            num += 1
-            if num % go_num == 0:
-                print(str(num) + ' : ' + data[0][0])
 
-            render_do(data[0][0], data[0][1], 1, None)
-        else:
-            break
+    curs.execute(db_change("select title from data d where not exists (select title from back where link = d.title)"))
+    title = curs.fetchall()
+    for name in title:
+        num += 1
+        if num % go_num == 0:
+            print(str(num) + ' : ' + name[0])
+
+        if num % 100 == 0:
+            conn.commit()
+
+        curs.execute(db_change("select data from data where title = ?"), [name[0]])
+        data = curs.fetchall()
+        render_do(name[0], data[0][0], 3, None)
 elif what_i_do == '2':
     curs.execute(db_change("delete from other where name = 'recaptcha'"))
     curs.execute(db_change("delete from other where name = 'sec_re'"))

+ 8 - 1
route/tool/mark.py

@@ -38,6 +38,12 @@ def send_parser(data):
     return data
 
 def render_do(title, data, num, include):
+    if num == 3:
+        num = 1
+        back_num = 3
+    else:
+        back_num = num
+
     curs.execute(db_change('select data from other where name = "markup"'))
     rep_data = curs.fetchall()
     if rep_data[0][0] == 'namumark':
@@ -67,7 +73,8 @@ def render_do(title, data, num, include):
 
                 curs.execute(db_change("delete from back where title = ? and type = 'no'"), [title])
 
-        conn.commit()
+        if back_num != 3:
+            conn.commit()
 
     if num == 2:
         return [data[0], data[1]]

+ 2 - 2
route/tool/set_mark/namumark.py

@@ -439,7 +439,7 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
 
     num = 0
     while 1:
-        syntax_data = re.search('<code class="((?:(?!").)+)">((?:(?:(?:(?!<\/code>|<span id="syntax_)).)+\n*)+)<\/code>', data)
+        syntax_data = re.search('<code class="((?:(?!"|>|<).)+)">((?:\n*(?:(?:(?!<\/code>|<span id="syntax_).)+)\n*)+)<\/code>', data)
         if syntax_data:
             syntax_data = syntax_data.groups()
 
@@ -448,7 +448,7 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
             end_data['syntax_' + str(num)] = [syntax_data[1], 'normal']
 
             data = re.sub(
-                '<code class="((?:(?!").)+)">((?:(?:(?:(?!<\/code>|<span id="syntax_)).)+\n*)+)<\/code>',
+                '<code class="((?:(?!"|>|<).)+)">((?:\n*(?:(?:(?!<\/code>|<span id="syntax_).)+)\n*)+)<\/code>',
                 '<code class="' + syntax_data[0] + '"><span id="syntax_' + str(num) + '"></span></code>',
                 data,
                 1