Beispiel #1
0
def _last_read(book, exclude_device = None):
	lr_list = []
	for lr in annotations.list_last_read(book.asin):
		if lr.device == exclude_device:
			continue
		device = devices.get(lr.device)
		lr_list.append(_LAST_READ % (lr.timestamp * 1000, 'US', device_lto(device), lr.pos, lr.device))
	xml = '<?xml version="1.0" encoding="UTF-8"?><book>' + ''.join(lr_list) + '</book>'
	return DummyResponse(headers = { 'Content-Type': 'text/xml;charset=UTF-8' }, data = bytes(xml, 'UTF-8'))
Beispiel #2
0
def _update_annotations(device, x_items):
	was_updated = False

	for lr in annotations.get_last_read_updates(device):
		source_device = devices.get(lr.device)
		source_device_alias = (source_device.alias or source_device.serial) if source_device else lr.device
		_add_item(x_items, 'UPD_LPRD', 'EBOK', key = lr.asin, priority = 1100, sequence = lr.pos,
				source_device = source_device_alias, lto = device_lto(source_device), annotation_time_utc = lr.timestamp)
		was_updated = True

	for asin in annotations.get_annotation_updates(device):
		_add_item(x_items, 'UPD_ANOT', 'EBOK', key = asin, priority = 1100)
		was_updated = True

	return was_updated
Beispiel #3
0
def _last_read(book, exclude_device = None):
	lr_list = []
	for lr in annotations.list_last_read(book.asin):
		if lr.device == exclude_device:
			continue
		device = devices.get(lr.device)
		alias = device.alias if device else lr.device
		alias = lr.device if alias is None \
					else alias.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace('\'', '&apos;')
		lr_list.append(_LAST_READ % (lr.timestamp * 1000, device_lto(device), lr.pos, alias))
	if lr_list:
		xml = '<?xml version="1.0" encoding="UTF-8"?><book>' + ''.join(lr_list) + '</book>'
	else:
		xml = '<?xml version="1.0" encoding="UTF-8"?><book/>'
	return DummyResponse(headers = { 'Content-Type': 'text/xml;charset=UTF-8' }, data = bytes(xml, 'UTF-8'))
Beispiel #4
0
def _last_read(book, exclude_device=None):
    lr_list = []
    for lr in annotations.list_last_read(book.asin):
        if lr.device == exclude_device:
            continue
        device = devices.get(lr.device)
        alias = device.alias if device else lr.device
        alias = lr.device if alias is None \
           else alias.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace('\'', '&apos;')
        lr_list.append(
            _LAST_READ %
            (lr.timestamp * 1000, device_lto(device), lr.pos, alias))
    if lr_list:
        xml = '<?xml version="1.0" encoding="UTF-8"?><book>' + ''.join(
            lr_list) + '</book>'
    else:
        xml = '<?xml version="1.0" encoding="UTF-8"?><book/>'
    return DummyResponse(headers={'Content-Type': 'text/xml;charset=UTF-8'},
                         data=bytes(xml, 'UTF-8'))
Beispiel #5
0
def _update_annotations(device, x_items):
    was_updated = False

    for lr in annotations.get_last_read_updates(device):
        source_device = devices.get(lr.device)
        source_device_alias = (source_device.alias or source_device.serial
                               ) if source_device else lr.device
        _add_item(x_items,
                  'UPD_LPRD',
                  'EBOK',
                  key=lr.asin,
                  priority=1100,
                  sequence=lr.pos,
                  source_device=source_device_alias,
                  lto=device_lto(source_device),
                  annotation_time_utc=lr.timestamp)
        was_updated = True

    for asin in annotations.get_annotation_updates(device):
        _add_item(x_items, 'UPD_ANOT', 'EBOK', key=asin, priority=1100)
        was_updated = True

    return was_updated