当前位置: 首页>>代码示例>>Python>>正文


Python Project.to_yaml_file方法代码示例

本文整理汇总了Python中pitz.project.Project.to_yaml_file方法的典型用法代码示例。如果您正苦于以下问题:Python Project.to_yaml_file方法的具体用法?Python Project.to_yaml_file怎么用?Python Project.to_yaml_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pitz.project.Project的用法示例。


在下文中一共展示了Project.to_yaml_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestFromPitzdir

# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import to_yaml_file [as 别名]
class TestFromPitzdir(unittest.TestCase):

    def setUp(self):

        self.p = Project(pathname='/tmp')
        self.p.to_yaml_file()
        self.p.to_pickle()

    def tearDown(self):

        for f in glob.glob('/tmp/*.yaml'):
            os.unlink(f)

        if os.path.isfile('/tmp/project.pickle'):
            os.unlink('/tmp/project.pickle')

    def test_fresh_pickle(self):
        """
        Verify we use the pickle when we can.
        """

        p = Project.from_pitzdir('/tmp')
        assert p.loaded_from == 'pickle', p.loaded_from

    def test_stale_pickle(self):
        """
        Verify we use the yaml files when the pickle is too old.
        """

        stat = os.stat('/tmp/project.pickle')

        os.utime('/tmp/project.pickle',
            (stat.st_atime-1, stat.st_mtime-1))

        print("pickle file: %s"
            % os.stat('/tmp/project.pickle').st_mtime)

        print("newest yaml file: %s"
            % max([os.stat(f).st_mtime for f in glob.glob('/tmp/*.yaml')]))

        p = Project.from_pitzdir('/tmp')
        assert p.loaded_from == 'yaml', p.loaded_from

    def test_from_yaml_files(self):
        """
        Verify we can use the yaml files when no pickle exists.
        """

        os.unlink('/tmp/project.pickle')

        p = Project.from_pitzdir('/tmp')
        assert p.loaded_from == 'yaml', p.loaded_from
开发者ID:gitmob,项目名称:pitz,代码行数:54,代码来源:test_project.py

示例2: pitz_setup

# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import to_yaml_file [as 别名]
def pitz_setup():

    """
    Start a new project
    """

    p = optparse.OptionParser()

    p.epilog = "Set up pitz"

    p.add_option('--version', action='store_true',
        help='show pitz version')

    options, args = p.parse_args()

    if options.version:
        print_version()
        return

    dir = os.path.basename(os.getcwd())

    project_name = raw_input(
        "Project name (hit ENTER for %s): " % dir).strip()

    if not project_name:
        project_name = dir

    pitzdir = mk_pitzdir()

    proj = Project(pathname=pitzdir, title=project_name)
    proj.to_yaml_file()

    Status.setup_defaults(proj)

    pw_name = pwd.getpwuid(os.getuid()).pw_name

    name = raw_input("Your name (hit ENTER for %s): " % pw_name).strip()

    if not name:
        name = pw_name

    person = Person(proj, title=name)

    proj.save_entities_to_yaml_files()
    print("All done!")
    print("Run pitz-add-task to add a task, or run pitz-help for help.")
开发者ID:gitmob,项目名称:pitz,代码行数:48,代码来源:pitzsetup.py

示例3: test_to_yaml_file_2

# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import to_yaml_file [as 别名]
def test_to_yaml_file_2(o):

    p = Project("Bogus")
    p.to_yaml_file()
开发者ID:gitmob,项目名称:pitz,代码行数:6,代码来源:test_project.py

示例4: test_to_yaml_file_1

# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import to_yaml_file [as 别名]
def test_to_yaml_file_1(m1, m2):

    p = Project("Bogus")
    p.to_yaml_file('bogus-pathname')
开发者ID:gitmob,项目名称:pitz,代码行数:6,代码来源:test_project.py


注:本文中的pitz.project.Project.to_yaml_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。