## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Indico;if not, see <http://www.gnu.org/licenses/>.

from indico.core.db import DBMgr
from MaKaC import user
from MaKaC.common.indexes import IndexesHolder
"""
Generates a file with all the avatars that are not well indexed by name.
"""

DBMgr.getInstance().startRequest()
error = False
ah = user.AvatarHolder()
ni = IndexesHolder()._getIdx()["name"]
log = file('names_ids.txt', 'w')
lines = []
for uid, user in ah._getIdx().iteritems():
    for word in ni._words:
        if uid in ni._words[word] and word != user.getName():
            lines.append(uid + "-" + user.getName() + "-" + word)
log.writelines("\n".join(lines))
log.close()
if not error:
    DBMgr.getInstance().endRequest()
    print "No error. The change are saved"
else:
    print "There were errors. The changes was not saved"
## You should have received a copy of the GNU General Public License
## along with Indico;if not, see <http://www.gnu.org/licenses/>.


from indico.core.db import DBMgr
from MaKaC import user
from MaKaC.common.indexes import IndexesHolder


"""
Generates a file with all the avatars that are not well indexed by name.
"""

DBMgr.getInstance().startRequest()
error = False
ah = user.AvatarHolder()
ni=IndexesHolder()._getIdx()["name"]
log = file('names_ids.txt','w')
lines = []
for uid, user in ah._getIdx().iteritems():
    for word in ni._words:
        if uid in ni._words[word] and word != user.getName():
            lines.append(uid + "-" + user.getName() + "-" + word)
log.writelines("\n".join(lines))
log.close()
if not error:
    DBMgr.getInstance().endRequest()
    print "No error. The change are saved"
else:
    print "There were errors. The changes was not saved"