Commits

Jonathan Fine committed 60d9ae2

Refactor to create populate._generic_do.

Comments (0)

Files changed (1)

     return dvi_bytes
 
 
-def do_dvipng(dirname):
+def _generic_do(dirname, args, short_filename):
 
-    args = [
-        'dvipng',
-        '-o', 'o.png',
-        'o.dvi',
-        ]
-
-    png_filename = os.path.join(dirname, 'o.png')
+    long_filename = os.path.join(dirname, short_filename)
     process = subprocess.Popen(
         args,
         cwd=dirname,
     stdout, stderr = process.communicate()
 
     # Pick up the resulting dvi file.
-    with open(png_filename, 'rb') as f:
-        png_bytes = f.read()
+    with open(long_filename, 'rb') as f:
+        field_value = f.read()
 
-    return png_bytes
+    return field_value
+
+
+def do_dvipng(dirname):
+
+    args = [
+        'dvipng',
+        '-o', 'o.png',
+        'o.dvi',
+        ]
+    short_filename = 'o.png'
+
+    return _generic_do(dirname, args, short_filename)
 
 
 def add_formulas_to_aos(aos_path, formula_path_pairs):