Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski authored Oct 12, 2024
1 parent 2f144ac commit 9013177
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
18 changes: 18 additions & 0 deletions libhockeydata/hockeydatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,16 @@ def GetHockeyLeaguesInfo(leaguename):
return leagueinfo.get(leaguename, {leaguename: {'LeagueName': leaguename, 'FullLeagueName': "Unknown", 'CountryName': "Unknown", 'FullCountryName': "Unknown", 'StartDate': 0, 'PlayOffFMT': "Unknown", 'OrderType': "Unknown"}})


def CheckKeyInArray(validkeys, checkdict):
ivalidkeys = 0
ilvalidkeys = len(validkeys)
while (ivalidkeys < ilvalidkeys):
if (validkeys[ivalidkeys] not in checkdict):
return False
ivalidkeys = ivalidkeys + 1
return True


def CheckHockeyArray(inhockeyarray):
if (isinstance(inhockeyarray, type(None)) or isinstance(inhockeyarray, type(True)) or isinstance(inhockeyarray, type(False)) or not isinstance(inhockeyarray, type({}))):
return False
Expand All @@ -1022,18 +1032,26 @@ def CheckHockeyArray(inhockeyarray):
return False
leaguelist = []
for hlkey in inhockeyarray['leaguelist']:
if (not CheckKeyInArray(["name", "fullname", "country", "fullcountry", "date", "playofffmt", "ordertype", "conferences", "divisions"], inhockeyarray[hlkey]['leagueinfo'])):
return False
if hlkey not in inhockeyarray.keys():
return False
if (hlkey in leaguelist):
return False
leaguelist.append(hlkey)
for hckey in inhockeyarray[hlkey]['conferencelist']:
if (not CheckKeyInArray(["name", "prefix", "suffix"], inhockeyarray[hlkey][hckey]['conferenceinfo'])):
return False
if hckey not in inhockeyarray[hlkey].keys() or hckey not in inhockeyarray[hlkey]['quickinfo']['conferenceinfo'].keys():
return False
for hdkey in inhockeyarray[hlkey][hckey]['divisionlist']:
if (not CheckKeyInArray(["name", "prefix", "suffix"], inhockeyarray[hlkey][hckey][hdkey]['divisioninfo'])):
return False
if hdkey not in inhockeyarray[hlkey][hckey].keys() or hdkey not in inhockeyarray[hlkey]['quickinfo']['divisioninfo'].keys():
return False
for htkey in inhockeyarray[hlkey][hckey][hdkey]['teamlist']:
if (not CheckKeyInArray(["city", "area", "fullarea", "country", "fullcountry", "name", "arena", "affiliates", "prefix", "suffix"], inhockeyarray[hlkey][hckey][hdkey][htkey]['teaminfo'])):
return False
if htkey not in inhockeyarray[hlkey][hckey][hdkey].keys() or htkey not in inhockeyarray[hlkey]['quickinfo']['teaminfo'].keys():
return False
return True
Expand Down
10 changes: 0 additions & 10 deletions libhockeydata/hockeyfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,16 +1052,6 @@ def BeautifyXMLCodeToFile(inxmlfile, outxmlfile, xmlisfile=True, indent="\t", ne
return True


def CheckKeyInArray(validkeys, checkdict):
ivalidkeys = 0
ilvalidkeys = len(validkeys)
while (ivalidkeys < ilvalidkeys):
if (validkeys[ivalidkeys] not in checkdict):
return False
ivalidkeys = ivalidkeys + 1
return True


def CheckHockeyXML(inxmlfile, xmlisfile=True):
if (xmlisfile and ((os.path.exists(inxmlfile) and os.path.isfile(inxmlfile)) or re.findall(r"^(http|https|ftp|ftps|sftp)\:\/\/", inxmlfile))):
try:
Expand Down

0 comments on commit 9013177

Please sign in to comment.