# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Authors: Carlos Garcia Campos <*****@*****.**> # from Guilty.OutputDevs import OutputDevice, register_output_device class TextOutputDevice (OutputDevice): def start_file (self, filename): print filename print def line (self, line): print line def end_file (self): print register_output_device ('text', TextOutputDevice)
from Guilty.Config import Config class XMLOutputDevice (OutputDevice): def begin (self, uri): rev = Config ().revision print '<?xml version="1.0"?>' print '<repository uri = "%s"' % (uri), if rev: print 'revision = "%s"' % (rev), print '>' def start_file (self, filename): print '\t<file path = "%s">' % (filename) def line (self, line): if line.file: orig_file = ' orig_file = "%s" ' % (line.file) else: orig_file = ' ' print '\t\t<line n = %d revision = "%s" author = "%s" date = "%s"%s/>' % \ (line.line, line.rev, line.author, line.date, orig_file) def end_file (self): print '\t</file>' def end (self): print '</repository>' register_output_device ('xml', XMLOutputDevice)
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Authors: Carlos Garcia Campos <*****@*****.**> # from Guilty.OutputDevs import OutputDevice, register_output_device class CSVOutputDevice (OutputDevice): def begin (self, uri): print 'file,line,revision,author,date,orig-file' def start_file (self, filename): self.file = filename def line (self, line): print '%s,%d,%s,"%s",%s,%s' % (self.file, line.line, line.rev, line.author, line.date, line.file or '""') def end_file (self): self.file = None register_output_device ('csv', CSVOutputDevice)
def __get_revision_id (self, revision): try: return self.revisions[revision] except KeyError: self.revisions[revision] = self.__insert_object (DBRevision (revision)).id return self.revisions[revision] def __get_author_id (self, author): try: return self.authors[author] except KeyError: self.authors[author] = self.__insert_object (DBAuthor (author)).id return self.authors[author] def start_file (self, filename): self.file_id = self.__insert_object (DBFile (filename)).id def line (self, line): db_line = DBLine (line.line, line.date,line.file) db_line.file_id = self.file_id db_line.revision_id = self.__get_revision_id (line.rev) db_line.author_id = self.__get_author_id (line.author) self.__insert_object (db_line) def end_file (self): self.cnn.commit () self.file_id = -1 register_output_device ('db', DBOutputDevice)