Exemplo n.º 1
0
def main(argv, global_options):
    """ Command entry-point for the cone pattern-generator. """
    import optparse
    _ = localization.get_translation()
    opt_parser = optparse.OptionParser(
    _('%prog [GLOBAL-OPTIONS] cone [--row-count=ROWS]'),
        description="""
Generate a crochet pattern for a cone.
""".strip())
    opt_parser.add_option(_('-r'), _('--row-count'), action='store', type='int',
        default=16, metavar='ROWS',
        help=_('the number of rows in the pattern. Defines the height'
        ' of the cone [%default]'))
    opt_parser.add_option(_('-c'), _('--max-circumference'), action='store',
        type='int', default=60, metavar='STITCHES',
        help=_('the number of stitches at the base of the pattern. Defines the'
        ' circumference of the base of the cone [%default]'))
    command_opts, __ = opt_parser.parse_args(argv)
    stitches = cone(command_opts.row_count, command_opts.max_circumference)
    stitches = snap(stitches, 1 if global_options.accurate else 6, 6)
    if not global_options.inhuman:
        title = _("Cone (%d rows, %d max-circumference)") % (
                command_opts.row_count, command_opts.max_circumference)
        print_instructions_txt(title, stitches)
    else:
        print_row_counts(stitches)
Exemplo n.º 2
0
def main(argv, global_options):
    """
    Command entry-point for the donut pattern-generator.
    """
    import optparse
    _ = localization.get_translation()
    opt_parser = optparse.OptionParser(
        _('%prog [GLOBAL-OPTIONS] '
        'donut [--inner-radius=STITCHES] [--row-count=ROWS]'),
        description="""
Generate a pattern for a donut (torus). The pattern
starts off with a row in the centre (the donut hole) and crocheted up
and around.""".strip())
    opt_parser.add_option(_('-i'), _('--inner-radius'), action='store', type='int',
        default=18, metavar='STITCHES',
        help=_('the circumference of the donut hole, in stitches [%default]'))
    opt_parser.add_option('-r', '--row-count', action='store', type='int',
        default=16, metavar='ROWS',
        help=_("the number of rows in the pattern - defines the 'thickness'"
            " of the donut [%default]"))
    command_opts, __ = opt_parser.parse_args(argv)
    stitches = donut(command_opts.inner_radius, command_opts.row_count)
    stitches = snap(stitches, 1 if global_options.accurate else 6)
    
    if not global_options.inhuman:
        title = _("Donut (inner-radius: %d, %d rows)") % (
                command_opts.inner_radius, command_opts.row_count)
        print_instructions_txt(title, stitches)
    else:
        print_row_counts(stitches)
Exemplo n.º 3
0
def main(argv, global_options):
    """ Command entry-point for the cone pattern-generator. """
    _ = localization.get_translation()
    opt_parser = optparse.OptionParser(
        '%prog [GLOBAL-OPTIONS] cone [--row-count=ROWS]',
        description=_("Generate a crochet pattern for a cone."))
    opt_parser.add_option(
        '-r',
        '--row-count',
        action='store',
        type='int',
        default=16,
        metavar='ROWS',
        help=_('the number of rows in the pattern. Defines the height'
               ' of the cone [%default]'))
    opt_parser.add_option(
        '-c',
        '--max-circumference',
        action='store',
        type='int',
        default=60,
        metavar='STITCHES',
        help=_('the number of stitches at the base of the pattern. Defines the'
               ' circumference of the base of the cone [%default]'))
    command_opts, __ = opt_parser.parse_args(argv)
    stitches = cone(command_opts.row_count, command_opts.max_circumference)
    stitches = snap(stitches, 1 if global_options.accurate else 6, 6)
    if not global_options.inhuman:
        title = _("Cone (%d rows, %d max-circumference)") % (
            command_opts.row_count, command_opts.max_circumference)
        print_instructions_txt(title, stitches)
    else:
        print_row_counts(stitches)
Exemplo n.º 4
0
def main(argv, global_options):
    """
    Command entry-point for the donut pattern-generator.
    """
    _ = localization.get_translation()
    opt_parser = optparse.OptionParser(
        '%prog [GLOBAL-OPTIONS] '
        'donut [--inner-radius=STITCHES] [--row-count=ROWS]',
        description=_("""
Generate a pattern for a donut (torus).

The pattern starts off with a row in the centre (the donut hole) and is
crocheted up and around.
""").strip())
    opt_parser.add_option(
        '-i',
        '--inner-radius',
        action='store',
        type='int',
        default=18,
        metavar='STITCHES',
        help=_('the circumference of the donut hole, in stitches [%default]'))
    opt_parser.add_option(
        '-r',
        '--row-count',
        action='store',
        type='int',
        default=16,
        metavar='ROWS',
        help=_("the number of rows in the pattern - defines the 'thickness'"
               " of the donut [%default]"))
    command_opts, __ = opt_parser.parse_args(argv)
    stitches = donut(command_opts.inner_radius, command_opts.row_count)
    stitches = snap(stitches, 1 if global_options.accurate else 6)

    if not global_options.inhuman:
        title = _("Donut (inner-radius: %d, %d rows)") % (
            command_opts.inner_radius, command_opts.row_count)
        print_instructions_txt(title, stitches)
    else:
        print_row_counts(stitches)
Exemplo n.º 5
0
def main(argv, global_options):
    """ Command entry-point for the ball pattern-generator. """
    _ = localization.get_translation()
    opt_parser = optparse.OptionParser(
        '%prog [GLOBAL-OPTIONS] ball [--row-count=ROWS]',
        description=_("""
Generate a crochet pattern for a ball (sphere).
""").strip())
    opt_parser.add_option('-r', '--row-count', action='store',
        type='int', default=16, metavar='ROWS',
        help=_('the number of rows in the pattern. Defines the size'
        ' of the ball - the circumference is 2x this value. [%default]'))
    command_opts, __ = opt_parser.parse_args(argv)
    stitches = ball(command_opts.row_count)
    stitches = snap(stitches, 1 if global_options.accurate else 6, 6)

    if not global_options.inhuman:
        title = _("Ball (%d rows)") % (command_opts.row_count)
        print_instructions_txt(title, stitches)
    else:
        print_row_counts(stitches)