Use "%r" % foo instead of "%s" % repr(foo). No functional changes.

This commit is contained in:
Thomas Hurst 2008-11-04 17:01:00 +00:00
parent 8e96d0eaa4
commit 901b5a8ea4
5 changed files with 29 additions and 29 deletions

View File

@ -238,7 +238,7 @@ class TerminatorConfValuestoreRC (TerminatorConfValuestore):
ini = ConfigFile(self.rcfilename, self._rc_set_callback()) ini = ConfigFile(self.rcfilename, self._rc_set_callback())
ini.parse() ini.parse()
except IOError, e: except IOError, e:
dbg (" VS_RCFile: unable to open %s (%s)" % (self.rcfilename, repr(e))) dbg (" VS_RCFile: unable to open %s (%r)" % (self.rcfilename, e))
except ParsedWithErrors, e: except ParsedWithErrors, e:
# We don't really want to produce an error dialog every run # We don't really want to produce an error dialog every run
if not is_init: if not is_init:
@ -287,24 +287,24 @@ Errors were encountered while parsing terminator_config(5) file:
dialog.run() dialog.run()
dialog.destroy() dialog.destroy()
dbg("ConfigFile settings are: %s" % repr(self.values)) dbg("ConfigFile settings are: %r" % self.values)
def _rc_set_callback(self): def _rc_set_callback(self):
def callback(sections, key, value): def callback(sections, key, value):
dbg("Setting: section=%s with %s => %s" % (repr(sections), repr(key), repr(value))) dbg("Setting: section=%r with %r => %r" % (sections, key, value))
section = None section = None
if len(sections) > 0: if len(sections) > 0:
section = sections[0] section = sections[0]
if section is None: if section is None:
if not Defaults.has_key (key): if not Defaults.has_key (key):
raise ValueError("Unknown configuration option %s" % repr(key)) raise ValueError("Unknown configuration option %r" % key)
deftype = Defaults[key].__class__.__name__ deftype = Defaults[key].__class__.__name__
if key.endswith('_color'): if key.endswith('_color'):
try: try:
gtk.gdk.color_parse(value) gtk.gdk.color_parse(value)
self.values[key] = value self.values[key] = value
except ValueError: except ValueError:
raise ValueError(_("Setting %s value %s not a valid colour; ignoring") % (key,repr(value))) raise ValueError(_("Setting %r value %r not a valid colour; ignoring") % (key, value))
elif key == 'tab_position': elif key == 'tab_position':
if value.lower() in ('top', 'left', 'bottom', 'right'): if value.lower() in ('top', 'left', 'bottom', 'right'):
self.values[key] = value.lower() self.values[key] = value.lower()
@ -325,20 +325,20 @@ Errors were encountered while parsing terminator_config(5) file:
raise ValueError(_("Reading list values from terminator_config(5) is not currently supported")) raise ValueError(_("Reading list values from terminator_config(5) is not currently supported"))
elif deftype == 'dict': elif deftype == 'dict':
if type(value) != dict: if type(value) != dict:
raise ValueError(_("Setting %s should be a section name") % repr(key)) raise ValueError(_("Setting %r should be a section name") % key)
self.values[key] = value self.values[key] = value
else: else:
self.values[key] = value self.values[key] = value
dbg (" VS_RCFile: Set value '%s' to %s" % (key, repr(self.values[key]))) dbg (" VS_RCFile: Set value %r to %r" % (key, self.values[key]))
elif section == 'keybindings': elif section == 'keybindings':
self.values.setdefault(section, {}) self.values.setdefault(section, {})
if not Defaults[section].has_key(key): if not Defaults[section].has_key(key):
raise ValueError("Keybinding name %s is unknown" % repr(key)) raise ValueError("Keybinding name %r is unknown" % key)
else: else:
self.values[section][key] = value self.values[section][key] = value
else: else:
raise ValueError("Section name %s is unknown" % repr(section)) raise ValueError("Section name %r is unknown" % section)
return callback return callback
class TerminatorConfValuestoreGConf (TerminatorConfValuestore): class TerminatorConfValuestoreGConf (TerminatorConfValuestore):

View File

@ -57,12 +57,12 @@ class ParsedWithErrors(Exception):
def __str__(self): def __str__(self):
return """Errors were encountered while parsing configuration file: return """Errors were encountered while parsing configuration file:
%s %r
Some lines have been ignored. Some lines have been ignored.
%s %s
""" % (repr(self.file), "\n".join(map(lambda error: str(error), self.errors))) """ % (self.file, "\n".join(map(lambda error: str(error), self.errors)))
class ConfigFile: class ConfigFile:
@ -127,7 +127,7 @@ class ConfigFile:
self._lnum += 1 self._lnum += 1
self._pos = 0 self._pos = 0
self._max = len(self._line) self._max = len(self._line)
dbg("Line %d: %s" % (self._lnum, repr(self._line))) dbg("Line %d: %r" % (self._lnum, self._line))
if HandleIndents: if HandleIndents:
self._find_indent() self._find_indent()
@ -146,7 +146,7 @@ class ConfigFile:
if not self._call_if_match(Barevalue, self._value, 1): if not self._call_if_match(Barevalue, self._value, 1):
raise ConfigSyntaxError(_("Setting without a value"), self) raise ConfigSyntaxError(_("Setting without a value"), self)
self._call_if_match(Ignore, lambda junk: dbg("Skipping: %s" % repr(junk))) self._call_if_match(Ignore, lambda junk: dbg("Skipping: %r" % junk))
if self._line[self._pos:] != '': if self._line[self._pos:] != '':
raise ConfigSyntaxError(_("Unexpected token"), self) raise ConfigSyntaxError(_("Unexpected token"), self)
@ -200,15 +200,15 @@ class ConfigFile:
return tuple(sections) return tuple(sections)
def _section(self, section): def _section(self, section):
dbg("Section %s" % repr(section)) dbg("Section %r" % section)
self._sections[len(self._indents)] = section.lower() self._sections[len(self._indents)] = section.lower()
def _setting(self, setting): def _setting(self, setting):
dbg("Setting %s" % repr(setting)) dbg("Setting %r" % setting)
self._currsetting = setting.lower() self._currsetting = setting.lower()
def _value(self, value): def _value(self, value):
dbg("Value %s" % repr(value)) dbg("Value %r" % value)
self._currvalue = value self._currvalue = value
def _line_ok(self): def _line_ok(self):

View File

@ -26,7 +26,7 @@ class PythonConsoleServer(SocketServer.BaseRequestHandler):
env = None env = None
def setup(self): def setup(self):
dbg('debugserver: connect from %s' % str(self.client_address)) dbg('debugserver: connect from %s' % str(self.client_address))
ddbg('debugserver: env=%s' % repr(PythonConsoleServer.env)) ddbg('debugserver: env=%r' % PythonConsoleServer.env)
self.console = TerminatorConsole(PythonConsoleServer.env) self.console = TerminatorConsole(PythonConsoleServer.env)
def handle(self): def handle(self):
@ -92,7 +92,7 @@ class TerminatorConsole(code.InteractiveConsole):
data = data.replace(NULL, '') data = data.replace(NULL, '')
bits = re.findall(DoDont, data) bits = re.findall(DoDont, data)
ddbg("bits = %s" % repr(bits)) ddbg("bits = %r" % bits)
if bits: if bits:
data = re.sub(DoDont, '\\1', data) data = re.sub(DoDont, '\\1', data)
ddbg("telnet: DO/DON'T answer") ddbg("telnet: DO/DON'T answer")
@ -124,12 +124,12 @@ class TerminatorConsole(code.InteractiveConsole):
data = data.replace(IAC + IAC, IAC) # and handle escapes data = data.replace(IAC + IAC, IAC) # and handle escapes
if data != odata: if data != odata:
ddbg("debugserver: Replaced %s with %s" % (repr(odata), repr(data))) ddbg("debugserver: Replaced %r with %r" % (odata, data))
return data return data
def raw_input(self, prompt = None): def raw_input(self, prompt = None):
ddbg("debugserver: raw_input prompt = %s" % repr(prompt)) ddbg("debugserver: raw_input prompt = %r" % prompt)
if prompt: if prompt:
self.write(prompt) self.write(prompt)
@ -137,7 +137,7 @@ class TerminatorConsole(code.InteractiveConsole):
compstate = 0 compstate = 0
while True: while True:
data = self.server.socketio.read(1) data = self.server.socketio.read(1)
ddbg('raw_input: char=%s' % repr(data)) ddbg('raw_input: char=%r' % data)
if data == LF or data == '\006': if data == LF or data == '\006':
buf = self.parse_telnet(buf + data) buf = self.parse_telnet(buf + data)
if buf != '': if buf != '':
@ -148,7 +148,7 @@ class TerminatorConsole(code.InteractiveConsole):
buf += data buf += data
def write(self, data): def write(self, data):
ddbg("debugserver: write %s" % repr(data)) ddbg("debugserver: write %r" % data)
self.server.socketio.write(data) self.server.socketio.write(data)
self.server.socketio.flush() self.server.socketio.flush()

View File

@ -209,7 +209,7 @@ class Terminator:
if self._geometry is not None: if self._geometry is not None:
dbg("Geometry=%s" % self._geometry) dbg("Geometry=%s" % self._geometry)
if not self.window.parse_geometry(self._geometry): if not self.window.parse_geometry(self._geometry):
err(_("Invalid geometry string %s") % repr(self._geometry)) err(_("Invalid geometry string %r") % self._geometry)
try: try:
self.window.set_icon (self.icon_theme.load_icon (APP_NAME, 48, 0)) self.window.set_icon (self.icon_theme.load_icon (APP_NAME, 48, 0))
@ -286,7 +286,7 @@ class Terminator:
# a shell script with the interpreter name etc. # a shell script with the interpreter name etc.
c = self.gnome_client c = self.gnome_client
c.set_program(sys.argv[0]) c.set_program(sys.argv[0])
dbg("Session restart command: %s with args %s in %s" % (sys.argv[0], repr(args), self.start_cwd)) dbg("Session restart command: %s with args %r in %s" % (sys.argv[0], args, self.start_cwd))
c.set_restart_style(gnome.ui.RESTART_IF_RUNNING) c.set_restart_style(gnome.ui.RESTART_IF_RUNNING)
c.set_current_directory(self.start_cwd) c.set_current_directory(self.start_cwd)
@ -372,7 +372,7 @@ class Terminator:
mapping = self.keybindings.lookup(event) mapping = self.keybindings.lookup(event)
if mapping: if mapping:
dbg("on_key_press: lookup found %s" % repr(mapping)) dbg("on_key_press: lookup found %r" % mapping)
if mapping == 'full_screen': if mapping == 'full_screen':
self.fullscreen_toggle () self.fullscreen_toggle ()
return (True) return (True)

View File

@ -688,7 +688,7 @@ text/plain
mapping = self.terminator.keybindings.lookup(event) mapping = self.terminator.keybindings.lookup(event)
if mapping and mapping not in self.UnhandledKeybindings: if mapping and mapping not in self.UnhandledKeybindings:
dbg("on_vte_key_press: lookup found %s" % repr(mapping)) dbg("on_vte_key_press: lookup found %r" % mapping)
getattr(self, "key_" + mapping)() getattr(self, "key_" + mapping)()
return True return True
@ -808,7 +808,7 @@ text/plain
def do_search(self, widget): def do_search(self, widget):
string = widget.get_text() string = widget.get_text()
dbg("do_search: Looking for %s" % repr(string)) dbg("do_search: Looking for %r" % string)
if string == '': if string == '':
return return
@ -833,7 +833,7 @@ text/plain
return return
buffer = self._vte.get_text_range(self._search_row, 0, self._search_row, -1, self._search_character) buffer = self._vte.get_text_range(self._search_row, 0, self._search_row, -1, self._search_character)
# dbg("Row %d buffer: %s" % (self._search_row, repr(buffer))) # dbg("Row %d buffer: %r" % (self._search_row, buffer))
index = buffer.find(self._search_string) index = buffer.find(self._search_string)
if index != -1: if index != -1:
self._search_result_label.set_text("Found at row %d" % self._search_row) self._search_result_label.set_text("Found at row %d" % self._search_row)