Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def prompt(groups: Sequence[Tuple[List[AddonFolder], List[Defn]]]) -> Iterable[Defn]:
uniq_defns = uniq(d for _, b in groups for d in b)
results = manager.run(manager.resolve(uniq_defns))
for addons, defns in groups:
shortlist = list(filter(is_pkg, (results[d] for d in defns)))
if shortlist:
if auto:
selection = Defn.from_pkg(shortlist[0])
else:
selection = prompt_one(addons, shortlist)
selection and (yield selection)
def parse_into_defn(
manager: CliManager, value: Union[str, List[str]], *, raise_invalid: bool = True
) -> Union[Defn, List[Defn]]:
if not isinstance(value, str):
defns = (parse_into_defn(manager, v, raise_invalid=raise_invalid) for v in value)
return uniq(defns)
parts: Tuple[str, str]
delim = ':'
any_source = '*'
if delim not in value:
if raise_invalid:
raise click.BadParameter(value)
parts = (any_source, value)
else:
maybe_parts = manager.pair_url(value)
parts = maybe_parts or value.partition(delim)[::2]
return Defn(*parts)
step = 1000
for index in count(0, step):
url = (self.addon_api_url / 'search').with_query(
# fmt: off
gameId='1',
sort='3', # Alphabetical
pageSize=step, index=index,
# fmt: on
)
async with self.web_client.get(url) as response:
json_response = await response.json()
if not json_response:
break
for item in json_response:
folders = uniq(
tuple(m['foldername'] for m in f['modules'])
for f in item['latestFiles']
if not f['exposeAsAlternative']
)
yield _CItem(
source=self.source,
id=item['id'],
slug=item['slug'],
name=item['name'],
folders=folders,
compatibility=set(excise_compatibility(item['latestFiles'])),
)