def check_knowls(cat='ec', verbose=False): cat_knowls = knowldb.search(category=cat) if verbose: print("%s knowls in category %s" % (len(cat_knowls), cat)) for k in cat_knowls: if verbose: print("Checking knowl %s" % k['id']) k = knowldb.get_knowl(k['id']) cont = k['content'] i = 0 while (i >= 0): i = cont.find("KNOWL_INC") if i >= 0: offset = 10 else: i = cont.find("KNOWL") if i >= 0: offset = 6 if (i >= 0): cont = cont[i + offset:] qu = cont[0] j = cont.find(qu, 1) ref = cont[1:j] if verbose: print("..cites %s" % ref) cont = cont[j + 1:] the_ref = knowldb.get_knowl(ref) if the_ref is None: print("Non-existing reference to %s in knowl %s" % (ref, k['id'])) elif verbose: print("--- found")
def find_knowl_crossrefs(id, all=True, verbose=False): """Finds knowl(s) which cite the given knowl. if verbose, list the citing knowls (or just the first if all=False), otherwise just return True/False according to whether any other knowls cite the given one. EXAMPLE: sage: find_knowl_crossrefs("ec.q.torsion_order", verbose=True) knowl ec.q.torsion_order is cited by ec.q.bsd_invariants knowl ec.q.torsion_order is cited by ec.q.mordell-weil True """ found = False for k in knowldb.search(): content = knowldb.get_knowl(k['id'])['content'] if id in content: found = True if verbose: print("knowl {} is cited by {}".format(id, k['id'])) if not all or not verbose: return True return found
def find_knowl_crossrefs(id, all=True, verbose=False): """Finds knowl(s) which cite the given knowl. if verbose, list the citing knowls (or just the first if all=False), otherwise just return True/False according to whether any other knowls cite the given one. EXAMPLE: sage: find_knowl_crossrefs("ec.q.torsion_order", verbose=True) knowl ec.q.torsion_order is cited by ec.q.bsd_invariants knowl ec.q.torsion_order is cited by ec.q.mordell-weil True """ found = False for k in knowldb.search(): content = knowldb.get_knowl(k['id'])['content'] if id in content: found = True if verbose: print("knowl {} is cited by {}".format(id,k['id'])) if not all or not verbose: return True return found
def check_knowls(cat='ec', verbose=False): cat_knowls = knowldb.search(category=cat) if verbose: print("%s knowls in category %s" % (len(cat_knowls),cat)) for k in cat_knowls: if verbose: print("Checking knowl %s" % k['id']) k = knowldb.get_knowl(k['id']) cont = k['content'] all_content = cont cont = cont.replace("KNOWL ","KNOWL") i = 0 while (i>=0): i = cont.find("KNOWL_INC") if i>=0: offset = 10 else: i = cont.find("KNOWL") if i>=0: offset=6 if (i>=0): cont = cont[i+offset:] qu = cont[0] j = cont.find(qu,1) ref = cont[1:j] if verbose: print("..cites %s" % ref) cont = cont[j+1:] the_ref = knowldb.get_knowl(ref) if the_ref is None: print("Non-existing reference to %s in knowl %s" % (ref,k['id'])) print("content of {} = ".format(k['id'])) print(all_content) return False elif verbose: print("--- found") return True