diff options
author | Andi_G <andigros72@googlemail.com> | 2011-03-13 15:30:40 (GMT) |
---|---|---|
committer | Andi_G <andigros72@googlemail.com> | 2011-03-13 15:30:40 (GMT) |
commit | b0b980e500f5707757d5b29233deb93004e117d8 (patch) | |
tree | 6bdbbaac3d639589e743e1a14c6092b9885ac85e | |
parent | e553b5acf198b8203aa462722d6c6f30483b462b (diff) |
updated URL querying
-rw-r--r-- | readdb.py | 35 |
1 files changed, 21 insertions, 14 deletions
@@ -284,13 +284,10 @@ class AnnotationManager: #send annotation to server -> get url back, store url in body-url #update annotation body url in local db - #url of the book? - #alter getBooks activity to add url to downloaded books' journal entry - #GetIABooksActivity.py self._bodysvg = self.assembleSVG(self._annotitle, self._content) #check the last id from the database store - row = self._conn.execute('select id from annotations where md5=? order by id desc limit 1', [self._filehash]) + row = self._conn.execute('select id from annotations order by id desc limit 1') aid = 0 r = row.fetchone() if r != None: @@ -300,16 +297,15 @@ class AnnotationManager: annotation = AnnoBookmark(t) self._rdf = self.create_rdf_representation(annotation) - #conn.execute("CREATE TABLE annotations (id INTEGER PRIMARY KEY, md5, page, title, content, bodyurl, context, created, modified, creator, annotates, rdf, color, local, mimetype, uuid)") t = (aid, self._filehash, page, self._annotitle, self._content, self._bodyurl, self._context, self._created, self._modified, self._creator, self._annotates, self._rdf, self._color, self._local, self._mimetype, annotation.get_uuid(), None, self._bodysvg) self._conn.execute('insert into annotations values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', t) self._conn.commit() self._resync_annotation_cache() self.current_annotation = self._annotations[-1] - #self.sync_annotations() + def edit_annotation(self, page, content, annotation_id, local=1): # local = 0 means that this is a bookmark originally @@ -329,8 +325,7 @@ class AnnotationManager: self.update_annotation_db_record(a) break - #self.sync_annotations() - + def del_annotation(self, annotation_id): @@ -357,7 +352,7 @@ class AnnotationManager: self._annotations.append(AnnoBookmark(row)) _logger.debug('picked %s', self._annotations[-1].get_note_body()) _logger.debug('row content %s', row[4]) - #self.sync_annotations() + @@ -389,10 +384,11 @@ class AnnotationManager: else: pages[a.page] = [a.id] - _logger.debug('id_ann_map: %s' % str(id_ann_map)) return pages, id_ann_map + + def get_prev_annotation(self, page): pages, id_ann_map = self.get_pages_and_id_to_ann_map() pages_with_annotations = sorted(pages.keys()) @@ -415,6 +411,8 @@ class AnnotationManager: return None + + def get_next_annotation(self, page): pages, id_ann_map = self.get_pages_and_id_to_ann_map() pages_with_annotations = sorted(pages.keys()) @@ -481,6 +479,7 @@ class AnnotationManager: return '' + def get_node_attribute(self, domnode, attributestr): if ( domnode != None ) and ( attributestr in domnode.attributes.keys() ): return domnode.attributes[attributestr].value @@ -488,6 +487,7 @@ class AnnotationManager: + def parse_annotations(self, rdf): remote_annotations = [] _logger.debug("parse_annotations: The RDF: %s", rdf) @@ -605,16 +605,23 @@ class AnnotationManager: def get_etext_url(self): + url_re = re.compile('Link:\s+(http.*)') count = 0 (results,count) = datastore.find({'mime_type' : ['application/epub+zip', 'application/pdf', mime.GENERIC_TYPE_TEXT]}, ['mime_type', 'checksum', 'description']) if count > 0: for r in results: m = r.get_metadata() if m['checksum'] == self._filehash: - if len(m['description']) > 0: - url = m['description'].lstrip('From: ') - self._annotates = url - _logger.debug('found url %s - self._annotates' % self._annotates) + url = m['url'] + if len(url) == 0: + if len(m['description']) > 0: + t = url_re.search(m['description']) + if t: + url = t.groups()[0].strip() + + self._annotates = url + _logger.debug('found url %s - self._annotates' % self._annotates) + |