Skip to content
Snippets Groups Projects
Commit 5322f0a5 authored by Saket Agrahari's avatar Saket Agrahari
Browse files

Flake 8 issue

parent c5470989
Branches
Tags
No related merge requests found
...@@ -10,15 +10,11 @@ API Endpoints ...@@ -10,15 +10,11 @@ API Endpoints
.. autofunction:: compendium_v2.routes.api.things .. autofunction:: compendium_v2.routes.api.things
""" """
import binascii
import hashlib
import random
import time
import os import os
import logging import logging
import json import json
from flask import Blueprint, jsonify from flask import Blueprint
from compendium_v2.routes import common from compendium_v2.routes import common
...@@ -37,7 +33,6 @@ file_name = open(DUMMY_DATA_FILENAME) ...@@ -37,7 +33,6 @@ file_name = open(DUMMY_DATA_FILENAME)
budget_matrix_response = json.loads(file_name.read()) budget_matrix_response = json.loads(file_name.read())
THING_LIST_SCHEMA = { THING_LIST_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#', '$schema': 'http://json-schema.org/draft-07/schema#',
...@@ -61,7 +56,6 @@ THING_LIST_SCHEMA = { ...@@ -61,7 +56,6 @@ THING_LIST_SCHEMA = {
'items': {'$ref': '#/definitions/thing'} 'items': {'$ref': '#/definitions/thing'}
} }
BUDGET_MATRIX_SCHEMA = { BUDGET_MATRIX_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#', '$schema': 'http://json-schema.org/draft-07/schema#',
'type': 'object', 'type': 'object',
...@@ -69,7 +63,7 @@ BUDGET_MATRIX_SCHEMA = { ...@@ -69,7 +63,7 @@ BUDGET_MATRIX_SCHEMA = {
'data': { 'data': {
'type': 'object', 'type': 'object',
'properties': { 'properties': {
'datasets': { 'datasets': {
'type': 'array', 'type': 'array',
'items': { 'items': {
'type': 'object', 'type': 'object',
...@@ -79,13 +73,13 @@ BUDGET_MATRIX_SCHEMA = { ...@@ -79,13 +73,13 @@ BUDGET_MATRIX_SCHEMA = {
}, },
'data': { 'data': {
'type': 'array', 'type': 'array',
"items": { 'items': {
"anyOf": [ 'anyOf': [
{ {
"type": "number" 'type': 'number'
}, },
{ {
"type": "null" 'type': 'null'
} }
] ]
}, },
...@@ -94,7 +88,7 @@ BUDGET_MATRIX_SCHEMA = { ...@@ -94,7 +88,7 @@ BUDGET_MATRIX_SCHEMA = {
'type': 'string' 'type': 'string'
} }
} }
} }
}, },
'labels': { 'labels': {
...@@ -128,9 +122,6 @@ def after_request(resp): ...@@ -128,9 +122,6 @@ def after_request(resp):
return common.after_request(resp) return common.after_request(resp)
@routes.route('/things', methods=['GET', 'POST']) @routes.route('/things', methods=['GET', 'POST'])
@common.require_accepts_json @common.require_accepts_json
def things(): def things():
...@@ -145,24 +136,3 @@ def things(): ...@@ -145,24 +136,3 @@ def things():
:return: :return:
""" """
return budget_matrix_response return budget_matrix_response
#
# def _hash(s, length):
# m = hashlib.sha256()
# m.update(s.encode('utf-8'))
# digest = binascii.b2a_hex(m.digest()).decode('utf-8')
# return digest[-length:].upper()
#
# def _make_thing(idx):
# six_months = 24 * 3600 * 180
# return {
# 'id': _hash(f'id-{idx}', 4),
# 'time': int(time.time() + random.randint(-six_months, six_months)),
# 'state': bool(idx % 2),
# 'data1': _hash(f'data1-{idx}', 2),
# 'data2': _hash(f'data2-{idx}', 8),
# 'data3': _hash(f'data3-{idx}', 32)
# }
#
# response = map(_make_thing, range(20))
# return jsonify(list(response))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment