extras: pylint fixes
[git-cola.git] / extras / build_util.py
blob7586335d147c28055c532be56670f576e873eb61
1 from __future__ import absolute_import, division, print_function, unicode_literals
2 import os
3 try:
4 from shutil import which # pylint: disable=unused-import
5 except ImportError:
6 from distutils.spawn import find_executable as which # pylint: disable=unused-import
9 def encode(string):
10 try:
11 result = string.encode('utf-8')
12 except (ValueError, UnicodeEncodeError):
13 result = string
14 return result
17 def make_string(x):
18 if x:
19 x = str(x)
20 return x
23 def stringify_options(items):
24 return [[make_string(x) for x in i] for i in items]
27 def stringify_list(items):
28 return [make_string(i) for i in items]
31 def newer(a, b):
32 """Return True if a is newer than b"""
33 try:
34 stat_a = os.stat(a)
35 stat_b = os.stat(b)
36 except OSError:
37 return True
38 return stat_a.st_mtime >= stat_b.st_mtime