# Path: pypot/utils/flushed_print.py
# def flushed_print(*args, **kwargs):
#     """
#     Use to replace print(*args, flush=True) that doesn't exist for python<3.3
#     """
#     print(*args, **kwargs)
#     file = kwargs.get('file', sys.stdout)
#     file.flush() if file is not None else sys.stdout.flush()


import sys
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from subprocess import call
from pypot.creatures import installed_poppy_creatures
from pypot.utils import flushed_print as print
        motors_on_bus = config['controllers'][bus]["attached_motors"]
        motors = flatten_motorgroups(motors_on_bus, config['motorgroups'])
        if motor in motors:
            return config['controllers'][bus]["port"]

    raise ValueError('Something must be wrong in your configuration file. '
                     'Could not find bus for motor {}'.format(motor))


def main():
    robots = [c.replace('poppy-', '') for c in installed_poppy_creatures]

    parser = ArgumentParser(description='Configuration tool for Poppy robots ',
                            formatter_class=ArgumentDefaultsHelpFormatter)

    parser.add_argument('robot', type=str, choices=robots,
                        help='Robot used.')

    parser.add_argument('motor', type=str,
                        help='Name of the motor to configure.')

    args = parser.parse_args()

    RobotCls = installed_poppy_creatures['poppy-{}'.format(args.robot)]
    c = RobotCls.default_config

    if args.motor not in c['motors']:
        print('"{}" is not a motor of "{}"! '
              'possibilities={}'.format(args.motor, args.robot,
                                        sorted(c['motors'].keys())))

# Path: pypot/utils/flushed_print.py
# def flushed_print(*args, **kwargs):
#     """
#     Use to replace print(*args, flush=True) that doesn't exist for python<3.3
#     """
#     print(*args, **kwargs)
#     file = kwargs.get('file', sys.stdout)
#     file.flush() if file is not None else sys.stdout.flush()


# Path: pypot/creatures/configure_utility.py
import sys
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from subprocess import call
from pypot.creatures import installed_poppy_creatures
from pypot.utils import flushed_print as print

        motors_on_bus = config['controllers'][bus]["attached_motors"]
        motors = flatten_motorgroups(motors_on_bus, config['motorgroups'])
        if motor in motors:
            return config['controllers'][bus]["port"]

    raise ValueError('Something must be wrong in your configuration file. '
                     'Could not find bus for motor {}'.format(motor))


def main():
    robots = [c.replace('poppy-', '') for c in installed_poppy_creatures]

    parser = ArgumentParser(description='Configuration tool for Poppy robots ',
                            formatter_class=ArgumentDefaultsHelpFormatter)

    parser.add_argument('robot', type=str, choices=robots,
                        help='Robot used.')

    parser.add_argument('motor', type=str,
                        help='Name of the motor to configure.')

    args = parser.parse_args()

    RobotCls = installed_poppy_creatures['poppy-{}'.format(args.robot)]
    c = RobotCls.default_config

    if args.motor not in c['motors']:
        print('"{}" is not a motor of "{}"! '
              'possibilities={}'.format(args.motor, args.robot,
                                        sorted(c['motors'].keys())))

        print('Exiting now...')