Skip to content
Permalink
Browse files
Fix style, remove dead code, disable stupid flake8 'l' variable name …
…check

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Oct 23, 2017
1 parent d1e84a7 commit 50c43b7d2437a7a18a543754b6ff886c9ae04c3e
@@ -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))
@@ -24,7 +24,7 @@ def _get_localzone():
assert tzname
dateutil.tz.gettz(tzname)
return tzname
except:
except Exception:
return None


@@ -26,7 +26,7 @@ def _get_localzone():
if tz:
dateutil.tz.gettz(tz)
return tz
except:
except Exception:
pass

try:
@@ -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
@@ -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,
@@ -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...
@@ -31,9 +31,9 @@
import nikola.plugins.command.init



LOGGER = get_logger('default_config')


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

@@ -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())
@@ -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

@@ -38,7 +38,7 @@

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

try:
@@ -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
@@ -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)
@@ -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):
@@ -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:
@@ -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('.'):
@@ -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

@@ -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))
@@ -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:
@@ -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
@@ -1,5 +1,5 @@
[flake8]
ignore=E501
ignore = E501,E741

[tool:pytest]
norecursedirs = .git
@@ -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


@@ -6,7 +6,7 @@
# needed if @unittest.expectedFailure is used
try:
import unittest2 as unittest
except:
except Exception:
import unittest

import nikola.nikola

0 comments on commit 50c43b7

Please sign in to comment.