Example #1
0
    def _parse_logs_json(self, logs, returnTotalPages=False):
        try:
            r = json.loads(logs)
        except Exception:
            logger.exception('Could not json-parse logs!')
        if not 'status' in r or r['status'] != 'success':
            logger.error('Could not read logs, status is "%s"' % r['status'])
        data = r['data']

        output = []
        for l in data:
            tpe = l['LogTypeImage'].replace('.gif', '').replace('icon_', '')
            date = l['Visited']
            finder = "%s (found %s)" % (l['UserName'], l['GeocacheFindCount'])
            text = HTMLManipulations._decode_htmlentities(HTMLManipulations._strip_html(HTMLManipulations._replace_br(l['LogText'])))
            output.append(dict(type=tpe, date=date, finder=finder, text=text))
        logger.debug("Read %d log entries" % len(output))

        if returnTotalPages is True:
            pageinfo = r['pageInfo']
            total_page = pageinfo['totalPages']
            #print "total pages", total_page
            return output,total_page
        

        return output
 def do_rot(widget):
     try:
         text = HTMLManipulations._rot13(unicode(source.get_buffer().get_text(source.get_buffer().get_start_iter(), source.get_buffer().get_end_iter())))
     except Exception:
         text = ''
         
     destination.get_buffer().set_text(text)
 def do_rot(widget):
     import cachedownloader
     try:
         text = HTMLManipulations._rot13(source.get_buffer().get_text(source.get_buffer().get_start_iter(), source.get_buffer().get_end_iter()))
     except Exception:
         text = ''
         
     destination.get_buffer().set_text(text)
Example #4
0
        def do_rot(widget):
            try:
                text = HTMLManipulations._rot13(
                    unicode(source.get_buffer().get_text(
                        source.get_buffer().get_start_iter(),
                        source.get_buffer().get_end_iter())))
            except Exception:
                text = ''

            destination.get_buffer().set_text(text)
Example #5
0
 def _handle_hints(self, hints, encrypted = True):
     hints = HTMLManipulations._strip_html(HTMLManipulations._replace_br(hints)).strip()
     if encrypted:
         hints = HTMLManipulations._rot13(hints)
         hints = re.sub(r'\[([^\]]+)\]', lambda match: HTMLManipulations._rot13(match.group(0)), hints)
     return hints
Example #6
0
    def _parse_logs_json(self, logs, returnTotalPages=False):
        try:
            r = json.loads(logs)
        except Exception, e:
            logger.exception('Could not json-parse logs!')
            raise e
        if not 'status' in r or r['status'] != 'success':
            logger.error('Could not read logs, status is "%s"' % r['status'])
        data = r['data']

        output = []
        for l in data:
            tpe = l['LogTypeImage'].replace('.gif', '').replace('icon_', '')
            date = l['Visited']
            finder = "%s (found %s)" % (l['UserName'], l['GeocacheFindCount'])
            text = HTMLManipulations._decode_htmlentities(HTMLManipulations._strip_html(HTMLManipulations._replace_br(l['LogText'])))
            output.append(dict(type=tpe, date=date, finder=finder, text=text))
        logger.debug("Read %d log entries" % len(output))

        if returnTotalPages:
            pageinfo = r['pageInfo']
            total_page = pageinfo['totalPages']
            return output,total_page
        
        return output

BACKENDS = {
    'geocaching-com-new': {'class': GeocachingComCacheDownloader, 'name': 'geocaching.com', 'description': 'Backend for geocaching.com'},
    }

def get(name, *args, **kwargs):
Example #7
0
 def _stripped_shortdesc(self):
     from utils import HTMLManipulations
     return HTMLManipulations.strip_html_visual(self._geocache.shortdesc)
 def _handle_hints(self, hints, encrypted = True):
     hints = HTMLManipulations._strip_html(HTMLManipulations._replace_br(hints)).strip()
     if encrypted:
        elif sizestring == 'regular':
            size = 3
        elif sizestring == 'large' or sizestring == 'big':
            size = 4
        else:   
            size = 5
        return size
        
    # Convert stars3_5 to 35, stars4 to 4 (and so on, basename of image of star rating)
    def _handle_stars(self, stars):
        return int(stars[5])*10 + (int(stars[7]) if len(stars) > 6 else 0)
        
    def _handle_hints(self, hints, encrypted = True):
        hints = HTMLManipulations._strip_html(HTMLManipulations._replace_br(hints)).strip()
        if encrypted:
            hints = HTMLManipulations._rot13(hints)
            hints = re.sub(r'\[([^\]]+)\]', lambda match: HTMLManipulations._rot13(match.group(0)), hints)
        return hints
        
    def _parse_logs_json(self, logs):
        logger.debug("Start json logs parsing")
        try:
            r = json.loads(logs)
        except Exception, e:
            logger.exception('Could not json-parse logs!')
            raise e
        if not 'status' in r or r['status'] != 'success':
            logger.error('Could not read logs, status is "%s"' % r['status'])
        data = r['data']

        output = []