Example #1
0
# 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)
Example #2
0
# 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)
Example #3
0
# 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)
Example #4
0
            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)
Example #5
0
    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)
Example #6
0

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)
Example #7
0
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)