py-avataaars icon indicating copy to clipboard operation
py-avataaars copied to clipboard

When I create a range loop for generating multiple avatars in one bacht then enum fails?

Open marcobaturan opened this issue 1 year ago • 0 comments

Hello,

I try to running a a method for loop in a range for generating by nested lists multiple avatars and I get this error type:

File "/home/marco/Programas/PAI/env/lib/python3.10/site-packages/py_avataaars/init.py", line 282, in __template_path return str(pathlib.PurePosixPath(path).joinpath(f"{enum_type.name.lower()}.svg"))

The code is: def face_generator(Facial_hair_color, Facial_hair_type, Hair_color, Skin_color, Style, Top, accessories_expr, clothe_expr, eye_expr, eyebrow_expr, face_expression, graphic, hatcolor, name_expression): """face generator.

    Received parameters to generate a new face or modify an existent face.
    In the first case It's will be used in configuration module.
    In the second case It'll be use in face module for modify eye and mouth expression.

"""
avatar = pa.PyAvataaar(
    style=Style,
    skin_color=Skin_color,
    hair_color=Hair_color,
    facial_hair_type=Facial_hair_type,
    facial_hair_color=Facial_hair_color,
    top_type=Top,
    hat_color=hatcolor,
    mouth_type=face_expression,
    eye_type=eye_expr,
    eyebrow_type=eyebrow_expr,
    nose_type=pa.NoseType.DEFAULT,
    accessories_type=accessories_expr,
    clothe_type=clothe_expr,
    clothe_color=hatcolor,
    clothe_graphic_type=graphic)
# generate
avatar.render_svg_file(str(pathlib.Path(__file__).parent.absolute().joinpath(f'{name_expression}.svg')))
#avatar.render_png_file(f'{name_expression}.svg')

Facial_hair_color, Facial_hair_type, Hair_color, Skin_color, Style, Top, accessories_expr, clothe_expr, eye_expr, eyebrow_expr, face_expression, hatcolor, graphic_expr = params_on_the_fly(
    values)
happy = ['HAPPY','HAPPY','DEFAULT_NATURAL', 'happy']
sad = ['SAD','CRY','SAD_CONCERNED', 'sad']
fear = ['SCREAM_OPEN','SURPRISED','SAD_CONCERNED_NATURAL', 'fear']
anger = ['SAD','DEFAULT','ANGRY', 'anger']
neutral_close = ['SERIOUS','DEFAULT','DEFAULT', 'close']
neutral_open = ['SCREAM_OPEN','DEFAULT','DEFAULT', 'open']
faces = [happy,sad,fear,anger,neutral_open,neutral_close]
# instance & config for generate png file by SVG,
for iteration in range(len(faces)):

    face_generator(Facial_hair_color, Facial_hair_type, Hair_color, Skin_color, Style, Top, accessories_expr,
                   clothe_expr, faces[iteration-1][1], faces[iteration-1][2], faces[iteration-1][0], graphic_expr,
                   hatcolor,faces[iteration-1][3])

The error in py-avataaars is preventing users from generating avatars with certain attributes. Specifically, the error occurs when the joinpath() method is called with a string object instead of an enum object. This prevents users from setting certain avatar attributes, which limits the functionality of the library.

By fixing this error, the library maintainers can improve the usability and functionality of py-avataaars. This will make the library more attractive to potential users, and can help to increase its adoption and popularity. Additionally, fixing this error will help to ensure that the library is compatible with future versions of Python and related libraries, which can help to ensure its long-term viability.

Overall, fixing this error can help to improve the user experience, increase adoption, and ensure the long-term viability of py-avataaars.

Thank you very much for your time and effort. Note: I try to invest some time research on Internet and I can't found anything.

marcobaturan avatar Jun 10 '23 12:06 marcobaturan