rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def update_bibfmt_format(id_bibrec, marc, format):
def update_bibfmt_format(id_bibrec, format_value, format_name):
def update_bibfmt_format(id_bibrec, marc, format): """Update the format in the table bibfmt""" # We check if the format is already in bibFmt found = find_record_format(id_bibrec, format) if int(found[0]) == 1: # Update the format # get the current time now = convert_datestruct_to_datetext(time.localtime()) # compress...
found = find_record_format(id_bibrec, format) if int(found[0]) == 1:
nb_found = find_record_format(id_bibrec, format_name) if nb_found == 1:
def update_bibfmt_format(id_bibrec, marc, format): """Update the format in the table bibfmt""" # We check if the format is already in bibFmt found = find_record_format(id_bibrec, format) if int(found[0]) == 1: # Update the format # get the current time now = convert_datestruct_to_datetext(time.localtime()) # compress...
pickled_marc = compress(marc)
pickled_format_value = compress(format_value)
def update_bibfmt_format(id_bibrec, marc, format): """Update the format in the table bibfmt""" # We check if the format is already in bibFmt found = find_record_format(id_bibrec, format) if int(found[0]) == 1: # Update the format # get the current time now = convert_datestruct_to_datetext(time.localtime()) # compress...
query = """UPDATE bibfmt SET format = %s, last_updated = %s, value = %s WHERE id_bibrec = %s """ params = (format, now, pickled_marc, id_bibrec)
query = """UPDATE bibfmt SET last_updated=%s, value=%s WHERE id_bibrec=%s AND format=%s""" params = (now, pickled_format_value, id_bibrec, format_name)
def update_bibfmt_format(id_bibrec, marc, format): """Update the format in the table bibfmt""" # We check if the format is already in bibFmt found = find_record_format(id_bibrec, format) if int(found[0]) == 1: # Update the format # get the current time now = convert_datestruct_to_datetext(time.localtime()) # compress...
write_message(" -Update the format %s in bibfmt : DONE" % format , verbose=2)
write_message(" -Update the format %s in bibfmt : DONE" % format_name , verbose=2)
def update_bibfmt_format(id_bibrec, marc, format): """Update the format in the table bibfmt""" # We check if the format is already in bibFmt found = find_record_format(id_bibrec, format) if int(found[0]) == 1: # Update the format # get the current time now = convert_datestruct_to_datetext(time.localtime()) # compress...
elif int(found[0]) > 1: write_message(" Failed: Same format %s found several time in bibfmt for the same record." % format, verbose=1, stream=sys.stderr)
elif nb_found > 1: write_message(" Failed: Same format %s found several time in bibfmt for the same record." % format_name, verbose=1, stream=sys.stderr)
def update_bibfmt_format(id_bibrec, marc, format): """Update the format in the table bibfmt""" # We check if the format is already in bibFmt found = find_record_format(id_bibrec, format) if int(found[0]) == 1: # Update the format # get the current time now = convert_datestruct_to_datetext(time.localtime()) # compress...
res = insert_bibfmt(id_bibrec, marc, format)
res = insert_bibfmt(id_bibrec, format_value, format_name)
def update_bibfmt_format(id_bibrec, marc, format): """Update the format in the table bibfmt""" # We check if the format is already in bibFmt found = find_record_format(id_bibrec, format) if int(found[0]) == 1: # Update the format # get the current time now = convert_datestruct_to_datetext(time.localtime()) # compress...
write_message(" -Insert the format %s in bibfmt : DONE" % format , verbose=2)
write_message(" -Insert the format %s in bibfmt : DONE" % format_name , verbose=2)
def update_bibfmt_format(id_bibrec, marc, format): """Update the format in the table bibfmt""" # We check if the format is already in bibFmt found = find_record_format(id_bibrec, format) if int(found[0]) == 1: # Update the format # get the current time now = convert_datestruct_to_datetext(time.localtime()) # compress...
query = """UPDATE bibdoc SET status='deleted' WHERE id IN (SELECT id_bibdoc FROM bibrec_bibdoc where id_bibrec = %s)"""
query = """UPDATE bibdoc SET status='deleted' WHERE id IN (SELECT id_bibdoc FROM bibrec_bibdoc WHERE id_bibrec=%s)"""
def delete_bibdoc(id_bibrec): """Delete document from bibdoc which correspond to the bibrec id given in parameter""" query = """UPDATE bibdoc SET status='deleted' WHERE id IN (SELECT id_bibdoc FROM bibrec_bibdoc where id_bibrec = %s)""" params = (id_bibrec,) try: run_sql(query, params) except Error, error: write_messag...
query = """DELETE FROM bibrec_bibdoc where id_bibrec = %s"""
query = """DELETE FROM bibrec_bibdoc WHERE id_bibrec=%s"""
def delete_bibrec_bibdoc(id_bibrec): """Delete the bibrec record from the table bibrec_bibdoc given in parameter""" # delete all the records with proper id_bibrec query = """DELETE FROM bibrec_bibdoc where id_bibrec = %s""" params = (id_bibrec,) try: run_sql(query, params) except Error, error: write_message(" Error d...
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
navtrail="""<a class="navtrail" href="%s/youraccount.py/account">Your Account</a>""" % weburl,
def send_email(req,p_email=None): uid = webuser.getUid(req) passw = webuser.givePassword(p_email) if passw == -999: eMsg = "The entered e-mail address doesn't exist in the database" return page(title="Your Account", body=webaccount.perform_emailMessage(eMsg), navtrail="""<a class="navtrail" href="%s/youraccount.py/di...
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
navtrail="""<a class="navtrail" href="%s/youraccount.py/account">Your Account</a>""" % weburl,
def delete(req): uid = webuser.getUid(req) return page(title="Delete Account", body=webaccount.perform_delete(), navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl, description="CDS Personalize, Main page", keywords="CDS, personalize", uid=uid)
navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl,
navtrail="""<a class="navtrail" href="%s/youraccount.py/account">Your Account</a>""" % weburl,
def logout(req): uid = webuser.logoutUser(req) return page(title="Logout", body=webaccount.perform_logout(req), navtrail="""<a class="navtrail" href="%s/youraccount.py/display">Your Account</a>""" % weburl, description="CDS Personalize, Main page", keywords="CDS, personalize", uid=uid)
try: align.append(type(int(item)) is int and 'admintdright') except ValueError: align.append('admintdleft')
if type(item) is int: align.append('admintdright') else: align.append('admintdleft')
def tupletotable(header=[], tuple=[], start='', end='', extracolumn=''): """create html table for a tuple. header - optional header for the columns tuple - create table of this start - text to be added in the beginning, most likely beginning of a form end - text to be added in the end, mot likely end of a form. ex...
p = sre_quotes.sub("", p)
def get_nearest_terms_in_bibxxx(p, f, n_below, n_above): """Browse (-n_above, +n_below) closest bibliographic phrases for the given pattern p in the given field f, regardless of collection. Return list of [phrase1, phrase2, ... , phrase_n].""" ## determine browse field: if not f and string.find(p, ":") > 0: # does 'p' ...
p = sre_quotes.sub("", p)
def get_nbhits_in_bibxxx(p, f): """Return number of hits for word 'word' inside words index for field 'f'.""" ## determine browse field: if not f and string.find(p, ":") > 0: # does 'p' contain ':'? f, p = split(p, ":", 1) ## wash 'p' argument: p = sre_quotes.sub("", p) ## construct 'tl' which defines the tag list (MAR...
def tmpl_print_record_list_for_similarity_boxen(self, title, score_list, ln=cdslang):
def tmpl_print_record_list_for_similarity_boxen(self, title, recID_score_list, ln=cdslang):
def tmpl_print_record_list_for_similarity_boxen(self, title, score_list, ln=cdslang): """Print list of records in the "hs" (HTML Similarity) format for similarity boxes. FIXME: bad symbol names again, e.g. SCORE_LIST is *not* a list of scores. Humph. """
FIXME: bad symbol names again, e.g. SCORE_LIST is *not* a list of scores. Humph. """ from invenio.search_engine import print_record
RECID_SCORE_LIST is a list of (recID1, score1), (recID2, score2), etc. """ from invenio.search_engine import print_record, record_public_p recID_score_list_to_be_printed = [] nb_records_to_be_printed = 0 nb_records_seen = 0 while nb_records_to_be_printed < 5 and nb_records_seen < len(recID_score_list) and nb_record...
def tmpl_print_record_list_for_similarity_boxen(self, title, score_list, ln=cdslang): """Print list of records in the "hs" (HTML Similarity) format for similarity boxes. FIXME: bad symbol names again, e.g. SCORE_LIST is *not* a list of scores. Humph. """
for recid, score in score_list [:5]:
for recid, score in recID_score_list_to_be_printed:
def tmpl_print_record_list_for_similarity_boxen(self, title, score_list, ln=cdslang): """Print list of records in the "hs" (HTML Similarity) format for similarity boxes. FIXME: bad symbol names again, e.g. SCORE_LIST is *not* a list of scores. Humph. """
number = locale.format('%d', number, True)
try: number = locale.format('%d', number, True) except TypeError: return str(number)
def tmpl_nice_number(self, number, ln=cdslang): "Returns nicely printed number NUM in language LN using the locale." if number is None: return None # Temporarily switch the numeric locale to the requeted one, and format the number # In case the system has no locale definition, use the vanilla form ol = locale.getlocale...
id = request.cookies.get(self._getSessionCookieName()) if id == "" or id == "*del*":
sessid = request.cookies.get(self._getSessionCookieName()) if sessid == "" or sessid == "*del*":
def _get_session_id (self, request): """_get_session_id(request : HTTPRequest) -> string
return id
return sessid
def _get_session_id (self, request): """_get_session_id(request : HTTPRequest) -> string
id = None while id is None or self.has_session(id): id = "%016X" % randlong(8)
sessid = None while sessid is None or self.has_session(sessid): sessid = "%016X" % randlong(8)
def _create_session (self, request): # Generate a session ID, which is just the value of the session # cookie we are about to drop on the user. (It's also the key # used with the session manager mapping interface.) id = None while id is None or self.has_session(id): id = "%016X" % randlong(8) # 64-bit random number
id = self._get_session_id(request)
sessid = self._get_session_id(request)
def get_session (self, request): """get_session(request : HTTPRequest) -> Session
if id is not None: session = self.get(id)
if sessid is not None: session = self.get(sessid)
def get_session (self, request): """get_session(request : HTTPRequest) -> Session
raise SessionError(session_id=id)
raise SessionError(session_id=sessid)
def get_session (self, request): """get_session(request : HTTPRequest) -> Session
session.get_remote_address() != request.get_environ("REMOTE_ADDR")):
session.get_remote_address() != \ request.get_environ("REMOTE_ADDR")):
def get_session (self, request): """get_session(request : HTTPRequest) -> Session
session_id=id) if id is None or session is None:
session_id=sessid) if sessid is None or session is None:
def get_session (self, request): """get_session(request : HTTPRequest) -> Session
id = request.cookies.get(self._getSessionCookieName()) if id is None:
sessid = request.cookies.get(self._getSessionCookieName()) if sessid is None:
def has_session_cookie (self, request, must_exist=0): """has_session_cookie(request : HTTPRequest, must_exist : boolean = false) -> boolean
return self.has_session(id)
return self.has_session(sessid)
def has_session_cookie (self, request, must_exist=0): """has_session_cookie(request : HTTPRequest, must_exist : boolean = false) -> boolean
def dump (self, file=None, header=1, deep=1): time_fmt = "%Y-%m-%d %H:%M:%S" ctime = strftime(time_fmt, localtime(self.__creation_time)) atime = strftime(time_fmt, localtime(self.__access_time)) if header: file.write('session %s:' % self.id) file.write(' user %s' % self.user) file.write(' __remote_address: %s' % sel...
def dump (self, file=None, header=1, deep=1): time_fmt = "%Y-%m-%d %H:%M:%S" ctime = strftime(time_fmt, localtime(self.__creation_time)) atime = strftime(time_fmt, localtime(self.__access_time))
except KeyError, e:
except KeyError:
def __init__(self, request): """Constructor of the class. Initialises the necessesary values. It should never be used, use getWrapper method instead. """ self.__request = request try: self.cookies = parse_cookie(self.__request.headers_in[ "Cookie" ]) except KeyError, e: self.cookies = {} self.environ = {} self.environ[...
self.environ["REMOTE_ADDR"] = self.__request.get_remote_host(apache.REMOTE_NOLOOKUP)
self.environ["REMOTE_ADDR"] = \ self.__request.get_remote_host(apache.REMOTE_NOLOOKUP)
def __init__(self, request): """Constructor of the class. Initialises the necessesary values. It should never be used, use getWrapper method instead. """ self.__request = request try: self.cookies = parse_cookie(self.__request.headers_in[ "Cookie" ]) except KeyError, e: self.cookies = {} self.environ = {} self.environ[...
except AttributeError, e:
except AttributeError:
def __init__(self, request): """Constructor of the class. Initialises the necessesary values. It should never be used, use getWrapper method instead. """ self.__request = request try: self.cookies = parse_cookie(self.__request.headers_in[ "Cookie" ]) except KeyError, e: self.cookies = {} self.environ = {} self.environ[...
self.request.headers_out["Set-Cookie"] = "%s=%s%s"%(cookie_name, cookie_value, options)
self.request.headers_out["Set-Cookie"] = "%s=%s%s" % \ (cookie_name, cookie_value, options)
def set_cookie(self, cookie_name, cookie_value, **attrs): """ """ options = "" for (name, value) in attrs.items(): if value is None: continue if name in ("max_age", "path"): name = name.replace("_", "-") options += "; %s=%s"%(name, value) elif name =="secure" and value: options += "; secure" self.request.headers_out["S...
if action != "Browse" and req:
if action != "Browse" and req and req.args:
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="id", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="0", d1m="0", ...
- A search unit consists of '(operand, pattern, field, type, hitlist)' tuples where
- A search unit consists of '(operand, pattern, field, type, hitset)' tuples where
def create_basic_search_units(req, p, f, m=None): """Splits search pattern and search field into a list of independently searchable units. - A search unit consists of '(operand, pattern, field, type, hitlist)' tuples where 'operand' is set union (|), set intersection (+) or set exclusion (-); 'pattern' is either a word...
elif m == 'a':
elif m == 'a' or m == 'w':
def create_basic_search_units(req, p, f, m=None): """Splits search pattern and search field into a list of independently searchable units. - A search unit consists of '(operand, pattern, field, type, hitlist)' tuples where 'operand' is set union (|), set intersection (+) or set exclusion (-); 'pattern' is either a word...
class HitList:
class HitSet:
def urlargs_replace_text_in_arg(urlargs, regexp_argname, text_old, text_new): """Analyze `urlargs' (URL CGI GET query arguments) and for each occurrence of argument matching `regexp_argname' replace every substring `text_old' by `text_new'. Return the resulting URL. Useful for create_nearest_terms_box.""" out = "" # p...
"Calculates the number of records set in the hitlist."
"Calculates the number of records set in the hitset."
def calculate_nbhits(self): "Calculates the number of records set in the hitlist." self._nbhits = Numeric.sum(self._set.copy().astype(Numeric.Int))
def tolist(self): "Return an array containing all recID." return Numeric.nonzero(self._set).tolist()
def items(self): "Return an array containing all recID." return Numeric.nonzero(self._set)
psyco.bind(HitList)
psyco.bind(HitSet)
def items(self): "Return an array containing all recID." return Numeric.nonzero(self._set)
p = sre.sub(r'(\s\w{1,3})[\*\%]+', "\\1", p)
p = sre.sub("'(.*?)'", lambda x: "'"+string.replace(x.group(1), ' ', '__SPACE__')+"'", p) p = sre.sub("\"(.*?)\"", lambda x: "\""+string.replace(x.group(1), ' ', '__SPACEBIS__')+"\"", p) p = sre.sub(r'([\s\"]\w{1,3})[\*\%]+', "\\1", p) p = sre.sub("__SPACE__", " ", p) p = sre.sub("__SPACEBIS__", " ", p)
def wash_pattern(p): """Wash pattern passed by URL.""" # add leading/trailing whitespace for the two following wildcard-sanity checking regexps: p = " " + p + " " # get rid of wildcards at the beginning of words: p = sre.sub(r'(\s)[\*\%]+', "\\1", p) # get rid of extremely short words (1-3 letters with wildcards): TODO...
set = HitList()
set = HitSet()
def get_collection_reclist(coll): """Return hitlist of recIDs that belong to the collection 'coll'.""" global collection_reclist_cache if not collection_reclist_cache[coll]: set = HitList() query = "SELECT nbrecs,reclist FROM collection WHERE name='%s'" % coll # launch the query: res = run_sql(query, None, 1) # fill th...
phrase_hitlist = HitList() phrase_hitlists = search_pattern("", phrase, f, colls, 'e')
phrase_hitset = HitSet() phrase_hitsets = search_pattern("", phrase, f, 'e')
def browse_pattern(req, colls, p, f, rg): """Browse either biliographic phrases or words indexes, and display it.""" ## do we search in words indexes? if not f: return browse_in_bibwords(req, p, f) ## prepare collection urlargument for later printing: p_orig = p urlarg_colls = "" for coll in colls: urlarg_colls += "&c=...
phrase_hitlist.union(phrase_hitlists[coll]) phrase_hitlist.calculate_nbhits() if phrase_hitlist._nbhits > 0:
phrase_hitset.union(phrase_hitsets[coll]) phrase_hitset.calculate_nbhits() if phrase_hitset._nbhits > 0:
def browse_pattern(req, colls, p, f, rg): """Browse either biliographic phrases or words indexes, and display it.""" ## do we search in words indexes? if not f: return browse_in_bibwords(req, p, f) ## prepare collection urlargument for later printing: p_orig = p urlarg_colls = "" for coll in colls: urlarg_colls += "&c=...
browsed_phrases_in_colls.append([phrase, phrase_hitlist._nbhits])
browsed_phrases_in_colls.append([phrase, phrase_hitset._nbhits])
def browse_pattern(req, colls, p, f, rg): """Browse either biliographic phrases or words indexes, and display it.""" ## do we search in words indexes? if not f: return browse_in_bibwords(req, p, f) ## prepare collection urlargument for later printing: p_orig = p urlarg_colls = "" for coll in colls: urlarg_colls += "&c=...
def search_basic_pattern(p, f=None, m=None): """Searches for basic pattern 'p' and field 'f' and return hitlist of recIDs. Does not break up 'p' into any smaller units: this function is called for already ``basic search units'' that have been broke up before. Optionally, the function accepts the match type argument 'm...
def search_pattern(req=None, p=None, f=None, m=None, ap=0, of="id", dbg=0): """Search for complex pattern 'p' within field 'f' according to matching type 'm'. Return hitset of recIDs. The function uses multi-stage searching algorithm in case of no exact match found. See the Search Internals document for detailed des...
def search_basic_pattern(p, f=None, m=None): """Searches for basic pattern 'p' and field 'f' and return hitlist of recIDs. Does not break up 'p' into any smaller units: this function is called for already ``basic search units'' that have been broke up before. Optionally, the function accepts the match type argument 'm...
hitlist_empty = HitList() hitlist_empty._nbhits = 0
hitset_empty = HitSet() hitset_empty._nbhits = 0
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
hitlist_full = HitList(Numeric.ones(cfg_max_recID+1, Numeric.Int0)) hitlist_full._nbhits = cfg_max_recID
hitset_full = HitSet(Numeric.ones(cfg_max_recID+1, Numeric.Int0)) hitset_full._nbhits = cfg_max_recID
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
return hitlist_full
return hitset_full
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
basic_search_units_hitlists = []
basic_search_units_hitsets = []
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
basic_search_unit_hitlist = search_basic_pattern(bsu_p, bsu_f, bsu_m) if basic_search_unit_hitlist._nbhits > 0:
basic_search_unit_hitset = search_unit(bsu_p, bsu_f, bsu_m) if ap==0 or basic_search_unit_hitset._nbhits > 0:
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
basic_search_units_hitlists.append(basic_search_unit_hitlist)
basic_search_units_hitsets.append(basic_search_unit_hitset)
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
if sre.search(r'\w[^a-zA-Z0-9\s\:]\w', bsu_p):
if sre.search(r'\w[^a-zA-Z0-9\s\:]+(\w|$)', bsu_p):
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
bsu_pn = sre.sub(r'(\w)[^a-zA-Z0-9\s\:]+(\w)', "\\1*\\2", bsu_p)
bsu_pn = sre.sub(r'(\w)[^a-zA-Z0-9\s\:]+(\w|$)', "\\1*\\2", bsu_p)
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
bsu_pn = sre.sub(r'(\w)[^a-zA-Z0-9\s:]+(\w)', "\\1 \\2", bsu_p) basic_search_unit_hitlist = search_basic_pattern(bsu_pn, bsu_f, bsu_m) if basic_search_unit_hitlist._nbhits > 0:
bsu_pn = sre.sub(r'(\w)[^a-zA-Z0-9\s\:]+(\w|$)', "\\1 \\2", bsu_p) if dbg and of.startswith('h') and req: print_warning(req, "trying %s/%s/%s" % (bsu_pn,bsu_f,bsu_m)) basic_search_unit_hitset = search_pattern(req=None, p=bsu_pn, f=bsu_f, m=bsu_m, of="id") if basic_search_unit_hitset._nbhits > 0:
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
return hitlist_empty
return hitset_empty
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
(basic_search_units[idx_unit][1:], basic_search_units_hitlists[idx_unit]._nbhits))
(basic_search_units[idx_unit][1:], basic_search_units_hitsets[idx_unit]._nbhits))
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
hitlist_in_any_collection = HitList()
hitset_in_any_collection = HitSet()
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
this_unit_hitlist = basic_search_units_hitlists[idx_unit]
this_unit_hitset = basic_search_units_hitsets[idx_unit]
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
hitlist_in_any_collection.intersect(this_unit_hitlist)
hitset_in_any_collection.intersect(this_unit_hitset)
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
hitlist_in_any_collection.difference(this_unit_hitlist)
hitset_in_any_collection.difference(this_unit_hitset)
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
hitlist_in_any_collection.union(this_unit_hitlist)
hitset_in_any_collection.union(this_unit_hitset)
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
hitlist_in_any_collection.calculate_nbhits() if hitlist_in_any_collection._nbhits == 0:
hitset_in_any_collection.calculate_nbhits() if hitset_in_any_collection._nbhits == 0:
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
bsu_nbhits = basic_search_units_hitlists[idx_unit]._nbhits
bsu_nbhits = basic_search_units_hitsets[idx_unit]._nbhits
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
print_warning(req, "Search stage 3: boolean query gave %d hits." % hitlist_in_any_collection._nbhits)
print_warning(req, "Search stage 3: boolean query gave %d hits." % hitset_in_any_collection._nbhits)
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
return hitlist_in_any_collection def search_intersect_with_collrecs(req, hitlist_in_any_collection, colls, of="hb", dbg=0): """Return dict of hitlists given by intersection of hitlist with the collection universes.""" if dbg: t1 = os.times()[4] results = {} results_nbhits = 0 for coll in colls: results[coll] = HitLis...
return hitset_in_any_collection def search_unit(p, f=None, m=None): """Search for basic search unit defined by pattern 'p' and field 'f' and matching type 'm'. Return hitset of recIDs. All the parameters are assumed to have been previously washed. 'p' is assumed already being a ``basic search unit'' so that it is se...
def search_pattern(req, p=None, f=None, m=None, of='hb', dbg=0): """Search for pattern 'p' and field 'f' and return hitlist of recIDs. Breaks `p' into ``basic search units'', runs the search for them, and aggregates the results together. Optionally, the function accepts the match type argument 'm'. If it is set (e.g. f...
hitlist_bibwrd = HitList(Numeric.loads(decompress(hitlist)))
hitset_bibwrd = HitSet(Numeric.loads(decompress(hitlist)))
def search_in_bibwords(word, f, decompress=zlib.decompress): """Searches for 'word' inside bibwordsX table for field 'f' and returns hitlist of recIDs.""" set = HitList() # will hold output result set set_used = 0 # not-yet-used flag, to be able to circumvent set operations # deduce into which bibwordsX table we will s...
set.union(hitlist_bibwrd)
set.union(hitset_bibwrd)
def search_in_bibwords(word, f, decompress=zlib.decompress): """Searches for 'word' inside bibwordsX table for field 'f' and returns hitlist of recIDs.""" set = HitList() # will hold output result set set_used = 0 # not-yet-used flag, to be able to circumvent set operations # deduce into which bibwordsX table we will s...
set = hitlist_bibwrd
set = hitset_bibwrd
def search_in_bibwords(word, f, decompress=zlib.decompress): """Searches for 'word' inside bibwordsX table for field 'f' and returns hitlist of recIDs.""" set = HitList() # will hold output result set set_used = 0 # not-yet-used flag, to be able to circumvent set operations # deduce into which bibwordsX table we will s...
def search_in_bibxxx(p, f, type): """Searches for pattern 'p' inside bibxxx tables for field 'f' and returns hitlist of recIDs found.
def search_unit_in_bibxxx(p, f, type): """Searches for pattern 'p' inside bibxxx tables for field 'f' and returns hitset of recIDs found.
def search_in_bibxxx(p, f, type): """Searches for pattern 'p' inside bibxxx tables for field 'f' and returns hitlist of recIDs found. The search type is defined by 'type' (e.g. equals to 'r' for a regexp search).""" p_orig = p # saving for eventual future 'no match' reporting # wash arguments: f = string.replace(f, '*'...
set = HitList()
set = HitSet()
def search_in_bibxxx(p, f, type): """Searches for pattern 'p' inside bibxxx tables for field 'f' and returns hitlist of recIDs found. The search type is defined by 'type' (e.g. equals to 'r' for a regexp search).""" p_orig = p # saving for eventual future 'no match' reporting # wash arguments: f = string.replace(f, '*'...
def search_in_bibrec(day1, day2, type='creation_date'): """Return hitlist of recIDs found that were either created or modified (see 'type' arg)
def search_unit_in_bibrec(day1, day2, type='creation_date'): """Return hitset of recIDs found that were either created or modified (see 'type' arg)
def search_in_bibrec(day1, day2, type='creation_date'): """Return hitlist of recIDs found that were either created or modified (see 'type' arg) from day1 until day2, inclusive. Does not pay attention to pattern, collection, anything. Useful to intersect later on with the 'real' query.""" set = HitList() if type != "cr...
set = HitList()
set = HitSet()
def search_in_bibrec(day1, day2, type='creation_date'): """Return hitlist of recIDs found that were either created or modified (see 'type' arg) from day1 until day2, inclusive. Does not pay attention to pattern, collection, anything. Useful to intersect later on with the 'real' query.""" set = HitList() if type != "cr...
if len(t) != 6 or t[-1:]=='%': query = "SELECT bx.value FROM %s AS bx WHERE bx.value='%s' AND bx.tag LIKE '%s%%' ORDER BY bx.value ASC" \ % (bx, escape_string(p), t) else: query = "SELECT bx.value FROM %s AS bx WHERE bx.value='%s' AND bx.tag='%s' ORDER BY bx.value ASC" \ % (bx, escape_string(p), t) res = run_sql(query)...
def get_nearest_terms_in_bibxxx(p, f, n_below, n_above): """Browse (-n_above, +n_below) closest bibliographic phrases for the given pattern p in the given field f, regardless of collection. Return list of [phrase1, phrase2, ... , phrase_n].""" ## determine browse field: if string.find(p, ":") > 0: # does 'p' contain ':...
out.append(p)
if len(browsed_phrases_exact)>0: for phrase in browsed_phrases_exact.keys(): out.append(phrase) else: out.append(p)
def get_nearest_terms_in_bibxxx(p, f, n_below, n_above): """Browse (-n_above, +n_below) closest bibliographic phrases for the given pattern p in the given field f, regardless of collection. Return list of [phrase1, phrase2, ... , phrase_n].""" ## determine browse field: if string.find(p, ":") > 0: # does 'p' contain ':...
pass
out = var
def wash_url_argument(var, new_type): """Wash list argument into 'new_type', that can be 'list', 'str', or 'int'. Useful for washing mod_python passed arguments, that are all lists of strings (URL args may be multiple), but we sometimes want only to take the first value, and sometimes to represent it as string or nume...
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0",
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="id", ot="", as="0",
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
d1y="", d1m="", d1d="", d2y="", d2m="", d2d="", dbg="0"): """Perform search, without checking for authentication. Return list of recIDs found, if of=id. Otherwise create web page."""
d1y="", d1m="", d1d="", d2y="", d2m="", d2d="", dbg="0", ap="0"): """Perform search or browse request, without checking for authentication. Return list of recIDs found, if of=id. Otherwise create web page. The arguments are as follows: req - mod_python Request class instance. cc - current collection (e.g. "ATLAS")....
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
if action != "Browse":
if action != "Browse" and req:
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
results_in_any_collection = HitList()
results_in_any_collection = HitSet()
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
results_in_any_collection = search_pattern(req, p1, f1, m1, of=of, dbg=dbg)
results_in_any_collection = search_pattern(req, p1, f1, m1, ap=ap, of=of, dbg=dbg)
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
results_tmp = search_pattern(req, p2, f2, m2, of=of, dbg=dbg)
results_tmp = search_pattern(req, p2, f2, m2, ap=ap, of=of, dbg=dbg)
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
results_tmp = search_pattern(req, p3, f3, m3, of=of, dbg=dbg)
results_tmp = search_pattern(req, p3, f3, m3, ap=ap, of=of, dbg=dbg)
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
results_in_any_collection = search_pattern(req, p, f, of=of, dbg=dbg)
results_in_any_collection = search_pattern(req, p, f, ap=ap, of=of, dbg=dbg)
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
results_final = search_intersect_with_collrecs(req, results_in_any_collection, colls_to_search, of, dbg)
results_final = intersect_results_with_collrecs(req, results_in_any_collection, colls_to_search, ap, of, dbg)
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
results_final = search_results_intersect_with_a_hitlist(req, results_final, search_in_bibrec(day1, day2), fallback=1, fallbacktext="No match within your time limits, "\ "discarding this condition...")
results_final = intersect_results_with_hitset(req, results_final, search_unit_in_bibrec(day1, day2), ap, aptext="No match within your time limits, "\ "discarding this condition...")
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
results_final = search_results_intersect_with_a_hitlist(req, results_final, search_pattern(req, pl), fallback=1, fallbacktext="No match within your search limits, "\ "discarding this condition...")
results_final = intersect_results_with_hitset(req, results_final, search_pattern(req, pl, ap=0), ap, aptext="No match within your search limits, "\ "discarding this condition...")
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
results_final_for_all_colls = HitList()
results_final_for_all_colls = HitSet()
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
return results_final_for_all_colls.items()
return results_final_for_all_colls.items().tolist()
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg="10", sf="", so="d", sp="", of="hb", ot="", as="0", p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc="0", jrec="0", recid="-1", recidb="-1", sysno="", id="-1", idb="-1", sysnb="", action="SEARCH", d1y="", d1m="", d1...
print_warning(req, "This matching type cannot be used within <em>any field</em>. I will perform a word search instead." , "") print_warning(req, "If you want to phrase/substring/regexp search in a specific field, e.g. inside title, then please choose <em>within title</em> search option.", "")
print_warning(req, "This matching type cannot be used within <em>any field</em>. I will perform a word search instead." ) print_warning(req, "If you want to phrase/substring/regexp search in a specific field, e.g. inside title, then please choose <em>within title</em> search option.")
def create_opft_search_units(req, p, f, m=None): """Splits search pattern and search field into a list of independently searchable units. - A search unit consists of '(operand, pattern, field, type)' tuples where 'operand' is set union (|), set intersection (+) or set exclusion (-); 'pattern' is either a word (e.g. muo...
print_warning(req, "Searching for an exact match inside any field may be slow. You may want to search for words instead, or choose to search within specific field.", "")
print_warning(req, "Searching for an exact match inside any field may be slow. You may want to search for words instead, or choose to search within specific field.")
def create_opft_search_units(req, p, f, m=None): """Splits search pattern and search field into a list of independently searchable units. - A search unit consists of '(operand, pattern, field, type)' tuples where 'operand' is set union (|), set intersection (+) or set exclusion (-); 'pattern' is either a word (e.g. muo...
print_warning(req, "The partial phrase search does not work in any field. I'll do a boolean AND searching instead.", "")
print_warning(req, "The partial phrase search does not work in any field. I'll do a boolean AND searching instead.")
def create_opft_search_units(req, p, f, m=None): """Splits search pattern and search field into a list of independently searchable units. - A search unit consists of '(operand, pattern, field, type)' tuples where 'operand' is set union (|), set intersection (+) or set exclusion (-); 'pattern' is either a word (e.g. muo...
cell_3_moreright = """<input class="formbutton" type="submit" name="search" value="SEARCH"><input class="formbutton" type="submit" name="search" value="Browse">&nbsp;"""
cell_3_moreright = """<input class="formbutton" type="submit" name="action" value="SEARCH"><input class="formbutton" type="submit" name="action" value="Browse">&nbsp;"""
def create_search_box(cc, colls, p, f, rg, sf, so, sp, of, ot, as, p1, f1, m1, op1, p2, f2, m2, op2, p3, f3, m3, sc, d1y, d1m, d1d, d2y, d2m, d2d, action="SEARCH"): "Create search box for 'search again in the results page' functionality." out = "" # print search box prolog: out += """ <h1 class="headline">%s</h1> <form...
cell_1_right = """<input class="formbutton" type="submit" name="search" value="SEARCH"><input class="formbutton" type="submit" name="search" value="Browse">&nbsp;"""
cell_1_right = """<input class="formbutton" type="submit" name="action" value="SEARCH"><input class="formbutton" type="submit" name="action" value="Browse">&nbsp;"""
def create_search_box(cc, colls, p, f, rg, sf, so, sp, of, ot, as, p1, f1, m1, op1, p2, f2, m2, op2, p3, f3, m3, sc, d1y, d1m, d1d, d2y, d2m, d2d, action="SEARCH"): "Create search box for 'search again in the results page' functionality." out = "" # print search box prolog: out += """ <h1 class="headline">%s</h1> <form...
def create_footer(): "Creates CDS page footer." return cdspagefooter
def create_footer(): "Creates CDS page footer." return cdspagefooter
browsed_words = browse_in_bibxxx(p, f, rg) while not browsed_words:
browsed_phrases = get_nearest_terms_in_bibxxx(p, f, rg, 1) while not browsed_phrases:
def browse_pattern(req, colls, p, f, rg): """Browse either biliographic phrases or words indexes, and display it.""" ## do we search in words indexes? if not f: return browse_in_bibwords(req, p, f) ## prepare collection urlargument for later printing: p_orig = p urlarg_colls = "" for coll in colls: urlarg_colls += "&c=...
browsed_words = browse_in_bibxxx(p, f, rg)
browsed_phrases = get_nearest_terms_in_bibxxx(p, f, rg, 1)
def browse_pattern(req, colls, p, f, rg): """Browse either biliographic phrases or words indexes, and display it.""" ## do we search in words indexes? if not f: return browse_in_bibwords(req, p, f) ## prepare collection urlargument for later printing: p_orig = p urlarg_colls = "" for coll in colls: urlarg_colls += "&c=...
browsed_words_in_colls = [] for word,nbhits in browsed_words: word_hitlist = HitList() word_hitlists = search_pattern("", word, f, colls, 'e')
browsed_phrases_in_colls = [] for phrase in browsed_phrases: phrase_hitlist = HitList() phrase_hitlists = search_pattern("", phrase, f, colls, 'e')
def browse_pattern(req, colls, p, f, rg): """Browse either biliographic phrases or words indexes, and display it.""" ## do we search in words indexes? if not f: return browse_in_bibwords(req, p, f) ## prepare collection urlargument for later printing: p_orig = p urlarg_colls = "" for coll in colls: urlarg_colls += "&c=...