Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: xml report iteration failure #301

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions bingads/v13/internal/reporting/xml_report.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import codecs
import xml.etree.cElementTree as et
import re
from collections.abc import Iterator
from typing import Protocol

from bingads.v13.internal.extensions import *
from bingads.v13.reporting.report_contract import *

'''
Implement with context.next.xml.etree.cElementTree is far more faster than xml.etree.ElementTree with python 2.7.10
'''


class _XmlIterator(Iterator, Protocol):
"""
Protocol for the XML iterator from ElementTree.
"""
def __next__(self):
...

schema=''
class _XmlReportRecord:
def __init__(self, row):
Expand All @@ -29,7 +38,8 @@ def double_value(self, header):

class _XmlReportIterator():

def __init__(self, context, header):

def __init__(self, context: _XmlIterator, header):
self._context = context
self._header = header
self._row_pattern = schema + 'Row'
Expand Down Expand Up @@ -71,10 +81,10 @@ def next(self):

class _XmlReportHeader:

def __init__(self, context):
def __init__(self, context: _XmlIterator):
self._report_columns = []
if context is not None:
event, root = context.next()
event, root = context.__next__()
if event == 'start':
m = re.compile(r'^(.*)Report').match(root.tag)
if not m:
Expand Down