Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def build(self) -> None:
installed_auras = iit(self.extract_installed_auras())
remote_auras = await gather(
[self.get_remote_auras(g) async for g in installed_auras], False,
)
await t(self.make_addon)(remote_auras)
async def open_temp_writer() -> AsyncIterator[Tuple[Path, Callable[[bytes], Awaitable[int]]]]:
fh = await AsyncNamedTemporaryFile(delete=False)
path = Path(fh.name)
try:
yield (path, t(fh.write))
except BaseException:
await t(fh.close)()
await t(path.unlink)()
raise
else:
await t(fh.close)()
async def open_temp_writer() -> AsyncIterator[Tuple[Path, Callable[[bytes], Awaitable[int]]]]:
fh = await AsyncNamedTemporaryFile(delete=False)
path = Path(fh.name)
try:
yield (path, t(fh.write))
except BaseException:
await t(fh.close)()
await t(path.unlink)()
raise
else:
await t(fh.close)()
from sqlalchemy.orm import scoped_session
from yarl import URL
from .config import Config
_T = TypeVar('_T')
_ArchiveACM = AsyncContextManager[Tuple[List[str], Callable[[Path], Awaitable[None]]]]
USER_AGENT = 'instawow (https://github.com/layday/instawow)'
_web_client: cv.ContextVar[aiohttp.ClientSession] = cv.ContextVar('_web_client')
AsyncNamedTemporaryFile = t(NamedTemporaryFile)
amkdtemp = t(mkdtemp)
acopy = t(copy)
amove = t(move)
@asynccontextmanager
async def open_temp_writer() -> AsyncIterator[Tuple[Path, Callable[[bytes], Awaitable[int]]]]:
fh = await AsyncNamedTemporaryFile(delete=False)
path = Path(fh.name)
try:
yield (path, t(fh.write))
except BaseException:
await t(fh.close)()
await t(path.unlink)()
raise
else:
await t(fh.close)()
async def cache_json_response(
manager: Manager, url: Union[str, URL], *args: Any, label: O[str] = None
) -> Any:
dst = manager.config.cache_dir / shasum(str(url))
if await t(is_not_stale)(dst, *args):
text = await t(dst.read_text)(encoding='utf-8')
else:
kwargs = {'raise_for_status': True}
if label:
kwargs = {**kwargs, 'trace_request_ctx': {'show_progress': True, 'label': label}}
async with manager.web_client.get(url, **kwargs) as response:
text = await response.text()
await t(dst.write_text)(text, encoding='utf-8')
return json.loads(text)
async def acquire_archive(path: PurePath):
from zipfile import ZipFile
def extract(parent: Path) -> None:
conflicts = base_dirs & {f.name for f in parent.iterdir()}
if conflicts:
raise E.PkgConflictsWithForeign(conflicts)
else:
members = filter(should_extract(base_dirs), names)
archive.extractall(parent, members=members)
archive = await t(ZipFile)(path)
try:
names = archive.namelist()
base_dirs = find_base_dirs(names)
yield (sorted(base_dirs), t(extract))
finally:
await t(archive.close)()
from yarl import URL
from .config import Config
_T = TypeVar('_T')
_ArchiveACM = AsyncContextManager[Tuple[List[str], Callable[[Path], Awaitable[None]]]]
USER_AGENT = 'instawow (https://github.com/layday/instawow)'
_web_client: cv.ContextVar[aiohttp.ClientSession] = cv.ContextVar('_web_client')
AsyncNamedTemporaryFile = t(NamedTemporaryFile)
amkdtemp = t(mkdtemp)
acopy = t(copy)
amove = t(move)
@asynccontextmanager
async def open_temp_writer() -> AsyncIterator[Tuple[Path, Callable[[bytes], Awaitable[int]]]]:
fh = await AsyncNamedTemporaryFile(delete=False)
path = Path(fh.name)
try:
yield (path, t(fh.write))
except BaseException:
await t(fh.close)()
await t(path.unlink)()
raise
else:
await t(fh.close)()
async def open_temp_writer() -> AsyncIterator[Tuple[Path, Callable[[bytes], Awaitable[int]]]]:
fh = await AsyncNamedTemporaryFile(delete=False)
path = Path(fh.name)
try:
yield (path, t(fh.write))
except BaseException:
await t(fh.close)()
await t(path.unlink)()
raise
else:
await t(fh.close)()
from prompt_toolkit.shortcuts import ProgressBar
from sqlalchemy.orm import scoped_session
from yarl import URL
from .config import Config
_T = TypeVar('_T')
_ArchiveACM = AsyncContextManager[Tuple[List[str], Callable[[Path], Awaitable[None]]]]
USER_AGENT = 'instawow (https://github.com/layday/instawow)'
_web_client: cv.ContextVar[aiohttp.ClientSession] = cv.ContextVar('_web_client')
AsyncNamedTemporaryFile = t(NamedTemporaryFile)
amkdtemp = t(mkdtemp)
acopy = t(copy)
amove = t(move)
@asynccontextmanager
async def open_temp_writer() -> AsyncIterator[Tuple[Path, Callable[[bytes], Awaitable[int]]]]:
fh = await AsyncNamedTemporaryFile(delete=False)
path = Path(fh.name)
try:
yield (path, t(fh.write))
except BaseException:
await t(fh.close)()
await t(path.unlink)()
raise
else:
await t(fh.close)()