def mainloop(self): """ moin-package's main code. """ # Initalize request self.init_request() request = self.request _ = self.request.getText # Check our command line args if self.options.pages and self.options.search: script.fatal(_("Options --pages and --search are mutually exclusive!")) elif not self.options.output: script.fatal(_("You must specify an output file!")) elif not self.options.pages and not self.options.search: script.log(_("No pages specified using --pages or --search, assuming full package.")) include_attachments = self.options.attachment or False if include_attachments: script.log(_("All attachments included into the package.")) # Sanity checks if os.path.exists(self.options.output): script.fatal(_("Output file already exists! Cowardly refusing to continue!")) # Check for user if self.options.package_user: request.user = user.User(request, name=self.options.package_user) # Import PackagePages here, as we now have an initalized request. from MoinMoin.action.PackagePages import PackagePages # Perform actual packaging. package = PackagePages(request.rootpage.page_name, request) packageoutput = open(self.options.output, "wb") if self.options.search: packagedata = package.collectpackage( package.searchpackage(request, self.options.search), packageoutput, include_attachments=include_attachments, ) elif self.options.pages: packagedata = package.collectpackage( self.options.pages.split(","), packageoutput, include_attachments=include_attachments ) else: packagedata = package.collectpackage( request.rootpage.getPageList( include_underlay=False, filter=lambda name: not wikiutil.isSystemPage(request, name) ), packageoutput, include_attachments=include_attachments, ) if packagedata: script.fatal(packagedata)
def mainloop(self): """ moin-package's main code. """ # Initalize request self.init_request() request = self.request _ = self.request.getText # Check our command line args if self.options.pages and self.options.search: script.fatal(_("Options --pages and --search are mutually exclusive!")) elif not self.options.output: script.fatal(_("You must specify an output file!")) elif not self.options.pages and not self.options.search: script.log(_("No pages specified using --pages or --search, assuming full package.")) include_attachments = self.options.attachment or False if include_attachments: script.log(_("All attachments included into the package.")) # Sanity checks if os.path.exists(self.options.output): script.fatal(_("Output file already exists! Cowardly refusing to continue!")) # Check for user if self.options.package_user: request.user = user.User(request, name=self.options.package_user) # Import PackagePages here, as we now have an initalized request. from MoinMoin.action.PackagePages import PackagePages # Perform actual packaging. package = PackagePages(request.rootpage.page_name, request) packageoutput = open(self.options.output, "wb") if self.options.search: packagedata = package.collectpackage(package.searchpackage(request, self.options.search), packageoutput, include_attachments=include_attachments) elif self.options.pages: packagedata = package.collectpackage(self.options.pages.split(","), packageoutput, include_attachments=include_attachments) else: packagedata = package.collectpackage(request.rootpage.getPageList( include_underlay=False, filter=lambda name: not wikiutil.isSystemPage(request, name)), packageoutput, include_attachments=include_attachments) if packagedata: script.fatal(packagedata)
def testSearch(self): package = PackagePages(self.request.rootpage.page_name, self.request) assert package.searchpackage(self.request, "BadCon") == [u'BadContent']
def testSearch(self): package = PackagePages(self.request.rootpage.page_name, self.request) assert package.searchpackage(self.request, "title:BadCon") == [u'BadContent']