<commit_before>""" test """
import datetime
import json
import pickle
from django.contrib.auth.models import User
def migrate():
   """ test """
   fp=open("nroer_user_data","r")   
   usernames=[]
   userids=[]
   for each in User.objects.all():
      usernames.append(each.username)
      userids.append(each.id)
   line = pickle.loads(fp.read())
   for each in line:
      b=each
      a=User()
      if not each['username'] in usernames:
         if each['id'] in userids:
            b['id']=max(userids)+1
         a.__dict__=b
         a.save()   
   fp.close()   


<commit_msg>Addded notification code for migrated users<commit_after>import datetime
import json
import pickle
from django.contrib.auth.models import User
from gnowsys_ndf.notification import models as notification
from django.contrib.sites.models import Site
from django.template.loader import render_to_string

def migrate():
   """ test """
   fp=open("cube_users","r")
   usernames=[]
   userids=[]
   for each in User.objects.all():
      usernames.append(each.username)
      userids.append(each.id)
   line = pickle.loads(fp.read())
   userobj=User.objects.all()[0]
   msg1="Your user account with username '"
   msg2="' has been migrated from cube.metastudio.org to www.metastudio.org"
   msg3="\nIncase you forgot your password, please use 'change password' option to change it.\nFrom now on, please use the site www.metastudio.org . All the resources from beta.metastudio.org will be migrated to this site."
   name=userobj.username
   activ="migrating users"
   site=Site.objects.all()[0]
   sender=name
   for each in line:
      b=each
      a=User()
      if not each['username'] in usernames:
         if each['id'] in userids:
            b['id']=max(userids)+1
         a.__dict__=b
         a.save()
      else:
         bx=User.objects.get(username=each['username'])
         msg=msg1+bx.username+msg2+msg3
         render = render_to_string("notification/label.html",{'sender':name,'activity':activ,'conjunction':'-','object':'','site':site,'link\
':''})
         notification.create_notice_type(render, msg, "notification")
         notification.send([bx], render, {"from_user": sender})
   fp.close()



{'fraction_non_alphanumeric': 0.13460663938153705, 'fraction_numerical': 0.004547521600727604, 'mean_word_length': 3.25531914893617, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '248821', 'n_tokens_mistral': 695, 'n_tokens_neox': 689, 'n_words': 169}