Giter Site home page Giter Site logo

cst-tools's Introduction

cst-tools's People

Contributors

akdh avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

cst-tools's Issues

Suggestions not rendered

Hi,
it's not possible to render the suggestions with the current version of the "render.py" script. Following code contains the necessary fixes. All fixes are commented.

import pystache, csv, json, sqlite3, sys

if len(sys.argv) != 2:
    print('usage: %s SUGGESTIONS')
    exit()

suggestions_filename = sys.argv[1]

with open('tags.csv') as f:
    reader = csv.reader(f)
    tags = [row[1].decode('utf-8') for row in reader] # Fix: The "pystache" module requires input in Unicode, but the "csv" module returns strings.

with open(suggestions_filename) as f:
    data = json.loads(f.read())

conn = sqlite3.connect('docs.db')
conn.row_factory = sqlite3.Row
cur = conn.cursor()

rows = []
for index in range(len(data['suggestions'])):
    id = data['suggestions'][index]
    cur.execute('select id, title, url, description from docs where id = ?', (id, ))
    row = dict(cur.fetchone())
    row['index'] = index
    rows.append(row) # Fix: Typo.

conn.close()

with open('templates/suggestions.html') as f:
    print (pystache.render(f.read(), {'tags': tags, 'raw_tags': json.dumps(tags), 'documents': rows})).encode('utf-8') # Fix: Necessary if you want to use shell redirection.

I'm using Python 2.7.9.

Database error

After modifying the suggestion file to satisfy the format which this tool is expecting, I receive this error:

Traceback (most recent call last):
File "render.py", line 26, in
cur.execute('select id, title, url, description from docs where id = ?', (id, ))
sqlite3.OperationalError: no such table: docs

(The line number is different because I added some sample codes to resolve the issue myself)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.