def _add_item(x_items, action, item_type, key='NONE', text=None, priority=600, sequence=0, url=None, body=None, **kwargs): item = qxml.add_child(x_items, 'item') item.setAttribute('action', str(action)) item.setAttribute('is_incremental', 'false') item.setAttribute('key', str(key)) item.setAttribute('priority', str(priority)) item.setAttribute('sequence', str(sequence)) item.setAttribute('type', str(item_type)) if url: item.setAttribute('url', url) if body: qxml.set_text(item, body) else: for k, v in kwargs.items(): qxml.add_child(item, k, str(v)) return item
def _add_item(x_items, action, item_type, key = 'NONE', text = None, priority = 600, sequence = 0, url = None, body = None, **kwargs): item = qxml.add_child(x_items, 'item') item.setAttribute('action', str(action)) item.setAttribute('is_incremental', 'false') item.setAttribute('key', str(key)) item.setAttribute('priority', str(priority)) item.setAttribute('sequence', str(sequence)) item.setAttribute('type', str(item_type)) if url: item.setAttribute('url', url) if body: qxml.set_text(item, body) else: for k, v in kwargs.items(): qxml.add_child(item, k, str(v)) return item
def _add_item(x_items, action, item_type, key = 'NONE', text = None, priority = 600, url = None, forced = False): item = qxml.add_child(x_items, 'item') item.setAttribute('action', str(action)) item.setAttribute('is_incremental', 'false') item.setAttribute('key', str(key)) item.setAttribute('priority', str(priority)) item.setAttribute('sequence', '0') item.setAttribute('type', str(item_type)) if url: item.setAttribute('url', url) if text: if forced: qxml.add_child(item, 'title', text) qxml.add_child(item, 'forced', 'true') else: qxml.set_text(item, text) return item
def _slim_book_node(doc, asin, cde_content_type): """builds a xml node from book info to be added to the removal_list node""" book_node = doc.createElement('meta_data') qxml.add_child(book_node, 'ASIN', asin) qxml.add_child(book_node, 'cde_contenttype', cde_content_type) return book_node
def _book_node(doc, book): """builds a xml node from book info to be added to the add_update_list node""" book_node = doc.createElement('meta_data') # we keep the same tag order as in Amazon's proper responses qxml.add_child(book_node, 'ASIN', book.asin) qxml.add_child(book_node, 'title', book.title) authors_node = qxml.add_child(book_node, 'authors') for author in book.authors: qxml.add_child(authors_node, 'author', author) publishers_node = qxml.add_child(book_node, 'publishers') for publisher in book.publishers: qxml.add_child(publishers_node, 'publisher', publisher) qxml.add_child(book_node, 'publication_date', date_iso(book.last_modified)) qxml.add_child(book_node, 'cde_contenttype', book.cde_content_type) qxml.add_child(book_node, 'content_type', book.content_type) if book.languages: qxml.add_child(book_node, 'content_language', book.languages[0]) return book_node