Skip to content

Commit

Permalink
#PRS-26 Fixes parser for otto_ru [Finishes clothes_html_parsers #1155…
Browse files Browse the repository at this point in the history
…12203]
  • Loading branch information
muhtar05 committed Mar 29, 2016
1 parent 108c2fe commit 7cb0507
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions clothes_html_parsers/otto_ru/parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import sys
import traceback
import json
import re
from codecs import getwriter
Expand Down Expand Up @@ -69,11 +70,8 @@ def parse_html(self, data):
if item_list:
row[url]["item_list"] = item_list

try:
self.check_validate_schema(row)
self.rows_data.append(row)
except Exception as e:
print e.message
self.check_validate_schema(row)
self.rows_data.append(row)

def check_validate_schema(self, node):
f = open('clothes.schema.json', 'r')
Expand All @@ -87,14 +85,13 @@ def close_parser(self):
def main():
parser = Parser()
for line in sys.stdin:
data = json.loads(line)
try:
data = json.loads(line)
try:
parser.parse_html(data)
except Exception as e:
print str(e)
parser.parse_html(data)
except Exception as e:
print str(e)
sys.stderr.write(
json.dumps({"url": data["url"], "traceback": traceback.format_exc()}, ensure_ascii=False).encode(
"utf-8") + "\n")

parser.close_parser()

Expand Down

0 comments on commit 7cb0507

Please sign in to comment.