Skip to content

Commit 50c43b7

Browse files
committedOct 23, 2017
Fix style, remove dead code, disable stupid flake8 'l' variable name check
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent d1e84a7 commit 50c43b7

17 files changed

+24
-37
lines changed
 

‎dodo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def set_nikola_test_locales():
4747
if lang not in languages:
4848
try:
4949
locale.setlocale(locale.LC_ALL, str(line))
50-
except:
50+
except Exception:
5151
continue
5252
languages.add(lang)
5353
locales.append((lang, line))

‎nikola/packages/tzlocal/darwin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def _get_localzone():
2424
assert tzname
2525
dateutil.tz.gettz(tzname)
2626
return tzname
27-
except:
27+
except Exception:
2828
return None
2929

3030

‎nikola/packages/tzlocal/unix.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _get_localzone():
2626
if tz:
2727
dateutil.tz.gettz(tz)
2828
return tz
29-
except:
29+
except Exception:
3030
pass
3131

3232
try:
@@ -37,7 +37,7 @@ def _get_localzone():
3737
if tz:
3838
dateutil.tz.gettz(tz)
3939
return tz
40-
except:
40+
except Exception:
4141
return None
4242

4343
# Now look for distribution specific configuration files
@@ -61,7 +61,7 @@ def _get_localzone():
6161
if tz:
6262
dateutil.tz.gettz(tz)
6363
return tz
64-
except:
64+
except Exception:
6565
pass
6666

6767
# CentOS has a ZONE setting in /etc/sysconfig/clock,
@@ -96,7 +96,7 @@ def _get_localzone():
9696
if tz:
9797
dateutil.tz.gettz(tz)
9898
return tz
99-
except:
99+
except Exception:
100100
pass
101101

102102
# Nikola cannot use this thing below...

‎nikola/plugins/command/default_config.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
import nikola.plugins.command.init
3232

3333

34-
3534
LOGGER = get_logger('default_config')
3635

36+
3737
class CommandShowConfig(Command):
3838
"""Show the default configuration."""
3939

@@ -44,8 +44,7 @@ class CommandShowConfig(Command):
4444
doc_purpose = "Print the default Nikola configuration."
4545
cmd_options = []
4646

47-
48-
def _execute(self, options={}, args=None):
47+
def _execute(self, options=None, args=None):
4948
"""Show the default configuration."""
5049
try:
5150
print(nikola.plugins.command.init.CommandInit.create_configuration_to_string())

‎nikola/plugins/command/deploy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _execute(self, command, args):
101101
for preset in presets:
102102
try:
103103
self.site.config['DEPLOY_COMMANDS'][preset]
104-
except:
104+
except KeyError:
105105
self.logger.error('No such preset: {0}'.format(preset))
106106
return 255
107107

‎nikola/plugins/command/import_wordpress.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
try:
4040
import html2text
41-
except:
41+
except ImportError:
4242
html2text = None
4343

4444
try:
@@ -983,7 +983,7 @@ def import_postpage_item(self, item, wordpress_namespace, out_folder=None, attac
983983
for lang, content in content_translations.items():
984984
try:
985985
content, extension, rewrite_html = self.transform_content(content, post_format, attachments)
986-
except:
986+
except Exception:
987987
LOGGER.error(('Cannot interpret post "{0}" (language {1}) with post ' +
988988
'format {2}!').format(os.path.join(out_folder, slug), lang, post_format))
989989
return False

‎nikola/plugins/command/init.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def tzhandler(default, toconf):
377377
while not answered:
378378
try:
379379
lz = get_localzone()
380-
except:
380+
except Exception:
381381
lz = None
382382
answer = ask('Time zone', lz if lz else "UTC")
383383
tz = dateutil.tz.gettz(answer)

‎nikola/plugins/command/plugin.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -243,20 +243,8 @@ def do_install(self, url, name, show_install_notes=True):
243243
utils.extract_all(zip_file, self.output_dir)
244244
dest_path = os.path.join(self.output_dir, name)
245245
else:
246-
try:
247-
plugin_path = utils.get_plugin_path(name)
248-
except:
249-
LOGGER.error("Can't find plugin " + name)
250-
return 1
251-
252-
utils.makedirs(self.output_dir)
253-
dest_path = os.path.join(self.output_dir, name)
254-
if os.path.exists(dest_path):
255-
LOGGER.error("{0} is already installed".format(name))
256-
return 1
257-
258-
LOGGER.info('Copying {0} into plugins'.format(plugin_path))
259-
shutil.copytree(plugin_path, dest_path)
246+
LOGGER.error("Can't find plugin " + name)
247+
return 1
260248

261249
reqpath = os.path.join(dest_path, 'requirements.txt')
262250
if os.path.exists(reqpath):

‎nikola/plugins/command/theme.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def do_install_deps(self, url, name):
196196
try:
197197
utils.get_theme_path_real(parent_name, self.site.themes_dirs)
198198
break
199-
except: # Not available
199+
except Exception: # Not available
200200
self.do_install(parent_name, data)
201201
name = parent_name
202202
if installstatus:

‎nikola/plugins/compile/rest/chart.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _gen_chart(chart_type, **_options):
180180
for k, v in _options.items():
181181
try:
182182
options[k] = literal_eval(v)
183-
except:
183+
except Exception:
184184
options[k] = v
185185
chart = pygal
186186
for o in chart_type.split('.'):

‎nikola/plugins/task/indexes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def get_path(self, classification, lang, dest_type='page'):
9898
# Interpret argument as page number
9999
try:
100100
page_number = int(classification)
101-
except:
101+
except ValueError:
102102
pass
103103
return [self.site.config['INDEX_PATH'](lang)], 'always', page_number
104104

‎nikola/plugins/task/listings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ def render_listing(in_name, out_name, input_folder, output_folder, folders=[], f
128128
with open(in_name, 'r') as fd:
129129
try:
130130
lexer = get_lexer_for_filename(in_name)
131-
except:
131+
except Exception:
132132
try:
133133
lexer = guess_lexer(fd.read())
134-
except:
134+
except Exception:
135135
lexer = TextLexer()
136136
fd.seek(0)
137137
code = highlight(fd.read(), lexer, utils.NikolaPygmentsHTML(in_name))

‎nikola/post.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ def text(self, lang=None, teaser_only=False, strip_html=False, show_read_more_li
691691

692692
try:
693693
data = lxml.html.tostring(document.body, encoding='unicode')
694-
except:
694+
except Exception:
695695
data = lxml.html.tostring(document, encoding='unicode')
696696

697697
if teaser_only:

‎scripts/jinjify.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def jinjify(in_theme, out_theme):
4141
out_templates_path = os.path.join(out_theme, "templates")
4242
try:
4343
os.makedirs(out_templates_path)
44-
except:
44+
except Exception:
4545
pass
4646
lookup = jinja2.Environment()
4747
lookup.filters['tojson'] = json.dumps

‎setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
ignore=E501
2+
ignore = E501,E741
33

44
[tool:pytest]
55
norecursedirs = .git

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def remove_old_files(self):
8484
tree = os.path.join(self.install_lib, 'nikola')
8585
try:
8686
shutil.rmtree(tree, ignore_errors=True)
87-
except:
87+
except Exception:
8888
pass
8989

9090

‎tests/test_locale.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# needed if @unittest.expectedFailure is used
77
try:
88
import unittest2 as unittest
9-
except:
9+
except Exception:
1010
import unittest
1111

1212
import nikola.nikola

0 commit comments

Comments
 (0)
Please sign in to comment.