Advertisement
tymonr

filter_list_entries.py

Feb 25th, 2020
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def filter_list_entries(path: str, tags: list):
  2.     """
  3.    Parameters
  4.    ----------
  5.    path : str
  6.        path to json file like {"bl_townhall_lvl1.png": {"path": "bl_townhall_lvl1.png", "tags": ["tag"]}, ... }
  7.    Returns
  8.    -------
  9.    list
  10.        list of files with given tags
  11.    """
  12.     with open(path, 'r') as read_file:
  13.         return [ value['path'] for key, value in json.load(read_file).items() if all(tag in value['tags'] for tag in tags) ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement