Skip to content

Commit 5283e77

Browse files
committed
Pylint improvements
1 parent 09a8cdc commit 5283e77

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

mbed/mbed.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ def clone(url, path=None, depth=None, protocol=None):
237237
m = Bld.isurl(url)
238238
if not m:
239239
raise ProcessException(1, "Not an mbed library build URL")
240-
return False
241240

242241
try:
243242
Bld.init(path, url+'/tip')
@@ -286,7 +285,6 @@ def checkout(rev):
286285
m = Bld.isurl(url)
287286
if not m:
288287
raise ProcessException(1, "Not an mbed library build URL")
289-
return False
290288

291289
log("Checkout \"%s\" in %s" % (rev, os.path.basename(os.getcwd())))
292290
arch_url = m.group(1) + '/archive/' + rev + '.zip'
@@ -311,7 +309,10 @@ def update(rev=None, clean=False, is_local=False):
311309
log("Cleaning up library build folder")
312310
for fl in os.listdir('.'):
313311
if not fl.startswith('.'):
314-
os.remove(fl) if os.path.isfile(fl) else shutil.rmtree(fl)
312+
if os.path.isfile(fl):
313+
os.remove(fl)
314+
else:
315+
shutil.rmtree(fl)
315316
return Bld.checkout(rev)
316317

317318
def status():
@@ -339,7 +340,7 @@ def seturl(url):
339340
f.write(url)
340341
except IOError:
341342
error("Unable to write bldrc file in \"%s\"" % fl, 1)
342-
343+
343344
def geturl():
344345
with open(os.path.join('.bld', 'bldrc')) as f:
345346
url = f.read().strip()
@@ -1070,15 +1071,18 @@ def __init__(self, path=None, print_warning=False):
10701071
err = (
10711072
"Could not find mbed program in current path. Assuming current dir.\n"
10721073
"You can fix this by calling \"mbed new .\" in the root dir of your program")
1073-
warning(err) if print_warning else error(err, 1)
1074+
if print_warning:
1075+
warning(err)
1076+
else:
1077+
error(err, 1)
10741078

10751079
# Sets config value
10761080
def set_cfg(self, var, val):
10771081
fl = os.path.join(self.path, self.config_file)
10781082
try:
10791083
with open(fl) as f:
10801084
lines = f.read().splitlines()
1081-
except:
1085+
except IOError:
10821086
lines = []
10831087

10841088
for line in lines:
@@ -1097,7 +1101,7 @@ def get_cfg(self, var, default_val=None):
10971101
try:
10981102
with open(fl) as f:
10991103
lines = f.read().splitlines()
1100-
except:
1104+
except IOError:
11011105
lines = []
11021106

11031107
for line in lines:
@@ -1155,7 +1159,7 @@ def post_action(self):
11551159
for line in f.read().splitlines():
11561160
if pkgutil.find_loader(line) is None:
11571161
missing.append(line)
1158-
except:
1162+
except IOError:
11591163
pass
11601164

11611165
if len(missing):
@@ -1338,14 +1342,20 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
13381342
err = "Unable to update \"%s\" to %s" % (repo.name, repo.revtype(repo.rev, True))
13391343
if depth:
13401344
err = err + ("\nThe --depth option might prevent fetching the whole revision tree and checking out %s." % (repo.revtype(repo.rev, True)))
1341-
warning(err) if ignore else error(err, e[0])
1345+
if ignore:
1346+
warning(err)
1347+
else:
1348+
error(err, e[0])
13421349
break
13431350
except ProcessException:
13441351
if os.path.isdir(repo.path):
13451352
rmtree_readonly(repo.path)
13461353
else:
13471354
err = "Unable to clone repository (%s)" % url
1348-
warning(err) if ignore else error(err, e[0])
1355+
if ignore:
1356+
warning(err)
1357+
else:
1358+
error(err, e[0])
13491359

13501360
repo.sync()
13511361

@@ -1494,7 +1504,10 @@ def update(rev=None, clean=False, force=False, ignore=False, top=True, depth=Non
14941504
err = "Unable to update \"%s\" to %s" % (repo.name, repo.revtype(rev, True))
14951505
if depth:
14961506
err = err + ("\nThe --depth option might prevent fetching the whole revision tree and checking out %s." % (repo.revtype(repo.rev, True)))
1497-
warning(err) if ignore else error(err, e[0])
1507+
if ignore:
1508+
warning(err)
1509+
else:
1510+
error(err, e[0])
14981511

14991512
repo.rm_untracked()
15001513
if top and cwd_type == 'library':

0 commit comments

Comments
 (0)