# Path: src/zeit/api/util.py
# def iri_to_uri(iri):
#     """Convert an Internationalized Resource Identifier to a URI."""
# 
#     parts = urlparse.urlparse(iri)
#     return urlparse.urlunparse(
#         part.encode('idna') if parti == 1 else
#             url_encode_non_ascii(part.encode('utf-8'))
#         for parti, part in enumerate(parts)
#     )
# 
# def save_xpath(element, xpath, fallback=''):
#     """Safely return the first result of an xpath expression."""
# 
#     try:
#         return element.xpath(xpath)[0]
#     except IndexError:
#         return fallback


import urllib
from flask import g, current_app
from lxml import etree
from .util import iri_to_uri, save_xpath
# -*- coding: utf-8 -*-
"""
    zeit.api.metadata
    ~~~~~~~~~~~~~~~~~

    This module contains methods that maintain metadata entities by parsing XML
    files and updating the API's SQLite database.

    Copyright: (c) 2013 by ZEIT ONLINE.
    License: BSD, see LICENSE.md for more details.
"""





def __update_product(product):
    """Update the given product entity."""

# Path: src/zeit/api/util.py
# def iri_to_uri(iri):
#     """Convert an Internationalized Resource Identifier to a URI."""
# 
#     parts = urlparse.urlparse(iri)
#     return urlparse.urlunparse(
#         part.encode('idna') if parti == 1 else
#             url_encode_non_ascii(part.encode('utf-8'))
#         for parti, part in enumerate(parts)
#     )
# 
# def save_xpath(element, xpath, fallback=''):
#     """Safely return the first result of an xpath expression."""
# 
#     try:
#         return element.xpath(xpath)[0]
#     except IndexError:
#         return fallback


# Path: src/zeit/api/metadata.py
import urllib
from flask import g, current_app
from lxml import etree
from .util import iri_to_uri, save_xpath

# -*- coding: utf-8 -*-
"""
    zeit.api.metadata
    ~~~~~~~~~~~~~~~~~

    This module contains methods that maintain metadata entities by parsing XML
    files and updating the API's SQLite database.

    Copyright: (c) 2013 by ZEIT ONLINE.
    License: BSD, see LICENSE.md for more details.
"""





def __update_product(product):
    """Update the given product entity."""

    product_id = save_xpath(product, './@id').lower()