Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5e6e2cd

Browse files
author
Roberto Alsina
committedMar 8, 2018
Avoid double calls to get_logger
1 parent 7ff83c2 commit 5e6e2cd

File tree

9 files changed

+7
-32
lines changed

9 files changed

+7
-32
lines changed
 

‎nikola/plugins/command/auto/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
import pkg_resources
5656

5757
from nikola.plugin_categories import Command
58-
from nikola.utils import dns_sd, req_missing, get_logger, get_theme_path
58+
from nikola.utils import dns_sd, req_missing, get_theme_path
5959
LRJS_PATH = os.path.join(os.path.dirname(__file__), 'livereload.js')
6060

6161
if sys.platform == 'win32':
@@ -66,7 +66,6 @@ class CommandAuto(Command):
6666
"""Automatic rebuilds for Nikola."""
6767

6868
name = "auto"
69-
logger = None
7069
has_server = True
7170
doc_purpose = "builds and serves a site; automatically detects site changes, rebuilds, and optionally refreshes a browser"
7271
dns_sd = None
@@ -116,7 +115,6 @@ class CommandAuto(Command):
116115

117116
def _execute(self, options, args):
118117
"""Start the watcher."""
119-
self.logger = get_logger('auto')
120118
self.sockets = []
121119
self.rebuild_queue = asyncio.Queue()
122120
self.last_rebuild = datetime.datetime.now()

‎nikola/plugins/command/check.py

-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import requests
4444

4545
from nikola.plugin_categories import Command
46-
from nikola.utils import get_logger
4746

4847

4948
def _call_nikola_list(site, cache=None):
@@ -103,7 +102,6 @@ class CommandCheck(Command):
103102
"""Check the generated site."""
104103

105104
name = "check"
106-
logger = None
107105

108106
doc_usage = "[-v] (-l [--find-sources] [-r] | -f [--clean-files])"
109107
doc_purpose = "check links and files in the generated site"
@@ -158,7 +156,6 @@ class CommandCheck(Command):
158156

159157
def _execute(self, options, args):
160158
"""Check the generated site."""
161-
self.logger = get_logger('check')
162159

163160
if not options['links'] and not options['files'] and not options['clean']:
164161
print(self.help())

‎nikola/plugins/command/deploy.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from blinker import signal
3838

3939
from nikola.plugin_categories import Command
40-
from nikola.utils import get_logger, clean_before_deployment
40+
from nikola.utils import clean_before_deployment
4141

4242

4343
class CommandDeploy(Command):
@@ -48,11 +48,9 @@ class CommandDeploy(Command):
4848
doc_usage = "[preset [preset...]]"
4949
doc_purpose = "deploy the site"
5050
doc_description = "Deploy the site by executing deploy commands from the presets listed on the command line. If no presets are specified, `default` is executed."
51-
logger = None
5251

5352
def _execute(self, command, args):
5453
"""Execute the deploy command."""
55-
self.logger = get_logger('deploy')
5654
# Get last successful deploy date
5755
timestamp_path = os.path.join(self.site.config['CACHE_FOLDER'], 'lastdeploy')
5856

‎nikola/plugins/command/github_deploy.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
from nikola.plugin_categories import Command
3434
from nikola.plugins.command.check import real_scan_files
35-
from nikola.utils import get_logger, req_missing, clean_before_deployment
35+
from nikola.utils import req_missing, clean_before_deployment
3636
from nikola.__main__ import main
3737
from nikola import __version__
3838

@@ -76,11 +76,9 @@ class CommandGitHubDeploy(Command):
7676
'help': 'Commit message (default: Nikola auto commit.)',
7777
},
7878
]
79-
logger = None
8079

8180
def _execute(self, options, args):
8281
"""Run the deployment."""
83-
self.logger = get_logger(CommandGitHubDeploy.name)
8482

8583
# Check if ghp-import is installed
8684
check_ghp_import_installed()

‎nikola/plugins/command/serve.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747

4848
from nikola.plugin_categories import Command
49-
from nikola.utils import dns_sd, get_logger
49+
from nikola.utils import dns_sd
5050

5151

5252
class IPv6Server(HTTPServer):
@@ -61,7 +61,6 @@ class CommandServe(Command):
6161
name = "serve"
6262
doc_usage = "[options]"
6363
doc_purpose = "start the test webserver"
64-
logger = None
6564
dns_sd = None
6665

6766
cmd_options = (
@@ -120,7 +119,6 @@ def shutdown(self, signum=None, _frame=None):
120119

121120
def _execute(self, options, args):
122121
"""Start test server."""
123-
self.logger = get_logger('serve')
124122
out_dir = self.site.config['OUTPUT_FOLDER']
125123
if not os.path.isdir(out_dir):
126124
self.logger.error("Missing '{0}' folder?".format(out_dir))

‎nikola/plugins/compile/ipynb.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
from nikola import shortcodes as sc
4444
from nikola.plugin_categories import PageCompiler
45-
from nikola.utils import makedirs, req_missing, get_logger, LocaleBorg
45+
from nikola.utils import makedirs, req_missing, LocaleBorg
4646

4747

4848
class CompileIPynb(PageCompiler):
@@ -54,11 +54,6 @@ class CompileIPynb(PageCompiler):
5454
default_kernel = 'python3'
5555
supports_metadata = True
5656

57-
def set_site(self, site):
58-
"""Set Nikola site."""
59-
self.logger = get_logger('compile_ipynb')
60-
super(CompileIPynb, self).set_site(site)
61-
6257
def _compile_string(self, nb_json):
6358
"""Export notebooks as HTML strings."""
6459
self._req_missing_ipynb()

‎nikola/plugins/task/bundles.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ class BuildBundles(LateTask):
4545

4646
def set_site(self, site):
4747
"""Set Nikola site."""
48-
self.logger = utils.get_logger('bundles')
48+
super(BuildBundles, self).set_site(site)
4949
if webassets is None and site.config['USE_BUNDLES']:
5050
utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)
5151
self.logger.warn('Setting USE_BUNDLES to False.')
5252
site.config['USE_BUNDLES'] = False
5353
site._GLOBAL_CONTEXT['use_bundles'] = False
54-
super(BuildBundles, self).set_site(site)
5554

5655
def gen_tasks(self):
5756
"""Bundle assets using WebAssets."""

‎nikola/plugins/task/galleries.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ class Galleries(Task, ImageProcessor):
6262

6363
def set_site(self, site):
6464
"""Set Nikola site."""
65+
super(Galleries, self).set_site(site)
6566
site.register_path_handler('gallery', self.gallery_path)
6667
site.register_path_handler('gallery_global', self.gallery_global_path)
6768
site.register_path_handler('gallery_rss', self.gallery_rss_path)
6869

69-
self.logger = utils.get_logger('render_galleries')
70-
7170
self.kw = {
7271
'thumbnail_size': site.config['THUMBNAIL_SIZE'],
7372
'max_image_size': site.config['MAX_IMAGE_SIZE'],
@@ -104,8 +103,6 @@ def set_site(self, site):
104103
# Create self.gallery_links
105104
self.create_galleries_paths()
106105

107-
return super(Galleries, self).set_site(site)
108-
109106
def _find_gallery_path(self, name):
110107
# The system using self.proper_gallery_links and self.improper_gallery_links
111108
# is similar as in listings.py.

‎nikola/plugins/task/scale_images.py

-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ class ScaleImage(Task, ImageProcessor):
3838

3939
name = "scale_images"
4040

41-
def set_site(self, site):
42-
"""Set Nikola site."""
43-
self.logger = utils.get_logger('scale_images')
44-
return super(ScaleImage, self).set_site(site)
45-
4641
def process_tree(self, src, dst):
4742
"""Process all images in a src tree and put the (possibly) rescaled images in the dst folder."""
4843
thumb_fmt = self.kw['image_thumbnail_format']

0 commit comments

Comments
 (0)
Please sign in to comment.