/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to diff.py

  • Committer: Gary van der Merwe
  • Date: 2007-08-10 10:45:06 UTC
  • mto: This revision was merged to the branch mainline in revision 256.
  • Revision ID: garyvdm@gmail.com-20070810104506-wo2mp9zfkh338axe
Make icon locations consistant between source and installed version. Let glade nkow where to find the icons with a project file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
1
# -*- coding: UTF-8 -*-
3
2
"""Difference window.
4
3
 
12
11
 
13
12
from cStringIO import StringIO
14
13
 
 
14
import pygtk
 
15
pygtk.require("2.0")
15
16
import gtk
16
17
import pango
17
18
import os
250
251
 
251
252
        :param lang: a "Diff" gtksourceview.SourceLanguage object.
252
253
        """
253
 
        def parse_colordiffrc(fileobj):
254
 
            """Parse fileobj as a colordiff configuration file.
255
 
            
256
 
            :return: A dict with the key -> value pairs.
257
 
            """
258
 
            colors = {}
259
 
            for line in fileobj:
260
 
                if re.match(r'^\s*#', line):
261
 
                    continue
262
 
                key, val = line.split('=')
263
 
                colors[key.strip()] = val.strip()
264
 
            return colors
265
 
 
266
254
        colors = {}
267
255
 
268
256
        for f in ('~/.colordiffrc', '~/.colordiffrc.bzr-gtk'):
273
261
                except IOError, e:
274
262
                    warning('could not open file %s: %s' % (f, str(e)))
275
263
                else:
276
 
                    colors.update(parse_colordiffrc(f))
 
264
                    colors.update(DiffWindow.parse_colordiffrc(f))
277
265
                    f.close()
278
266
 
279
267
        if not colors:
311
299
                warning('not a valid color: %s' % color)
312
300
            else:
313
301
                lang.set_tag_style(tag_id, style)
 
302
 
 
303
    @staticmethod
 
304
    def parse_colordiffrc(fileobj):
 
305
        """Parse fileobj as a colordiff configuration file.
 
306
        
 
307
        :return: A dict with the key -> value pairs.
 
308
        """
 
309
        colors = {}
 
310
        for line in fileobj:
 
311
            if re.match(r'^\s*#', line):
 
312
                continue
 
313
            if '=' not in line:
 
314
                continue
 
315
            key, val = line.split('=', 1)
 
316
            colors[key.strip()] = val.strip()
 
317
        return colors
 
318