Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import langcodes
|
|
|
3 |
|
4 |
st.write("# Language code/tag search")
|
5 |
st.write("Fed up with language tag confusion? Here's your one-stop shop!")
|
@@ -42,18 +43,15 @@ if lang is None:
|
|
42 |
|
43 |
|
44 |
def pull_obsolete_codes(iso_code):
|
45 |
-
from requests_html import HTMLSession
|
46 |
session = HTMLSession()
|
47 |
r= session.get(f"https://iso639-3.sil.org/code/{iso_code}")
|
48 |
# https://www.w3schools.com/cssref/css_selectors.asp
|
|
|
49 |
for found_element in r.html.find(".views-field-nothing", clean=True):
|
50 |
lines = found_element.text.splitlines()
|
51 |
-
# lines = text.splitlines()
|
52 |
-
obsolete_codes = {}
|
53 |
for line in lines:
|
54 |
for obsolete_code_name in ["639-1","639-2/B", "639-2/T", "639-3"]:
|
55 |
-
if obsolete_code_name in line:
|
56 |
-
|
57 |
code = line.split()[-1]
|
58 |
obsolete_codes[obsolete_code_name] = code
|
59 |
return obsolete_codes
|
|
|
1 |
import streamlit as st
|
2 |
import langcodes
|
3 |
+
from requests_html import HTMLSession
|
4 |
|
5 |
st.write("# Language code/tag search")
|
6 |
st.write("Fed up with language tag confusion? Here's your one-stop shop!")
|
|
|
43 |
|
44 |
|
45 |
def pull_obsolete_codes(iso_code):
|
|
|
46 |
session = HTMLSession()
|
47 |
r= session.get(f"https://iso639-3.sil.org/code/{iso_code}")
|
48 |
# https://www.w3schools.com/cssref/css_selectors.asp
|
49 |
+
obsolete_codes = {}
|
50 |
for found_element in r.html.find(".views-field-nothing", clean=True):
|
51 |
lines = found_element.text.splitlines()
|
|
|
|
|
52 |
for line in lines:
|
53 |
for obsolete_code_name in ["639-1","639-2/B", "639-2/T", "639-3"]:
|
54 |
+
if obsolete_code_name in line and ":" in line:
|
|
|
55 |
code = line.split()[-1]
|
56 |
obsolete_codes[obsolete_code_name] = code
|
57 |
return obsolete_codes
|