Skip to content

Commit

Permalink
further PEP8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
David Marin committed Mar 17, 2015
1 parent 65450b3 commit 2110910
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion mrjob/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def translate_jobconf(variable, version):
"""Translate *variable* to Hadoop version *version*. If it's not
a variable we recognize, leave as-is.
"""
if not variable in _JOBCONF_MAP:
if variable not in _JOBCONF_MAP:
return variable

req_version = LooseVersion(version)
Expand Down
10 changes: 5 additions & 5 deletions mrjob/emr.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ def __init__(self, **kwargs):
if isinstance(maybe_path_dict, dict):
self._bootstrap_dir_mgr.add(**maybe_path_dict)

if not (isinstance(self._opts['additional_emr_info'], basestring)
or self._opts['additional_emr_info'] is None):
if not (isinstance(self._opts['additional_emr_info'], basestring) or
self._opts['additional_emr_info'] is None):
self._opts['additional_emr_info'] = json.dumps(
self._opts['additional_emr_info'])

Expand Down Expand Up @@ -1280,7 +1280,7 @@ def _job_flow_args(self, persistent=False, steps=None):
args['additional_info'] = self._opts['additional_emr_info']

if (self._opts['visible_to_all_users'] and
not 'VisibleToAllUsers' in self._opts['emr_api_params']): # noqa
'VisibleToAllUsers' not in self._opts['emr_api_params']): # noqa

self._opts['emr_api_params']['VisibleToAllUsers'] = (
'true' if self._opts['visible_to_all_users'] else 'false')
Expand Down Expand Up @@ -1902,8 +1902,8 @@ def _create_master_bootstrap_script_if_needed(self):

# Also don't bother if we're not bootstrapping
if not (self._bootstrap or self._legacy_bootstrap or
self._opts['bootstrap_files']
or self._opts['bootstrap_mrjob']):
self._opts['bootstrap_files'] or
self._opts['bootstrap_mrjob']):
return

# create mrjob.tar.gz if we need it, and add commands to install it
Expand Down
11 changes: 6 additions & 5 deletions mrjob/hadoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,12 @@ def _enforce_path_regexp(self, paths, regexp, step_nums):
"""
for path in paths:
m = regexp.match(path)
if (m
and (step_nums is None or
int(m.group('step_num')) in step_nums)
and (self._job_timestamp is None or
m.group('timestamp') == self._job_timestamp)):
if (m and
(step_nums is None or
int(m.group('step_num')) in step_nums) and
(self._job_timestamp is None or
m.group('timestamp') == self._job_timestamp)):

yield path

def _ls_logs(self, relative_path):
Expand Down
4 changes: 2 additions & 2 deletions mrjob/inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
"""Run an MRJob inline by running all mappers and reducers through the same
process. Useful for debugging."""
__author__ = 'Matthew Tai <mtai@adku.com>'

import logging
import os

Expand All @@ -35,6 +33,8 @@

log = logging.getLogger(__name__)

__author__ = 'Matthew Tai <mtai@adku.com>'

# Deprecated in favor of class variables, remove in v0.5.0
DEFAULT_MAP_TASKS = 1
DEFAULT_REDUCE_TASKS = 1
Expand Down
6 changes: 3 additions & 3 deletions mrjob/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def configure_options(self):
raise OptionError(
'passthrough file options must take strings' % pass_opt.type)

if not pass_opt.action in ('store', 'append'):
if pass_opt.action not in ('store', 'append'):
raise OptionError("passthrough file options must use the options"
" 'store' or 'append'")

Expand Down Expand Up @@ -461,8 +461,8 @@ def load_options(self, args):
self.options.emr_api_params[param] = None

def parse_commas(cleanup_str):
cleanup_error = ('cleanup option %s is not one of '
+ ', '.join(CLEANUP_CHOICES))
cleanup_error = ('cleanup option %s is not one of ' +
', '.join(CLEANUP_CHOICES))
new_cleanup_options = []
for choice in cleanup_str.split(','):
if choice in CLEANUP_CHOICES:
Expand Down
5 changes: 3 additions & 2 deletions mrjob/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ def parse_s3_uri(uri):
If ``uri`` is not an S3 URI, raise a ValueError
"""
components = urlparse(uri)
if (components.scheme not in ('s3', 's3n')
or '/' not in components.path):
if (components.scheme not in ('s3', 's3n') or
'/' not in components.path): # noqa

raise ValueError('Invalid S3 URI: %s' % uri)

return components.netloc, components.path[1:]
Expand Down
12 changes: 6 additions & 6 deletions mrjob/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ def parse_setup_cmd(cmd):
tokens = []

for m in SETUP_CMD_RE.finditer(cmd):
keep_as_is = (m.group('single_quoted')
or m.group('double_quoted')
or m.group('unquoted')
or m.group('whitespace')
or m.group('colon_or_equals'))
keep_as_is = (m.group('single_quoted') or
m.group('double_quoted') or
m.group('unquoted') or
m.group('whitespace') or
m.group('colon_or_equals'))

if keep_as_is:
if tokens and isinstance(tokens[-1], basestring):
Expand Down Expand Up @@ -428,7 +428,7 @@ def _check_name(self, name):
raise ValueError('names may not contain slashes: %r' % (name,))

def _check_type(self, type):
if not type in self._SUPPORTED_TYPES:
if type not in self._SUPPORTED_TYPES:
raise ValueError('bad path type %r, must be one of %s' % (
type, ', '.join(sorted(self._SUPPORTED_TYPES))))

Expand Down
2 changes: 1 addition & 1 deletion mrjob/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def reducer_key(line):

file_names[outfile_name]['length'] = bytes_written
finally:
if not outfile is None:
if outfile is not None:
outfile.close()

return file_names
Expand Down
5 changes: 3 additions & 2 deletions mrjob/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ def _ssh_args(ssh_bin, address, ec2_key_pair_file):

def check_output(out, err):
if err:
if (('No such file or directory' in err)
or ('Warning: Permanently added' not in err)):
if ('No such file or directory' in err or
'Warning: Permanently added' not in err): # noqa

raise IOError(err)

if 'Permission denied' in out:
Expand Down

0 comments on commit 2110910

Please sign in to comment.