def _init_site(self): from nikola.plugins.command.init import CommandInit command_init = CommandInit() command_init.execute(options={'demo': True, 'quiet': True}, args=['demo']) sys.path.insert(0, '') os.chdir('demo') import conf _reload(conf) sys.path.pop(0) self._site = nikola.Nikola(**conf.__dict__)
def _init_site(self): from nikola.plugins.command.init import CommandInit command_init = CommandInit() command_init.execute(options={'demo': True, 'quiet': True}, args=['demo']) sys.path.insert(0, '') os.chdir('demo') import conf _reload(conf) sys.path.pop(0) self._site = nikola.Nikola(**conf.__dict__) self._site.init_plugins()
def disable_vimeo_api_query(): """ Disable query of the vimeo api over the wire Set Vimeo.request_size to False for avoiding querying the Vimeo api over the network. """ before = vimeo.Vimeo.request_size vimeo.Vimeo.request_size = False try: _reload(nikola.plugins.compile.rest) yield finally: vimeo.Vimeo.request_size = before
def _init_site(self, monkeypatch, tmp_path): from nikola.plugins.command.init import CommandInit monkeypatch.chdir(tmp_path) command_init = CommandInit() command_init.execute(options={ 'demo': True, 'quiet': True }, args=['demo']) sys.path.insert(0, '') monkeypatch.chdir(tmp_path / 'demo') import conf # noqa _reload(conf) sys.path.pop(0) self._site = nikola.Nikola(**conf.__dict__) self._site.init_plugins()
def _execute(self, options, args): """Manage the tags on the site.""" try: import conf except ImportError: LOGGER.error("No configuration found, cannot run the console.") else: _reload(conf) nikola = Nikola(**conf.__dict__) nikola.scan_posts() if len(options['add']) > 0 and len(args) > 0: add_tags(nikola, options['add'], args, options['dry-run']) elif options['list']: list_tags(nikola, options['list_sorting']) elif options['merge'].count(',') > 0 and len(args) > 0: merge_tags(nikola, options['merge'], args, options['dry-run']) elif len(options['remove']) > 0 and len(args) > 0: remove_tags(nikola, options['remove'], args, options['dry-run']) elif len(options['search']) > 0: search_tags(nikola, options['search']) elif options['tag'] and len(args) > 0: tagger = _AutoTag(nikola) for post in args: tags = ','.join(tagger.tag(post)) add_tags(nikola, tags, [post], options['dry-run']) elif options['sort'] and len(args) > 0: sort_tags(nikola, args, options['dry-run']) else: print(self.help())
def setUp(self): """ Disable query of the vimeo api over the wire """ vimeo.Vimeo.request_size = False super(VimeoTestCase, self).setUp() _reload(nikola.plugins.compile.rest)
def setUp(self): """ Patch GitHubGist for avoiding network dependency """ super(GistTestCase, self).setUp() self.gist_type.get_raw_gist_with_filename = lambda *_: 'raw_gist_file' self.gist_type.get_raw_gist = lambda *_: "raw_gist" _reload(nikola.plugins.compile.rest)
def _get_disabled(self): import conf utils._reload(conf) return set(getattr(conf, 'DISABLED_PLUGINS', []))
def setUp(self): """ Inject a mock open function for not generating a test site """ f = StringIO("import antigravity\n") nikola.plugins.compile_rest.Listing.open = lambda *_: f _reload(nikola.plugins.compile_rest)