Get the ID of the user with `username` from write-math.com. If he
    doesn't exist by now, create it. Add `copyright_str` as a description.

    Parameters
    ----------
    username : string
        Name of a user.
    copyright_str : string
        Description text of a user in Markdown format.

    Returns
    -------
    int :
        ID on write-math.com of the user.

def getuserid(username, copyright_str):
    """Get the ID of the user with `username` from write-math.com. If he
    doesn't exist by now, create it. Add `copyright_str` as a description.

    Parameters
    ----------
    username : string
        Name of a user.
    copyright_str : string
        Description text of a user in Markdown format.

    Returns
    -------
    int :
        ID on write-math.com of the user.
    """
    global username2id
    if username not in username2id:
        mysql = utils.get_mysql_cfg()
        connection = pymysql.connect(host=mysql['host'],
                                     user=mysql['user'],
                                     passwd=mysql['passwd'],
                                     db=mysql['db'],
                                     charset='utf8mb4',
                                     cursorclass=pymysql.cursors.DictCursor)
        cursor = connection.cursor()

        sql = ("INSERT IGNORE INTO  `wm_users` ("
               "`display_name` , "
               "`password` ,"
               "`account_type` ,"
               "`confirmation_code` ,"
               "`status` ,"
               "`description`"
               ") "
               "VALUES ("
               "%s, '',  'Regular User',  '',  'activated', %s"
               ");")
        cursor.execute(sql, (username, copyright_str))
        connection.commit()

        # Get the id
        try:
            sql = ("SELECT  `id` FROM  `wm_users` "
                   "WHERE  `display_name` =  %s LIMIT 1")
            cursor.execute(sql, username)
            uid = cursor.fetchone()['id']
        except Exception as inst:
            logging.debug("username not found: %s", username)
            print(inst)
        # logging.info("%s: %s", username, uid)
        username2id[username] = uid
    return username2id[username]