Commits

Jonathan Fine committed 643ec4b

Have populate produce AmsMath object, not tuple.

  • Participants
  • Parent commits 8d5bafd
  • Branches populate

Comments (0)

Files changed (2)

 
 
 # TODO: Inherit from a metaclass here.
+# TODO: repr AmsMath is "anon(tex='lots of stuff ...', etc)"
 class AmsMath(
     collections.namedtuple('anon', 'tex dvi png'),
     _Base

File aos/populate.py

 import tempfile
 import shutil
 import subprocess
+from aos.ao import AmsMath      # TODO: Remove this ugly dependency.
 
 _AMSMATH_TEMPLATE = r'''
 \documentclass{article}
     # TODO: Refactor this code - similar code in python-hvector.
     dirname = tempfile.mkdtemp()
     try:
-        dvi_bytes = do_amsmath(dirname, source)
-        png_bytes = do_dvipng(dirname)
+        dvi = do_amsmath(dirname, source)
+        png = do_dvipng(dirname)
+        ao = AmsMath(tex=source, dvi=dvi, png=png)
 
     finally:
         shutil.rmtree(dirname)
 
-    return dvi_bytes, png_bytes
+    return ao
 
 
 def do_amsmath(dirname, source):
 
 if __name__ == '__main__':
 
-    dvi_bytes = create_ao('2 + 2 = 4')
-
-    print repr(dvi_bytes)
+    ao = create_ao('2 + 2 = 4')
+    print repr(ao)