Missing script for 854481d

This commit is contained in:
Rémi Oudin 2018-02-24 17:22:52 +01:00
parent 854481dbd3
commit c58f42476f

View file

@ -0,0 +1,27 @@
""" Small module that import browser fingerprints into the databose,
based on the data listed in https://huit.re/user-agent-json.
"""
import json
from django.core.management.base import BaseCommand
from django.db import models
from profiles.models import SearchEngine
def import_file(filename):
with open(filename, mode='r') as file:
data = json.load(file)
for search_engine in data:
import_search_engine(search_engine["searchengine"])
def import_search_engine(engine):
search_engine = SearchEngine(
name=engine.get("name", ""),
url=engine.get("url", ""),
query_pattern=engine.get("query_pattern", "")
)
#print(search_engine)
search_engine.save()
class Command(BaseCommand):
def handle(self, *args, **kwargs):
import_file("data/search_engine.json")