本文整理汇总了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)