def test_parse_axi_values_file(self): s = """ # This file contains the mapping between names of numeric values indexed in the # APT Xapian index and their index # # Xapian allows to index numeric values as well as keywords and to use them for # all sorts of useful querying tricks. However, every numeric value needs to # have a unique index, and this configuration file is needed to record which # indices are allocated and to provide a mnemonic name for them. # # The format is exactly like /etc/services with name, number and optional # aliases, with the difference that the second column does not use the # "/protocol" part, which would be meaningless here. version 0 # package version catalogedtime 1 # Cataloged timestamp installedsize 2 # installed size packagesize 3 # package size app-popcon 4 # app-install .desktop popcon rank """ fname = "axi-test-values" with open(fname, "w") as f: f.write(s) self.addCleanup(os.remove, fname) #db = StoreDatabase("/var/cache/software-center/xapian", self.cache) axi_values = parse_axi_values_file(fname) self.assertNotEqual(axi_values, {})
def test_parse_axi_values_file(self): s = """ # This file contains the mapping between names of numeric values indexed in the # APT Xapian index and their index # # Xapian allows to index numeric values as well as keywords and to use them for # all sorts of useful querying tricks. However, every numeric value needs to # have a unique index, and this configuration file is needed to record which # indices are allocated and to provide a mnemonic name for them. # # The format is exactly like /etc/services with name, number and optional # aliases, with the difference that the second column does not use the # "/protocol" part, which would be meaningless here. version 0 # package version catalogedtime 1 # Cataloged timestamp installedsize 2 # installed size packagesize 3 # package size app-popcon 4 # app-install .desktop popcon rank """ open("axi-test-values","w").write(s) #db = StoreDatabase("/var/cache/software-center/xapian", self.cache) axi_values = parse_axi_values_file("axi-test-values") self.assertNotEqual(axi_values, {}) print axi_values
WEIGHT_DESKTOP_NAME = 10 WEIGHT_DESKTOP_KEYWORD = 5 WEIGHT_DESKTOP_GENERICNAME = 3 WEIGHT_DESKTOP_COMMENT = 1 WEIGHT_APT_PKGNAME = 8 WEIGHT_APT_SUMMARY = 5 WEIGHT_APT_DESCRIPTION = 1 # some globals (FIXME: that really need to go into a new Update class) popcon_max = 0 seen = set() LOG = logging.getLogger(__name__) # init axi axi_values = parse_axi_values_file() # get cataloged_times cataloged_times = {} CF = "/var/lib/apt-xapian-index/cataloged_times.p" if os.path.exists(CF): try: cataloged_times = pickle.load(open(CF)) except Exception as e: LOG.warn("failed to load file %s: %s", CF, e) del CF # Enable Xapian's CJK tokenizer (see LP: #745243) os.environ['XAPIAN_CJK_NGRAM'] = '1'