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
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
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
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
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_
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())