tymonr icon

filter_list_entries.py

tymonr | PRO | 02/25/20 06:08:42 PM UTC | 0 ⭐ | 375 👁️ | Never ⏰ | []
Python |

460 B

|

None

|

0 👍

/

0 👎

def filter_list_entries(path: str, tags: list):
    """
    Parameters
    ----------
    path : str
        path to json file like {"bl_townhall_lvl1.png": {"path": "bl_townhall_lvl1.png", "tags": ["tag"]}, ... }
    Returns
    -------
    list
        list of files with given tags
    """
    with open(path, 'r') as read_file:
        return [ value['path'] for key, value in json.load(read_file).items() if all(tag in value['tags'] for tag in tags) ]

Comments