Esempio n. 1
0
def move(path, date=None):
    '''
    Moves a post given its path.
    '''
    post = Post(title=None, path=path, date=date)
    if os.path.exists(post.path):
        raise Exception("Post '%s' already exists" % (post.path, ))
    shutil.move(path, post.path)
    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 2
0
def move(path, date=None):
    '''
    Moves a post given its path.
    '''
    post = Post(title=None, path=path, date=date)
    if os.path.exists(post.path):
        raise Exception("Post '%s' already exists" %
                        (post.path,))
    shutil.move(path, post.path)
    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 3
0
def move(path, date=None):
    '''
    Moves a post given its path.
    '''
    post = Post(title=None, path=path, date=date)

    target_dir = os.path.dirname(post.path)
    utils.move(path, target_dir)

    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 4
0
def create(title, date=None, template=None):
    '''
    Creates a new post given its title.
    '''
    post = Post(title, path=None, date=date)
    if os.path.exists(post.path):
        raise Exception("Post '%s' already exists at '%s" % (title, post.path))

    post.write(template=template)
    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 5
0
def create(title, date=None, template=None):
    '''
    Creates a new post given its title.
    '''
    post = Post(title, path=None, date=date)
    if os.path.exists(post.path):
        raise Exception("Post '%s' already exists at '%s" %
                        (title, post.path))

    post.write(template=template)
    if not master.exists_doc(post.docname):
        master.prepend_doc(post.docname)
    return post
Esempio n. 6
0
def post(twinkerer, cmd_args):
    user_id_ = twinkerer.me['id']
    title_ = twinkerer.build_title(cmd_args.from_date, cmd_args.to_date)
    post_ = twinkerer.create_post(title_, cmd_args.post_date)
    post_content = ''
    timeline_ = twinkerer.fetch_timeline(
        user_id_,
        cmd_args.from_datetime,
        cmd_args.to_datetime,
    )
    post_content = ''.join([tl.as_html() for tl in timeline_])
    result_ = post_.write(post_content, author="default",
              categories="none", tags="none",
              template=None)
    if not master.exists_doc(post_.docname):
        master.prepend_doc(post_.docname)
    return post_
Esempio n. 7
0
    def test_prepend(self):
        new_docs = ["somewhere/somedoc", "anotherdoc"]

        # first doc should be prepended in the correct place
        master.prepend_doc(new_docs[0])

        self.assertEquals(
            TestMaster.MASTER_HEAD + ["   %s\n" % new_docs[0]] +
            TestMaster.MASTER_TAIL, master.read_master())

        master.prepend_doc(new_docs[1])

        # order should be second doc then first doc
        self.assertEquals(
            TestMaster.MASTER_HEAD +
            ["   %s\n" % new_docs[1],
             "   %s\n" % new_docs[0]] + TestMaster.MASTER_TAIL,
            master.read_master())
Esempio n. 8
0
    def test_prepend(self):
        new_docs = ["somewhere/somedoc", "anotherdoc"]

        # first doc should be prepended in the correct place
        master.prepend_doc(new_docs[0])

        self.assertEquals(
            TestMaster.MASTER_HEAD +
            ["   %s\n" % new_docs[0]] +
            TestMaster.MASTER_TAIL,
            master.read_master())

        master.prepend_doc(new_docs[1])

        # order should be second doc then first doc
        self.assertEquals(
            TestMaster.MASTER_HEAD +
            ["   %s\n" % new_docs[1], "   %s\n" % new_docs[0]] +
            TestMaster.MASTER_TAIL,
            master.read_master())