Commits

John Chandler committed 1649efb

Began to flesh out the DOT writer. Added Copyright and GPL notices to files

  • Participants
  • Parent commits 46c62d1

Comments (0)

Files changed (7)

File qadpid/__init__.py

 """
  'Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.'
  - Golding
+
+Copyright 2011 John Chandler
+This software is distributed under the terms of the GNU General Public License version 3
 """

File qadpid/parser.py

 """
 Parser Code
+
+Copyright 2011 John Chandler
+This software is distributed under the terms of the GNU General Public License version 3
 """
 import re
 

File qadpid/writer.py

+"""
+Writer Code
+
+Copyright 2011 John Chandler
+This software is distributed under the terms of the GNU General Public License version 3
+"""
+
+class DOTWriter( object ):
+    """ DOT File Writer """
+    def __init__( self, code_hierarchy ):
+        pass
+
+    def write( self, file_object ):
+        """ Write a DOT file to the file object
+            Assumes we can start writing at the current location in the file (i.e. append)
+        """
+        file_object.write( "digraph code_hierarchy {\n" )
+        file_object.write( "}\n" )
+
 #!/usr/bin/env python
-
+"""
+Copyright 2011 John Chandler
+This software is distributed under the terms of the GNU General Public License version 3
+"""
 from setuptools import setup
 
 

File tests/__init__.py

 """
  'If debugging is the process of removing bugs, then programming must be the process of putting them in.'
  - Dijkstra
+
+Copyright 2011 John Chandler
+This software is distributed under the terms of the GNU General Public License version 3
 """
 

File tests/test_dot_writer.py

+"""
+DOT writer tests
+
+Copyright 2011 John Chandler
+This software is distributed under the terms of the GNU General Public License version 3
+"""
+
+import unittest
+from StringIO import StringIO
+
+from qadpid.writer import DOTWriter
+
+
+class TestDOTWriter( unittest.TestCase ):
+    """ Tests for DOT writer """
+    def test_minimal_file( self ):
+        """ Tests output when no hierarchy """
+        output_file = StringIO()
+        writer      = DOTWriter("")
+        
+        writer.write(output_file)
+        output_file.seek(0)  # rewind to the beginning
+
+        self.assertEquals( output_file.readline(), "digraph code_hierarchy {\n" )
+        self.assertEquals( output_file.readline(), "}\n" )
+
+
+if __name__ == "__main__":
+    unittest.main()

File tests/test_parser.py

 """
 File parser tests
+
+Copyright 2011 John Chandler
+This software is distributed under the terms of the GNU General Public License version 3
 """
 
-from unittest import TestCase
+import unittest
 
 from qadpid.parser import PHPFileParser
 
 
-class TestPHPParser( TestCase ):
+class TestPHPParser( unittest.TestCase ):
     """ Tests for the PHP file parser """
     def setUp( self ):
         self.parser = PHPFileParser()
         require_once "qux.php"
         '''
         self.assertEquals( self.parser.parse(php_code), [ ("include", "foo.php"), ("require", "bar.php"), ("include", "baz.php"), ("require", "qux.php") ] )
-        
 
-        
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     unittest.main()