Created
September 29, 2020 17:22
-
-
Save dsottimano/f2865591c5e855afe48a114bcb98968d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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