Example #1
0
def create_page(title, template):
    '''
    Creates a new page with the given title or makes an existing file a page.
    '''
    move = os.path.exists(title)

    if move:
        new_page = page.move(title)
    else:
        new_page = page.create(title, template)

    output.filename.info(new_page.path)
    if move:
        output.write.info("Draft moved to page '%s'" % new_page.path)
    else:
        output.write.info("New page created as '%s'" % new_page.path)
Example #2
0
def create_page(title, template):
    '''
    Creates a new page with the given title or makes an existing file a page.
    '''
    move = os.path.exists(title)

    if move:
        new_page = page.move(title)
    else:
        new_page = page.create(title, template)

    output.filename.info(new_page.path)
    if move:
        output.write.info("Draft moved to page '%s'" % new_page.path)
    else:
        output.write.info("New page created as '%s'" % new_page.path)
Example #3
0
    def test_move(self):
        # create a "pre-existing" file
        draft_file = os.path.join(utils.TEST_ROOT, "drafts", "afile.rst")

        with open(draft_file, "w") as f:
            f.write("Content")

        # move file to page
        moved_page = page.move(draft_file)

        self.assertEquals(
            os.path.abspath(os.path.join(utils.TEST_ROOT, "pages",
                                         "afile.rst")), moved_page.path)

        self.assertTrue(os.path.exists(moved_page.path))
        self.assertFalse(os.path.exists(draft_file))
        self.assertEquals("pages/afile", moved_page.docname)
Example #4
0
    def test_move(self):
        # create a "pre-existing" file
        draft_file = os.path.join(utils.TEST_ROOT, "drafts", "afile.rst")

        with open(draft_file, "w") as f:
            f.write("Content")

        # move file to page
        moved_page = page.move(draft_file)

        self.assertEquals(
            os.path.abspath(os.path.join(
                utils.TEST_ROOT,
                "pages",
                "afile.rst")),
            moved_page.path)

        self.assertTrue(os.path.exists(moved_page.path))
        self.assertFalse(os.path.exists(draft_file))
        self.assertEquals("pages/afile", moved_page.docname)
Example #5
0
    def test_move_duplicate(self):
        # create initial page
        page.create("Page1")

        # should raise
        page.move("Page1")
Example #6
0
    def test_move_duplicate(self):
        # create initial page
        page.create("Page1")

        # should raise
        page.move("Page1")