stefanitsky / yandex_market_language Goto Github PK
View Code? Open in Web Editor NEWYandex Market Language for Python provides user-friendly interface for parsing or creating XML files
License: MIT License
Yandex Market Language for Python provides user-friendly interface for parsing or creating XML files
License: MIT License
I tried to process a 100 MB file and the processing machine exceeded the memory limit (~2 gb). Is there any way to optimize file reading or processing so that it doesn't go out of memory?
When parsing the price list, I get an exception. The price list is generated by the official Yandex module for Bitrix. As you can see, the timezone is used in the price list.
Run command
feed = parse(file_path)
I get an exception
yandex_market_language.exceptions.ValidationError: time data '2021-08-05T02:13:01+00:00' does not match format '%Y-%m-%d %H:%M'
Need to replace Travis CI with Github actions.
When I try to parse a file that has a tag called <seller_warranty> I get an error. I attach the log below.
Code
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)
File template
<?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>
Log error
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.