#!/usr/bin/env python
#
# This file is part of aDBa.
#
# aDBa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# aDBa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# 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 aDBa. If not, see .
from random import shuffle
class AniDBMaper:
blacklist = ('unused','retired','reserved')
def getAnimeBitsA(self,amask):
map = self.getAnimeMapA()
return self._getBitChain(map,amask);
def getAnimeCodesA(self,aBitChain):
amap = self.getAnimeMapA()
return self._getCodes(amap,aBitChain);
def getFileBitsF(self,fmask):
fmap = self.getFileMapF()
return self._getBitChain(fmap,fmask)
def getFileCodesF(self,bitChainF):
fmap = self.getFileMapF()
return self._getCodes(fmap,bitChainF)
def getFileBitsA(self,amask):
amap = self.getFileMapA()
return self._getBitChain(amap,amask)
def getFileCodesA(self,bitChainA):
amap = self.getFileMapA()
return self._getCodes(amap,bitChainA)
def _getBitChain(self,map,wanted):
"""Return an hex string with the correct bit set corresponding to the wanted fields in the map
"""
bit = 0
for index,field in enumerate(map):
if field in wanted and not field in self.blacklist:
bit = bit ^ (1<