本文整理汇总了Python中pitz.project.Project类的典型用法代码示例。如果您正苦于以下问题:Python Project类的具体用法?Python Project怎么用?Python Project使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pitz_add_person
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.")
示例2: pitz_destroy
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()
示例3: pitz_estimate_task
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()
示例4: pitz_add_milestone
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)
示例5: pitz_attach_file
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()
示例6: pitz_claim_task
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()
示例7: pitz_add_status
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()
示例8: setup_proj
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
示例9: TestFromPitzdir
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
示例10: test_self_destruct_1
def test_self_destruct_1():
"""
Delete an entity.
"""
p = Project()
p.pathname = '/tmp'
e1 = Entity(p, title="e1", a=1, b=2)
file_written = e1.to_yaml_file(p.pathname)
files_deleted = e1.self_destruct(p)
assert files_deleted == [file_written]
assert not os.path.exists(file_written)
示例11: test_from_yaml_file_1
def test_from_yaml_file_1(m1, m2, m3):
# yaml.load(...) will return m2.
m2.return_value = {
'order_method_name': 'bogus_method',
'module': 'pitz.project',
'classname': 'Project'}
# globals() will return m3.
m3.return_value = {'bogus_method': lambda e1, e2: 1}
p = Project("Bogus")
b2 = p.from_yaml_file('xyz')
assert b2.order_method == m3.return_value['bogus_method']
示例12: TestSorting1
class TestSorting1(unittest.TestCase):
"""
Verify that we can sort on the pscore attribute.
"""
def setUp(self):
self.p = Project(title="test pscore")
self.e1 = Entity(self.p, title="e1")
self.e2 = Entity(self.p, title="e2")
self.e3 = Entity(self.p, title="e3")
self.e4 = Entity(self.p, title="e4")
print("Original order of entities:")
for e in self.p:
print("%(title)s %(pscore)s" % e)
def test_sort(self):
assert self.p.length == 4
assert self.p.order_method == \
pitz.by_milestone_status_pscore_created_time, \
self.p.order_method
for e in self.p:
assert e['pscore'] == 0, e['pscore']
assert list(self.p) == [self.e1, self.e2, self.e3, self.e4]
self.e1['pscore'] = -10
self.p.order()
print("After first pscore change")
for e in self.p:
print("%(title)s %(pscore)s" % e)
assert list(self.p) == [self.e2, self.e3, self.e4, self.e1]
self.e3['pscore'] = 10
self.p.order()
print("After second pscore change")
for e in self.p:
print "%(title)s %(pscore)s" % e
assert list(self.p) == [self.e3, self.e2, self.e4, self.e1], \
"self.p is \n---\n%s\n---\n" % self.p
示例13: pitz_webapp
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()
示例14: test_4
def test_4(self):
"""
Verify we can walk up and find pitzdir.
"""
os.chdir('/tmp/walkup/pitzdir/foo')
assert Project.find_pitzdir() == '/tmp/walkup/pitzdir'
示例15: test_1
def test_1(self):
"""
Verify we can use the parameter
"""
assert Project.find_pitzdir('/tmp/walkup/pitzdir') \
== '/tmp/walkup/pitzdir'