Commit 229e255b authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

Update providers database

parent 2f54c1ec
Pipeline #82682 passed with stage
in 2 minutes and 42 seconds
This diff is collapsed.
......@@ -9,8 +9,18 @@ from glob import glob
from os import path, remove
from shutil import rmtree
from subprocess import call
import sys
try:
import yaml
except ImportError:
sys.exit("Please install pyaml first")
try:
from HTMLParser import HTMLParser
except ImportError:
from html.parser import HTMLParser
import yaml
GIT_CLONE_URI = "https://github.com/2factorauth/twofactorauth"
TMP_FOLDER = path.join(tempfile.gettempdir(), "Authenticator")
......@@ -36,13 +46,16 @@ def is_valid(provider):
output = {}
html_parser = HTMLParser()
for db_file in glob(DATA_DIR + "/*.yml"):
with open(db_file, 'r') as file_data:
with open(db_file, 'r', encoding='utf8') as file_data:
try:
providers = yaml.load(file_data)["websites"]
for provider in providers:
if is_valid(provider):
output[provider.get("name")] = {
name = provider.get("name")
output[html_parser.unescape(name)] = {
"img": provider.get("img"),
"url": provider.get("url", ""),
"doc": provider.get("doc", "")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment