This commit is contained in:
adithyagenie 2023-08-17 17:45:59 +05:30
commit 7fb7b5b69b
8 changed files with 87 additions and 2 deletions

0
.fleet/settings.json Normal file
View file

3
.gitignore vendored
View file

@ -7,3 +7,6 @@ maze/modules/__pycache__
saves
tetris
wordle-curses/__pycache__
1.json
2.json
3.json

View file

View file

1
helper_scripts/play.bat Normal file
View file

@ -0,0 +1 @@
start python %~f1/starter.py

37
play.bat Normal file
View file

@ -0,0 +1,37 @@
:: Play the game
@ECHO off
cls
:start
ECHO.
ECHO 1. Play game
ECHO 2. Initialise SQL login creds
ECHO 3. Dump sample data
ECHO 4. Exit
set choice=
set /p choice=Choice?
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto play
if '%choice%'=='2' goto initsql
if '%choice%'=='3' goto dump
if '%choice%'=='4' goto end
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:play
start cmd /c "python %~dp0%~1/starter.py"
move nul 2>&0
goto end
:initsql
start cmd /c "python %~dp0%~1/starter.py initsql"
move nul 2>&0
goto end
:dump
start cmd /c "python %~dp0%~1/starter.py dumpsample"
move nul 2>&0
goto end
:end
pause

39
play.vbs Normal file
View file

@ -0,0 +1,39 @@
strTitle = "Labyrinth"
strMsg = "1. Play" & vbCr
strMsg = strMsg & "2. Initialise SQL creds" & vbCR
strMsg = strMsg & "3. Dump sample data" & vbCR
strMsg = strMsg & "Select choice:" & vbCR
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
Dim folderName
folderName = "."
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim fullpath
fullpath = fso.GetAbsolutePathName(folderName)
const quote = """"
Dim command
Do
inp01 = InputBox(strMsg,strTitle)
OK = True
Select Case inp01
Case "1"
command = quote + "C:\Program Files\PowerShell\7\pwsh.exe" & quote & "-ExecutionPolicy ByPass -NoExit -Command & " & quote & "E:\Programs\Miniconda3\shell\condabin\conda-hook.ps1" & quote & "; conda activate " & quote & "E:\Programs\Miniconda3" & quote & "; conda activate adi; python " & fullpath & "\starter.py"
command = "cmd.exe /C python "+fullpath+"\starter.py"
msgBox command
oShell.run ""+command
Case "2"
command = quote + "C:\Program Files\PowerShell\7\pwsh.exe" & quote & "-ExecutionPolicy ByPass -NoExit -Command & " & quote & "E:\Programs\Miniconda3\shell\condabin\conda-hook.ps1" & quote & "; conda activate " & quote & "E:\Programs\Miniconda3" & quote & "; conda activate adi; python " & fullpath & "\starter.py initsql"
command = "cmd.exe /C python "+fullpath+"\starter.py initsql"
oShell.run ""+command
Case "3"
command = quote + "C:\Program Files\PowerShell\7\pwsh.exe" & quote & "-ExecutionPolicy ByPass -NoExit -Command & " & quote & "E:\Programs\Miniconda3\shell\condabin\conda-hook.ps1" & quote & "; conda activate " & quote & "E:\Programs\Miniconda3" & quote & "; conda activate adi; python " & fullpath & "\starter.py dumpsample"
command = "cmd.exe /C python "+fullpath+"\starter.py dumpsample"
oShell.run ""+command
Case ""
WScript.quit
Case Else
MsgBox "You made an incorrect selection!",64,strTitle
OK = False
End Select
Loop While Not OK

View file

@ -1,5 +1,5 @@
import pickle
import json
import requests
with open("credentials.pickle", "rb") as f:
@ -9,6 +9,7 @@ with open("credentials.pickle", "rb") as f:
if d["credtype"] == "oxfordapi":
app_id = d["app_id"]
app_key = d["app_key"]
break
except EOFError:
pass
@ -17,6 +18,7 @@ language = "en-us"
def defnsyn(w):
"""Returns definition and synonym of said word"""
f = open("log.txt", "a")
url = (
r"https://od-api.oxforddictionaries.com:443/api/v2/entries/"
+ language
@ -25,13 +27,16 @@ def defnsyn(w):
)
r = requests.get(url, headers={"app_id": app_id, "app_key": app_key})
if r.status_code != 200:
f.write("GOT "+str(r.status_code))
return None, None
res = r.json()
f.write(json.dumps(res))
s1 = res["results"][0]["lexicalEntries"]
lexicalCategories = []
synonyms = []
defn = ""
try:
defn = res["entries"]["senses"]["definitions"][0]
if len(s1) > 1:
for i in range(len(s1)):
lexicalCategories.append(s1[i]["lexicalCategory"]["id"])