예제 #1
0
파일: __init__.py 프로젝트: nstinus/pitz
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
0
파일: __init__.py 프로젝트: gitmob/pitz
    def edit(self, attr):
        """
        if attr is in the allowed_types dictionary, and the allowed type
        is an Entity subclass, then show a list of all instances of the
        subclass and ask for a choice.

        Otherwise, open an editor with the value for this attr.
        """

        if attr in self.allowed_types:
            allowed_type = self.allowed_types[attr]

            # Handle stuff like foo=[Entity] here.
            if isinstance(allowed_type, list) \
            and len(allowed_type) == 1 \
            and issubclass(allowed_type[0], Entity):

                self[attr] = allowed_type[0]\
                .choose_many_from_already_instantiated()


            # Handle stuff like foo=Entity here.
            elif issubclass(allowed_type, Entity):

                self[attr] = \
                allowed_type.choose_from_already_instantiated()

        else:
            self[attr] = clepy.edit_with_editor(self.get(attr))

        return self
예제 #3
0
파일: __init__.py 프로젝트: nstinus/pitz
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.")
예제 #4
0
파일: __init__.py 프로젝트: nstinus/pitz
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
0
파일: pitzaddtag.py 프로젝트: gitmob/pitz
    def handle_proj(self, p, options, args, proj):

        t = Tag(

            proj,

            title=options.title or raw_input('Tag title: ').strip(),

            description=(
                '' if options.no_description
                else clepy.edit_with_editor('# Tag description here')),

        )

        proj.append(t)

        print("Added %r to the project." % t)
예제 #6
0
파일: pitzcomment.py 프로젝트: gitmob/pitz
    def handle_proj(self, p, options, args, proj):

        if not proj.me:
            print("Sorry, I don't know who you are.")
            print("Use pitz-me to add yourself to the project.")
            sys.exit()

        e = proj[args[0]]

        c = e.comment(

            who_said_it=proj.me,

            title=options.title or raw_input("Comment title: ").strip(),

            description='' if options.no_description \
            else clepy.edit_with_editor('# Comment description goes here'))

        print("Added comment %r on entity %r to the project." % (c, e))
예제 #7
0
파일: __init__.py 프로젝트: nstinus/pitz
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()
예제 #8
0
파일: __init__.py 프로젝트: gitmob/pitz
    def comment(self, who_said_it=None, title=None, description=None):
        """
        Store a comment on this entity.
        """

        if not who_said_it:

            if self.project and hasattr(self.project, 'me'):
                who_said_it = self.project.me

            else:
                who_said_it = Person.choose()

        if title is None:
            title = '''RE: task %(frag)s "%(title)s"''' % self

        if description is None:
            description = clepy.edit_with_editor("# Comment goes here")

        return Comment(self.project, entity=self.uuid, title=title,
            who_said_it=who_said_it, description=description)
예제 #9
0
파일: __init__.py 프로젝트: nstinus/pitz
    def handle_proj(self, p, options, args, proj):

        default_milestone = Milestone(proj, title='unscheduled')
        default_estimate = Estimate(proj, title='not estimated')
        default_owner = Person(proj, title='no owner')
        default_tags = list()

        t = Task(

            proj,

            title=options.title or raw_input("Task title: ").strip(),

            description=(
                '' if options.no_description
                else clepy.edit_with_editor('# Task description goes here')),

            status=Status(proj, title='unstarted'),

            milestone=default_milestone if options.use_defaults \
            else Milestone.choose_from_already_instantiated(
                default_milestone,
                predicate=lambda m: not m.reached),

            estimate=default_estimate if options.use_defaults \
            else Estimate.choose_from_already_instantiated(default_estimate),

            owner=default_owner if options.use_defaults \
            else Person.choose_from_already_instantiated(default_owner),

            tags=default_tags if options.use_defaults \
            else Tag.choose_many_from_already_instantiated(),

        )

        proj.append(t)

        print("Added %r to the project." % t)