Skip to content

Commit af32280

Browse files
committed
Merge pull request #149 from tony/cleanup_early2016
2016 Spring Cleaning
2 parents 8583eed + 0fbe0ed commit af32280

33 files changed

+396
-403
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ build_docs:
99

1010
watch_docs:
1111
cd doc && $(MAKE) watch_docs
12+
13+
flake8:
14+
flake8 tmuxp
15+
16+
watch_flake8:
17+
if command -v entr > /dev/null; then find . -type f -not -path '*/\.*' | grep -i '.*[.][py]' | entr -c make flake8; else make flake8; echo "\nInstall entr(1) to automatically run tests on file change.\n See http://entrproject.org/"; fi
18+
19+
.PHONY: flake8

bootstrap_env.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/usr/bin/env python
22

3-
from __future__ import (
4-
absolute_import, division, print_function, with_statement, unicode_literals
5-
)
3+
from __future__ import (absolute_import, division, print_function,
4+
unicode_literals, with_statement)
65

76
import os
8-
import sys
9-
import subprocess
107
import platform
8+
import subprocess
9+
import sys
1110

1211

1312
def warning(*objs):

doc/_ext/aafig.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@
1414

1515
import posixpath
1616
from os import path
17+
18+
from docutils import nodes
19+
from docutils.parsers.rst.directives import flag, images, nonnegative_int
20+
from sphinx.errors import SphinxError
21+
from sphinx.util import ensuredir, relative_uri
22+
from sphinx.util.compat import Directive
23+
1724
try:
1825
from hashlib import sha1 as sha
1926
except ImportError:
2027
from sha import sha
2128

22-
from docutils import nodes
23-
from docutils.parsers.rst.directives import images, nonnegative_int, flag
2429

25-
from sphinx.errors import SphinxError
26-
from sphinx.util import ensuredir, relative_uri
27-
from sphinx.util.compat import Directive
2830

2931
try:
3032
import aafigure
@@ -92,7 +94,7 @@ def run(self):
9294
if isinstance(image_node, nodes.system_message):
9395
return [image_node]
9496
text = '\n'.join(self.content)
95-
image_node.aafig = dict(options = aafig_options, text = text)
97+
image_node.aafig = dict(options = aafig_options, text = text)
9698
return [image_node]
9799

98100

@@ -187,7 +189,7 @@ def render_aafigure(app, text, options):
187189

188190
try:
189191
(visitor, output) = aafigure.render(text, outfn, options)
190-
output.close()
192+
output.close()
191193
except aafigure.UnsupportedFormatError, e:
192194
raise AafigError(str(e))
193195

run-tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
# -*- coding: utf-8 -*-
33

44
from tmuxp.testsuite import main
5+
56
main()

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
exclude = .tox,*.egg,tmuxp/_compat.py,tmuxp/__*__.py,
3+
select = E,W,F,N

tmuxp/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
~~~~~
66
77
"""
8-
from __future__ import absolute_import, division, print_function, \
9-
with_statement, unicode_literals
8+
from __future__ import (absolute_import, division, print_function,
9+
unicode_literals, with_statement)
1010

1111
import os
1212
import sys
@@ -20,6 +20,6 @@ def run():
2020
tmuxp.cli.main()
2121

2222
if __name__ == '__main__':
23-
exit = run()
23+
_exit = run()
2424
if exit:
25-
sys.exit(exit)
25+
sys.exit(_exit)

tmuxp/cli.py

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
~~~~~~~~~
66
77
"""
8-
from __future__ import absolute_import, division, print_function, \
9-
with_statement, unicode_literals
8+
from __future__ import (absolute_import, division, print_function,
9+
unicode_literals, with_statement)
1010

1111
import argparse
1212
import logging
@@ -16,12 +16,11 @@
1616
import argcomplete
1717
import kaptan
1818

19-
from . import log, util, exc, WorkspaceBuilder, Server, config
19+
from . import Server, WorkspaceBuilder, config, exc, log, util
2020
from .__about__ import __version__
2121
from ._compat import input, string_types
2222
from .workspacebuilder import freeze
2323

24-
2524
logger = logging.getLogger(__name__)
2625

2726
config_dir = os.path.expanduser('~/.tmuxp/')
@@ -46,10 +45,10 @@ def prompt(name, default=None):
4645
4746
"""
4847

49-
prompt = name + (default and ' [%s]' % default or '')
50-
prompt += name.endswith('?') and ' ' or ': '
48+
_prompt = name + (default and ' [%s]' % default or '')
49+
_prompt += name.endswith('?') and ' ' or ': '
5150
while True:
52-
rv = input(prompt)
51+
rv = input(_prompt)
5352
if rv:
5453
return rv
5554
if default is not None:
@@ -77,11 +76,11 @@ def prompt_bool(name, default=False, yes_choices=None, no_choices=None):
7776
else:
7877
prompt_choice = 'y/N'
7978

80-
prompt = name + ' [%s]' % prompt_choice
81-
prompt += name.endswith('?') and ' ' or ': '
79+
_prompt = name + ' [%s]' % prompt_choice
80+
_prompt += name.endswith('?') and ' ' or ': '
8281

8382
while True:
84-
rv = input(prompt)
83+
rv = input(_prompt)
8584
if not rv:
8685
return default
8786
if rv.lower() in yes_choices:
@@ -261,7 +260,7 @@ def load_workspace(config_file, args):
261260
logger.error('%s is empty or parsed no config data' % config_file)
262261
return
263262

264-
tmux_bin = util.which('tmux')
263+
util.which('tmux')
265264

266265
try:
267266
logger.info('Loading %s.' % config_file)
@@ -576,11 +575,12 @@ def command_import_tmuxinator(args):
576575
else:
577576
sys.exit('Unknown config format.')
578577

579-
print(newconfig)
580-
print(
581-
'---------------------------------------------------------------')
582578
print(
583-
'Configuration import does its best to convert tmuxinator files.\n')
579+
newconfig,
580+
'---------------------------------------------------------------'
581+
'Configuration import does its best to convert tmuxinator files.'
582+
'\n'
583+
)
584584
if args.answer_yes or prompt_yes_no(
585585
'The new config *WILL* require adjusting afterwards. Save config?'
586586
):
@@ -633,7 +633,7 @@ def command_convert(args):
633633

634634
if 'json' in ext:
635635
if args.answer_yes or prompt_yes_no(
636-
'convert to <%s> to yaml?' % (fullfile)
636+
'convert to <%s> to yaml?' % fullfile
637637
):
638638
configparser = kaptan.Kaptan()
639639
configparser.import_config(configfile)
@@ -642,33 +642,32 @@ def command_convert(args):
642642
'yaml', indent=2, default_flow_style=False
643643
)
644644
if args.answer_yes or prompt_yes_no(
645-
'Save config to %s?' % (newfile)
645+
'Save config to %s?' % newfile
646646
):
647647
buf = open(newfile, 'w')
648648
buf.write(newconfig)
649649
buf.close()
650-
print('New config saved to %s' % (newfile))
650+
print('New config saved to %s' % newfile)
651651
elif 'yaml' in ext:
652652
if args.answer_yes or prompt_yes_no(
653-
'convert to <%s> to json?' % (fullfile)
653+
'convert to <%s> to json?' % fullfile
654654
):
655655
configparser = kaptan.Kaptan()
656656
configparser.import_config(configfile)
657657
newfile = fullfile.replace(ext, '.json')
658658
newconfig = configparser.export('json', indent=2)
659659
print(newconfig)
660660
if args.answer_yes or prompt_yes_no(
661-
'Save config to <%s>?' % (newfile)
661+
'Save config to <%s>?' % newfile
662662
):
663663
buf = open(newfile, 'w')
664664
buf.write(newconfig)
665665
buf.close()
666-
print('New config saved to <%s>.' % (newfile))
666+
print('New config saved to <%s>.' % newfile)
667667

668668

669669
def command_attach_session(args):
670670
"""Command to attach / switch client to a tmux session."""
671-
commands = []
672671
ctext = ' '.join(args.session_name)
673672

674673
t = Server(
@@ -697,7 +696,6 @@ def command_attach_session(args):
697696

698697
def command_kill_session(args):
699698
"""Command to kill a tmux session."""
700-
commands = []
701699
ctext = ' '.join(args.session_name)
702700

703701
t = Server(
@@ -898,7 +896,7 @@ def get_parser():
898896
help='''\
899897
Checks current ~/.teamocil and current directory for yaml files.
900898
'''
901-
).completer = TeamocilCompleter(allowednames=('.yml'), directories=False)
899+
).completer = TeamocilCompleter(allowednames='.yml', directories=False)
902900
import_teamocil.set_defaults(callback=command_import_teamocil)
903901

904902
import_tmuxinator = importsubparser.add_parser(
@@ -910,7 +908,9 @@ def get_parser():
910908
required=True)
911909
import_tmuxinatorgroup.add_argument(
912910
'--list', dest='list', action='store_true',
913-
help='List yaml configs in ~/.tmuxinator and current working directory.'
911+
help=(
912+
'List yaml configs in ~/.tmuxinator and current working directory.'
913+
)
914914
)
915915

916916
import_tmuxinatorgroup.add_argument(
@@ -920,14 +920,16 @@ def get_parser():
920920
help='''\
921921
Checks current ~/.tmuxinator and current directory for yaml files.
922922
'''
923-
).completer = TmuxinatorCompleter(allowednames=('.yml'), directories=False)
923+
).completer = TmuxinatorCompleter(allowednames='.yml', directories=False)
924924

925925
import_tmuxinator.set_defaults(callback=command_import_tmuxinator)
926926

927927
parser.add_argument(
928928
'--log-level', dest='log_level',
929929
default=None,
930-
help='Level of debug verbosity. DEBUG, INFO, WARNING, ERROR, CRITICAL.',
930+
help=(
931+
'Level of debug verbosity. DEBUG, INFO, WARNING, ERROR, CRITICAL.',
932+
)
931933
)
932934

933935
parser.add_argument(
@@ -964,7 +966,7 @@ def main():
964966

965967
util.oh_my_zsh_auto_title()
966968

967-
t = Server(
969+
t = Server( # noqa
968970
socket_name=args.socket_name,
969971
socket_path=args.socket_path,
970972
colors=args.colors

tmuxp/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class EnvironmentMixin(object):
1010

1111
def __init__(self, add_option=None):
1212
self._add_option = add_option
13-
13+
1414
def set_environment(self, name, value):
1515
"""Set environment ``$ tmux set-environment <name> <value>``.
1616
@@ -26,7 +26,7 @@ def set_environment(self, name, value):
2626
args += [self._add_option]
2727

2828
args += [name, value]
29-
29+
3030
proc = self.cmd(*args)
3131

3232
if proc.stderr:
@@ -45,7 +45,7 @@ def unset_environment(self, name):
4545
if self._add_option:
4646
args += [self._add_option]
4747
args += ['-u', name]
48-
48+
4949
proc = self.cmd(*args)
5050

5151
if proc.stderr:
@@ -64,7 +64,7 @@ def remove_environment(self, name):
6464
if self._add_option:
6565
args += [self._add_option]
6666
args += ['-r', name]
67-
67+
6868
proc = self.cmd(*args)
6969

7070
if proc.stderr:

0 commit comments

Comments
 (0)