# Path: geetools/tools/string.py
# def eq(string, to_compare):
# def format(string, replacement):
#     def addFormat(st):
#         def true():
#         def false():
#     def formatValues(k, val):
#         def true(v):
#         def false(v):
#     def wrap(kv, ini):
# def _zip(l1, l2):
#     def wrap(el):
# def mix(strings):
#     def wrap(eelist, aggregate):


import pandas as pd
import ee
import threading
from copy import deepcopy
from .tools import string
    from collections import namedtuple
    else:
        return ee.Image.constant(value)


def makeName(img, pattern, date_pattern=None, extra=None):
    """ Make a name with the given pattern. The pattern must contain the
    propeties to replace between curly braces. There are 2 special words:

    * 'system_date': replace with the date of the image formatted with
      `date_pattern`, which defaults to 'yyyyMMdd'
    * 'id' or 'ID': the image id. If None, it'll be replaced with 'id'

    Pattern example (supposing each image has a property called `city`):
    'image from {city} on {system_date}'

    You can add extra parameters using keyword `extra`
    """
    img = ee.Image(img)
    props = img.toDictionary()
    props = ee.Dictionary(ee.Algorithms.If(
        img.id(),
        props.set('id', img.id()).set('ID', img.id()),
        props))
    props = ee.Dictionary(ee.Algorithms.If(
        img.propertyNames().contains('system:time_start'),
        props.set('system_date', img.date().format(date_pattern)),
        props))
    if extra:
        extra = ee.Dictionary(extra)
        props = props.combine(extra)

# Path: geetools/tools/string.py
# def eq(string, to_compare):
# def format(string, replacement):
#     def addFormat(st):
#         def true():
#         def false():
#     def formatValues(k, val):
#         def true(v):
#         def false(v):
#     def wrap(kv, ini):
# def _zip(l1, l2):
#     def wrap(el):
# def mix(strings):
#     def wrap(eelist, aggregate):


# Path: geetools/utils.py
import pandas as pd
import ee
import threading
from copy import deepcopy
from .tools import string
    from collections import namedtuple

    else:
        return ee.Image.constant(value)


def makeName(img, pattern, date_pattern=None, extra=None):
    """ Make a name with the given pattern. The pattern must contain the
    propeties to replace between curly braces. There are 2 special words:

    * 'system_date': replace with the date of the image formatted with
      `date_pattern`, which defaults to 'yyyyMMdd'
    * 'id' or 'ID': the image id. If None, it'll be replaced with 'id'

    Pattern example (supposing each image has a property called `city`):
    'image from {city} on {system_date}'

    You can add extra parameters using keyword `extra`
    """
    img = ee.Image(img)
    props = img.toDictionary()
    props = ee.Dictionary(ee.Algorithms.If(
        img.id(),
        props.set('id', img.id()).set('ID', img.id()),
        props))
    props = ee.Dictionary(ee.Algorithms.If(
        img.propertyNames().contains('system:time_start'),
        props.set('system_date', img.date().format(date_pattern)),
        props))
    if extra:
        extra = ee.Dictionary(extra)
        props = props.combine(extra)

    name = string.format(pattern, props)