Skip to content

Commit

Permalink
fix: correct python sample (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwmkerr authored Sep 6, 2024
1 parent 5b7b21d commit 047595d
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 17 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
<mxfile host="Electron" modified="2022-04-21T03:52:03.502Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/17.4.2 Chrome/100.0.4896.60 Electron/18.0.1 Safari/537.36" etag="p_Sv5_mJrCn7mMXcK1W1" version="17.4.2" type="device"><diagram id="zMdPa7TFIofes7aEGqtK" name="Page-1">7Vhdc9o6EP01nrYPZfwJ5jFA0s40d5o7tNP2qSPsxVaRvYwsAvTXV7JlYyMnaZqkpR+ZIUhHKxmds7ta2fKm2e4VJ+v0P4yBWa4d7yxvZrmu49hD+aWQfYWEnl8BCaexNjoAc/oVNGhrdENjKDqGApEJuu6CEeY5RKKDEc5x2zVbIus+dU0SMIB5RJiJfqCxSOt9DceHgddAk1Q/OnRH1UBGamO9kyIlMW5bkHdueVOOKKpWtpsCU+TVvFTzLm4YbX4Yh1x8z4Rd+H5JPn98Hfm76TC4wFX8/9lLt1rlmrCN3vCUAxGg2Mtj+R/yiO/XQvXlZw4RB6H3I/Y1SRw3eQzqObblTbYpFTBfk0iNbqVbSCwVGZM9RzYLOULz5B2utb0GLmEpusgEhcCsi8leIHvm5jUf18AF7FqQJuMVYAaC76WJHvWCaoZ2TKfWaduSucbSlsJDjRHtWUmz8oF82dD830ML39BiggvLHTL54MmCy1aiWs/nwOUuXxgqSAdbq+YmY2eRQC5tFRtUOvMlWQC7woIKirk0WWhmG4MzRhM1IPBILdwIRnOYNuFlPw77od1hv4d872dyHxjcm8SbiGQtgmeFOXC1WcghE38D+xtly1GG3Z3RsyDRKinj7W2ljMZjwldvVYgIxag9sB8pSpyuTs7YN4QKe4Ry7KdSavhDSslI6tPphnx26pKcmiajHk2OKG3xdWdSIjoZRZIjUGmMKctJQ/MUmcpucllvWf7dmMgKwXHVHNxug7RWsO3QvigPmPp8tkvtirQ50Gp3yHaJKnIGFIvRgMqKoxgwjFbK7lF0dfwjXUeGrq5v6uo9layhoSLEsjjSXeQixQRzws4P6KRbChxsLrE875X+X0CIva70yEZgN5okf3z/Uc8vO5/K6Anq7mzXHpzta5EE4eJMVXxl4KoorLALqnatZ8S1RcRIUcgUXYLaxLlNR7X1W1XkwIig1926sU8TPfUKaS5a5cj4qB7xx4Ogu4jcTQJCz2tXekdLOcGdSxW44REYS5Vu0uzpxz1nbCSE86aOrHOuLjALKL+kG7h2eZ72Ol2ZK7qOYmSJ4xSQ0TiufBIK+pUsyvWUG6zVtksigokVzHpVvy0gjJBurh/6IVa7wu8L9Zf2wLFDr5r7QMdxvO4MXC4LeBJV61qgJesMaln1CftnXRGOY/KX3xEcx5BAB41xTZgyKnf+m18TfP+07gmOeWF+2EWB0+vyuv373xS80amVpXVm/FeXPkzY8MTqUsd8U/K33QH94ckFW98rlH/Bdm9hR98RbMOeYPPuravsHt4+VzXi4R2+d/4N</diagram></mxfile>
<mxfile host="Electron" modified="2024-09-02T06:30:40.142Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/22.0.3 Chrome/114.0.5735.289 Electron/25.8.4 Safari/537.36" etag="eqjCcR1KJk3eORPeFGY4" version="22.0.3" type="device">
<diagram id="zMdPa7TFIofes7aEGqtK" name="Page-1">
<mxGraphModel dx="1306" dy="838" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="x8Ufa_XHc4xC65FokdQA-2" value="Create and encrypt a Secret" style="rounded=0;whiteSpace=wrap;html=1;spacingTop=0;spacingLeft=0;spacingBottom=0;spacing=5;" parent="1" vertex="1">
<mxGeometry x="405" y="120" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-4" value="Bob&lt;br&gt;(Server)" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" parent="1" vertex="1">
<mxGeometry x="450" y="20" width="30" height="60" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-5" value="&lt;br&gt;&lt;br&gt;Alice&#39;s&lt;br&gt;Public&lt;br&gt;Key" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="380" y="194" width="80" height="100" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-6" value="&lt;br&gt;&lt;br&gt;Bob&#39;s&lt;br&gt;Secret" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="470" y="194" width="80" height="100" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-7" value="" style="html=1;verticalLabelPosition=bottom;align=center;labelBackgroundColor=#ffffff;verticalAlign=top;strokeWidth=2;strokeColor=#0080F0;shadow=0;dashed=0;shape=mxgraph.ios7.icons.locked;" parent="1" vertex="1">
<mxGeometry x="484" y="197" width="24" height="30" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;startArrow=none;startFill=0;endArrow=classic;endFill=1;" parent="1" edge="1" target="x8Ufa_XHc4xC65FokdQA-10">
<mxGeometry relative="1" as="geometry">
<mxPoint x="65" y="149.5" as="targetPoint" />
<mxPoint x="400" y="150" as="sourcePoint" />
</mxGeometry>
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-9" value="Encrypt Secret and send to Alice" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="x8Ufa_XHc4xC65FokdQA-8" vertex="1" connectable="0">
<mxGeometry x="-0.1083" relative="1" as="geometry">
<mxPoint x="13" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-10" value="Decrypt Bob&#39;s Secret" style="rounded=0;whiteSpace=wrap;html=1;spacingTop=0;spacingLeft=0;spacingBottom=0;spacing=5;" parent="1" vertex="1">
<mxGeometry x="65" y="120" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-11" value="Alice&lt;br&gt;(Client)" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" parent="1" vertex="1">
<mxGeometry x="110" y="20" width="30" height="60" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-12" value="&lt;br&gt;&lt;br&gt;Alice&#39;s&lt;br&gt;Private&lt;br&gt;Key" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="40" y="194" width="80" height="100" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-13" value="" style="html=1;verticalLabelPosition=bottom;align=center;labelBackgroundColor=#ffffff;verticalAlign=top;strokeWidth=2;strokeColor=#0080F0;shadow=0;dashed=0;shape=mxgraph.ios7.icons.locked;" parent="1" vertex="1">
<mxGeometry x="54" y="197" width="24" height="30" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-14" value="&lt;br&gt;&lt;br&gt;Bob&#39;s&lt;br&gt;Secret" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="130" y="194" width="80" height="100" as="geometry" />
</mxCell>
<mxCell id="x8Ufa_XHc4xC65FokdQA-15" value="" style="html=1;verticalLabelPosition=bottom;align=center;labelBackgroundColor=#ffffff;verticalAlign=top;strokeWidth=2;strokeColor=#0080F0;shadow=0;dashed=0;shape=mxgraph.ios7.icons.locked;" parent="1" vertex="1">
<mxGeometry x="144" y="197" width="26" height="33" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
4 changes: 2 additions & 2 deletions samples/programs/lookup/lookup-v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Add the word to our list of lookups, and strip any whitespace from the
# beginning and end of it. For now, we don't have a definition.
word = word.strip()
definition = ''
definition = ""

# Write the result.
print("{} - {}".format(word, definition))
print(word, " - ", definition)
4 changes: 2 additions & 2 deletions samples/programs/lookup/lookup-v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def search_for_word(word):
# If the word is not found, return an empty definition.
except urllib.error.HTTPError as http_error:
if http_error.code == 404:
return ''
return ""
raise

# Now try and parse the data.
Expand Down Expand Up @@ -49,4 +49,4 @@ def search_for_word(word):
definition = search_for_word(stripped_word)

# Write the result.
print("{} - {}".format(word, definition))
print(word, " - ", definition)
8 changes: 4 additions & 4 deletions samples/programs/lookup/lookup-v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# Create an argument parser and define the arguments for our program.
parser = argparse.ArgumentParser()
parser.add_argument(
'-c', '--crop',
help='crop the output line length',
"-c", "--crop",
help="crop the output line length",
type=int,
nargs='?',
nargs="?",
const=80, # Default value if -c is supplied
default=None) # Default value if -c is not supplied
args = parser.parse_args()
Expand All @@ -35,7 +35,7 @@ def search_for_word(word):
# If the word is not found, return an empty definition.
except urllib.error.HTTPError as http_error:
if http_error.code == 404:
return ''
return ""
raise
except Exception as e:
sys.stderr.write("An error occurred trying to download the definition of '{}'".format(word))
Expand Down
16 changes: 8 additions & 8 deletions samples/programs/lookup/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@

# Create an argument parser and define the arguments for our program.
parser = argparse.ArgumentParser(
prog='parser',
description='lookup the defintion of words from dictionaryapi.dev',
prog="parser",
description="lookup the defintion of words from dictionaryapi.dev",
epilog=examples,
formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument(
'words',
help='optional list of words to define - if omitted stdin is used',
"words",
help="optional list of words to define - if omitted stdin is used",
type=str,
nargs='*'
)
parser.add_argument(
'-c', '--crop',
help='crop the output line length',
"-c", "--crop",
help="crop the output line length",
type=int,
nargs='?',
nargs="?",
const=80, # Default value if -c is supplied
default=None # Default value if -c is not supplied
)
Expand All @@ -56,7 +56,7 @@ def search_for_word(word):
# If the word is not found, return an empty definition.
except urllib.error.HTTPError as http_error:
if http_error.code == 404:
return ''
return ""
raise
# If the user hits ctrl hit, exit without an error message.
except KeyboardInterrupt:
Expand Down

0 comments on commit 047595d

Please sign in to comment.