def find_texture_files(fbasename, log=None):
fext = os.path.splitext(fbasename)[<NUM_LIT:1>][<NUM_LIT:1>:].strip().lower()<EOL>material_file = None<EOL>texture_files = []<EOL>vert_colors = False<EOL>face_colors = False<EOL>if fext == '<STR_LIT>':<EOL><INDENT>with open(fbasename, '<STR_LIT:r>') as fread:<EOL><INDENT>for line in fread:<EOL><INDENT>if '<STR_LIT>' in line:<EOL><INDENT>material_file = os.path.basename(line.split()[<NUM_LIT:1>])<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if material_file is not None:<EOL><INDENT>with open(material_file, '<STR_LIT:r>') as fread:<EOL><INDENT>for line in fread:<EOL><INDENT>if '<STR_LIT>' in line:<EOL><INDENT>texture_files.append(os.path.basename(line.split()[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>elif fext == '<STR_LIT>':<EOL><INDENT>face_element = False<EOL>with open(fbasename, '<STR_LIT:rb>') as fread:<EOL><INDENT>while True:<EOL><INDENT>line = fread.readline().strip().decode('<STR_LIT:ascii>')<EOL>if '<STR_LIT>' in line:<EOL><INDENT>face_element = True<EOL><DEDENT>if '<STR_LIT>' in line:<EOL><INDENT>if face_element:<EOL><INDENT>face_colors = True<EOL><DEDENT>else:<EOL><INDENT>vert_colors = True<EOL><DEDENT><DEDENT>if '<STR_LIT>' in line:<EOL><INDENT>texture_files.append(os.path.basename(line.split()[<NUM_LIT:2>]))<EOL><DEDENT>if '<STR_LIT>' in line:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif fext == '<STR_LIT>':  <EOL><INDENT>namespace = '<STR_LIT>'<EOL>tree = ET.parse(fbasename)<EOL>for elem in tree.findall(<EOL>'<STR_LIT>' % (namespace, namespace, namespace)):<EOL><INDENT>texture_files.append(elem.text)<EOL><DEDENT><DEDENT>elif fext == '<STR_LIT>':<EOL><INDENT>tree = ET.parse(fbasename)<EOL>for elem in tree.iter(tag='<STR_LIT>'):<EOL><INDENT>texture_files.append(elem.attrib['<STR_LIT:url>'])<EOL><DEDENT><DEDENT>elif fext == '<STR_LIT>':<EOL><INDENT>with open(fbasename, '<STR_LIT:r>') as fread:<EOL><INDENT>for line in fread:<EOL><INDENT>if '<STR_LIT>' in line:<EOL><INDENT>texture_files.append(os.path.basename(line.split('<STR_LIT:">')[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif fext != '<STR_LIT>':  <EOL><INDENT>print('<STR_LIT>' % fext)<EOL><DEDENT>texture_files_unique = list(set(texture_files))<EOL>if log is not None:<EOL><INDENT>log_file = open(log, '<STR_LIT:a>')<EOL>log_file.write('<STR_LIT>')<EOL>log_file.write('<STR_LIT>' % fbasename)<EOL>log_file.write('<STR_LIT>' % texture_files)<EOL>log_file.write('<STR_LIT>' % texture_files_unique)<EOL>log_file.write('<STR_LIT>' % len(texture_files))<EOL>log_file.write(<EOL>'<STR_LIT>' %<EOL>len(texture_files_unique))<EOL>log_file.write('<STR_LIT>' % vert_colors)<EOL>log_file.write('<STR_LIT>' % face_colors)<EOL>log_file.close()<EOL><DEDENT>colors = {'<STR_LIT>':bool(texture_files), '<STR_LIT>':vert_colors, '<STR_LIT>':face_colors}<EOL>return texture_files, texture_files_unique, material_file, colors<EOL>
Finds the filenames of the referenced texture file(s) (and material
    file for obj) for the mesh.

    Args:
        fbasename (str): input filename. Supported file extensions:
            obj
            ply
            dae
            x3d
            wrl
        log (str): filename to log output

    Returns:
        list: list of all of the texture filenames referenced by the input file.
            May contain duplicates if the texture files are referenced more
            than once. List is empty if no texture files are found.
        list: list of all of the unique texture filenames, also empty if no
            texture files are found.
        str: for obj files only, returns the name of the referenced material file.
            Returns None if no material file is found.