def playback(): web.load() reader = LogReader(RsyncLogFile("wiki-beta::pharos/log", "log")) # skip the log till the latest entry in the database timestamp = web.query( 'SELECT last_modified FROM thing ORDER BY last_modified DESC LIMIT 1' )[0].last_modified reader.skip_till(timestamp) playback = LogPlayback(Infobase()) while True: for entry in reader: print reader.logfile.tell(), entry.timestamp playback.playback(entry) time.sleep(60)
) append(thing_id, key, _value, datatype, i) else: _value, datatype = self.prepare_datum( value, result, "%s/%s" % (path, key) ) if key == 'key': datatype = 1 append(thing_id, key, _value, datatype, None) return (thing_id, DATATYPE_REFERENCE) elif isinstance(query, string_types): return (query, TYPES['/type/string']) elif isinstance(query, int): return (query, TYPES['/type/int']) elif isinstance(query, float): return (query, TYPES['/type/float']) elif isinstance(query, bool): return (int(query), TYPES['/type/boolean']) else: raise Exception('%s: invalid value: %s' % (path, repr(query))) if __name__ == "__main__": web.config.db_parameters = dict( dbn='postgres', host='pharosdb', db='infobase_data2', user='******', pw='' ) web.config.db_printing = True web.load() site = Infobase().get_site('infogami.org') BulkUpload(site)
#!/usr/bin/python from __future__ import print_function import web, re, sys, codecs sys.stdout = codecs.getwriter('utf-8')(sys.stdout) web.load() from infogami.infobase.infobase import Infobase import infogami.infobase.writequery as writequery site = Infobase().get_site('openlibrary.org') re_marc_name = re.compile('^(.*), (.*)$') re_end_dot = re.compile('[^ ][^ ]\.$', re.UNICODE) re_odd_dot = re.compile('[^ ][^ ]\. ', re.UNICODE) re_initial_then_dot = re.compile(r'\b[A-Z]\.') def find_by_statements(author_key): q = { 'authors': author_key, 'type': '/type/edition', } by = [] for key in site.things(q): try: by.append(site.withKey(key).by_statement.value) except AttributeError: pass return by