from uuid import uuid4

__test_missile = """\
POST /advq/search HTTP/1.1\r
Connection: close\r
Host: ust1-1.advq.yandex.ru\r
Content-length: 163\r
\r
ph_page_size=50&ph_page=0&words=%22%21%D1%81%D0%BA%D0%B0%D1%87%D0%B0%D1%82%D1%8C+%21pelingator+%211.07+%21%D0%B1%D0%B5%D1%81%D0%BF%D0%BB%D0%B0%D1%82%D0%BD%D0%BE%22
"""


def __mark_by_uri(missile):
    return '_'.join(missile.split('\n', 1)[0].split(' ', 2)[1].split('/'))


__markers = {
    'uniq': lambda m: uuid4().hex,
    'uri': __mark_by_uri,
}


def get_marker(marker_type):
    '''
    Returns a marker function of the requested marker_type

    >>> marker = get_marker('uniq')(__test_missile)
    >>> type(marker)
    <type 'str'>
    >>> len(marker)
    32

    >>> get_marker('uri')(__test_missile)
    '_advq_search'

    >>> marker = get_marker('non-existent')(__test_missile)
    Traceback (most recent call last):
      ...
    NotImplementedError: No such marker: "non-existent"

    '''
    if marker_type and marker_type is not '0':
        if marker_type in __markers:
            return __markers[marker_type]
        else:
            raise NotImplementedError(
                'No such marker: "%s"' % marker_type)
    else:
        return lambda m: 'None'

@@ -45,20 +45,23 @@
 %5C%0APOST /
-advq
+example
 /search 
@@ -101,29 +101,19 @@
 st: 
-ust1-1.advq.yandex.ru
+example.org
 %5Cr%0AC
@@ -131,180 +131,47 @@
 th: 
-16
 3
+2
 %5Cr%0A%5Cr%0Ap
-h_page_size=50&ph_page=0&words=%2522%2521%25D1%2581%25D0%25BA%25D0%25B0%25D1%2587%25D0%25B0%25D1%2582%25D1%258C+%2521pelingator+%25211.07+%2521%25D0%25B1%25D0%25B5%25D1%2581%25D0%25BF%25D0%25BB%25D0%25B0%25D1%2582%25D0%25BD%25D0%25BE%2522
+aram1=50&param2=0&param3=hello
 %0A%22%22%22
@@ -624,12 +624,15 @@
   '_
-advq
+example
 _sea

fix doctest data