Skip to content

Commit

Permalink
Fix style, remove dead code, disable stupid flake8 'l' variable name …
Browse files Browse the repository at this point in the history
…check

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Oct 23, 2017
1 parent d1e84a7 commit 50c43b7
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 37 deletions.
2 changes: 1 addition & 1 deletion dodo.py
Expand Up @@ -47,7 +47,7 @@ def set_nikola_test_locales():
if lang not in languages:
try:
locale.setlocale(locale.LC_ALL, str(line))
except:
except Exception:
continue
languages.add(lang)
locales.append((lang, line))
Expand Down
2 changes: 1 addition & 1 deletion nikola/packages/tzlocal/darwin.py
Expand Up @@ -24,7 +24,7 @@ def _get_localzone():
assert tzname
dateutil.tz.gettz(tzname)
return tzname
except:
except Exception:
return None


Expand Down
8 changes: 4 additions & 4 deletions nikola/packages/tzlocal/unix.py
Expand Up @@ -26,7 +26,7 @@ def _get_localzone():
if tz:
dateutil.tz.gettz(tz)
return tz
except:
except Exception:
pass

try:
Expand All @@ -37,7 +37,7 @@ def _get_localzone():
if tz:
dateutil.tz.gettz(tz)
return tz
except:
except Exception:
return None

# Now look for distribution specific configuration files
Expand All @@ -61,7 +61,7 @@ def _get_localzone():
if tz:
dateutil.tz.gettz(tz)
return tz
except:
except Exception:
pass

# CentOS has a ZONE setting in /etc/sysconfig/clock,
Expand Down Expand Up @@ -96,7 +96,7 @@ def _get_localzone():
if tz:
dateutil.tz.gettz(tz)
return tz
except:
except Exception:
pass

# Nikola cannot use this thing below...
Expand Down
5 changes: 2 additions & 3 deletions nikola/plugins/command/default_config.py
Expand Up @@ -31,9 +31,9 @@
import nikola.plugins.command.init



LOGGER = get_logger('default_config')


class CommandShowConfig(Command):
"""Show the default configuration."""

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


def _execute(self, options={}, args=None):
def _execute(self, options=None, args=None):
"""Show the default configuration."""
try:
print(nikola.plugins.command.init.CommandInit.create_configuration_to_string())
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/deploy.py
Expand Up @@ -101,7 +101,7 @@ def _execute(self, command, args):
for preset in presets:
try:
self.site.config['DEPLOY_COMMANDS'][preset]
except:
except KeyError:
self.logger.error('No such preset: {0}'.format(preset))
return 255

Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/import_wordpress.py
Expand Up @@ -38,7 +38,7 @@

try:
import html2text
except:
except ImportError:
html2text = None

try:
Expand Down Expand Up @@ -983,7 +983,7 @@ def import_postpage_item(self, item, wordpress_namespace, out_folder=None, attac
for lang, content in content_translations.items():
try:
content, extension, rewrite_html = self.transform_content(content, post_format, attachments)
except:
except Exception:
LOGGER.error(('Cannot interpret post "{0}" (language {1}) with post ' +
'format {2}!').format(os.path.join(out_folder, slug), lang, post_format))
return False
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/init.py
Expand Up @@ -377,7 +377,7 @@ def tzhandler(default, toconf):
while not answered:
try:
lz = get_localzone()
except:
except Exception:
lz = None
answer = ask('Time zone', lz if lz else "UTC")
tz = dateutil.tz.gettz(answer)
Expand Down
16 changes: 2 additions & 14 deletions nikola/plugins/command/plugin.py
Expand Up @@ -243,20 +243,8 @@ def do_install(self, url, name, show_install_notes=True):
utils.extract_all(zip_file, self.output_dir)
dest_path = os.path.join(self.output_dir, name)
else:
try:
plugin_path = utils.get_plugin_path(name)
except:
LOGGER.error("Can't find plugin " + name)
return 1

utils.makedirs(self.output_dir)
dest_path = os.path.join(self.output_dir, name)
if os.path.exists(dest_path):
LOGGER.error("{0} is already installed".format(name))
return 1

LOGGER.info('Copying {0} into plugins'.format(plugin_path))
shutil.copytree(plugin_path, dest_path)
LOGGER.error("Can't find plugin " + name)
return 1

reqpath = os.path.join(dest_path, 'requirements.txt')
if os.path.exists(reqpath):
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/theme.py
Expand Up @@ -196,7 +196,7 @@ def do_install_deps(self, url, name):
try:
utils.get_theme_path_real(parent_name, self.site.themes_dirs)
break
except: # Not available
except Exception: # Not available
self.do_install(parent_name, data)
name = parent_name
if installstatus:
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/compile/rest/chart.py
Expand Up @@ -180,7 +180,7 @@ def _gen_chart(chart_type, **_options):
for k, v in _options.items():
try:
options[k] = literal_eval(v)
except:
except Exception:
options[k] = v
chart = pygal
for o in chart_type.split('.'):
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/indexes.py
Expand Up @@ -98,7 +98,7 @@ def get_path(self, classification, lang, dest_type='page'):
# Interpret argument as page number
try:
page_number = int(classification)
except:
except ValueError:
pass
return [self.site.config['INDEX_PATH'](lang)], 'always', page_number

Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/task/listings.py
Expand Up @@ -128,10 +128,10 @@ def render_listing(in_name, out_name, input_folder, output_folder, folders=[], f
with open(in_name, 'r') as fd:
try:
lexer = get_lexer_for_filename(in_name)
except:
except Exception:
try:
lexer = guess_lexer(fd.read())
except:
except Exception:
lexer = TextLexer()
fd.seek(0)
code = highlight(fd.read(), lexer, utils.NikolaPygmentsHTML(in_name))
Expand Down
2 changes: 1 addition & 1 deletion nikola/post.py
Expand Up @@ -691,7 +691,7 @@ def text(self, lang=None, teaser_only=False, strip_html=False, show_read_more_li

try:
data = lxml.html.tostring(document.body, encoding='unicode')
except:
except Exception:
data = lxml.html.tostring(document, encoding='unicode')

if teaser_only:
Expand Down
2 changes: 1 addition & 1 deletion scripts/jinjify.py
Expand Up @@ -41,7 +41,7 @@ def jinjify(in_theme, out_theme):
out_templates_path = os.path.join(out_theme, "templates")
try:
os.makedirs(out_templates_path)
except:
except Exception:
pass
lookup = jinja2.Environment()
lookup.filters['tojson'] = json.dumps
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,5 +1,5 @@
[flake8]
ignore=E501
ignore = E501,E741

[tool:pytest]
norecursedirs = .git
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -84,7 +84,7 @@ def remove_old_files(self):
tree = os.path.join(self.install_lib, 'nikola')
try:
shutil.rmtree(tree, ignore_errors=True)
except:
except Exception:
pass


Expand Down
2 changes: 1 addition & 1 deletion tests/test_locale.py
Expand Up @@ -6,7 +6,7 @@
# needed if @unittest.expectedFailure is used
try:
import unittest2 as unittest
except:
except Exception:
import unittest

import nikola.nikola
Expand Down

0 comments on commit 50c43b7

Please sign in to comment.