OSDN Git Service

tiny changes
authorhylom <hylom@users.sourceforge.jp>
Tue, 16 Jun 2009 09:51:59 +0000 (18:51 +0900)
committerhylom <hylom@users.sourceforge.jp>
Tue, 16 Jun 2009 09:51:59 +0000 (18:51 +0900)
markupper.py
merge_csv.py
wikimarkupper.py

index 3de80fe..6fa2c87 100755 (executable)
@@ -148,21 +148,31 @@ class Markupper(object):
         # end-of-loop
 
     def _head_l(self, line):
+        line = line.rstrip()
+        if re.search(ur"\*{[a-zA-Z0-9_]*}\s*$", line):
+            self._anchor = re.search(ur"\*\{([a-zA-Z0-9_]*)\}\s*$", line).group(1)
+            line = re.sub(ur"\s*\*\{[a-zA-Z0-9_]*\}\s*$", "", line)
+
         line = self._default_markup_rule(line)
         if self._anchor != "":
-            line = re.sub(ur"^●(.*)$", ur'<h4 id="%s">\1</h4>' % self._anchor, line)
+            line = re.sub(ur"^●(.*)$", ur'<div id="%s"><h3>\1</h3></div>' % self._anchor, line)
             self._anchor = ""
         else:
-            line = re.sub(ur"^●(.*)$", ur"<h4>\1</h4>", line)
+            line = re.sub(ur"^●(.*)$", ur"<h3>\1</h3>", line)
         print line
 
     def _head_m(self, line):
+        line = line.rstrip()
+        if re.search(ur"\*{[a-zA-Z0-9_]*}\s*$", line):
+            self._anchor = re.search(ur"\*\{([a-zA-Z0-9_]*)\}\s*$", line).group(1)
+            line = re.sub(ur"\s*\*\{[a-zA-Z0-9_]*\}\s*$", "", line)
+
         line = self._default_markup_rule(line)
         if self._anchor != "":
-            line = re.sub(ur"^○(.*)$", ur'<b id="%s">\1</b>' % self._anchor, line)
+            line = re.sub(ur"^○(.*)$", ur'<div id="%s"><h4>\1</h4></div>' % self._anchor, line)
             self._anchor = ""
         else:
-            line = re.sub(ur"^○(.*)$", ur"<b>\1</b>", line)
+            line = re.sub(ur"^○(.*)$", ur"<h4>\1</h4>", line)
         print line
 
     def _paragraph(self, line):
@@ -326,7 +336,7 @@ class Markupper(object):
             #        line = line.strip()
             if re.search(ur"^☆}}}", line):
                 break
-            print line,
+            print line
 
     def _comment(self, line):
         for line in self.input_iter:
@@ -352,6 +362,7 @@ class Markupper(object):
 </div>
 
 """
+        arrow = '<div style="margin:1em auto;"><img src="%s"></div>\n' % (down_arrow,)
 
         rex_title = re.compile(ur"^☆flow\s+(.*)$")
         if rex_title.search(line):
@@ -373,7 +384,6 @@ class Markupper(object):
             fig = self._anchored_fig(file, cap)
             outputs.append(flow_item % (fig, cap))
 
-        arrow = '<img src="%s">\n' % (down_arrow,)
         print flow_header
         print flow_title % (title,)
         print arrow.join(outputs)
@@ -405,6 +415,8 @@ class Markupper(object):
             str_title = re.search(ur"^☆(図.*)$", line).group(1)
         except AttributeError:
             str_title = ""
+        if str_title.find(u"図*") == 0:
+            str_title = str_title.replace(u"図*", "")
         print self._fig_start()
 
         line = self.input_iter.next()
@@ -513,6 +525,9 @@ class Markupper(object):
         except AttributeError:
             str_title = ""
             fig_name = ""
+        if str_title.find(u"表*") == 0:
+            str_title = str_title.replace(u"表*", "")
+
         print self._table_start(str_title)
         self._table_buf1 =  self._table_start(str_title)
 
index 1065928..66bf463 100755 (executable)
@@ -19,15 +19,15 @@ except IndexError:
 ga_file = codecs.open(ga_data_path, "r", input_codec)
 output_file = codecs.open(output_path, "w", output_codec)
 
-ga_dict = {}
+#ga_data = []
 ga_titles = []
 for row in ga_file:
 #Page Title,Pageviews,Unique Pageviews,Avg. Time on Page,Bounce Rate,% Exit,$ Index
        
        items = row.strip().split( "," )
        title = items.pop(0)
-       ga_dict[title] = items
-       ga_titles.append(title)
+#      ga_dict.append(items)
+       ga_titles.append((title,items))
 #      print title
 ga_file.close()
 
@@ -39,21 +39,22 @@ for row in otp_file:
 #url,title,editor,PVs,comments,date,tags
        items = row.strip().split( "," )
 
-       for ga_title in ga_titles:
+       for (ga_title, ga_item) in ga_titles:
                if ga_title.find( items[1] ) != -1:
-                       ga_info = ga_dict.pop(ga_title)
-                       ga_info.append( items[5] )
-                       ga_info.append( items[6] )
-                       updated_dict[ga_title] = ga_info
+                       ga_item.append( items[5] )
+                       ga_item.append( items[6] )
                        break
        else:
                sys.stderr.write( "! %s - %s\n" % (items[1],items[5]) )
 
 otp_file.close()
-for title in updated_dict:
-       print >> output_file, title, ",",  ",".join( updated_dict[title] )
+for (title, item) in ga_titles:
+       print >> output_file, title, ",", ",".join(item)
 
-for title in ga_dict:
-       print >> output_file, title, ",",  ",".join( ga_dict[title] )
+#for title in updated_dict:
+#      print >> output_file, title, ",",  ",".join( updated_dict[title] )
+
+#for title in ga_dict:
+#      print >> output_file, title, ",",  ",".join( ga_dict[title] )
 
 output_file.close()
index 9d42956..e3b3238 100755 (executable)
@@ -176,7 +176,7 @@ class WikiMarkupper(markupper.Markupper):
             fig = self._anchored_fig(file, cap)
             outputs.append(flow_item % (fig))
 
-        arrow = '<div style="margin-top: 1em;"><img src="%s"></div>\n' % (down_arrow,)
+        arrow = '<div style="margin: 1em auto;"><img src="%s"></div>\n' % (down_arrow,)
         print flow_header
         print flow_title % (title,)
         print arrow.join(outputs)
@@ -201,6 +201,8 @@ class WikiMarkupper(markupper.Markupper):
             str_title = re.search(ur"^☆(図.*)$", line).group(1)
         except AttributeError:
             str_title = ""
+        if str_title.find(u"図*") == 0:
+            str_title = str_title.replace(u"図*", "")
         print self._fig_start()
 
         line = self.input_iter.next()
@@ -244,7 +246,7 @@ class WikiMarkupper(markupper.Markupper):
         if not os.path.isfile(file_s):
             file_s = file
 
-        return """[[Thumb(%s, caption=%s)]]""" % (file, alt)
+        return """[[Thumb(%s, size=large, caption=%s)]]""" % (file, alt)
         
 
     def _fig_release(self, line):
@@ -304,6 +306,8 @@ class WikiMarkupper(markupper.Markupper):
         except AttributeError:
             str_title = ""
             fig_name = ""
+        if str_title.find(u"表*") == 0:
+            str_title = str_title.replace(u"表*", "")
 #        print self._table_start(str_title)
         self._table_buf1 =  self._table_start(str_title) + "\n"