Remove some interpolation operators
Keeping the one used in translations for now.
This commit is contained in:
parent
012501624f
commit
476825c6fe
|
@ -75,7 +75,7 @@ if __name__ == '__main__':
|
||||||
args = sys.argv
|
args = sys.argv
|
||||||
argc = len(args)
|
argc = len(args)
|
||||||
if argc == 2 and args[1] in [ '-v', '--version' ]:
|
if argc == 2 and args[1] in [ '-v', '--version' ]:
|
||||||
print('%s %s\n%s' % (APP_NAME, VERSION, COPYRIGHT))
|
print(f'{APP_NAME} {VERSION}\n{COPYRIGHT}')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
if argc == 2 and args[1] in [ '-h', '-?', '--help' ]:
|
if argc == 2 and args[1] in [ '-h', '-?', '--help' ]:
|
||||||
print(_('''Usage:
|
print(_('''Usage:
|
||||||
|
@ -156,7 +156,7 @@ if not hasattr(__builtins__, 'WindowsError'):
|
||||||
|
|
||||||
# convenience function to display debug messages
|
# convenience function to display debug messages
|
||||||
def logDebug(s):
|
def logDebug(s):
|
||||||
pass #sys.stderr.write('%s: %s\n', (APP_NAME, s))
|
pass #sys.stderr.write(f'{APP_NAME}: {s}\n')
|
||||||
|
|
||||||
# avoid some dictionary lookups when string.whitespace is used in loops
|
# avoid some dictionary lookups when string.whitespace is used in loops
|
||||||
# this is sorted based upon frequency to speed up code for stripping whitespace
|
# this is sorted based upon frequency to speed up code for stripping whitespace
|
||||||
|
@ -164,7 +164,7 @@ whitespace = ' \t\n\r\x0b\x0c'
|
||||||
|
|
||||||
# escape special glob characters
|
# escape special glob characters
|
||||||
def globEscape(s):
|
def globEscape(s):
|
||||||
m = dict([ (c, u'[%s]' % (c, )) for c in u'[]?*' ])
|
m = dict([ (c, f'[{c}]') for c in u'[]?*' ])
|
||||||
return u''.join([ m.get(c, c) for c in s ])
|
return u''.join([ m.get(c, c) for c in s ])
|
||||||
|
|
||||||
# associate our icon with all of our windows
|
# associate our icon with all of our windows
|
||||||
|
@ -544,7 +544,7 @@ class Resources:
|
||||||
try:
|
try:
|
||||||
return self.colours[symbol]
|
return self.colours[symbol]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logDebug('Warning: unknown colour "%s"' % (symbol, ))
|
logDebug(f'Warning: unknown colour "{symbol}"')
|
||||||
self.colours[symbol] = v = Colour(0.0, 0.0, 0.0)
|
self.colours[symbol] = v = Colour(0.0, 0.0, 0.0)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ class Resources:
|
||||||
try:
|
try:
|
||||||
return self.floats[symbol]
|
return self.floats[symbol]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logDebug('Warning: unknown float "%s"' % (symbol, ))
|
logDebug(f'Warning: unknown float "{symbol}"')
|
||||||
self.floats[symbol] = v = 0.5
|
self.floats[symbol] = v = 0.5
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ class Resources:
|
||||||
try:
|
try:
|
||||||
return self.strings[symbol]
|
return self.strings[symbol]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logDebug('Warning: unknown string "%s"' % (symbol, ))
|
logDebug(f'Warning: unknown string "{symbol}"')
|
||||||
self.strings[symbol] = v = ''
|
self.strings[symbol] = v = ''
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@ -949,10 +949,10 @@ class Preferences:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# this may happen if the prefs were written by a
|
# this may happen if the prefs were written by a
|
||||||
# different version -- don't bother the user
|
# different version -- don't bother the user
|
||||||
logDebug('Error processing line %d of %s.' % (j + 1, self.path))
|
logDebug(f'Error processing line {j + 1} of {self.path}.')
|
||||||
except IOError:
|
except IOError:
|
||||||
# bad $HOME value? -- don't bother the user
|
# bad $HOME value? -- don't bother the user
|
||||||
logDebug('Error reading %s.' % (self.path, ))
|
logDebug(f'Error reading {self.path}.')
|
||||||
|
|
||||||
# recursively traverses 'template' to discover the preferences and
|
# recursively traverses 'template' to discover the preferences and
|
||||||
# initialise their default values in self.bool_prefs, self.int_prefs, and
|
# initialise their default values in self.bool_prefs, self.int_prefs, and
|
||||||
|
@ -1011,16 +1011,17 @@ class Preferences:
|
||||||
ss = []
|
ss = []
|
||||||
for k, v in self.bool_prefs.items():
|
for k, v in self.bool_prefs.items():
|
||||||
if v != self.default_bool_prefs[k]:
|
if v != self.default_bool_prefs[k]:
|
||||||
ss.append('%s %s\n' % (k, v))
|
ss.append(f'{k} {v}\n')
|
||||||
for k, v in self.int_prefs.items():
|
for k, v in self.int_prefs.items():
|
||||||
if v != self.default_int_prefs[k]:
|
if v != self.default_int_prefs[k]:
|
||||||
ss.append('%s %s\n' % (k, v))
|
ss.append(f'{k} {v}\n')
|
||||||
for k, v in self.string_prefs.items():
|
for k, v in self.string_prefs.items():
|
||||||
if v != self.default_string_prefs[k]:
|
if v != self.default_string_prefs[k]:
|
||||||
ss.append('%s "%s"\n' % (k, v.replace('\\', '\\\\').replace('"', '\\"')))
|
v_escaped = v.replace('\\', '\\\\').replace('"', '\\"')
|
||||||
|
ss.append(f'{k} "{v_escaped}"\n')
|
||||||
ss.sort()
|
ss.sort()
|
||||||
f = open(self.path, 'w')
|
f = open(self.path, 'w')
|
||||||
f.write('# This prefs file was generated by %s %s.\n\n' % (APP_NAME, VERSION))
|
f.write(f'# This prefs file was generated by {APP_NAME} {VERSION}.\n\n')
|
||||||
for s in ss:
|
for s in ss:
|
||||||
f.write(s)
|
f.write(s)
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -1351,7 +1352,7 @@ def popenRead(dn, cmd, prefs, bash_pref, success_results=None):
|
||||||
success_results = [ 0 ]
|
success_results = [ 0 ]
|
||||||
if isWindows() and prefs.getBool(bash_pref):
|
if isWindows() and prefs.getBool(bash_pref):
|
||||||
# launch the command from a bash shell is requested
|
# launch the command from a bash shell is requested
|
||||||
cmd = [ prefs.convertToNativePath('/bin/bash.exe'), '-l', '-c', 'cd %s; %s' % (bashEscape(dn), ' '.join([ bashEscape(arg) for arg in cmd ])) ]
|
cmd = [ prefs.convertToNativePath('/bin/bash.exe'), '-l', '-c', 'cd {}; {}'.format(bashEscape(dn), ' '.join([ bashEscape(arg) for arg in cmd ])) ]
|
||||||
dn = None
|
dn = None
|
||||||
# use subprocess.Popen to retrieve the file contents
|
# use subprocess.Popen to retrieve the file contents
|
||||||
if isWindows():
|
if isWindows():
|
||||||
|
@ -1948,7 +1949,7 @@ class _Git:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getRevision(self, prefs, name, rev):
|
def getRevision(self, prefs, name, rev):
|
||||||
return popenRead(self.root, [ prefs.getString('git_bin'), 'show', '%s:%s' % (rev, relpath(self.root, os.path.abspath(name)).replace(os.sep, '/')) ], prefs, 'git_bash')
|
return popenRead(self.root, [ prefs.getString('git_bin'), 'show', '{}:{}'.format(rev, relpath(self.root, os.path.abspath(name)).replace(os.sep, '/')) ], prefs, 'git_bash')
|
||||||
|
|
||||||
def _get_git_repo(path, prefs):
|
def _get_git_repo(path, prefs):
|
||||||
if 'GIT_DIR' in os.environ:
|
if 'GIT_DIR' in os.environ:
|
||||||
|
@ -2003,7 +2004,7 @@ class _Hg:
|
||||||
prev = prev[:-1]
|
prev = prev[:-1]
|
||||||
self.working_rev = prev
|
self.working_rev = prev
|
||||||
return self.working_rev
|
return self.working_rev
|
||||||
return 'p1(%s)' % (rev, )
|
return f'p1({rev})'
|
||||||
|
|
||||||
def getFileTemplate(self, prefs, name):
|
def getFileTemplate(self, prefs, name):
|
||||||
return [ (name, self._getPreviousRevision(prefs, None)), (name, None) ]
|
return [ (name, self._getPreviousRevision(prefs, None)), (name, None) ]
|
||||||
|
@ -2488,7 +2489,7 @@ class _Svn:
|
||||||
# determine which are directories
|
# determine which are directories
|
||||||
added = {}
|
added = {}
|
||||||
for p, v in m.items():
|
for p, v in m.items():
|
||||||
for s in popenReadLines(self.root, [ vcs_bin, 'list', '-r', rev, '%s/%s' % (self._getURL(prefs), p.replace(os.sep, '/')) ], prefs, vcs_bash):
|
for s in popenReadLines(self.root, [ vcs_bin, 'list', '-r', rev, '{}/{}'.format(self._getURL(prefs), p.replace(os.sep, '/')) ], prefs, vcs_bash):
|
||||||
if s in v:
|
if s in v:
|
||||||
# confirmed as added file
|
# confirmed as added file
|
||||||
k = os.path.join(self.root, os.path.join(p, s))
|
k = os.path.join(self.root, os.path.join(p, s))
|
||||||
|
@ -2514,7 +2515,7 @@ class _Svn:
|
||||||
m[d].add(b)
|
m[d].add(b)
|
||||||
removed_dir, removed = set(), {}
|
removed_dir, removed = set(), {}
|
||||||
for p, v in m.items():
|
for p, v in m.items():
|
||||||
for s in popenReadLines(self.root, [ vcs_bin, 'list', '-r', prev, '%s/%s' % (self._getURL(prefs), p.replace(os.sep, '/')) ], prefs, vcs_bash):
|
for s in popenReadLines(self.root, [ vcs_bin, 'list', '-r', prev, '{}/{}'.format(self._getURL(prefs), p.replace(os.sep, '/')) ], prefs, vcs_bash):
|
||||||
if s.endswith('/'):
|
if s.endswith('/'):
|
||||||
s = s[:-1]
|
s = s[:-1]
|
||||||
if s in v:
|
if s in v:
|
||||||
|
@ -2532,7 +2533,7 @@ class _Svn:
|
||||||
tmp = removed_dir
|
tmp = removed_dir
|
||||||
removed_dir = set()
|
removed_dir = set()
|
||||||
for p in tmp:
|
for p in tmp:
|
||||||
for s in popenReadLines(self.root, [ vcs_bin, 'list', '-r', prev, '%s/%s' % (self._getURL(prefs), p.replace(os.sep, '/')) ], prefs, vcs_bash):
|
for s in popenReadLines(self.root, [ vcs_bin, 'list', '-r', prev, '{}/{}'.format(self._getURL(prefs), p.replace(os.sep, '/')) ], prefs, vcs_bash):
|
||||||
if s.endswith('/'):
|
if s.endswith('/'):
|
||||||
# confirmed item as directory
|
# confirmed item as directory
|
||||||
removed_dir.add(os.path.join(p, s[:-1]))
|
removed_dir.add(os.path.join(p, s[:-1]))
|
||||||
|
@ -2561,8 +2562,8 @@ class _Svn:
|
||||||
def getRevision(self, prefs, name, rev):
|
def getRevision(self, prefs, name, rev):
|
||||||
vcs_bin = prefs.getString('svn_bin')
|
vcs_bin = prefs.getString('svn_bin')
|
||||||
if rev in [ 'BASE', 'COMMITTED', 'PREV' ]:
|
if rev in [ 'BASE', 'COMMITTED', 'PREV' ]:
|
||||||
return popenRead(self.root, [ vcs_bin, 'cat', '%s@%s' % (safeRelativePath(self.root, name, prefs, 'svn_cygwin'), rev) ], prefs, 'svn_bash')
|
return popenRead(self.root, [ vcs_bin, 'cat', '{}@{}'.format(safeRelativePath(self.root, name, prefs, 'svn_cygwin'), rev) ], prefs, 'svn_bash')
|
||||||
return popenRead(self.root, [ vcs_bin, 'cat', '%s/%s@%s' % (self._getURL(prefs), relpath(self.root, os.path.abspath(name)).replace(os.sep, '/'), rev) ], prefs, 'svn_bash')
|
return popenRead(self.root, [ vcs_bin, 'cat', '{}/{}@{}'.format(self._getURL(prefs), relpath(self.root, os.path.abspath(name)).replace(os.sep, '/'), rev) ], prefs, 'svn_bash')
|
||||||
|
|
||||||
def _get_svn_repo(path, prefs):
|
def _get_svn_repo(path, prefs):
|
||||||
p = _find_parent_dir_with(path, '.svn')
|
p = _find_parent_dir_with(path, '.svn')
|
||||||
|
@ -2592,7 +2593,7 @@ class _Svk(_Svn):
|
||||||
return str(int(rev) - 1)
|
return str(int(rev) - 1)
|
||||||
|
|
||||||
def getRevision(self, prefs, name, rev):
|
def getRevision(self, prefs, name, rev):
|
||||||
return popenRead(self.root, [ prefs.getString('svk_bin'), 'cat', '-r', rev, '%s/%s' % (self._getURL(prefs), relpath(self.root, os.path.abspath(name)).replace(os.sep, '/')) ], prefs, 'svk_bash')
|
return popenRead(self.root, [ prefs.getString('svk_bin'), 'cat', '-r', rev, '{}/{}'.format(self._getURL(prefs), relpath(self.root, os.path.abspath(name)).replace(os.sep, '/')) ], prefs, 'svk_bash')
|
||||||
|
|
||||||
def _get_svk_repo(path, prefs):
|
def _get_svk_repo(path, prefs):
|
||||||
name = path
|
name = path
|
||||||
|
@ -7651,10 +7652,10 @@ class Diffuse(Gtk.Window):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# this may happen if the state was written by a
|
# this may happen if the state was written by a
|
||||||
# different version -- don't bother the user
|
# different version -- don't bother the user
|
||||||
logDebug('Error processing line %d of %s.' % (j + 1, statepath))
|
logDebug(f'Error processing line {j + 1} of {statepath}.')
|
||||||
except IOError:
|
except IOError:
|
||||||
# bad $HOME value? -- don't bother the user
|
# bad $HOME value? -- don't bother the user
|
||||||
logDebug('Error reading %s.' % (statepath, ))
|
logDebug(f'Error reading {statepath}.')
|
||||||
|
|
||||||
self.move(self.int_state['window_x'], self.int_state['window_y'])
|
self.move(self.int_state['window_x'], self.int_state['window_y'])
|
||||||
self.resize(self.int_state['window_width'], self.int_state['window_height'])
|
self.resize(self.int_state['window_width'], self.int_state['window_height'])
|
||||||
|
@ -7666,18 +7667,18 @@ class Diffuse(Gtk.Window):
|
||||||
try:
|
try:
|
||||||
ss = []
|
ss = []
|
||||||
for k, v in self.bool_state.items():
|
for k, v in self.bool_state.items():
|
||||||
ss.append('%s %s\n' % (k, v))
|
ss.append(f'{k} {v}\n')
|
||||||
for k, v in self.int_state.items():
|
for k, v in self.int_state.items():
|
||||||
ss.append('%s %s\n' % (k, v))
|
ss.append(f'{k} {v}\n')
|
||||||
ss.sort()
|
ss.sort()
|
||||||
f = open(statepath, 'w')
|
f = open(statepath, 'w')
|
||||||
f.write("# This state file was generated by %s %s.\n\n" % (APP_NAME, VERSION))
|
f.write(f"# This state file was generated by {APP_NAME} {VERSION}.\n\n")
|
||||||
for s in ss:
|
for s in ss:
|
||||||
f.write(s)
|
f.write(s)
|
||||||
f.close()
|
f.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
# bad $HOME value? -- don't bother the user
|
# bad $HOME value? -- don't bother the user
|
||||||
logDebug('Error writing %s.' % (statepath, ))
|
logDebug(f'Error writing {statepath}.')
|
||||||
|
|
||||||
# select viewer for a newly selected file in the confirm close dialogue
|
# select viewer for a newly selected file in the confirm close dialogue
|
||||||
def __confirmClose_row_activated_cb(self, tree, path, col, model):
|
def __confirmClose_row_activated_cb(self, tree, path, col, model):
|
||||||
|
@ -7798,7 +7799,7 @@ class Diffuse(Gtk.Window):
|
||||||
# update window's title
|
# update window's title
|
||||||
def updateTitle(self, viewer):
|
def updateTitle(self, viewer):
|
||||||
title = self.notebook.get_tab_label(viewer).get_text()
|
title = self.notebook.get_tab_label(viewer).get_text()
|
||||||
self.set_title('%s - %s' % (title, APP_NAME))
|
self.set_title(f'{title} - {APP_NAME}')
|
||||||
|
|
||||||
# update the message in the status bar
|
# update the message in the status bar
|
||||||
def setStatus(self, s):
|
def setStatus(self, s):
|
||||||
|
|
Loading…
Reference in New Issue