def testDumpEnums(self): """Test case - to verify enum ordering - """ try: myIo = IoAdapter(raiseExceptions=True) self.__containerList = myIo.readFile( inputFilePath=self.__pathPdbxDictionary) dApi = DictionaryApi(containerList=self.__containerList, consolidate=True, verbose=self.__verbose) # eList = dApi.getEnumListAlt(category="pdbx_audit_support", attribute="country") logger.debug("Item %s Enum list sorted %r\n", "country", eList) eList = dApi.getEnumListAlt(category="pdbx_audit_support", attribute="country", sortFlag=False) logger.debug("Item %s Enum list unsorted %r\n", "country", eList) eList = dApi.getEnumListAltWithDetail( category="pdbx_audit_support", attribute="country") logger.debug("Item %s Enum with detail list %r\n", "country", eList) self.assertGreater(len(eList), 100) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def test_dump_enums(self, api_paths): myIo = IoAdapter(raiseExceptions=True) containerList = myIo.readFile( inputFilePath=str(api_paths['pathPdbxDictionary'])) dApi = DictionaryApi(containerList=containerList, consolidate=True) eList = dApi.getEnumListAlt(category="pdbx_audit_support", attribute="country") print("Item %s Enum list sorted %r\n" % ('country', eList)) eList = dApi.getEnumListAlt(category="pdbx_audit_support", attribute="country", sortFlag=False) print("Item %s Enum list unsorted %r\n" % ('country', eList)) eList = dApi.getEnumListAltWithDetail(category="pdbx_audit_support", attribute="country") print("Item %s Enum with detail list %r\n" % ('country', eList)) assert len(eList) > 100
class DictionaryData(object): def __init__(self): basedir = os.path.join(os.path.dirname(__file__), "..", "dist") self.dictPath = os.path.join(basedir, "mmcif_pdbx_v5_next.dic") def readDictionary(self): myIo = IoAdapterPy() self.__containerList = myIo.readFile(inputFilePath=self.dictPath) self._dApi = DictionaryApi(containerList=self.__containerList, consolidate=True) assert len(self.getGroups()) > 0, "Failed to load %s" % self.dictPath def getGroups(self): groupList = self._dApi.getCategoryGroups() return groupList def getTypeRegex(self, cat, attrib): return self._dApi.getTypeRegex(cat, attrib) def getTypeRegexAlt(self, cat, attrib): return self._dApi.getTypeRegexAlt(cat, attrib) def getDataTypeList(self): """ Return list of tuples containing ('code','primitive_code','construct','detail' ) """ return self._dApi.getDataTypeList() def getEnumList(self, category, attribute, sortFlag=True): return self._dApi.getEnumList(category, attribute, sortFlag) def getEnumListAlt(self, category, attribute, sortFlag=True): return self._dApi.getEnumListAlt(category, attribute, sortFlag) def getEnumListAltWithDetail(self, category, attribute): return self._dApi.getEnumListAltWithDetail(category, attribute) def getAllCategory(self): """Returns list of all categories""" return self._dApi.getCategoryList() def getCategoryList(self): return self._dApi.getCategoryList() def getItemNameList(self, category): return self._dApi.getItemNameList(category) def wwPDBContext(self, catItem): """Returns true if category or item have local context""" category, item = catItem.split('.') if category[0] == "_": category = category[1:] #print "CHECKING ", category, item, self.__dictA.getCategoryContextList(category) if self._dApi.getCategoryContextList(category) == ['WWPDB_LOCAL']: return True if self._dApi.getContextList(category, item) == ['WWPDB_LOCAL']: return True return False def getCategoryItemEnum(self, itemName): """Returns any archive enum list""" categoryName = CifName.categoryPart(itemName) attributeName = CifName.attributePart(itemName) return self._dApi.getEnumList(categoryName, attributeName) def getCategoryPdbxItemEnum(self, itemName): """Returns any DepUI enum list""" categoryName = CifName.categoryPart(itemName) attributeName = CifName.attributePart(itemName) return self._dApi.getEnumListAlt(categoryName, attributeName) def getItemRelatedList(self, itemName): categoryName = CifName.categoryPart(itemName) attributeName = CifName.attributePart(itemName) return self._dApi.getItemRelatedList(categoryName, attributeName)