When I try to parse a file that has a tag called <seller_warranty> I get an error. I attach the log below.
import argparse
from typing import Optional
import yandex_market_language as yml
class YMLParser:
def __init__(self, file: str, count: Optional[int] = None):
self.feed = yml.parse(file)
self.data = self.feed.to_dict()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('file', help='.yml or .xml file to parse')
parser.add_argument('-c', '--count', type=int, help='minimum count of items to add them to separate file')
args = parser.parse_args()
if not args.file:
raise ValueError('You need to select file for parse')
yml_parser = YMLParser(args.file, args.count)
print(yml_parser.data)
<?xml version="1.0" encoding="windows-1251"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="2020-04-14 12:00">
<shop>
<name>...</name>
<company>...</company>
<url>...</url>
<categories>There is some <category> tags </categories>
<offers>
<offer>
// Some tags with information about offer
// Empty tag <seller_warranty>
<seller_warranty></seller_warranty>
</offer>
</offers>
</shop>
</yml_catalog>
Traceback (most recent call last):
File "C:/Users/god/PycharmProjects/yml_parser/app/main.py", line 24, in <module>
yml_parser = YMLParser(args.file, args.count)
File "C:/Users/god/PycharmProjects/yml_parser/app/main.py", line 10, in __init__
self.feed = yml.parse(file)
File "C:\Users\god\.virtualenvs\virtualenvs\yml-parser-GzhhnpNv-py3.8\lib\site-packages\yandex_market_language\yml.py", line 44, in parse
return YML(file_or_path).parse()
File "C:\Users\god\.virtualenvs\virtualenvs\yml-parser-GzhhnpNv-py3.8\lib\site-packages\yandex_market_language\yml.py", line 30, in parse
return Feed.from_xml(root)
File "C:\Users\god\.virtualenvs\virtualenvs\yml-parser-GzhhnpNv-py3.8\lib\site-packages\yandex_market_language\models\feed.py", line 44, in from_xml
shop = Shop.from_xml(el[0])
File "C:\Users\god\.virtualenvs\virtualenvs\yml-parser-GzhhnpNv-py3.8\lib\site-packages\yandex_market_language\models\shop.py", line 183, in from_xml
offer = models.ArbitraryOffer.from_xml(offer_el)
File "C:\Users\god\.virtualenvs\virtualenvs\yml-parser-GzhhnpNv-py3.8\lib\site-packages\yandex_market_language\models\offers.py", line 536, in from_xml
return ArbitraryOffer(**kwargs)
File "C:\Users\god\.virtualenvs\virtualenvs\yml-parser-GzhhnpNv-py3.8\lib\site-packages\yandex_market_language\models\offers.py", line 506, in __init__
super().__init__(vendor=vendor, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'seller_warranty'