work on initial tag load

This commit is contained in:
Sam
2021-02-10 12:50:25 +00:00
parent 07c3a42ee8
commit 41e68031fa
7 changed files with 10910 additions and 0 deletions

View File

@@ -7,9 +7,12 @@ from django.utils.http import urlsafe_base64_encode
from django.template.loader import render_to_string
from django.core.mail import EmailMessage
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.conf import settings
from rest_framework_simplejwt.tokens import RefreshToken
from tagulous.models import TagModel
User = get_user_model()
@@ -74,3 +77,23 @@ def send_verification_email(request, user):
logging.info(f"Verification email sent to {user.email}")
except Exception as e:
logging.error(f"Could not sent verification email to: {user.email}")
def reformat_google_taxonomy(file_name):
"""
Read from flat text file
Create Herarchical Tag for each line
"""
base = settings.BASE_DIR + '/../datasets/'
counter = 0
source_file_path = base + file_name
destination_file_path = base + 'ALT' + file_name
source_file = open(source_file_path, 'rt')
destination_file = open(destination_file_path, 'wt')
for line in source_file.readlines():
line = line.replace(' > ', '/')
destination_file.write(line)