From 6dd4161339c2486f79cf4761b8ce7ad3b6c53719 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 17 Aug 2015 12:47:54 -0400 Subject: [PATCH] fix some linting errors mostly variable/function names and spacing --- test.py | 60 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/test.py b/test.py index b2d1d81..5f61fd8 100644 --- a/test.py +++ b/test.py @@ -6,14 +6,14 @@ from flask import Flask, render_template app = Flask(__name__) data = [] -attributes= ["title", - "authors", - "isbn"] +attributes = ["title", + "authors", + "isbn"] fields = {} @app.route("/r") -def updateData(): +def update_data(): global data out = [] @@ -31,40 +31,40 @@ def updateData(): name = field.attrib["name"] fields[name] = field.attrib - for book in collection.iter(ns + "entry"): + for entry in collection.iter(ns + "entry"): bookout = {} - for dName in fields.keys(): - datum = book.find(ns + dName) + for datum_name in fields.keys(): + datum = entry.find(ns + datum_name) if datum != None: - t = int(fields[dName]["type"]) + datum_type = int(fields[datum_name]["type"]) #simple text, paragraph, multiple choice, image - if t == 1 or t == 2 or t == 3 or t == 10: + if datum_type == 1 or datum_type == 2 or datum_type == 3 or datum_type == 10: #check if multiple entries are allowed #if so, put entries in a list - if (int(fields[dName]["flags"]) & 0x01 & 0xff) != 0: - bookout[dName] = [] + if (int(fields[datum_name]["flags"]) & 0x01 & 0xff) != 0: + bookout[datum_name] = [] for sub in datum: - bookout[dName].append(sub.text) + bookout[datum_name].append(sub.text) else: - bookout[dName] = datum.text + bookout[datum_name] = datum.text #date - elif t == 12: - bookout[dName] = "" + elif datum_type == 12: + bookout[datum_name] = "" if datum.find(ns + "year") != None: - bookout[dName] += datum.find(ns + "year").text + bookout[datum_name] += datum.find(ns + "year").text if datum.find(ns + "month") != None: - bookout[dName] += "-" + datum.find(ns + "month").text + bookout[datum_name] += "-" + datum.find(ns + "month").text if datum.find(ns + "day") != None: - bookout[dName] += "-" + datum.find(ns + "day").text + bookout[datum_name] += "-" + datum.find(ns + "day").text - elif t == 6: #Number - bookout[dName] = datum.text + elif datum_type == 6: #Number + bookout[datum_name] = datum.text else: - print("Did not parse:" + dName + ", type:" + str(t)) - bookout[dName] = "" + print("Did not parse:" + datum_name + ", type:" + str(datum_type)) + bookout[datum_name] = "" else: - bookout[dName] = "" + bookout[datum_name] = "" out.append(bookout.copy()) data = out.copy() return "success" @@ -72,15 +72,15 @@ def updateData(): @app.route("/") def main(): if data == []: - updateData() - return render_template("main.html", books = data, attributes = attributes) + update_data() + return render_template("main.html", books=data, attributes=attributes) -@app.route("/book/") -def book(id): +@app.route("/book/") +def book(id_num): if data == []: - updateData() - book = next((item for item in data if int(item["id"]) == id), {}) - return render_template("book.html", book = book, fields = fields) + update_data() + entry = next((item for item in data if int(item["id"]) == id_num), {}) + return render_template("book.html", book=entry, fields=fields) if __name__ == "__main__": app.run(debug=True, host='0.0.0.0')