def sitemap_delete(sitemap, domain=None):
    """ Delete a sitemap.
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)
    sitemap, sitemapid = _get_sitemap(sitemap, domain)

    try:
        entry = client.DeleteSitemap(domain, sitemap)
        status.error = False
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']
def sitemap_delete(sitemap, domain=None):
    """ Delete a sitemap.
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)
    sitemap, sitemapid = _get_sitemap(sitemap, domain)

    try:
        entry = client.DeleteSitemap(domain, sitemap)
        status.error = False
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']
def sitemap_add(sitemap, sitemap_type, domain=None):
    """ Add a sitemap to a domain. sitemap_type must be one of the API supported type
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)
    sitemap, sitemapid = _get_sitemap(sitemap, domain)

    try:
        entry = client.AddSitemap(domain, sitemap, sitemap_type)
        status.error = False
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']
def sitemap_add(sitemap, sitemap_type, domain=None):
    """ Add a sitemap to a domain. sitemap_type must be one of the API supported type
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)
    sitemap, sitemapid = _get_sitemap(sitemap, domain)

    try:
        entry = client.AddSitemap(domain, sitemap, sitemap_type)
        status.error = False
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']
def sitemap_stats(sitemap, domain=None):
    """ Extracts sitemap statistic from API
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)
    sitemap, sitemapid = _get_sitemap(sitemap, domain)

    def pretty(status):
        return _sitemap_pretty_print(status.entry)

    try:
        url = SITEMAP_FEED % {"siteid":siteid, "sitemapid":sitemapid}
        entry = client.Get(url)
        g = atom.CreateClassFromXMLString(SitemapsEntry, str(entry))
        status.error = False
        status.entry = g
        status.pretty_print = pretty
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']
def sitemap_stats(sitemap, domain=None):
    """ Extracts sitemap statistic from API
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)
    sitemap, sitemapid = _get_sitemap(sitemap, domain)

    def pretty(status):
        return _sitemap_pretty_print(status.entry)

    try:
        url = SITEMAP_FEED % {"siteid": siteid, "sitemapid": sitemapid}
        entry = client.Get(url)
        g = atom.CreateClassFromXMLString(SitemapsEntry, str(entry))
        status.error = False
        status.entry = g
        status.pretty_print = pretty
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']
def sitemap_list(domain=None):
    """ List sitemaps registered for the domain
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)

    def pretty(status):
        text = ""
        text += "%s sitemaps\n" % len(status.entry.entry)
        text += "Last updated %s\n" % status.entry.updated.text
        for map in status.entry.entry:
            text += _sitemap_pretty_print(map)
        return text

    try:
        entry = client.GetSitemapsFeed(domain)
        status.error = False
        status.entry = entry
        status.pretty_print = pretty
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']
def keywords_list(domain=None):
    """ Lists keywords as reported by the API.
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)

    def pretty(status):
        text = u"\n".join(status.entry)
        return text

    try:
        url = KEYWORDS_FEED % {"siteid":siteid}
        entry = client.Get(url)
        keywords = []
        for k in entry.FindExtensions():
            keywords.append(unicode(k.text))
        status.error = False
        status.entry = keywords
        status.pretty_print = pretty
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']
def sitemap_list(domain=None):
    """ List sitemaps registered for the domain
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)

    def pretty(status):
        text = ""
        text += "%s sitemaps\n" % len(status.entry.entry)
        text += "Last updated %s\n" % status.entry.updated.text
        for map in status.entry.entry:
            text += _sitemap_pretty_print(map)
        return text

    try:
        entry = client.GetSitemapsFeed(domain)
        status.error = False
        status.entry = entry
        status.pretty_print = pretty
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']
def keywords_list(domain=None):
    """ Lists keywords as reported by the API.
    """
    domain, siteid = _get_domain(domain)
    client = get_client()
    status = StatusObject(domain)

    def pretty(status):
        text = u"\n".join(status.entry)
        return text

    try:
        url = KEYWORDS_FEED % {"siteid": siteid}
        entry = client.Get(url)
        keywords = []
        for k in entry.FindExtensions():
            keywords.append(unicode(k.text))
        status.error = False
        status.entry = keywords
        status.pretty_print = pretty
    except gdata.service.RequestError, e:
        status.error_message = e.message['body']