def plain(self): """Plain Python shell.""" from nikola import Nikola try: import conf SITE = Nikola(**conf.__dict__) SITE.scan_posts() gl = {'conf': conf, 'SITE': SITE, 'Nikola': Nikola} except ImportError: LOGGER.error("No configuration found, cannot run the console.") else: import code try: import readline except ImportError: pass else: import rlcompleter readline.set_completer(rlcompleter.Completer(gl).complete) readline.parse_and_bind("tab:complete") pythonrc = os.environ.get("PYTHONSTARTUP") if pythonrc and os.path.isfile(pythonrc): try: execfile(pythonrc) # NOQA except NameError: pass code.interact(local=gl, banner=self.header.format('Python'))
def f(ext: str, data: str, extra_plugins_dirs: List[Path] = None, metadata: str = None, extra_config: Dict = None) -> CompileResult: data = dedent(data) (tmp_site_path / 'pages' / 'test').with_suffix(ext).write_text( data, encoding='utf8') metadata = metadata or '.. title: test' (tmp_site_path / 'pages' / 'test').with_suffix('.meta').write_text( metadata, encoding='utf8') config = { 'EXTRA_PLUGINS_DIRS': map(str, extra_plugins_dirs or []), 'PAGES': (('pages/*' + ext, 'pages', 'page.tmpl'), ), } if extra_config: config.update(extra_config) site = Nikola(**config) site.init_plugins() site.scan_posts() post = site.timeline[0] post.compile('en') return CompileResult(request, post)
def _execute(self, options, args): """Start the console.""" from nikola import Nikola try: import conf SITE = Nikola(**conf.__dict__) SITE.scan_posts() print("You can now access your configuration as conf and your " "site engine as SITE.") except ImportError: print("No configuration found.") import code try: import readline except ImportError: pass else: import rlcompleter readline.set_completer(rlcompleter.Completer(globals()).complete) readline.parse_and_bind("tab:complete") pythonrc = os.environ.get("PYTHONSTARTUP") if pythonrc and os.path.isfile(pythonrc): try: execfile(pythonrc) # NOQA except NameError: pass code.interact(local=globals())
def ipython(self): """IPython shell.""" from nikola import Nikola try: import conf except ImportError: LOGGER.error("No configuration found, cannot run the console.") else: import IPython SITE = Nikola(**conf.__dict__) SITE.scan_posts() IPython.embed(header=self.header.format('IPython'))
def bpython(self): """bpython shell.""" from nikola import Nikola try: import conf except ImportError: LOGGER.error("No configuration found, cannot run the console.") else: import bpython SITE = Nikola(**conf.__dict__) SITE.scan_posts() gl = {'conf': conf, 'SITE': SITE, 'Nikola': Nikola} bpython.embed(banner=self.header.format('bpython'), locals_=gl)
def bpython(self): """bpython shell.""" from nikola import Nikola try: import conf except ImportError: print("No configuration found, cannot run the console.") else: import bpython SITE = Nikola(**conf.__dict__) SITE.scan_posts() gl = {'conf': conf, 'SITE': SITE, 'Nikola': Nikola} bpython.embed(banner=self.header.format('bpython'), locals_=gl)
def bpython(self): """bpython shell.""" from nikola import Nikola try: import conf except ImportError: print("No configuration found, cannot run the console.") else: import bpython SITE = Nikola(**conf.__dict__) SITE.scan_posts() bpython.embed(banner='Nikola Console (conf = configuration, SITE ' '= site engine)')
def ipython(self): """IPython shell.""" from nikola import Nikola try: import conf except ImportError: print("No configuration found, cannot run the console.") else: import IPython SITE = Nikola(**conf.__dict__) SITE.scan_posts() IPython.embed(header='Nikola Console (conf = configuration, SITE ' '= site engine)')
def bpython(self): """bpython shell.""" from nikola import Nikola try: import conf except ImportError: print("No configuration found, cannot run the console.") else: import bpython SITE = Nikola(**conf.__dict__) SITE.scan_posts() gl = {'conf': conf, 'SITE': SITE, 'Nikola': Nikola} bpython.embed(banner='Nikola Console (conf = configuration, SITE ' '= site engine)', locals_=gl)
from __future__ import print_function, unicode_literals from nikola import Nikola import conf SITE = Nikola(**conf.__dict__) SITE.scan_posts() print("You can now access your configuration as conf and your site engine as SITE")