本文整理汇总了Python中pitz.project.Project.from_pitzdir方法的典型用法代码示例。如果您正苦于以下问题:Python Project.from_pitzdir方法的具体用法?Python Project.from_pitzdir怎么用?Python Project.from_pitzdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pitz.project.Project
的用法示例。
在下文中一共展示了Project.from_pitzdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pitz_add_status
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_add_status():
p = setup_options()
p.add_option('-t', '--title', help='Status title')
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
s = Status(
proj,
title=options.title or raw_input("Status title: ").strip(),
description=clepy.edit_with_editor('# Status description goes here'),
)
proj.append(s)
print("Added %s to the project." % s.summarized_view)
proj.save_entities_to_yaml_files()
示例2: pitz_estimate_task
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_estimate_task():
# Start of code to set up project.
p = setup_options()
p.set_usage("%prog task [estimate]")
options, args = p.parse_args()
if not args:
p.print_usage()
return
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
# end of code to set up project.
t = proj[args[0]]
if len(args) == 2:
est = proj[args[1]]
else:
est = Estimate.choose_from_already_instantiated()
t['estimate'] = est
# Save the project.
proj.save_entities_to_yaml_files()
示例3: test_fresh_pickle
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
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
示例4: pitz_claim_task
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_claim_task():
p = setup_options()
p.set_usage("%prog task")
options, args = p.parse_args()
if not args:
p.print_usage()
return
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
if not proj.me:
print("Sorry, I don't know who you are.")
print("Use pitz-me to add yourself to the project.")
return
t = proj[args[0]]
t.assign(proj.me)
proj.save_entities_to_yaml_files()
示例5: pitz_destroy
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_destroy():
p = setup_options()
p.add_option('-t', '--title', help='Status title')
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
e = proj[args[0]]
if isinstance(e, Entity):
e.self_destruct(proj)
print("""%(frag)s: "%(title)s" is no longer part of the project."""
% e)
proj.save_entities_to_yaml_files()
示例6: pitz_add_person
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_add_person():
p = setup_options()
p.add_option('-t', '--title', help='Person title')
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
person = Person(
proj,
title=options.title or raw_input("Person title: ").strip(),
description=clepy.edit_with_editor('# Person description goes here'),
)
proj.append(person)
print("Added %s to the project." % person.summarized_view)
proj.save_entities_to_yaml_files()
if raw_input("Should I identify you as %(title)s? (y/N)" % person)\
.strip().lower().startswith('y'):
person.save_as_me_yaml()
print("OK, I'll recognize you as %(title)s from now on.")
示例7: pitz_attach_file
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_attach_file():
# Generic.
p = setup_options()
# Every script may have a slightly different usage.
p.set_usage("%prog entity file-to-attach")
# This is generic.
options, args = p.parse_args()
if options.version:
print_version()
return
# End of generic stuff.
# Every script may have different required args.
if len(args) != 2:
p.print_usage()
return
# Generic code to build the project.
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
# Start of interesting stuff that is specific just for this script.
e, filepath = proj[args[0]], args[1]
e.save_attachment(filepath)
# Save the project. (This could also be generic).
proj.save_entities_to_yaml_files()
示例8: pitz_add_milestone
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_add_milestone():
p = setup_options()
p.add_option('-t', '--title', help='Milestone title')
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
pidfile = write_pidfile_or_die(pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
m = Milestone(
proj,
title=options.title or raw_input("Milestone title: ").strip(),
description=clepy.edit_with_editor(
'# Milestone description goes here'),
reached=Milestone.choose_from_allowed_values('reached', False),
)
proj.append(m)
print("Added %s to the project." % m.summarized_view)
proj.save_entities_to_yaml_files()
os.remove(pidfile)
示例9: test_from_yaml_files
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
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
示例10: setup_proj
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def setup_proj(self, p, options, args):
pitzdir = Project.find_pitzdir(options.pitzdir)
pidfile = write_pidfile_or_die(pitzdir)
proj = Project.from_pitzdir(pitzdir)
log.debug("Loaded project from %s" % proj.loaded_from)
proj.pidfile = pidfile
proj.find_me()
return proj
示例11: pitz_webapp
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_webapp():
"""
This function gets run by the command-line script pitz-webapp.
"""
p = setup_options()
p.add_option('-p', '--port', help='HTTP port (default is 9876)',
type='int', action='store', default=9876)
options, args = p.parse_args()
pitz.setup_logging(getattr(logging, options.log_level))
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
app = webapp.SimpleWSGIApp(proj)
# Remember that the order that you add handlers matters. When a
# request arrives, the app starts with the first handler added and
# asks it if wants to handle that request. So, the default handler
# (if you make one) belongs at the end.
# Consider this section below the same as the urls.py file in
# django.
static_files = os.path.join(os.path.split(
os.path.dirname(__file__))[0], 'static')
app.handlers.append(handlers.FaviconHandler(static_files))
app.handlers.append(handlers.StaticHandler(static_files))
app.handlers.append(handlers.HelpHandler(proj))
app.handlers.append(handlers.Update(proj))
app.handlers.append(handlers.ByFragHandler(proj))
app.handlers.append(handlers.EditAttributes(proj))
app.handlers.append(handlers.Project(proj))
app.handlers.append(handlers.Team(proj))
httpd = make_server('', options.port, app)
print "Serving on port %d..." % options.port
httpd.serve_forever()
示例12: pitz_html
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_html():
"""
Write out a bunch of HTML files.
"""
with clepy.spinning_distraction():
p = setup_options()
p.set_usage('%prog [options] directory')
p.add_option('--force',
help='Ignore timestamps and regenerate all files',
action='store_true',
default=False)
options, args = p.parse_args()
if options.version:
print_version()
return
if not args:
p.print_usage()
sys.exit()
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
htmldir = args[0]
proj.to_html(htmldir)
proj.todo.to_html(htmldir)
proj.milestones.to_html(htmldir)
proj.tasks.to_html(htmldir)
proj.components.to_html(htmldir)
print("Wrote %d html files out of %d entities in project."
% (
len([e for e in proj
if e.to_html_file(htmldir, options.force)]),
len(proj)))
# Record that we rebuilt all the HTML files.
proj.save_entities_to_yaml_files()
示例13: test_stale_pickle
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
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
示例14: pitz_add_estimate
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_add_estimate():
p = setup_options()
p.add_option('-t', '--title', help='Estimate title')
p.add_option('--from-builtin-estimates',
action='store_true',
help='Choose from estimates I already made')
options, args = p.parse_args()
if options.version:
print_version()
raise SystemExit
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
if options.from_builtin_estimates:
print("Right now, you got %d estimates in your project."
% (proj.estimates.length))
range = Estimate.choose_estimate_range()
if range:
print("Adding...")
Estimate.add_range_of_estimates_to_project(proj, range)
proj.save_entities_to_yaml_files()
raise SystemExit
est = Estimate(
proj,
title=options.title or raw_input("Estimate title: ").strip(),
description=clepy.edit_with_editor('# Estimate description goes here'),
points=int(raw_input("Points: ").strip()),
)
proj.append(est)
print("Added %s to the project." % est.summarized_view)
proj.save_entities_to_yaml_files()
示例15: pitz_shell
# 需要导入模块: from pitz.project import Project [as 别名]
# 或者: from pitz.project.Project import from_pitzdir [as 别名]
def pitz_shell():
"""
Start an ipython session after loading in a project.
"""
p = setup_options()
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
pidfile = write_pidfile_or_die(pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj._shell_mode = True
proj.find_me()
# Everything in this dictionary will be added to the top-level
# namespace in the shell.
ns = dict([(C.__name__, C) for C in proj.classes.values()])
ns['p'] = proj
ns['send_through_pager'] = clepy.send_through_pager
ns['edit_with_editor'] = clepy.edit_with_editor
from IPython.Shell import IPShellEmbed
s = IPShellEmbed(['-colors', 'Linux'])
s(local_ns=ns)
# This stuff happens when you close the IPython session.
answer = raw_input("Write out updated yaml files? ([y]/n) ").strip()
if answer.lower() not in ['n', 'no']:
proj.to_yaml_file()
proj.to_pickle()
proj.save_entities_to_yaml_files()
# Remove the pidfile.
os.remove(pidfile)