Skip to content

Commit

Permalink
notes-to-self: fix table in how-does-windows-so-reuseaddr-work.py
Browse files Browse the repository at this point in the history
- Generate the table headers dynamically.

Prior to this change the table headers were static and incorrect,
'specific' and 'wildcard' labels were reversed.

Example from before the change (incorrect):
~~~
                   | default           |
                   | specific| wildcard|
                   ---------------------
default | wildcard |   INUSE | Success |
default | wildcard | Success |   INUSE |
~~~

Example from after the change (correct):
~~~
                   | default             |
                   | wildcard | specific |
                   -----------------------
default | wildcard |    INUSE |  Success |
default | wildcard |  Success |    INUSE |
~~~

Bug: python-trio#928 (comment)

Closes #xxxx
  • Loading branch information
jay committed Feb 8, 2021
1 parent 00e31f7 commit d9e60e5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions notes-to-self/how-does-windows-so-reuseaddr-work.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ def table_entry(mode1, bind_type1, mode2, bind_type2):

print("""
second bind
| default | SO_REUSEADDR | SO_EXCLUSIVEADDRUSE
| specific| wildcard| specific| wildcard| specific| wildcard
first bind ------------------------------------------------------------"""
# default | wildcard | INUSE | Success | ACCESS | Success | INUSE | Success
| """
+ " | ".join(["%-19s" % mode for mode in modes])
)

print(""" """, end='')
for mode in modes:
print(" | " + " | ".join(["%8s" % bind_type for bind_type in bind_types]), end='')

print("""
first bind -----------------------------------------------------------------"""
# default | wildcard | INUSE | Success | ACCESS | Success | INUSE | Success
)

for i, mode1 in enumerate(modes):
Expand All @@ -58,4 +65,4 @@ def table_entry(mode1, bind_type1, mode2, bind_type2):
row.append(entry)
#print(mode1, bind_type1, mode2, bind_type2, entry)
print("{:>19} | {:>8} | ".format(mode1, bind_type1)
+ " | ".join(["%7s" % entry for entry in row]))
+ " | ".join(["%8s" % entry for entry in row]))

0 comments on commit d9e60e5

Please sign in to comment.