Sfoglia il codice sorgente

파서 변수 명 정리 및 코드 정리

ect (or 2du) 8 anni fa
parent
commit
96af7c5213
1 ha cambiato i file con 90 aggiunte e 114 eliminazioni
  1. 90 114
      mark.py

+ 90 - 114
mark.py

@@ -75,135 +75,111 @@ def table_p(d, d2):
     row = ''
     row = ''
     cel = ''
     cel = ''
 
 
-    q = re.search("<table\s?width=((?:(?!>).)*)>", d)
-    w = re.search("<table\s?height=((?:(?!>).)*)>", d)
-    e = re.search("<table\s?align=((?:(?!>).)*)>", d)
-    if(q):
-        resultss = q.groups()
-        alltable += 'width:' + resultss[0] + ';'
-    if(w):
-        resultss = w.groups()
-        alltable += 'height:' + resultss[0] + ';'
-    if(e):
-        resultss = e.groups()
-        if(resultss[0] == 'right'):
-            alltable += 'float:right;'
-        elif(resultss[0] == 'center'):
-            alltable += 'margin:auto;'
+    table_w = re.search("<table\s?width=((?:(?!>).)*)>", d)
+    table_h = re.search("<table\s?height=((?:(?!>).)*)>", d)
+    table_a = re.search("<table\s?align=((?:(?!>).)*)>", d)
+    if(table_w):
+        alltable += 'width: ' + table_w.groups()[0] + ';'
+    if(table_h):
+        alltable += 'height: ' + table_h.groups()[0] + ';'
+    if(table_a):
+        if(table_a.groups()[0] == 'right'):
+            alltable += 'float: right;'
+        elif(table_a.groups()[0] == 'center'):
+            alltable += 'margin: auto;'
             
             
-    ee = re.search("<table\s?textalign=((?:(?!>).)*)>", d)
-    if(ee):
-        resultss = ee.groups()
-        if(resultss[0] == 'right'):
-            alltable += 'text-align:right;'
-        elif(resultss[0] == 'center'):
-            alltable += 'text-align:center;'
-
-    row_text = re.search("<row\s?textalign=((?:(?!>).)*)>", d)
-    if(row_text):
-        row_text_d = row_text.groups()
-        if(row_text_d[0] == 'right'):
+    table_t_a = re.search("<table\s?textalign=((?:(?!>).)*)>", d)
+    if(table_t_a):
+        if(table_t_a.groups()[0] == 'right'):
+            alltable += 'text-align: right;'
+        elif(table_t_a.groups()[0] == 'center'):
+            alltable += 'text-align: center;'
+
+    row_t_a = re.search("<row\s?textalign=((?:(?!>).)*)>", d)
+    if(row_t_a):
+        if(row_t_a.groups()[0] == 'right'):
             rowstyle += 'text-align: right;'
             rowstyle += 'text-align: right;'
-        elif(row_text_d[0] == 'center'):
+        elif(row_t_a.groups()[0] == 'center'):
             rowstyle += 'text-align: center;'
             rowstyle += 'text-align: center;'
         else:
         else:
             rowstyle += 'text-align: left;'
             rowstyle += 'text-align: left;'
     
     
-    r = re.search("<-((?:(?!>).)*)>", d)
-    if(r):
-        resultss = r.groups()
-        cel = 'colspan="' + resultss[0] + '"'
+    table_cel = re.search("<-((?:(?!>).)*)>", d)
+    if(table_cel):
+        cel = 'colspan="' + table_cel.groups()[0] + '"'
     else:
     else:
         cel = 'colspan="' + str(round(len(d2) / 2)) + '"'   
         cel = 'colspan="' + str(round(len(d2) / 2)) + '"'   
 
 
-    t = re.search("<\|((?:(?!>).)*)>", d)
-    if(t):
-        resultss = t.groups()
-        row = 'rowspan="' + resultss[0] + '"'
-
-    ba = re.search("<rowbgcolor=(#[0-9a-f-A-F]{6})>", d)
-    bb = re.search("<rowbgcolor=(#[0-9a-f-A-F]{3})>", d)
-    bc = re.search("<rowbgcolor=(\w+)>", d)
-    if(ba):
-        resultss = ba.groups()
-        rowstyle += 'background:' + resultss[0] + ';'
-    elif(bb):
-        resultss = bb.groups()
-        rowstyle += 'background:' + resultss[0] + ';'
-    elif(bc):
-        resultss = bc.groups()
-        rowstyle += 'background:' + resultss[0] + ';'
+    table_row = re.search("<\|((?:(?!>).)*)>", d)
+    if(table_row):
+        row = 'rowspan="' + table_row.groups()[0] + '"'
+
+    row_bgcolor_1 = re.search("<rowbgcolor=(#[0-9a-f-A-F]{6})>", d)
+    row_bgcolor_2 = re.search("<rowbgcolor=(#[0-9a-f-A-F]{3})>", d)
+    row_bgcolor_3 = re.search("<rowbgcolor=(\w+)>", d)
+    if(row_bgcolor_1): 
+        rowstyle += 'background: ' + row_bgcolor_1.groups()[0] + ';'
+    elif(row_bgcolor_2):
+        rowstyle += 'background: ' + row_bgcolor_2.groups()[0] + ';'
+    elif(row_bgcolor_3):
+        rowstyle += 'background: ' + row_bgcolor_3.groups()[0] + ';'
         
         
-    z = re.search("<table\s?bordercolor=(#[0-9a-f-A-F]{6})>", d)
-    x = re.search("<table\s?bordercolor=(#[0-9a-f-A-F]{3})>", d)
-    c = re.search("<table\s?bordercolor=(\w+)>", d)
-    if(z):
-        resultss = z.groups()
-        alltable += 'border:' + resultss[0] + ' 2px solid;'
-    elif(x):
-        resultss = x.groups()
-        alltable += 'border:' + resultss[0] + ' 2px solid;'
-    elif(c):
-        resultss = c.groups()
-        alltable += 'border:' + resultss[0] + ' 2px solid;'
+    table_border_1 = re.search("<table\s?bordercolor=(#[0-9a-f-A-F]{6})>", d)
+    table_border_2 = re.search("<table\s?bordercolor=(#[0-9a-f-A-F]{3})>", d)
+    table_border_3 = re.search("<table\s?bordercolor=(\w+)>", d)
+    if(table_border_1):
+        alltable += 'border: ' + table_border_1.groups()[0] + ' 2px solid;'
+    elif(table_border_2):
+        alltable += 'border: ' + table_border_2.groups()[0] + ' 2px solid;'
+    elif(table_border_3):
+        alltable += 'border: ' + table_border_3.groups()[0] + ' 2px solid;'
         
         
-    aq = re.search("<table\s?bgcolor=(#[0-9a-f-A-F]{6})>", d)
-    aw = re.search("<table\s?bgcolor=(#[0-9a-f-A-F]{3})>", d)
-    ae = re.search("<table\s?bgcolor=(\w+)>", d)
-    if(aq):
-        resultss = aq.groups()
-        alltable += 'background:' + resultss[0] + ';'
-    elif(aw):
-        resultss = aw.groups()
-        alltable += 'background:' + resultss[0] + ';'
-    elif(ae):
-        resultss = ae.groups()
-        alltable += 'background:' + resultss[0] + ';'
+    table_bgcolor_1 = re.search("<table\s?bgcolor=(#[0-9a-f-A-F]{6})>", d)
+    table_bgcolor_2 = re.search("<table\s?bgcolor=(#[0-9a-f-A-F]{3})>", d)
+    table_bgcolor_3 = re.search("<table\s?bgcolor=(\w+)>", d)
+    if(table_bgcolor_1)
+        alltable += 'background: ' + table_bgcolor_1.groups()[0] + ';'
+    elif(table_bgcolor_2):
+        alltable += 'background: ' + table_bgcolor_2.groups()[0] + ';'
+    elif(table_bgcolor_3):
+        alltable += 'background: ' + table_bgcolor_3.groups()[0] + ';'
         
         
-    j = re.search("<bgcolor=(#[0-9a-f-A-F]{6})>", d)
-    k = re.search("<bgcolor=(#[0-9a-f-A-F]{3})>", d)
-    l = re.search("<bgcolor=(\w+)>", d)
-    if(j):
-        resultss = j.groups()
-        celstyle += 'background:' + resultss[0] + ';'
-    elif(k):
-        resultss = k.groups()
-        celstyle += 'background:' + resultss[0] + ';'
-    elif(l):
-        resultss = l.groups()
-        celstyle += 'background:' + resultss[0] + ';'
+    bgcolor_1 = re.search("<bgcolor=(#[0-9a-f-A-F]{6})>", d)
+    bgcolor_2 = re.search("<bgcolor=(#[0-9a-f-A-F]{3})>", d)
+    bgcolor_3 = re.search("<bgcolor=(\w+)>", d)
+    if(bgcolor_1):
+        celstyle += 'background: ' + bgcolor_1.groups()[0] + ';'
+    elif(bgcolor_2):
+        celstyle += 'background: ' + bgcolor_2.groups()[0] + ';'
+    elif(bgcolor_3):
+        celstyle += 'background: ' + bgcolor_3.groups()[0] + ';'
         
         
-    aa = re.search("<(#[0-9a-f-A-F]{6})>", d)
-    ab = re.search("<(#[0-9a-f-A-F]{3})>", d)
-    ac = re.search("<(\w+)>", d)
-    if(aa):
-        resultss = aa.groups()
-        celstyle += 'background:' + resultss[0] + ';'
-    elif(ab):
-        resultss = ab.groups()
-        celstyle += 'background:' + resultss[0] + ';'
-    elif(ac):
-        resultss = ac.groups()
-        celstyle += 'background:' + resultss[0] + ';'
+    st_bgcolor_1 = re.search("<(#[0-9a-f-A-F]{6})>", d)
+    st_bgcolor_2 = re.search("<(#[0-9a-f-A-F]{3})>", d)
+    st_bgcolor_3 = re.search("<(\w+)>", d)
+    if(st_bgcolor_1):
+        celstyle += 'background: ' + st_bgcolor_1.groups()[0] + ';'
+    elif(st_bgcolor_2):
+        celstyle += 'background: ' + st_bgcolor_2.groups()[0] + ';'
+    elif(st_bgcolor_3):
+        celstyle += 'background: ' + st_bgcolor_3.groups()[0] + ';'
         
         
-    qa = re.search("<width=((?:(?!>).)*)>", d)
-    qb = re.search("<height=((?:(?!>).)*)>", d)
-    if(qa):
-        resultss = qa.groups()
-        celstyle += 'width:' + resultss[0] + ';'
-    if(qb):
-        resultss = qb.groups()
-        celstyle += 'height:' + resultss[0] + ';'
+    n_width = re.search("<width=((?:(?!>).)*)>", d)
+    n_height = re.search("<height=((?:(?!>).)*)>", d)
+    if(n_width):
+        celstyle += 'width: ' + n_width.groups()[0] + ';'
+    if(n_height):
+        celstyle += 'height: ' + n_height.groups()[0] + ';'
         
         
-    i = re.search("<\)>", d)
-    o = re.search("<:>", d)
-    p = re.search("<\(>",  d)
-    if(i):
-        celstyle += 'text-align:right;'
-    elif(o):
-        celstyle += 'text-align:center;'
-    elif(p):
-        celstyle += 'text-align:left;'
+    text_right = re.search("<\)>", d)
+    text_center = re.search("<:>", d)
+    text_left = re.search("<\(>",  d)
+    if(text_right):
+        celstyle += 'text-align: right;'
+    elif(text_center):
+        celstyle += 'text-align: center;'
+    elif(text_left):
+        celstyle += 'text-align: left;'
         
         
     alltable += '"'
     alltable += '"'
     celstyle += '"'
     celstyle += '"'