Merge pull request #57 from MightyCreak/remove-u-prefix
Remove 'u' before strings
This commit is contained in:
commit
22c512bea0
|
@ -164,8 +164,8 @@ whitespace = ' \t\n\r\x0b\x0c'
|
|||
|
||||
# escape special glob characters
|
||||
def globEscape(s):
|
||||
m = dict([ (c, f'[{c}]') for c in u'[]?*' ])
|
||||
return u''.join([ m.get(c, c) for c in s ])
|
||||
m = dict([ (c, f'[{c}]') for c in '[]?*' ])
|
||||
return ''.join([ m.get(c, c) for c in s ])
|
||||
|
||||
# associate our icon with all of our windows
|
||||
if __name__ == '__main__':
|
||||
|
@ -289,7 +289,7 @@ def readlines(fd):
|
|||
return strip_eols(splitlines(fd.read()))
|
||||
|
||||
def readconfiglines(fd):
|
||||
return fd.read().replace(u'\r', u'').split(u'\n')
|
||||
return fd.read().replace('\r', '').split('\n')
|
||||
|
||||
# This class to hold all customisable behaviour not exposed in the preferences
|
||||
# dialogue: hotkey assignment, colours, syntax highlighting, etc.
|
||||
|
@ -605,7 +605,7 @@ class Resources:
|
|||
try:
|
||||
# eg. add Python syntax highlighting:
|
||||
# import /usr/share/diffuse/syntax/python.syntax
|
||||
if args[0] == u'import' and len(args) == 2:
|
||||
if args[0] == 'import' and len(args) == 2:
|
||||
path = os.path.expanduser(args[1])
|
||||
# relative paths are relative to the parsed file
|
||||
path = os.path.join(globEscape(os.path.dirname(file_name)), path)
|
||||
|
@ -619,28 +619,28 @@ class Resources:
|
|||
self.parse(os.path.abspath(path))
|
||||
# eg. make Ctrl+o trigger the open_file menu item
|
||||
# keybinding menu open_file Ctrl+o
|
||||
elif args[0] == u'keybinding' and len(args) == 4:
|
||||
elif args[0] == 'keybinding' and len(args) == 4:
|
||||
self.setKeyBinding(args[1], args[2], args[3])
|
||||
# eg. set the regular background colour to white
|
||||
# colour text_background 1.0 1.0 1.0
|
||||
elif args[0] in [ u'colour', u'color' ] and len(args) == 5:
|
||||
elif args[0] in [ 'colour', 'color' ] and len(args) == 5:
|
||||
self.colours[args[1]] = Colour(float(args[2]), float(args[3]), float(args[4]))
|
||||
# eg. set opacity of the line_selection colour
|
||||
# float line_selection_opacity 0.4
|
||||
elif args[0] == u'float' and len(args) == 3:
|
||||
elif args[0] == 'float' and len(args) == 3:
|
||||
self.floats[args[1]] = float(args[2])
|
||||
# eg. set the help browser
|
||||
# string help_browser gnome-help
|
||||
elif args[0] == u'string' and len(args) == 3:
|
||||
elif args[0] == 'string' and len(args) == 3:
|
||||
self.strings[args[1]] = args[2]
|
||||
if args[1] == u'difference_colours':
|
||||
if args[1] == 'difference_colours':
|
||||
self.setDifferenceColours(args[2])
|
||||
# eg. start a syntax specification for Python
|
||||
# syntax Python normal text
|
||||
# where 'normal' is the name of the default state and
|
||||
# 'text' is the classification of all characters not
|
||||
# explicitly matched by a syntax highlighting rule
|
||||
elif args[0] == u'syntax' and (len(args) == 2 or len(args) == 4):
|
||||
elif args[0] == 'syntax' and (len(args) == 2 or len(args) == 4):
|
||||
key = args[1]
|
||||
if len(args) == 2:
|
||||
# remove file pattern for a syntax specification
|
||||
|
@ -666,10 +666,10 @@ class Resources:
|
|||
# the pattern '#' is matched and classify the matched
|
||||
# characters as 'python_comment'
|
||||
# syntax_pattern normal comment python_comment '#'
|
||||
elif args[0] == u'syntax_pattern' and self.current_syntax is not None and len(args) >= 5:
|
||||
elif args[0] == 'syntax_pattern' and self.current_syntax is not None and len(args) >= 5:
|
||||
flags = 0
|
||||
for arg in args[5:]:
|
||||
if arg == u'ignorecase':
|
||||
if arg == 'ignorecase':
|
||||
flags |= re.IGNORECASE
|
||||
else:
|
||||
raise ValueError()
|
||||
|
@ -677,7 +677,7 @@ class Resources:
|
|||
# eg. default to the Python syntax rules when viewing
|
||||
# a file ending with '.py' or '.pyw'
|
||||
# syntax_files Python '\.pyw?$'
|
||||
elif args[0] == u'syntax_files' and (len(args) == 2 or len(args) == 3):
|
||||
elif args[0] == 'syntax_files' and (len(args) == 2 or len(args) == 3):
|
||||
key = args[1]
|
||||
if len(args) == 2:
|
||||
# remove file pattern for a syntax specification
|
||||
|
@ -693,7 +693,7 @@ class Resources:
|
|||
# eg. default to the Python syntax rules when viewing
|
||||
# a files starting with patterns like #!/usr/bin/python
|
||||
# syntax_magic Python '^#!/usr/bin/python$'
|
||||
elif args[0] == u'syntax_magic' and len(args) > 1:
|
||||
elif args[0] == 'syntax_magic' and len(args) > 1:
|
||||
key = args[1]
|
||||
if len(args) == 2:
|
||||
# remove magic pattern for a syntax specification
|
||||
|
@ -704,7 +704,7 @@ class Resources:
|
|||
else:
|
||||
flags = 0
|
||||
for arg in args[3:]:
|
||||
if arg == u'ignorecase':
|
||||
if arg == 'ignorecase':
|
||||
flags |= re.IGNORECASE
|
||||
else:
|
||||
raise ValueError()
|
||||
|
@ -1138,7 +1138,7 @@ class Preferences:
|
|||
return str(s, encoding=encoding), encoding
|
||||
except (UnicodeDecodeError, LookupError):
|
||||
pass
|
||||
return u''.join([ chr(ord(c)) for c in s ]), None
|
||||
return ''.join([ chr(ord(c)) for c in s ]), None
|
||||
|
||||
# cygwin and native applications can be used on windows, use this method
|
||||
# to convert a path to the usual form expected on sys.platform
|
||||
|
@ -2396,14 +2396,14 @@ class _Svn:
|
|||
# FIXME: verify this
|
||||
# merge conflict
|
||||
escaped_name = globEscape(name)
|
||||
left = glob.glob(escaped_name + u'.merge-left.r*')
|
||||
right = glob.glob(escaped_name + u'.merge-right.r*')
|
||||
left = glob.glob(escaped_name + '.merge-left.r*')
|
||||
right = glob.glob(escaped_name + '.merge-right.r*')
|
||||
if len(left) > 0 and len(right) > 0:
|
||||
return [ (left[-1], None), (name, None), (right[-1], None) ]
|
||||
# update conflict
|
||||
left = sorted(glob.glob(escaped_name + u'.r*'))
|
||||
right = glob.glob(escaped_name + u'.mine')
|
||||
right.extend(glob.glob(escaped_name + u'.working'))
|
||||
left = sorted(glob.glob(escaped_name + '.r*'))
|
||||
right = glob.glob(escaped_name + '.mine')
|
||||
right.extend(glob.glob(escaped_name + '.working'))
|
||||
if len(left) > 0 and len(right) > 0:
|
||||
return [ (left[-1], None), (name, None), (right[0], None) ]
|
||||
# default case
|
||||
|
@ -2936,7 +2936,7 @@ OTHER_CLASS = 2
|
|||
|
||||
# maps similar types of characters to a group
|
||||
def getCharacterClass(c):
|
||||
if c.isalnum() or c == u'_':
|
||||
if c.isalnum() or c == '_':
|
||||
return ALPHANUMERIC_CLASS
|
||||
elif c.isspace():
|
||||
return WHITESPACE_CLASS
|
||||
|
@ -3471,22 +3471,22 @@ class FileDiffViewer(Gtk.Grid):
|
|||
if c == ' ':
|
||||
if visible:
|
||||
# show spaces using a centre-dot
|
||||
result.append(u'\u00b7')
|
||||
result.append('\u00b7')
|
||||
else:
|
||||
result.append(c)
|
||||
elif c == '\t':
|
||||
width = tab_width - col % tab_width
|
||||
if visible:
|
||||
# show tabs using a right double angle quote
|
||||
result.append(u'\u00bb' + (width - 1) * u' ')
|
||||
result.append('\u00bb' + (width - 1) * ' ')
|
||||
else:
|
||||
result.append(width * u' ')
|
||||
result.append(width * ' ')
|
||||
elif c == '\n' and visible:
|
||||
# show newlines using a pilcrow
|
||||
result.append(u'\u00b6')
|
||||
result.append('\u00b6')
|
||||
else:
|
||||
# prefix with a ^
|
||||
result.append(u'^' + chr(v + 64))
|
||||
result.append('^' + chr(v + 64))
|
||||
else:
|
||||
result.append(c)
|
||||
col += self.characterWidth(col, c)
|
||||
|
@ -5704,10 +5704,10 @@ class FileDiffViewer(Gtk.Grid):
|
|||
width = self.prefs.getInt('editor_soft_tab_width')
|
||||
w = (w - 1) // width * width
|
||||
if self.prefs.getBool('editor_expand_tabs'):
|
||||
s = u' ' * w
|
||||
s = ' ' * w
|
||||
else:
|
||||
width = self.prefs.getInt('display_tab_width')
|
||||
s = u'\t' * (w // width) + u' ' * (w % width)
|
||||
s = '\t' * (w // width) + ' ' * (w % width)
|
||||
j = 0
|
||||
else:
|
||||
# delete back to an end of line character from the
|
||||
|
@ -5788,10 +5788,10 @@ class FileDiffViewer(Gtk.Grid):
|
|||
ws = max(0, w + offset * self.prefs.getInt('editor_soft_tab_width'))
|
||||
if ws != w:
|
||||
if self.prefs.getBool('editor_expand_tabs'):
|
||||
s = u' ' * ws
|
||||
s = ' ' * ws
|
||||
else:
|
||||
tab_width = self.prefs.getInt('display_tab_width')
|
||||
s = u'\t' * (ws // tab_width) + u' ' * (ws % tab_width)
|
||||
s = '\t' * (ws // tab_width) + ' ' * (ws % tab_width)
|
||||
if i == start_i:
|
||||
start_j = len(s) + max(0, start_j - j)
|
||||
if i == end_i:
|
||||
|
@ -5827,11 +5827,11 @@ class FileDiffViewer(Gtk.Grid):
|
|||
w = 0
|
||||
if self.prefs.getBool('editor_expand_tabs'):
|
||||
# convert to spaces
|
||||
s = u' ' * ws
|
||||
s = ' ' * ws
|
||||
else:
|
||||
# replace with tab characters where possible
|
||||
s = u'\t' * ((w + ws) // tab_width - w // tab_width)
|
||||
s += u' ' * ((w + ws) % tab_width)
|
||||
s = '\t' * ((w + ws) // tab_width - w // tab_width)
|
||||
s += ' ' * ((w + ws) % tab_width)
|
||||
self.replaceText(s)
|
||||
# handle all other printable characters
|
||||
elif len(event.string) > 0:
|
||||
|
@ -6340,7 +6340,7 @@ class FileDiffViewer(Gtk.Grid):
|
|||
w = self.characterWidth(col, c)
|
||||
# replace tab with spaces
|
||||
if c == '\t':
|
||||
c = w * u' '
|
||||
c = w * ' '
|
||||
ss.append(c)
|
||||
col += w
|
||||
# determine the range of interest
|
||||
|
@ -6388,7 +6388,7 @@ class FileDiffViewer(Gtk.Grid):
|
|||
j += 1
|
||||
if col >= tab_width:
|
||||
# convert to tabs
|
||||
s = ''.join([ u'\t' * (col // tab_width), u' ' * (col % tab_width), text[j:] ])
|
||||
s = ''.join([ '\t' * (col // tab_width), ' ' * (col % tab_width), text[j:] ])
|
||||
# update line only if it changed
|
||||
if text != s:
|
||||
self.updateText(f, i, s)
|
||||
|
@ -6420,10 +6420,10 @@ class FileDiffViewer(Gtk.Grid):
|
|||
ws = max(0, w + offset * self.prefs.getInt('editor_soft_tab_width'))
|
||||
if ws != w:
|
||||
if self.prefs.getBool('editor_expand_tabs'):
|
||||
s = u' ' * ws
|
||||
s = ' ' * ws
|
||||
else:
|
||||
tab_width = self.prefs.getInt('display_tab_width')
|
||||
s = u'\t' * (ws // tab_width) + u' ' * (ws % tab_width)
|
||||
s = '\t' * (ws // tab_width) + ' ' * (ws % tab_width)
|
||||
self.updateText(f, i, s + text[j:])
|
||||
if self.mode == CHAR_MODE:
|
||||
# ensure the cursor position is valid
|
||||
|
@ -7266,7 +7266,7 @@ class Diffuse(Gtk.Window):
|
|||
s = line.getText()
|
||||
if s is not None:
|
||||
ss.append(s)
|
||||
encoded = codecs.encode(u''.join(ss), encoding)
|
||||
encoded = codecs.encode(''.join(ss), encoding)
|
||||
|
||||
# write file
|
||||
fd = open(name, 'wb')
|
||||
|
@ -8321,16 +8321,16 @@ def make_subdirs(p, ss):
|
|||
# process the command line arguments
|
||||
if __name__ == '__main__':
|
||||
# find the config directory and create it if it didn't exist
|
||||
rc_dir, subdirs = os.environ.get('XDG_CONFIG_HOME', None), [u'diffuse']
|
||||
rc_dir, subdirs = os.environ.get('XDG_CONFIG_HOME', None), ['diffuse']
|
||||
if rc_dir is None:
|
||||
rc_dir = os.path.expanduser(u'~')
|
||||
subdirs.insert(0, u'.config')
|
||||
rc_dir = os.path.expanduser('~')
|
||||
subdirs.insert(0, '.config')
|
||||
rc_dir = make_subdirs(rc_dir, subdirs)
|
||||
# find the local data directory and create it if it didn't exist
|
||||
data_dir, subdirs = os.environ.get('XDG_DATA_HOME', None), [u'diffuse']
|
||||
data_dir, subdirs = os.environ.get('XDG_DATA_HOME', None), ['diffuse']
|
||||
if data_dir is None:
|
||||
data_dir = os.path.expanduser(u'~')
|
||||
subdirs[:0] = [ u'.local', u'share' ]
|
||||
data_dir = os.path.expanduser('~')
|
||||
subdirs[:0] = [ '.local', 'share' ]
|
||||
data_dir = make_subdirs(data_dir, subdirs)
|
||||
# load resource files
|
||||
i, rc_files = 1, []
|
||||
|
@ -8343,10 +8343,10 @@ if __name__ == '__main__':
|
|||
else:
|
||||
# parse system wide then personal initialisation files
|
||||
if isWindows():
|
||||
rc_file = os.path.join(bin_dir, u'diffuserc')
|
||||
rc_file = os.path.join(bin_dir, 'diffuserc')
|
||||
else:
|
||||
rc_file = os.path.join(bin_dir, u'../../etc/diffuserc')
|
||||
for rc_file in rc_file, os.path.join(rc_dir, u'diffuserc'):
|
||||
rc_file = os.path.join(bin_dir, '../../etc/diffuserc')
|
||||
for rc_file in rc_file, os.path.join(rc_dir, 'diffuserc'):
|
||||
if os.path.isfile(rc_file):
|
||||
rc_files.append(rc_file)
|
||||
for rc_file in rc_files:
|
||||
|
|
Loading…
Reference in New Issue