Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6fb0832

Browse filesBrowse files
committed
sync from Atlas
1 parent 43f1bf2 commit 6fb0832
Copy full SHA for 6fb0832

File tree

Expand file treeCollapse file tree

7 files changed

+31
-34
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+31
-34
lines changed

‎02-array-seq/lispy/py3.10/examples_test.py

Copy file name to clipboardExpand all lines: 02-array-seq/lispy/py3.10/examples_test.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_factorial():
147147

148148
gcd_src = """
149149
(define (mod m n)
150-
(- m (* n (// m n))))
150+
(- m (* n (quotient m n))))
151151
(define (gcd m n)
152152
(if (= n 0)
153153
m

‎02-array-seq/lispy/py3.9/lis.py

Copy file name to clipboardExpand all lines: 02-array-seq/lispy/py3.9/lis.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def standard_env() -> Environment:
8080
'-': op.sub,
8181
'*': op.mul,
8282
'/': op.truediv,
83-
'//': op.floordiv,
83+
'quotient': op.floordiv,
8484
'>': op.gt,
8585
'<': op.lt,
8686
'>=': op.ge,

‎18-with-match/lispy/py3.10/examples_test.py

Copy file name to clipboardExpand all lines: 18-with-match/lispy/py3.10/examples_test.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_factorial():
146146

147147
gcd_src = """
148148
(define (mod m n)
149-
(- m (* n (// m n))))
149+
(- m (* n (quotient m n))))
150150
(define (gcd m n)
151151
(if (= n 0)
152152
m

‎18-with-match/lispy/py3.10/lis.py

Copy file name to clipboardExpand all lines: 18-with-match/lispy/py3.10/lis.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def standard_env() -> Environment:
8383
'-': op.sub,
8484
'*': op.mul,
8585
'/': op.truediv,
86-
'//': op.floordiv,
86+
'quotient': op.floordiv,
8787
'>': op.gt,
8888
'<': op.lt,
8989
'>=': op.ge,

‎18-with-match/lispy/py3.9/examples_test.py

Copy file name to clipboardExpand all lines: 18-with-match/lispy/py3.9/examples_test.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_factorial():
147147

148148
gcd_src = """
149149
(define (mod m n)
150-
(- m (* n (// m n))))
150+
(- m (* n (quotient m n))))
151151
(define (gcd m n)
152152
(if (= n 0)
153153
m
@@ -255,4 +255,4 @@ def test_closure_with_change(capsys):
255255
def test_closure_averager():
256256
got = run(closure_averager_src)
257257
assert got == 12.0
258-
# end::RUN_AVERAGER[]
258+
# end::RUN_AVERAGER[]

‎18-with-match/lispy/py3.9/lis.py

Copy file name to clipboardExpand all lines: 18-with-match/lispy/py3.9/lis.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def standard_env() -> Environment:
8080
'-': op.sub,
8181
'*': op.mul,
8282
'/': op.truediv,
83-
'//': op.floordiv,
83+
'quotient': op.floordiv,
8484
'>': op.gt,
8585
'<': op.lt,
8686
'>=': op.ge,

‎20-executors/getflags/flags2_asyncio.py

Copy file name to clipboardExpand all lines: 20-executors/getflags/flags2_asyncio.py
+24-27Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,36 @@
1616

1717
from flags2_common import main, DownloadStatus, save_flag
1818

19-
# default set low to avoid errors from remote site, such as
20-
# 503 - Service Temporarily Unavailable
19+
# low concurrency default to avoid errors from remote site,
20+
# such as 503 - Service Temporarily Unavailable
2121
DEFAULT_CONCUR_REQ = 5
2222
MAX_CONCUR_REQ = 1000
2323

24-
async def get_flag(session: httpx.AsyncClient, # <2>
24+
async def get_flag(client: httpx.AsyncClient, # <1>
2525
base_url: str,
2626
cc: str) -> bytes:
2727
url = f'{base_url}/{cc}/{cc}.gif'.lower()
28-
resp = await session.get(url, timeout=3.1, follow_redirects=True) # <3>
28+
resp = await client.get(url, timeout=3.1, follow_redirects=True) # <2>
2929
resp.raise_for_status()
3030
return resp.content
3131

32-
async def download_one(session: httpx.AsyncClient,
32+
async def download_one(client: httpx.AsyncClient,
3333
cc: str,
3434
base_url: str,
35-
semaphore: asyncio.Semaphore, # <4>
35+
semaphore: asyncio.Semaphore,
3636
verbose: bool) -> DownloadStatus:
3737
try:
38-
async with semaphore: # <5>
39-
image = await get_flag(session, base_url, cc)
40-
except httpx.HTTPStatusError as exc: # <4>
38+
async with semaphore: # <3>
39+
image = await get_flag(client, base_url, cc)
40+
except httpx.HTTPStatusError as exc: # <5>
4141
res = exc.response
4242
if res.status_code == HTTPStatus.NOT_FOUND:
43-
status = DownloadStatus.NOT_FOUND # <5>
43+
status = DownloadStatus.NOT_FOUND
4444
msg = f'not found: {res.url}'
4545
else:
4646
raise
47-
4847
else:
49-
await asyncio.to_thread(save_flag, image, f'{cc}.gif')
48+
await asyncio.to_thread(save_flag, image, f'{cc}.gif') # <6>
5049
status = DownloadStatus.OK
5150
msg = 'OK'
5251
if verbose and msg:
@@ -61,33 +60,31 @@ async def supervisor(cc_list: list[str],
6160
concur_req: int) -> Counter[DownloadStatus]: # <1>
6261
counter: Counter[DownloadStatus] = Counter()
6362
semaphore = asyncio.Semaphore(concur_req) # <2>
64-
async with httpx.AsyncClient() as session:
65-
to_do = [download_one(session, cc, base_url, semaphore, verbose)
63+
async with httpx.AsyncClient() as client:
64+
to_do = [download_one(client, cc, base_url, semaphore, verbose)
6665
for cc in sorted(cc_list)] # <3>
6766
to_do_iter = asyncio.as_completed(to_do) # <4>
6867
if not verbose:
6968
to_do_iter = tqdm.tqdm(to_do_iter, total=len(cc_list)) # <5>
70-
error: httpx.HTTPError | None = None
71-
for coro in to_do_iter: # <6>
69+
error: httpx.HTTPError | None = None # <6>
70+
for coro in to_do_iter: # <7>
7271
try:
73-
status = await coro # <7>
74-
except httpx.HTTPStatusError as exc: # <8>
72+
status = await coro # <8>
73+
except httpx.HTTPStatusError as exc:
7574
error_msg = 'HTTP error {resp.status_code} - {resp.reason_phrase}'
7675
error_msg = error_msg.format(resp=exc.response)
77-
error = exc
78-
except httpx.RequestError as exc: # <9>
76+
error = exc # <9>
77+
except httpx.RequestError as exc:
7978
error_msg = f'{exc} {type(exc)}'.strip()
80-
error = exc
81-
except KeyboardInterrupt: # <10>
79+
error = exc # <10>
80+
except KeyboardInterrupt:
8281
break
83-
else: # <11>
84-
error = None
8582

8683
if error:
87-
status = DownloadStatus.ERROR # <12>
84+
status = DownloadStatus.ERROR # <11>
8885
if verbose:
89-
url = str(error.request.url) # <13>
90-
cc = Path(url).stem.upper() # <14>
86+
url = str(error.request.url) # <12>
87+
cc = Path(url).stem.upper() # <13>
9188
print(f'{cc} error: {error_msg}')
9289
counter[status] += 1
9390

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.