示例#1
0
    def _build_installer(self):
        if not self._create_installer:
            return

        print_info(u'Create installer...')
        if self.is_stable:
            installerName = u'outwiker_{}_win'.format(self.facts.version_items[0])
        else:
            installerName = u'outwiker_win_unstable'.format(self.facts.version)

        installer_path = os.path.join(self.facts.temp_dir, installerName)

        installer_template = readTextFile(os.path.join(NEED_FOR_BUILD_DIR, u'windows', u'outwiker_setup.iss.tpl'))

        installer_text = Template(installer_template).safe_substitute(
            version=self.facts.version,
            resultname=installerName
        )

        installer_script_path = os.path.join(self.facts.temp_dir,
                                             u'outwiker_setup.iss')

        writeTextFile(installer_script_path, installer_text)

        with lcd(self.facts.temp_dir):
            local("iscc outwiker_setup.iss")

        shutil.move(installer_path + u'.exe', self.build_dir)
示例#2
0
    def _debuild(self, command, distriblist):
        """
        Run command with debuild.
        The function assembles the deb packages for all releases in distriblist
        """
        date = datetime.datetime.now()
        date_str = date.strftime(u'%a, %d %b %Y %H:%M:%S ' + TIMEZONE)
        outwiker_appinfo = getOutwikerAppInfo()
        changelog_generator = DebChangelogGenerator(outwiker_appinfo,
                                                    DEB_MAINTAINER,
                                                    DEB_MAINTAINER_EMAIL)

        for distrib_name in distriblist:
            self._orig(distrib_name)
            changelog = changelog_generator.make(distrib_name, date_str)
            current_debian_dirname = os.path.join(self.build_dir,
                                                  self._getDebName(),
                                                  'debian')

            # Change release name in the changelog file
            changelog_path = os.path.join(current_debian_dirname,
                                          u'changelog')
            writeTextFile(changelog_path, changelog)

            with lcd(current_debian_dirname):
                local(command)
示例#3
0
    def _build_installer(self):
        if not self._create_installer:
            return

        print_info(u'Create installer...')
        if self.is_stable:
            installerName = u'outwiker_{}_win'.format(
                self.facts.version_items[0])
        else:
            installerName = u'outwiker_win_unstable'.format(self.facts.version)

        installer_path = os.path.join(self.facts.temp_dir, installerName)

        installer_template = readTextFile(
            os.path.join(NEED_FOR_BUILD_DIR, u'windows',
                         u'outwiker_setup.iss.tpl'))

        installer_text = Template(installer_template).safe_substitute(
            version=self.facts.version, resultname=installerName)

        installer_script_path = os.path.join(self.facts.temp_dir,
                                             u'outwiker_setup.iss')

        writeTextFile(installer_script_path, installer_text)

        with lcd(self.facts.temp_dir):
            local("iscc outwiker_setup.iss")

        shutil.move(installer_path + u'.exe', self.build_dir)
示例#4
0
    def test_content_include(self):
        text = '(:snip:){% include "__test_snippets/included" %}(:snipend:)'
        fname = os.path.join(self._snippets_dir, 'included')
        writeTextFile(fname, 'Включенный текст')
        result_right = 'Включенный текст'

        result = self.parser.toHtml(text)

        self.assertEqual(result_right, result)
示例#5
0
    def test_content_include(self):
        text = '(:snip:){% include "__test_snippets/included" %}(:snipend:)'
        fname = os.path.join(self._snippets_dir, 'included')
        writeTextFile(fname, 'Включенный текст')
        result_right = 'Включенный текст'

        result = self.parser.toHtml(text)

        self.assertEqual(result_right, result)
示例#6
0
    def test_file_var_01(self):
        snippet_text = '{{varname}}'
        snippet_fname = 'testsnip'
        text = '(:snip file="__test_snippets/testsnip" varname="Переменная":)(:snipend:)'
        result_right = 'Переменная'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#7
0
    def test_file_var_03(self):
        snippet_text = '{{__text}}'
        snippet_fname = 'testsnip'
        text = '(:snip file="__test_snippets/testsnip":)Текст(:snipend:)'
        result_right = 'Текст'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#8
0
    def test_file_simple(self):
        snippet_text = u'Текст шаблона'
        snippet_fname = u'testsnip'
        text = u'(:snip file="__test_snippets/testsnip":)(:snipend:)'
        result_right = u'Текст шаблона'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#9
0
    def test_file_global_var_title_02(self):
        snippet_text = '{{__title}}'
        snippet_fname = 'testsnip'
        text = '(:snip file="__test_snippets/testsnip":)(:snipend:)'
        result_right = 'Страница 1'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#10
0
    def test_file_var_01(self):
        snippet_text = '{{varname}}'
        snippet_fname = 'testsnip'
        text = '(:snip file="__test_snippets/testsnip" varname="Переменная":)(:snipend:)'
        result_right = 'Переменная'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#11
0
    def test_file_simple(self):
        snippet_text = u'Текст шаблона'
        snippet_fname = u'testsnip'
        text = u'(:snip file="__test_snippets/testsnip":)(:snipend:)'
        result_right = u'Текст шаблона'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#12
0
    def test_file_var_03(self):
        snippet_text = '{{__text}}'
        snippet_fname = 'testsnip'
        text = '(:snip file="__test_snippets/testsnip":)Текст(:snipend:)'
        result_right = 'Текст'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#13
0
    def test_file_global_var_title_02(self):
        snippet_text = '{{__title}}'
        snippet_fname = 'testsnip'
        text = '(:snip file="__test_snippets/testsnip":)(:snipend:)'
        result_right = 'Страница 1'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#14
0
    def test_file_global_var_title_alias(self):
        self.testPage.alias = u'Псевдоним'
        snippet_text = u'{{__title}}'
        snippet_fname = u'testsnip'
        text = u'(:snip file="__test_snippets/testsnip":)(:snipend:)'
        result_right = u'Псевдоним'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#15
0
    def test_file_global_var_title_alias(self):
        self.testPage.alias = u'Псевдоним'
        snippet_text = u'{{__title}}'
        snippet_fname = u'testsnip'
        text = u'(:snip file="__test_snippets/testsnip":)(:snipend:)'
        result_right = u'Псевдоним'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#16
0
    def generate (self, fname):
        """
        Создать файл (с имемени fname), содержащий список страниц
        """
        resultList = []

        resultList.append ("<ul>")
        self.__addpage (resultList, self.__rootpage, 1)
        resultList.append ("</ul>")

        finalresult = self.__prepareResult (u"\n".join (resultList))

        writeTextFile(fname, finalresult)
示例#17
0
    def __replacePageLinks (self, outdir):
        """
        Скорректировать ссылки на страницы
        """
        for page in list(self.__renames.keys()):
            fullname = os.path.join (outdir, self.__renames[page] + u".html")

            try:
                text = readTextFile(fullname)
                newtext = self.__replacePageLinksInText (text, page, outdir)
                writeTextFile(fullname, newtext)
            except BaseException as error:
                self.__log.append (u"{0}: {1}".format (page.title, str(error)))
示例#18
0
    def __replacePageLinks(self, outdir):
        """
        Скорректировать ссылки на страницы
        """
        for page in list(self.__renames.keys()):
            fullname = os.path.join(outdir, self.__renames[page] + u".html")

            try:
                text = readTextFile(fullname)
                newtext = self.__replacePageLinksInText(text, page, outdir)
                writeTextFile(fullname, newtext)
            except BaseException as error:
                self.__log.append(u"{0}: {1}".format(page.title, str(error)))
示例#19
0
    def generate(self, fname):
        """
        Создать файл (с имемени fname), содержащий список страниц
        """
        resultList = []

        resultList.append("<ul>")
        self.__addpage(resultList, self.__rootpage, 1)
        resultList.append("</ul>")

        finalresult = self.__prepareResult(u"\n".join(resultList))

        writeTextFile(fname, finalresult)
示例#20
0
    def _saveItemSnippet(self, item):
        if not item.IsOk():
            return

        path = self._getItemData(item).path
        if os.path.isdir(path):
            return
        try:
            writeTextFile(path, self._dialog.snippetEditor.GetText())
        except EnvironmentError:
            MessageBox(
                _(u"Can't save snippet\n{}").format(path), _(u"Error"),
                wx.ICON_ERROR | wx.OK)
            raise
示例#21
0
    def test_file_include_01(self):
        snippet_text = u'{% include "included" %}'
        snippet_fname = u'testsnip'
        text = u'(:snip file="__test_snippets/testsnip":)(:snipend:)'
        result_right = u'Включение'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        snip_fname_full_2 = os.path.join(self._snippets_dir, u'included')
        writeTextFile(snip_fname_full_2, u'Включение')

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#22
0
    def test_file_include_02(self):
        snippet_text = '{% include "included" %}'
        snippet_fname = 'testsnip'
        text = '(:snip file="__test_snippets/testsnip" var="Переменная":)(:snipend:)'
        result_right = 'Переменная'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        snip_fname_full_2 = os.path.join(self._snippets_dir, 'included')
        writeTextFile(snip_fname_full_2, '{{var}}')

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#23
0
    def test_file_include_01(self):
        snippet_text = u'{% include "included" %}'
        snippet_fname = u'testsnip'
        text = u'(:snip file="__test_snippets/testsnip":)(:snipend:)'
        result_right = u'Включение'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        snip_fname_full_2 = os.path.join(self._snippets_dir, u'included')
        writeTextFile(snip_fname_full_2, u'Включение')

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#24
0
    def test_file_include_02(self):
        snippet_text = '{% include "included" %}'
        snippet_fname = 'testsnip'
        text = '(:snip file="__test_snippets/testsnip" var="Переменная":)(:snipend:)'
        result_right = 'Переменная'

        snip_fname_full = os.path.join(self._snippets_dir, snippet_fname)
        writeTextFile(snip_fname_full, snippet_text)

        snip_fname_full_2 = os.path.join(self._snippets_dir, 'included')
        writeTextFile(snip_fname_full_2, '{{var}}')

        result = self.parser.toHtml(text)
        self.assertEqual(result_right, result, result)
示例#25
0
    def _saveItemSnippet(self, item):
        if not item.IsOk():
            return

        path = self._getItemData(item).path
        if os.path.isdir(path):
            return
        try:
            writeTextFile(path, self._dialog.snippetEditor.GetText())
        except EnvironmentError:
            MessageBox(
                _(u"Can't save snippet\n{}").format(path),
                _(u"Error"),
                wx.ICON_ERROR | wx.OK)
            raise
示例#26
0
    def _updatePage(self, page):
        path = page.getHtmlPath()
        cache = HtmlCache(page, self._application)

        # Проверим, можно ли прочитать уже готовый HTML
        if cache.canReadFromCache() and os.path.exists(path):
            return

        style = Style()
        stylepath = style.getPageStyle(page)
        generator = MarkdownHtmlGenerator(page)

        html = generator.makeHtml(stylepath)
        writeTextFile(path, html)
        cache.saveHash()
示例#27
0
    def test_getCustomStylesNames_more_dirs_repeat_names(self):
        dirname_1 = mkdtemp()
        dirname_2 = mkdtemp()
        self._tmp_dirs.append(dirname_1)
        self._tmp_dirs.append(dirname_2)

        writeTextFile(os.path.join(dirname_1, 'style-1.css'), '')
        writeTextFile(os.path.join(dirname_1, 'style-2.css'), '')
        writeTextFile(os.path.join(dirname_1, 'style-3.css'), '')

        writeTextFile(os.path.join(dirname_2, 'style-1.css'), '')
        writeTextFile(os.path.join(dirname_2, 'style-5.css'), '')

        styles = sorted(getCustomStylesNames(self._tmp_dirs))
        self.assertEqual(styles, ['style-1', 'style-2', 'style-3', 'style-5'])
示例#28
0
    def test_getCustomStylesNames_more_dirs_repeat_names(self):
        dirname_1 = mkdtemp()
        dirname_2 = mkdtemp()
        self._tmp_dirs.append(dirname_1)
        self._tmp_dirs.append(dirname_2)

        writeTextFile(os.path.join(dirname_1, 'style-1.css'), '')
        writeTextFile(os.path.join(dirname_1, 'style-2.css'), '')
        writeTextFile(os.path.join(dirname_1, 'style-3.css'), '')

        writeTextFile(os.path.join(dirname_2, 'style-1.css'), '')
        writeTextFile(os.path.join(dirname_2, 'style-5.css'), '')

        styles = sorted(getCustomStylesNames(self._tmp_dirs))
        self.assertEqual(styles, ['style-1', 'style-2', 'style-3', 'style-5'])
示例#29
0
    def _updatePage(self, page):
        path = page.getHtmlPath()
        cache = HtmlCache(page, self._application)

        # Проверим, можно ли прочитать уже готовый HTML
        if cache.canReadFromCache() and os.path.exists(path):
            return

        style = Style()
        stylepath = style.getPageStyle(page)
        generator = HtmlGenerator(page)

        html = generator.makeHtml(stylepath)
        writeTextFile(path, html)
        cache.saveHash()
示例#30
0
    def content(self, text):
        if self.readonly:
            raise ReadonlyException

        text = text.replace('\r\n', '\n')

        params = events.PreContentWritingParams(text)
        self.root.onPreContentWriting(self, params)
        text = params.content

        if text != self.content or text == u"":
            path = os.path.join(self.path, RootWikiPage.contentFile)

            writeTextFile(path, text)
            self.updateDateTime()
            self.root.onPageUpdate(self, change=events.PAGE_UPDATE_CONTENT)
示例#31
0
    def content(self, text):
        if self.readonly:
            raise ReadonlyException

        text = text.replace('\r\n', '\n')

        params = events.PreContentWritingParams(text)
        self.root.onPreContentWriting(self, params)
        text = params.content

        if text != self.content or text == u"":
            path = os.path.join(self.path, RootWikiPage.contentFile)

            writeTextFile(path, text)
            self.updateDateTime()
            self.root.onPageUpdate(self, change=events.PAGE_UPDATE_CONTENT)
示例#32
0
    def generatefiles (self, indexfname, contentfname):
        """
        Создать файлы с оглавлением
        outdir - папка, где должны быть созданы файлы
        indexfname - имя главного файла содержания (index.html)
        contentfname - имя файла со ссылками на страницы
        """
        # Создать экземпляр класса, оформляющий список страниц
        contentgenerator = IndexContentGenerator (self.__rootpage, self.__renames)
        contentgenerator.generate (contentfname)

        # Создать файл с фреймами, отображающий все оглавление
        indextemplate = loadTemplate (self.__templatename)
        indexresult = indextemplate.substitute (contentfname=os.path.basename (contentfname))

        writeTextFile(indexfname, indexresult)
示例#33
0
    def generatefiles(self, indexfname, contentfname):
        """
        Создать файлы с оглавлением
        outdir - папка, где должны быть созданы файлы
        indexfname - имя главного файла содержания (index.html)
        contentfname - имя файла со ссылками на страницы
        """
        # Создать экземпляр класса, оформляющий список страниц
        contentgenerator = IndexContentGenerator(self.__rootpage,
                                                 self.__renames)
        contentgenerator.generate(contentfname)

        # Создать файл с фреймами, отображающий все оглавление
        indextemplate = loadTemplate(self.__templatename)
        indexresult = indextemplate.substitute(
            contentfname=os.path.basename(contentfname))

        writeTextFile(indexfname, indexresult)
示例#34
0
    def _processSource(self, source: SiteContentSource) -> None:
        if not os.path.exists(os.path.join(self._templates_path, source.template_file)):
            print_error('Template file not found: {}'.format(
                source.template_file))
            return

        if not os.path.exists(source.versions_xml_file):
            print_error('XML file not found: {}'.format(
                source.versions_xml_file))
            return

        versions_xml_content = readTextFile(source.versions_xml_file)
        versions_info = ChangeLogFactory.fromString(versions_xml_content,
                                                    source.lang)

        template_env = Environment(
            loader=FileSystemLoader(self._templates_path))
        template = template_env.get_template(source.template_file)

        current_version = versions_info.latestVersion
        if current_version is not None:
            version_full_str = str(current_version.version)
            version_main = '.'.join([str(n)
                                     for n
                                     in current_version.version[:-1]]
                                    )
            version_build = current_version.version[-1]
        else:
            print_error('Invalid version in {}'.format(source.versions_xml_file))
            return

        versions_list = versions_info.versions

        result = template.render(
            version_full=version_full_str,
            version_main=version_main,
            version_build=version_build,
            versions_list=versions_list,
            date=current_version.date,
        )

        template_name = os.path.basename(source.template_file)
        result_fname = os.path.join(self.build_dir, template_name)
        writeTextFile(result_fname, result)
示例#35
0
    def _exportContent(self, page, content, exportname, outdir, imagesonly,
                       alwaisOverwrite):
        """
        Экспортировать обработанное содержимое и вложения
        """
        exportfile = os.path.join(outdir, exportname + ".html")
        exportdir = os.path.join(outdir, exportname)

        if not alwaisOverwrite and os.path.exists(exportfile):
            raise FileAlreadyExists(
                _(u"File {0} already exists").format(exportfile))

        if not os.path.exists(outdir):
            raise FolderNotExists(_(u"Folder {0} not exists").format(outdir))

        writeTextFile(exportfile, content)

        self.__exportAttaches(page, exportdir, imagesonly, alwaisOverwrite)
        self.__exportIcon(page, exportdir, alwaisOverwrite)
示例#36
0
    def test_loadCustomStyles_more_dirs_repeat_names(self):
        dirname_1 = mkdtemp()
        dirname_2 = mkdtemp()
        self._tmp_dirs.append(dirname_1)
        self._tmp_dirs.append(dirname_2)

        writeTextFile(os.path.join(dirname_1, 'style-1.css'), 'test-1')
        writeTextFile(os.path.join(dirname_1, 'style-2.css'), 'test-2')
        writeTextFile(os.path.join(dirname_1, 'style-3.css'), 'test-3')

        writeTextFile(os.path.join(dirname_2, 'style-1.css'), 'test-1-new')
        writeTextFile(os.path.join(dirname_2, 'style-5.css'), 'test-5')

        styles = loadCustomStyles(self._tmp_dirs)
        self.assertEqual(styles, {'style-1': 'test-1-new',
                                  'style-2': 'test-2',
                                  'style-3': 'test-3',
                                  'style-5': 'test-5',
                                  })
示例#37
0
    def test_loadCustomStyles_more_dirs_repeat_names(self):
        dirname_1 = mkdtemp()
        dirname_2 = mkdtemp()
        self._tmp_dirs.append(dirname_1)
        self._tmp_dirs.append(dirname_2)

        writeTextFile(os.path.join(dirname_1, 'style-1.css'), 'test-1')
        writeTextFile(os.path.join(dirname_1, 'style-2.css'), 'test-2')
        writeTextFile(os.path.join(dirname_1, 'style-3.css'), 'test-3')

        writeTextFile(os.path.join(dirname_2, 'style-1.css'), 'test-1-new')
        writeTextFile(os.path.join(dirname_2, 'style-5.css'), 'test-5')

        styles = loadCustomStyles(self._tmp_dirs)
        self.assertEqual(styles, {'style-1': 'test-1-new',
                                  'style-2': 'test-2',
                                  'style-3': 'test-3',
                                  'style-5': 'test-5',
                                  })
示例#38
0
    def _processSource(self, source: SiteContentSource) -> None:
        if not os.path.exists(os.path.join(self._templates_path, source.template_file)):
            print_error('Template file not found: {}'.format(source.template_file))
            return

        if not os.path.exists(source.xml_file):
            print_error('XML file not found: {}'.format(source.xml_file))
            return

        xml_content = readTextFile(source.xml_file)
        parser = XmlVersionParser([source.lang])
        appinfo = parser.parse(xml_content)

        # template_content = readTextFile(source.template_file)
        # template = Template(template_content)
        template_env = Environment(loader=FileSystemLoader(self._templates_path))
        template = template_env.get_template(source.template_file)

        current_version = appinfo.versionsList[0]
        version_full_str = str(current_version.version)
        version_main = '.'.join([str(n)
                                 for n
                                 in current_version.version[:-1]]
                                )
        version_build = current_version.version[-1]
        versions_list = appinfo.versionsList
        date = current_version.date_str

        result = template.render(
            version_full=version_full_str,
            version_main=version_main,
            version_build=version_build,
            versions_list=versions_list,
            date=date,
        )

        template_name = os.path.basename(source.template_file)
        result_fname = os.path.join(self.build_dir, template_name)
        writeTextFile(result_fname, result)
示例#39
0
    def _processSource(self, source: SiteContentSource) -> None:
        if not os.path.exists(
                os.path.join(self._templates_path, source.template_file)):
            print_error('Template file not found: {}'.format(
                source.template_file))
            return

        if not os.path.exists(source.xml_file):
            print_error('XML file not found: {}'.format(source.xml_file))
            return

        xml_content = readTextFile(source.xml_file)
        parser = XmlVersionParser([source.lang])
        appinfo = parser.parse(xml_content)

        # template_content = readTextFile(source.template_file)
        # template = Template(template_content)
        template_env = Environment(
            loader=FileSystemLoader(self._templates_path))
        template = template_env.get_template(source.template_file)

        current_version = appinfo.versionsList[0]
        version_full_str = str(current_version.version)
        version_main = '.'.join([str(n) for n in current_version.version[:-1]])
        version_build = current_version.version[-1]
        versions_list = appinfo.versionsList
        date = current_version.date_str

        result = template.render(
            version_full=version_full_str,
            version_main=version_main,
            version_build=version_build,
            versions_list=versions_list,
            date=date,
        )

        template_name = os.path.basename(source.template_file)
        result_fname = os.path.join(self.build_dir, template_name)
        writeTextFile(result_fname, result)
示例#40
0
    def _exportContent (self,
                        page,
                        content,
                        exportname,
                        outdir,
                        imagesonly,
                        alwaisOverwrite):
        """
        Экспортировать обработанное содержимое и вложения
        """
        exportfile = os.path.join (outdir, exportname + ".html")
        exportdir = os.path.join (outdir, exportname)

        if not alwaisOverwrite and os.path.exists (exportfile):
            raise FileAlreadyExists (_(u"File {0} already exists").format (exportfile))

        if not os.path.exists (outdir):
            raise FolderNotExists (_(u"Folder {0} not exists").format (outdir))

        writeTextFile(exportfile, content)

        self.__exportAttaches (page, exportdir, imagesonly, alwaisOverwrite)
        self.__exportIcon (page, exportdir, alwaisOverwrite)
示例#41
0
    def test_getCustomStylesNames_single_dir(self):
        dirname = mkdtemp()
        self._tmp_dirs.append(dirname)

        writeTextFile(os.path.join(dirname, 'style-1.css'), '')
        writeTextFile(os.path.join(dirname, 'style-2.css'), '')
        writeTextFile(os.path.join(dirname, 'style-3.css'), '')

        styles = sorted(getCustomStylesNames(self._tmp_dirs))
        self.assertEqual(styles, ['style-1', 'style-2', 'style-3'])
示例#42
0
    def test_getCustomStylesNames_single_dir(self):
        dirname = mkdtemp()
        self._tmp_dirs.append(dirname)

        writeTextFile(os.path.join(dirname, 'style-1.css'), '')
        writeTextFile(os.path.join(dirname, 'style-2.css'), '')
        writeTextFile(os.path.join(dirname, 'style-3.css'), '')

        styles = sorted(getCustomStylesNames(self._tmp_dirs))
        self.assertEqual(styles, ['style-1', 'style-2', 'style-3'])
示例#43
0
    def test_loadCustomStyles_single_dir(self):
        dirname = mkdtemp()
        self._tmp_dirs.append(dirname)

        writeTextFile(os.path.join(dirname, 'style-1.css'), 'test-1')
        writeTextFile(os.path.join(dirname, 'style-2.css'), 'test-2')
        writeTextFile(os.path.join(dirname, 'style-3.css'), 'test-3')

        styles = loadCustomStyles(self._tmp_dirs)
        self.assertEqual(styles, {'style-1': 'test-1',
                                  'style-2': 'test-2',
                                  'style-3': 'test-3',
                                  })
示例#44
0
    def test_loadCustomStyles_single_dir(self):
        dirname = mkdtemp()
        self._tmp_dirs.append(dirname)

        writeTextFile(os.path.join(dirname, 'style-1.css'), 'test-1')
        writeTextFile(os.path.join(dirname, 'style-2.css'), 'test-2')
        writeTextFile(os.path.join(dirname, 'style-3.css'), 'test-3')

        styles = loadCustomStyles(self._tmp_dirs)
        self.assertEqual(styles, {'style-1': 'test-1',
                                  'style-2': 'test-2',
                                  'style-3': 'test-3',
                                  })
示例#45
0
 def _updatePage(self, page):
     path = page.getHtmlPath()
     html = self.generateHtml(page)
     writeTextFile(path, html)
示例#46
0
 def _updatePage(self, page):
     path = page.getHtmlPath()
     html = self.generateHtml(page)
     writeTextFile(path, html)
示例#47
0
 def _saveCustomDict (self):
     text = self._sanitizeDictText (self.customDict.GetValue())
     try:
         writeTextFile (self._getCustomDictFileName(), text)
     except (IOError, SystemError):
         pass
示例#48
0
 def _saveCustomDict(self):
     text = self._sanitizeDictText(self.customDict.GetValue())
     try:
         writeTextFile(self._getCustomDictFileName(), text)
     except (IOError, SystemError):
         pass
示例#49
0
 def save(self, items):
     text = json.dumps(items)
     try:
         writeTextFile(self._fname, text)
     except IOError:
         logger.error('Error saving a notes tree registry')
示例#50
0
 def save(self, items):
     text = json.dumps(items)
     try:
         writeTextFile(self._fname, text)
     except IOError:
         logger.error('Error saving a notes tree registry')