mirror of
https://github.com/powerline/powerline.git
synced 2025-04-08 19:25:04 +02:00
Fix style in a number of places
- Fixes lines where line with N tab indent is followed by a line with N+2 tab indent or greater (most of such lines were already fixed in ae92d83eae5142322ff20b9aa81eb53b0b363575, but regex used there has one flow: it does not catches lines where N=0 for which case first `\+` needs to be replaced with `*`). - Replace print(…, file=sys.stderr) with sys.stderr.write in powerline-daemon.
This commit is contained in:
parent
a2b58370c4
commit
0e98bc2d4f
@ -213,13 +213,17 @@ class INotifyTreeWatcher(INotify):
|
||||
|
||||
def add_watch(self, path):
|
||||
bpath = path if isinstance(path, bytes) else path.encode(self.fenc)
|
||||
wd = self._add_watch(self._inotify_fd, ctypes.c_char_p(bpath),
|
||||
# Ignore symlinks and watch only directories
|
||||
self.DONT_FOLLOW | self.ONLYDIR |
|
||||
wd = self._add_watch(
|
||||
self._inotify_fd,
|
||||
ctypes.c_char_p(bpath),
|
||||
|
||||
self.MODIFY | self.CREATE | self.DELETE |
|
||||
self.MOVE_SELF | self.MOVED_FROM | self.MOVED_TO |
|
||||
self.ATTRIB | self.DELETE_SELF)
|
||||
# Ignore symlinks and watch only directories
|
||||
self.DONT_FOLLOW | self.ONLYDIR |
|
||||
|
||||
self.MODIFY | self.CREATE | self.DELETE |
|
||||
self.MOVE_SELF | self.MOVED_FROM | self.MOVED_TO |
|
||||
self.ATTRIB | self.DELETE_SELF
|
||||
)
|
||||
if wd == -1:
|
||||
eno = ctypes.get_errno()
|
||||
if eno == errno.ENOTDIR:
|
||||
|
@ -560,8 +560,8 @@ def check_top_theme(theme, data, context, echoerr):
|
||||
return True, False, False
|
||||
|
||||
|
||||
divider_spec = Spec().type(unicode).len('le', 3,
|
||||
lambda value: 'Divider {0!r} is too large!'.format(value)).copy
|
||||
divider_spec = Spec().type(unicode).len(
|
||||
'le', 3, (lambda value: 'Divider {0!r} is too large!'.format(value))).copy
|
||||
ext_theme_spec = Spec().type(unicode).func(lambda *args: check_config('themes', *args)).copy
|
||||
top_theme_spec = Spec().type(unicode).func(check_top_theme).copy
|
||||
ext_spec = Spec(
|
||||
|
@ -264,32 +264,25 @@ class Constructor(BaseConstructor):
|
||||
|
||||
|
||||
Constructor.add_constructor(
|
||||
'tag:yaml.org,2002:null',
|
||||
Constructor.construct_yaml_null)
|
||||
'tag:yaml.org,2002:null', Constructor.construct_yaml_null)
|
||||
|
||||
Constructor.add_constructor(
|
||||
'tag:yaml.org,2002:bool',
|
||||
Constructor.construct_yaml_bool)
|
||||
'tag:yaml.org,2002:bool', Constructor.construct_yaml_bool)
|
||||
|
||||
Constructor.add_constructor(
|
||||
'tag:yaml.org,2002:int',
|
||||
Constructor.construct_yaml_int)
|
||||
'tag:yaml.org,2002:int', Constructor.construct_yaml_int)
|
||||
|
||||
Constructor.add_constructor(
|
||||
'tag:yaml.org,2002:float',
|
||||
Constructor.construct_yaml_float)
|
||||
'tag:yaml.org,2002:float', Constructor.construct_yaml_float)
|
||||
|
||||
Constructor.add_constructor(
|
||||
'tag:yaml.org,2002:str',
|
||||
Constructor.construct_yaml_str)
|
||||
'tag:yaml.org,2002:str', Constructor.construct_yaml_str)
|
||||
|
||||
Constructor.add_constructor(
|
||||
'tag:yaml.org,2002:seq',
|
||||
Constructor.construct_yaml_seq)
|
||||
'tag:yaml.org,2002:seq', Constructor.construct_yaml_seq)
|
||||
|
||||
Constructor.add_constructor(
|
||||
'tag:yaml.org,2002:map',
|
||||
Constructor.construct_yaml_map)
|
||||
'tag:yaml.org,2002:map', Constructor.construct_yaml_map)
|
||||
|
||||
Constructor.add_constructor(None,
|
||||
Constructor.construct_undefined)
|
||||
Constructor.add_constructor(
|
||||
None, Constructor.construct_undefined)
|
||||
|
@ -110,21 +110,21 @@ class Resolver(BaseResolver):
|
||||
|
||||
|
||||
Resolver.add_implicit_resolver(
|
||||
'tag:yaml.org,2002:bool',
|
||||
re.compile(r'''^(?:true|false)$''', re.X),
|
||||
list('yYnNtTfFoO'))
|
||||
'tag:yaml.org,2002:bool',
|
||||
re.compile(r'''^(?:true|false)$''', re.X),
|
||||
list('yYnNtTfFoO'))
|
||||
|
||||
Resolver.add_implicit_resolver(
|
||||
'tag:yaml.org,2002:float',
|
||||
re.compile(r'^-?(?:0|[1-9]\d*)(?=[.eE])(?:\.\d+)?(?:[eE][-+]?\d+)?$', re.X),
|
||||
list('-0123456789'))
|
||||
'tag:yaml.org,2002:float',
|
||||
re.compile(r'^-?(?:0|[1-9]\d*)(?=[.eE])(?:\.\d+)?(?:[eE][-+]?\d+)?$', re.X),
|
||||
list('-0123456789'))
|
||||
|
||||
Resolver.add_implicit_resolver(
|
||||
'tag:yaml.org,2002:int',
|
||||
re.compile(r'^(?:0|-?[1-9]\d*)$', re.X),
|
||||
list('-0123456789'))
|
||||
'tag:yaml.org,2002:int',
|
||||
re.compile(r'^(?:0|-?[1-9]\d*)$', re.X),
|
||||
list('-0123456789'))
|
||||
|
||||
Resolver.add_implicit_resolver(
|
||||
'tag:yaml.org,2002:null',
|
||||
re.compile(r'^null$', re.X),
|
||||
['n'])
|
||||
'tag:yaml.org,2002:null',
|
||||
re.compile(r'^null$', re.X),
|
||||
['n'])
|
||||
|
@ -246,7 +246,7 @@ def daemonize(stdin=os.devnull, stdout=os.devnull, stderr=os.devnull):
|
||||
# exit first parent
|
||||
sys.exit(0)
|
||||
except OSError as e:
|
||||
print ("fork #1 failed: %d (%s)" % (e.errno, e.strerror), file=sys.stderr)
|
||||
sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror))
|
||||
sys.exit(1)
|
||||
|
||||
# decouple from parent environment
|
||||
@ -261,7 +261,7 @@ def daemonize(stdin=os.devnull, stdout=os.devnull, stderr=os.devnull):
|
||||
# exit from second parent
|
||||
sys.exit(0)
|
||||
except OSError as e:
|
||||
print ("fork #2 failed: %d (%s)" % (e.errno, e.strerror), file=sys.stderr)
|
||||
sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror))
|
||||
sys.exit(1)
|
||||
|
||||
# Redirect standard file descriptors.
|
||||
@ -399,16 +399,18 @@ def main():
|
||||
# Create a locked pid file containing the daemon's PID
|
||||
if lockpidfile() is None:
|
||||
if not args.quiet:
|
||||
print ('The daemon is already running. Use %s -k to kill it.' % os.path.basename(sys.argv[0]),
|
||||
file=sys.stderr)
|
||||
sys.stderr.write(
|
||||
'The daemon is already running. Use %s -k to kill it.\n' % (
|
||||
os.path.basename(sys.argv[0])))
|
||||
raise SystemExit(1)
|
||||
|
||||
# Bind to address or bail if we cannot bind
|
||||
sock = check_existing()
|
||||
if sock is None:
|
||||
if not args.quiet:
|
||||
print ('The daemon is already running. Use %s -k to kill it.' % os.path.basename(sys.argv[0]),
|
||||
file=sys.stderr)
|
||||
sys.stderr.write(
|
||||
'The daemon is already running. Use %s -k to kill it.\n' % (
|
||||
os.path.basename(sys.argv[0])))
|
||||
raise SystemExit(1)
|
||||
|
||||
if args.foreground:
|
||||
|
Loading…
x
Reference in New Issue
Block a user