Skip to content

Instantly share code, notes, and snippets.

@dsottimano
Created September 29, 2020 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsottimano/f2865591c5e855afe48a114bcb98968d to your computer and use it in GitHub Desktop.
Save dsottimano/f2865591c5e855afe48a114bcb98968d to your computer and use it in GitHub Desktop.
def parsepath(string):
try:
string = str(string)
if string[0] == "/":
country = ''
language = ''
category = ''
category_flag = False
split_string = string.split("/")
if (len(split_string[1]) == 2 and len(split_string[2]) == 2):
country = split_string[1]
language = split_string[2]
#reverse the order so that we can get pricing, home, etc.. first before the country names
for x in reversed(split_string):
category = categorize(x)
if len(category) > 2:
category_flag = True
break
if category_flag == True:
return [country,language,category]
else:
return [country,language,"Country Home"]
else:
return ""
except:
print(string)
return ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment