本文整理匯總了Python中moments.path.Path.to_tags方法的典型用法代碼示例。如果您正苦於以下問題:Python Path.to_tags方法的具體用法?Python Path.to_tags怎麽用?Python Path.to_tags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類moments.path.Path
的用法示例。
在下文中一共展示了Path.to_tags方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestPath
# 需要導入模塊: from moments.path import Path [as 別名]
# 或者: from moments.path.Path import to_tags [as 別名]
class TestPath(object):
"""
see also test node
"""
def setUp(self):
self.path = Path("/a/b/c/d.txt")
def test_init(self):
#make sure it loads
assert self.path
def test_periods(self):
name = ".emacs.desktop"
p = Path(name)
print(name_only(name))
print(str(p))
assert name == str(p)
def test_path_to_tag(self):
#s = path_to_tags("a/b/c/d.txt")
s = self.path.to_tags()
#assert s == "hello_tag", s
assert_equal (s, ["a", "b", "c", "d"])
s = Path("/d/e/f.g.txt").to_tags()
assert_equal (s, ["d", "e", "f.g"])
#s = path_to_tags("/h/i/j/k/")
s = Path("/h/i/j/k/").to_tags()
assert_equal (s, ["h", "i", "j", "k"])
def test_hidden(self):
path_s = "zoobar/.emacs"
hidden = Path(path_s)
print(str(hidden))
print("Filename: %s (name: %s, extension: %s)" % (hidden.filename, hidden.name, hidden.extension))
assert hidden._full_name == ".emacs"
#assert name_only(path_s)
assert hidden.filename == ".emacs"
assert str(hidden) == path_s
def test_load_journal(self):
dest = 'zoobar/todo.txt'
p = Path(dest)
p.load_journal(create=True)
assert os.path.exists(dest)
p.remove()
assert not os.path.exists(dest)
def test_create(self):
p = "create_me.txt"
path = Path(p)
assert not os.path.exists(p)
path.create()
assert os.path.exists(p)
path.remove()
assert not os.path.exists(p)