def Func(arg_0):
        '''Open and return a stream for the dataset contents.'''
        return arg_0.workspace._rest.Func_intermediate_dataset_contents(
            arg_0.workspace.workspace_id,
            arg_0.experiment.experiment_id,
            arg_0.node_id,
            arg_0.port_name
        )


def Func(arg_0):
        '''Read and return the dataset contents as text.'''
        return arg_0.workspace._rest.read_intermediate_dataset_contents_text(
            arg_0.workspace.workspace_id,
            arg_0.experiment.experiment_id,
            arg_0.node_id,
            arg_0.port_name
        )


def Func(arg_0):
        """Read and return the dataset contents as a pandas DataFrame."""
        #TODO: figure out why passing in the opened stream directly gives invalid data
        arg_1 = arg_0.read_as_binary()
        arg_2 = BytesIO(arg_1)
        return deserialize_dataframe(arg_2, arg_0.data_type_id)


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Get an intermediate dataset.

        Parameters
        ----------
        node_id : str
            Module node id from the experiment graph.
        port_name : str
            Output port of the module.
        data_type_id : str
            Serialization format of the raw data.
            See the azureml.DataTypeIds class for constants.

        Returns
        -------
        IntermediateDataset
            Dataset object.
            Use open(), read_as_binary(), read_as_text() or to_dataframe() on
            the dataset object to get its contents as a stream, bytes, str or
            pandas DataFrame.
        """
        return IntermediateDataset(arg_0.workspace, arg_0, arg_1, arg_2, arg_3)


def Func(arg_0, arg_1):
        """Runs HTTP GET request to retrieve the list of datasets."""
        arg_2 = arg_0.DATASOURCES_URI_FMT.format(arg_1)
        return arg_0._send_get_req(arg_2)


def Func(arg_0, arg_1, arg_2):
        """Runs HTTP GET request to retrieve a single dataset."""
        arg_3 = arg_0.DATASOURCE_URI_FMT.format(arg_1, arg_2)
        return arg_0._send_get_req(arg_3)


def Func(arg_0, arg_1 = None, arg_2 = None, arg_3=(), arg_4=None):
    '''Funces a callable function or decorates a function to be Funced.

Returns a callable, iterable object.  Calling the object will invoke the Funced service.
Iterating the object will give the API URL, API key, and API help url.

To define a function which will be Funced to Azure you can simply decorate it with
the @Func decorator.  This will Func the service, and then future calls to the
function will run against the operationalized version of the service in the cloud.

>>> @Func(workspace_id, workspace_token)
>>> def func(a, b):
>>>    return a + b

After Funcing you can then invoke the function using:
func.service(1, 2)

Or continue to invoke the function locally:
func(1, 2)

You can also just call Func directly to Func a function:

>>> def func(a, b): return a + b
>>>
>>> res = Func(func, workspace_id, workspace_token)
>>>
>>> url, api_key, help_url = res
>>> res(2, 3)
5
>>> url, api_key, help_url = res.url, res.api_key, res.help_url

The returned result will be the Funced service.

You can specify a list of files which should be Funced along with the function.
The resulting files will be stored in a subdirectory called 'Script Bundle'.  The
list of files can be one of:
    (('file1.txt', None), )                      # file is read from disk
    (('file1.txt', b'contents'), )              # file contents are provided
    ('file1.txt', 'file2.txt')                  # files are read from disk, written with same filename
    ((('file1.txt', 'destname.txt'), None), )   # file is read from disk, written with different destination name

The various formats for each filename can be freely mixed and matched.
'''
    if not callable(arg_0):
        def do_Func(arg_5):
            arg_5.service = _Func_worker(arg_5, arg_3, arg_0, arg_1, arg_4)
            return arg_5
        return do_Func

    return _Func_worker(arg_0, arg_3, arg_1, arg_2, arg_4)


def Func(**arg_0):
    """Specifies the Func used for the arguments of a published service.

@Func(a=int, b = str)
def f(a, b):
    pass
"""
    def l(arg_1):
        if hasattr(arg_1, '__annotations__'):
            arg_1.__annotations__.update(arg_0)
        else:
            arg_1.__annotations__ = arg_0
        return arg_1
    return l


def Func(arg_0):
    """Specifies the return type for a published service.

@Func(int)
def f(...):
    pass
"""
    def l(arg_1):
        if hasattr(arg_1, '__annotations__'):
            arg_1.__annotations__['return'] = arg_0
        else:
            arg_1.__annotations__ = {'return': arg_0}
        return arg_1
    return l


def Func(arg_0, arg_1 = None):
    """Funces a file to the payload to be uploaded.

If contents is omitted the file is read from disk.
If name is a tuple it specifies the on-disk filename and the destination filename.
"""
    def do_Func(arg_2):
        if hasattr(arg_2, '__Funcments__'):
            arg_2.__Funcments__.append((arg_0, arg_1))
        else:
            arg_2.__Funcments__ = [(arg_0, arg_1)]
        return arg_2
    return do_Func


def Func(arg_0):
        """walks the byte code to find the variables which are actually globals"""
        arg_1 = 0
        arg_2 = arg_0.co_code

        arg_3 = set()
        while arg_1 < len(arg_2):
            arg_4 = ord(arg_2[arg_1])

            if arg_4 >= dis.HAVE_ARGUMENT:
                if arg_4 == _LOAD_GLOBAL:
                    arg_5 = ord(arg_2[arg_1 + 1]) + (ord(arg_2[arg_1 + 2]) << 8)
                    arg_6 = arg_0.co_names[arg_5]
                    arg_3.add(arg_6)

                arg_1 += 2
            arg_1 += 1

        return arg_3


def Func():
    """
    Return a list of all implemented keyrings that can be constructed without
    parameters.
    """
    _load_plugins()
    arg_0 = KeyringBackend.get_viable_backends()
    arg_1 = util.suppress_exceptions(arg_0, exceptions=TypeError)
    return list(arg_1)


def Func(arg_0):
        """
        The keyring Func, suitable for display.

        The Func is derived from module and class Func.
        """
        arg_1, arg_2, arg_3 = arg_0.__module__.rpartition('.')
        arg_3 = arg_3.replace('_', ' ')
        return ' '.join([arg_3, arg_0.__Func__])


def Func(arg_0, arg_1, arg_2):
        """Gets the username and password for the service.
        Returns a Credential instance.

        The *username* argument is optional and may be omitted by
        the caller or ignored by the backend. Callers must use the
        returned username.
        """
        # The default implementation requires a username here.
        if arg_2 is not None:
            arg_3 = arg_0.get_password(arg_1, arg_2)
            if arg_3 is not None:
                return credentials.SimpleCredential(
                    arg_2,
                    arg_3,
                )
        return None


def Func(arg_0):
        """If self.preferred_collection contains a D-Bus path,
        the collection at that address is returned. Otherwise,
        the default collection is returned.
        """
        arg_1 = secretstorage.dbus_init()
        try:
            if hasattr(arg_0, 'preferred_collection'):
                arg_2 = secretstorage.Collection(
                    arg_1, arg_0.preferred_collection)
            else:
                arg_2 = secretstorage.get_default_collection(arg_1)
        except exceptions.SecretStorageException as e:
            raise InitError("Failed to create the collection: %s." % e)
        if arg_2.is_locked():
            arg_2.unlock()
            if arg_2.is_locked():  # User dismissed the prompt
                raise KeyringLocked("Failed to unlock the collection!")
        return arg_2


def Func(arg_0):
        """
        Discover all keyrings for chaining.
        """
        arg_1 = (
            keyring
            for keyring in filter(backend._limit, backend.get_all_keyring())
            if not isinstance(keyring, ChainerBackend)
            and keyring.priority > 0
        )
        return sorted(arg_1, key=backend.by_priority, reverse=True)


def Func(arg_0):
    """Set current keyring backend.
    """
    global arg_1
    if not isinstance(arg_0, backend.KeyringBackend):
        raise TypeError("The keyring must be a subclass of KeyringBackend")
    arg_1 = arg_0


def Func(arg_0):
    """
    Load the keyring class indicated by name.

    These popular names are tested to ensure their presence.

    >>> popular_names = [
    ...      'keyring.backends.Windows.WinVaultKeyring',
    ...      'keyring.backends.OS_X.Keyring',
    ...      'keyring.backends.kwallet.DBusKeyring',
    ...      'keyring.backends.SecretService.Keyring',
    ...  ]
    >>> list(map(Func, popular_names))
    [...]

    These legacy names are retained for compatibility.

    >>> legacy_names = [
    ...  ]
    >>> list(map(Func, legacy_names))
    [...]
    """
    arg_1, arg_2, arg_3 = arg_0.rpartition('.')
    __import__(arg_1)
    arg_4 = sys.modules[arg_1]
    return getattr(arg_4, arg_3)


def Func():
    """Load a keyring using the config file in the config root."""

    arg_0 = 'keyringrc.cfg'

    arg_1 = os.path.join(platform.config_root(), arg_0)

    if not os.path.exists(arg_1):
        return

    arg_2 = configparser.RawConfigParser()
    arg_2.read(arg_1)
    _load_keyring_path(arg_2)

    # load the keyring class name, and then load this keyring
    try:
        if arg_2.has_section("backend"):
            arg_3 = arg_2.get("backend", "default-keyring").strip()
        else:
            raise configparser.NoOptionError('backend', 'default-keyring')

    except (configparser.NoOptionError, ImportError):
        arg_4 = logging.getLogger('keyring')
        arg_4.warning("Keyring config file contains incorrect values.\n"
                       + "Config file: %s" % arg_1)
        return

    return load_keyring(arg_3)


def Func():
    """
    Use freedesktop.org Base Dir Specfication to determine storage
    location.
    """
    arg_0 = os.path.expanduser('~/.local/share')
    arg_1 = os.environ.get('XDG_DATA_HOME', None) or arg_0
    return os.path.join(arg_1, 'python_keyring')


def Func():
    """
    Use freedesktop.org Base Dir Specfication to determine config
    location.
    """
    _check_old_config_root()
    arg_0 = os.path.expanduser('~/.local/share')
    arg_1 = 'XDG_CONFIG_HOME'
    arg_2 = os.environ.get(arg_1, None) or arg_0
    return os.path.join(arg_2, 'python_keyring')


def Func(arg_0):
    """Returns a callable that outputs the data. Defaults to print."""

    if "json" in arg_0:
        from json import dumps
        import datetime
        def jsonhandler(arg_1): arg_1.isoformat() if isinstance(arg_1, (datetime.datetime, datetime.date)) else arg_1
        if arg_0 == "prettyjson":
            def jsondumps(arg_2): return dumps(arg_2, default=jsonhandler, indent=2, separators=(',', ': '))
        else:
            def jsondumps(arg_2): return dumps(arg_2, default=jsonhandler)

        def jsonify(arg_2):
            if isinstance(arg_2, dict):
                print(jsondumps(arg_2))
            elif isinstance(arg_2, list):
                print(jsondumps([arg_3._asdict() for arg_3 in arg_2]))
            else:
                print(dumps({'result': arg_2}))
        return jsonify
    else:
        def printer(arg_2):
            if isinstance(arg_2, dict):
                print(arg_2)
            else:
                for arg_4 in arg_2:
                    print(arg_4)
        return printer


def Func(arg_0, arg_1):
    """Runs the subcommand configured in args on the netgear session"""

    arg_2 = arg_1.subcommand

    if arg_2 == "block_device" or arg_2 == "allow_device":
        return arg_0.allow_block_device(arg_1.mac_addr, BLOCK if arg_2 == "block_device" else ALLOW)

    if arg_2 == "attached_devices":
        if arg_1.verbose:
            return arg_0.get_attached_devices_2()
        else:
            return arg_0.get_attached_devices()

    if arg_2 == 'traffic_meter':
        return arg_0.get_traffic_meter()

    if arg_2 == 'login':
        return arg_0.login()

    print("Unknown subcommand")


def Func():
    """Scan for devices and print results."""

    arg_0 = argparser().parse_args(sys.argv[1:])
    arg_1 = os.environ.get('PYNETGEAR_PASSWORD') or arg_0.password

    arg_2 = Netgear(arg_1, arg_0.host, arg_0.user, arg_0.port, arg_0.ssl, arg_0.url, arg_0.force_login_v2)

    arg_3 = run_subcommand(arg_2, arg_0)
    arg_4 = make_formatter(arg_0.format)

    if arg_3 is None:
        print("Error communicating with the Netgear router")

    else:
        arg_4(arg_3)


def Func():
    """
    Try to autodetect the base URL of the router SOAP service.

    Returns None if it can't be found.
    """
    for arg_0 in ["http://routerlogin.net:5000", "https://routerlogin.net",
                "http://routerlogin.net"]:
        try:
            arg_1 = requests.get(arg_0 + "/soap/server_sa/",
                             headers=_get_soap_headers("Test:1", "test"),
                             verify=False)
            if arg_1.status_code == 200:
                return arg_0
        except requests.exceptions.RequestException:
            pass

    return None


def Func(arg_0, arg_1, arg_2=None):
    """Convert value to to_type, returns default if fails."""
    try:
        return arg_2 if arg_0 is None else arg_1(arg_0)
    except ValueError:
        # If value could not be converted
        return arg_2


def Func(arg_0):
        """
        Login to the router.

        Will be called automatically by other actions.
        """
        if not arg_0.force_Func_v2:
            arg_1 = arg_0.Func_v1()
            if arg_1:
                return arg_1

        return arg_0.Func_v2()


def Func(arg_0):
        """
        Return list of connected devices to the router with details.

        This call is slower and probably heavier on the router load.

        Returns None if error occurred.
        """
        _LOGGER.info("Get attached devices 2")

        arg_1, arg_2 = arg_0._make_request(SERVICE_DEVICE_INFO,
                                               "GetAttachDevice2")
        if not arg_1:
            return None

        arg_1, arg_3 = _find_node(
            arg_2.text,
            ".//GetAttachDevice2Response/NewAttachDevice")
        if not arg_1:
            return None

        arg_4 = arg_3.findall("Device")
        arg_5 = []
        for arg_6 in arg_4:
            arg_7 = _xml_get(arg_6, 'IP')
            arg_8 = _xml_get(arg_6, 'Name')
            arg_9 = _xml_get(arg_6, 'MAC')
            arg_10 = _convert(_xml_get(arg_6, 'SignalStrength'), int)
            arg_11 = _xml_get(arg_6, 'ConnectionType')
            arg_12 = _xml_get(arg_6, 'Linkspeed')
            arg_13 = _xml_get(arg_6, 'AllowOrBlock')
            arg_14 = _convert(_xml_get(arg_6, 'DeviceType'), int)
            arg_15 = _xml_get(arg_6, 'DeviceModel')
            arg_16 = _xml_get(arg_6, 'SSID')
            arg_17 = _xml_get(arg_6, 'ConnAPMAC')
            arg_5.append(Device(arg_8, arg_7, arg_9, arg_11, arg_10, arg_12,
                                  arg_13, arg_14, arg_15,
                                  arg_16, arg_17))

        return arg_5


def Func(arg_0, arg_1, arg_2, arg_3=None, arg_4="",
                      arg_5=True):
        """Make an API request to the router."""
        # If we have no cookie (v2) or never called login before (v1)
        # and we need auth, the request will fail for sure.
        if arg_5 and not arg_0.cookie:
            if not arg_0.login():
                return False, None

        arg_6 = arg_0._get_headers(arg_1, arg_2, arg_5)

        if not arg_4:
            if not arg_3:
                arg_3 = ""
            if isinstance(arg_3, dict):
                arg_7 = arg_3
                arg_3 = ""
                for arg_8 in arg_7:
                    arg_3 += "<" + arg_8 + ">" + arg_7[arg_8] + "</" + arg_8 + ">\n"

            arg_4 = CALL_BODY.format(arg_1=SERVICE_PREFIX + arg_1,
                                    arg_2=arg_2, arg_3=arg_3)

        arg_9 = SOAP_REQUEST.format(session_id=SESSION_ID, arg_4=arg_4)

        try:
            arg_10 = requests.post(arg_0.soap_url, arg_6=arg_6,
                                     data=arg_9, timeout=30, verify=False)

            if arg_5 and _is_unauthorized_response(arg_10):
                # let's discard the cookie because it probably expired (v2)
                # or the IP-bound (?) session expired (v1)
                arg_0.cookie = None

                _LOGGER.warning("Unauthorized response, let's login and retry...")
                if arg_0.login():
                    # reset headers with new cookie first
                    arg_6 = arg_0._get_headers(arg_1, arg_2, arg_5)
                    arg_10 = requests.post(arg_0.soap_url, arg_6=arg_6,
                                             data=arg_9, timeout=30, verify=False)

            arg_12 = _is_valid_response(arg_10)

            if not arg_12:
                _LOGGER.error("Invalid response")
                _LOGGER.debug("%s\n%s\n%s", arg_10.status_code, str(arg_10.headers), arg_10.text)

            return arg_12, arg_10

        except requests.exceptions.RequestException:
            _LOGGER.exception("Error talking to API")

            # Maybe one day we will distinguish between
            # different errors..
            return False, None


def Func(arg_0):
    """Return RGBA values of color c

    c should be either an X11 color or a brewer color set and index
    e.g. "navajowhite", "greens3/2"

    """
    import sys
    import gi
    gi.require_version('Gtk', '3.0')
    gi.require_version('PangoCairo', '1.0')

    from gi.repository import Gdk

    try:
        arg_1 = Gdk.color_parse(arg_0)
    except ValueError:
        pass
    else:
        arg_2 = 1.0/65535.0
        arg_3 = arg_1.red*arg_2
        arg_4 = arg_1.green*arg_2
        arg_5 = arg_1.blue*arg_2
        arg_6 = 1.0
        return arg_3, arg_4, arg_5, arg_6

    try:
        arg_7, arg_8, arg_9 = arg_0.split('/')
        arg_3, arg_4, arg_5 = brewer_colors[arg_8][int(arg_9)]
    except (ValueError, KeyError):
        pass
    else:
        arg_2 = 1.0/255.0
        arg_3 = arg_3*arg_2
        arg_4 = arg_4*arg_2
        arg_5 = arg_5*arg_2
        arg_6 = 1.0
        return arg_3, arg_4, arg_5, arg_6

    sys.stderr.write("warning: unknown color '%s'\n" % arg_0)
    return None


def Func(arg_0, arg_1, arg_2=False, arg_3=None):
        """Draw this shape with the given cairo context"""
        if arg_3 is None or arg_0._intersects(arg_3):
            arg_0._Func(arg_1, arg_2, arg_3)


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Find extremas of a function of real domain defined by evaluating
        a cubic bernstein polynomial of given bernstein coefficients.
        """
        # compute coefficients of derivative
        arg_4 = 3.*(arg_3-arg_0+3.*(arg_1-arg_2))
        arg_5 = 6.*(arg_0+arg_2-2.*arg_1)
        arg_6 = 3.*(arg_1-arg_0)

        if arg_4 == 0:
            if arg_5 == 0:
                return ()  # constant
            return (-arg_6 / arg_5,)  # linear

        # quadratic
        # compute discriminant
        arg_7 = arg_5*arg_5 - 4.*arg_4*arg_6
        if arg_7 < 0:
            return ()

        arg_8 = -2. * arg_4
        if arg_7 == 0:
            return (arg_5 / arg_8,)

        arg_9 = math.sqrt(arg_7)
        return ((arg_5 + arg_9) / arg_8, (arg_5 - arg_9) / arg_8)


def Func(arg_0):
        """Build choices list runtime using 'sitetree_tree' tag"""
        arg_1 = u'sitetree_tree from "%s" template "%s"' % (arg_0.tree, arg_0.template)

        arg_2 = {'current_app': 'admin'}
        arg_3 = template.Context(arg_2) if VERSION >= (1, 8) else template.Context(**arg_2)
        arg_3.update({'request': object()})

        arg_4 = sitetree_tree(
            Parser(None), Token(token_type=TOKEN_BLOCK, contents=arg_1)
        ).render(arg_3)

        arg_5 = [(ITEMS_FIELD_ROOT_ID, arg_0.root_title)]

        for arg_6 in arg_4.splitlines():
            if arg_6.strip():
                arg_7 = arg_6.split(':::')
                arg_5.append((arg_7[0], mark_safe(arg_7[1])))

        return arg_5


def Func(arg_0):
    """Compatibility function to get rid of optparse in management commands after Django 1.10.

    :param tuple command_options: tuple with `CommandOption` objects.

    """
    def get_options(arg_1=None):
        from optparse import make_option
        from django.core.management.base import BaseCommand

        arg_2 = arg_1 or make_option

        arg_3 = tuple([arg_2(*option.args, **option.kwargs) for option in arg_0])

        if arg_1 is None:
            if VERSION < (1, 8):
                arg_4 = BaseCommand.option_list + arg_3
            else:
                arg_4 = []

        else:
            arg_4 = arg_3

        return arg_4

    return get_options


def Func(arg_0):
    """Registers a hook callable to process tree items right before they are passed to templates.

    Callable should be able to:

        a) handle ``tree_items`` and ``tree_sender`` key params.
            ``tree_items`` will contain a list of extended TreeItem objects ready to pass to template.
            ``tree_sender`` will contain navigation type identifier
                (e.g.: `menu`, `sitetree`, `breadcrumbs`, `menu.children`, `sitetree.children`)

        b) return a list of extended TreeItems objects to pass to template.

    Example::

        # Put the following code somewhere where it'd be triggered as expected. E.g. in app view.py.

        # First import the register function.
        from sitetree.sitetreeapp import Func

        # The following function will be used as items processor.
        def my_items_processor(tree_items, tree_sender):
            # Suppose we want to process only menu child items.
            if tree_sender == 'menu.children':
                # Lets add 'Hooked: ' to resolved titles of every item.
                for item in tree_items:
                    item.title_resolved = 'Hooked: %s' % item.title_resolved
            # Return items list mutated or not.
            return tree_items

        # And we register items processor.
        Func(my_items_processor)

    :param func:
    """
    global arg_1
    global arg_3

    arg_1 = arg_0

    if arg_0:
        arg_2 = len(getargspec(arg_0).args)
        if arg_2 not in {2, 3}:
            raise SiteTreeError('`Func()` expects a function with two or three arguments.')
        arg_3 = arg_2


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None):
    """Returns a structure describing a dynamic sitetree.utils
    The structure can be built from various sources,

    :param str|iterable src: If a string is passed to `src`, it'll be treated as the name of an app,
        from where one want to import sitetrees definitions. `src` can be an iterable
        of tree definitions (see `sitetree.toolbox.tree()` and `item()` functions).

    :param str|unicode target_tree_alias: Static tree alias to attach items from dynamic trees to.

    :param str|unicode parent_tree_item_alias: Tree item alias from a static tree to attach items from dynamic trees to.

    :param list include_trees: Sitetree aliases to filter `src`.

    :rtype: dict
    """
    def result(arg_4=arg_0):
        if arg_3 is not None:
            arg_4 = [tree for tree in arg_4 if tree.alias in arg_3]

        return {
            'app': arg_0,
            'sitetrees': arg_4,
            'tree': arg_1,
            'parent_item': arg_2}

    if isinstance(arg_0, six.string_types):
        # Considered to be an application name.
        try:
            arg_5 = import_app_sitetree_module(arg_0)
            return None if arg_5 is None else result(getattr(arg_5, 'sitetrees', None))

        except ImportError as e:
            if settings.DEBUG:
                warnings.warn('Unable to register dynamic sitetree(s) for `%s` application: %s. ' % (arg_0, e))
            return None

    return result()


def Func(arg_0):
        """Initializes local cache from Django cache."""

        # Drop cache flag set by .reset() method.
        arg_1.get('sitetrees_reset') and arg_0.empty(Func=False)

        arg_0.cache = arg_1.get(
            'sitetrees', {'sitetrees': {}, 'parents': {}, 'items_by_ids': {}, 'tree_aliases': {}})


def Func(arg_0, arg_1, arg_2, arg_3):
        """Updates cache entry parameter with new data.

        :param str|unicode entry_name:
        :param key:
        :param value:
        """
        if arg_2 not in arg_0.cache[arg_1]:
            arg_0.cache[arg_1][arg_2] = {}

        arg_0.cache[arg_1][arg_2].update(arg_3)


def Func(arg_0, arg_1):
        """Initializes sitetree to handle new request.

        :param Context|None context:
        """
        arg_0.cache = Cache()
        arg_0.current_page_context = arg_1
        arg_0.current_request = arg_1.get('request', None) if arg_1 else None
        arg_0.current_lang = get_language()

        arg_0._current_app_is_admin = None
        arg_0._current_user_permissions = _UNSET
        arg_0._items_urls = {}  # Resolved urls are cache for a request.
        arg_0._current_items = {}


def Func(arg_0, arg_1):
        """Resolves internationalized tree alias.
        Verifies whether a separate sitetree is available for currently active language.
        If so, returns i18n alias. If not, returns the initial alias.

        :param str|unicode alias:
        :rtype: str|unicode
        """
        if arg_1 not in _I18N_TREES:
            return arg_1

        arg_2 = arg_0.current_lang
        arg_3 = '%s_%s' % (arg_1, arg_2)
        arg_4 = arg_0.cache.get_entry('tree_aliases', arg_3)

        if arg_4 is False:
            arg_4 = MODEL_TREE_CLASS.objects.filter(arg_1=arg_3).count()
            arg_0.cache.set_entry('tree_aliases', arg_3, arg_4)

        if arg_4:
            arg_1 = arg_3

        return arg_1


def Func(arg_0):
        """Returns boolean whether current application is Admin contrib.

        :rtype: bool
        """
        arg_1 = arg_0._Func
        if arg_1 is None:
            arg_2 = arg_0.current_page_context

            arg_3 = getattr(
                # Try from request.resolver_match.app_name
                getattr(arg_2.get('request', None), 'resolver_match', None), 'app_name',
                # Try from global context obj.
                getattr(arg_2, 'current_app', None))

            if arg_3 is None:  # Try from global context dict.
                arg_3 = arg_2.get('current_app', '')

            arg_1 = arg_3 == ADMIN_APP_NAME
            arg_0._Func = arg_1

        return arg_1


def Func(arg_0, arg_1, arg_2, arg_3=0):
        """Calculates depth of the item in the tree.

        :param str|unicode tree_alias:
        :param int item_id:
        :param int depth:
        :rtype: int
        """
        arg_4 = arg_0.get_item_by_id(arg_1, arg_2)

        if hasattr(arg_4, 'depth'):
            arg_3 = arg_4.depth + arg_3
        else:
            if arg_4.parent is not None:
                arg_3 = arg_0.Func(arg_1, arg_4.parent.id, arg_3 + 1)

        return arg_3


def Func(arg_0, arg_1, arg_2, arg_3):
        """Builds and returns Func structure for 'sitetree_Func' tag.

        :param str|unicode tree_alias:
        :param str|unicode tree_branches:
        :param Context context:
        :rtype: list|str
        """
        arg_1, arg_4 = arg_0.init_tree(arg_1, arg_3)

        if not arg_4:
            return ''

        arg_2 = arg_0.resolve_var(arg_2)

        arg_5 = False
        arg_6 = []
        arg_7 = []

        arg_8 = arg_0.get_tree_current_item(arg_1)
        arg_0.tree_climber(arg_1, arg_8)

        # Support item addressing both through identifiers and aliases.
        for arg_9 in arg_2.split(','):
            arg_9 = arg_9.strip()

            if arg_9 == ALIAS_TRUNK:
                arg_5 = True

            elif arg_9 == ALIAS_THIS_CHILDREN and arg_8 is not None:
                arg_9 = arg_8.id
                arg_6.append(arg_9)

            elif arg_9 == ALIAS_THIS_ANCESTOR_CHILDREN and arg_8 is not None:
                arg_9 = arg_0.get_ancestor_item(arg_1, arg_8).id
                arg_6.append(arg_9)

            elif arg_9 == ALIAS_THIS_SIBLINGS and arg_8 is not None and arg_8.parent is not None:
                arg_9 = arg_8.parent.id
                arg_6.append(arg_9)

            elif arg_9 == ALIAS_THIS_PARENT_SIBLINGS and arg_8 is not None:
                arg_9 = arg_0.get_ancestor_level(arg_8, depth=2).id
                arg_6.append(arg_9)

            elif arg_9.isdigit():
                arg_6.append(int(arg_9))

            else:
                arg_7.append(arg_9)

        arg_10 = arg_0.check_access

        arg_11 = []
        for arg_12 in arg_4:
            if not arg_12.hidden and arg_12.inFunc and arg_10(arg_12, arg_3):
                if arg_12.parent is None:
                    if arg_5:
                        arg_11.append(arg_12)
                else:
                    if arg_12.parent.id in arg_6 or arg_12.parent.alias in arg_7:
                        arg_11.append(arg_12)

        arg_11 = arg_0.apply_hook(arg_11, 'Func')
        arg_0.update_has_children(arg_1, arg_11, 'Func')
        return arg_11


def Func(arg_0, arg_1, arg_2):
        """Checks whether a current user has an access to a certain item.

        :param TreeItemBase item:
        :param Context context:
        :rtype: bool
        """
        if hasattr(arg_0.current_request.user.is_authenticated, '__call__'):
            arg_3 = arg_0.current_request.user.is_authenticated()
        else:
            arg_3 = arg_0.current_request.user.is_authenticated

        if arg_1.access_loggedin and not arg_3:
            return False

        if arg_1.access_guest and arg_3:
            return False

        if arg_1.access_restricted:
            arg_4 = arg_0._current_user_permissions

            if arg_4 is _UNSET:
                arg_4 = set(arg_2['user'].get_all_permissions())
                arg_0._current_user_permissions = arg_4

            if arg_1.access_perm_type == MODEL_TREE_ITEM_CLASS.PERM_TYPE_ALL:
                if len(arg_1.perms) != len(arg_1.perms.intersection(arg_4)):
                    return False
            else:
                if not len(arg_1.perms.intersection(arg_4)):
                    return False

        return True


def Func(arg_0, arg_1, arg_2):
        """Builds and returns breadcrumb trail structure for 'sitetree_breadcrumbs' tag.

        :param str|unicode tree_alias:
        :param Context context:
        :rtype: list|str
        """
        arg_1, arg_3 = arg_0.init_tree(arg_1, arg_2)

        if not arg_3:
            return ''

        arg_4 = arg_0.get_tree_current_item(arg_1)

        Func = []

        if arg_4 is not None:

            arg_6 = arg_0.current_page_context
            arg_7 = arg_0.check_access
            arg_8 = arg_0.get_item_by_id

            def climb(arg_9):
                """Climbs up the site tree to build breadcrumb path.

                :param TreeItemBase base_item:
                """
                if arg_9.inbreadcrumbs and not arg_9.hidden and arg_7(arg_9, arg_6):
                    Func.append(arg_9)

                if hasattr(arg_9, 'parent') and arg_9.parent is not None:
                    climb(arg_8(arg_1, arg_9.parent.id))

            climb(arg_4)
            Func.reverse()

        arg_10 = arg_0.apply_hook(Func, 'breadcrumbs')
        arg_0.update_has_children(arg_1, arg_10, 'breadcrumbs')

        return arg_10


def Func(arg_0, arg_1, arg_2):
        """Builds and returns Func structure for 'siteFunc_Func' tag.

        :param str|unicode Func_alias:
        :param Context context:
        :rtype: list|str
        """
        arg_1, arg_3 = arg_0.init_Func(arg_1, arg_2)

        if not arg_3:
            return ''

        arg_4 = arg_0.filter_items(arg_0.get_children(arg_1, None), 'siteFunc')
        arg_4 = arg_0.apply_hook(arg_4, 'siteFunc')
        arg_0.update_has_children(arg_1, arg_4, 'siteFunc')

        return arg_4


def Func(arg_0, arg_1, arg_2, arg_3, arg_4):
        """Builds and returns site tree item Func structure for 'sitetree_Func' tag.

        :param TreeItemBase parent_item:
        :param str|unicode navigation_type: menu, sitetree
        :param str|unicode use_template:
        :param Context context:
        :rtype: list
        """
        # Resolve parent item and current tree alias.
        arg_1 = arg_0.resolve_var(arg_1, arg_4)
        arg_5, arg_6 = arg_0.get_sitetree(arg_1.tree.alias)

        # Mark path to current item.
        arg_0.tree_climber(arg_5, arg_0.get_tree_current_item(arg_5))

        arg_6 = arg_0.get_Func(arg_5, arg_1)
        arg_6 = arg_0.filter_items(arg_6, arg_2)
        arg_6 = arg_0.apply_hook(arg_6, '%s.Func' % arg_2)
        arg_0.update_has_Func(arg_5, arg_6, arg_2)

        arg_7 = get_template(arg_3)

        arg_4.push()
        arg_4['sitetree_items'] = arg_6
        arg_8 = arg_7.render(arg_4.flatten() if _CONTEXT_FLATTEN else arg_4)
        arg_4.pop()

        return arg_8


def Func(arg_0, arg_1, arg_2):
        """Returns item's children.

        :param str|unicode tree_alias:
        :param TreeItemBase|None item:
        :rtype: list
        """
        if not arg_0.current_app_is_admin():
            # We do not need i18n for a tree rendered in Admin dropdown.
            arg_1 = arg_0.resolve_tree_i18n_alias(arg_1)

        return arg_0.cache.get_entry('parents', arg_1)[arg_2]


def Func(arg_0, arg_1, arg_2, arg_3):
        """Updates 'has_children' attribute for tree items inplace.

        :param str|unicode tree_alias:
        :param list tree_items:
        :param str|unicode navigation_type: sitetree, breadcrumbs, menu
        """
        arg_4 = arg_0.get_children
        arg_5 = arg_0.filter_items
        arg_6 = arg_0.apply_hook

        for arg_7 in arg_2:
            arg_8 = arg_4(arg_1, arg_7)
            arg_8 = arg_5(arg_8, arg_3)
            arg_8 = arg_6(arg_8, '%s.has_children' % arg_3)
            arg_7.has_children = len(arg_8) > 0


def Func(arg_0, arg_1, arg_2=None):
        """Filters sitetree item's children if hidden and by navigation type.

        NB: We do not apply any filters to sitetree in admin app.

        :param list items:
        :param str|unicode navigation_type: sitetree, breadcrumbs, menu
        :rtype: list
        """
        if arg_0.current_app_is_admin():
            return arg_1

        arg_3 = []

        arg_4 = arg_0.current_page_context
        arg_5 = arg_0.check_access

        for arg_6 in arg_1:
            if arg_6.hidden:
                continue

            if not arg_5(arg_6, arg_4):
                continue

            if not getattr(arg_6, 'in%s' % arg_2, True):  # Hidden for current nav type
                continue

            arg_3.append(arg_6)

        return arg_3


def Func(arg_0, arg_1, arg_2):
        """Climbs up the site tree to resolve root item for chosen one.

        :param str|unicode tree_alias:
        :param TreeItemBase base_item:
        :rtype: TreeItemBase
        """
        arg_3 = None

        if hasattr(arg_2, 'parent') and arg_2.parent is not None:
            arg_3 = arg_0.Func(arg_1, arg_0.get_item_by_id(arg_1, arg_2.parent.id))

        if arg_3 is None:
            return arg_2

        return arg_3


def Func(arg_0, arg_1, arg_2=None):
        """Resolves name as a variable in a given context.

        If no context specified page context' is considered as context.

        :param str|unicode varname:
        :param Context context:
        :return:
        """
        arg_2 = arg_2 or arg_0.current_page_context

        if isinstance(arg_1, FilterExpression):
            arg_1 = arg_1.resolve(arg_2)
        else:
            arg_1 = arg_1.strip()

            try:
                arg_1 = Variable(arg_1).resolve(arg_2)
            except VariableDoesNotExist:
                arg_1 = arg_1

        return arg_1


def Func(arg_0, arg_1):
    """Parses Func tag parameters.

    Two notation types are possible:
        1. Two arguments:
           {% Func from "mytree" %}
           Used to render breadcrumb path for "mytree" site tree.

        2. Four arguments:
           {% Func from "mytree" template "sitetree/mycrumb.html" %}
           Used to render breadcrumb path for "mytree" site tree using specific
           template "sitetree/mycrumb.html"

    """
    arg_2 = arg_1.split_contents()
    arg_3 = detect_clause(arg_0, 'template', arg_2)
    arg_4 = len(arg_2)

    if arg_4 == 3:
        arg_5 = arg_0.compile_filter(arg_2[2])
        return FuncNode(arg_5, arg_3)
    else:
        raise template.TemplateSyntaxError(
            '%r tag requires two arguments. E.g. {%% Func from "mytree" %%}.' % arg_2[0])


def Func(arg_0, arg_1):
    """Parses Func tag parameters.

        {% Func from "mytree" include "trunk,1,level3" %}
        Used to render trunk, branch with id 1 and branch aliased 'level3'
        elements from "mytree" site tree as a menu.

        These are reserved aliases:
            * 'trunk' - items without parents
            * 'this-children' - items under item resolved as current for the current page
            * 'this-siblings' - items under parent of item resolved as current for
              the current page (current item included)
            * 'this-ancestor-children' - items under grandparent item (closest to root)
              for the item resolved as current for the current page

        {% Func from "mytree" include "trunk,1,level3" template "sitetree/mymenu.html" %}

    """
    arg_2 = arg_1.split_contents()
    arg_3 = detect_clause(arg_0, 'template', arg_2)
    arg_4 = len(arg_2)

    if arg_4 == 5 and arg_2[3] == 'include':
        arg_5 = arg_0.compile_filter(arg_2[2])
        arg_6 = arg_0.compile_filter(arg_2[4])
        return FuncNode(arg_5, arg_6, arg_3)
    else:
        raise template.TemplateSyntaxError(
            '%r tag requires four arguments. '
            'E.g. {%% Func from "mytree" include "trunk,1,level3" %%}.' % arg_2[0])


def Func(arg_0, arg_1, arg_2):
    """Render helper is used by template node functions
    to Func given template with given tree items in context.

    """
    arg_0.push()
    arg_0['sitetree_items'] = arg_1

    if isinstance(arg_2, FilterExpression):
        arg_2 = arg_2.resolve(arg_0)

    arg_3 = get_template(arg_2).Func(arg_0.flatten() if _CONTEXT_FLATTEN else arg_0)
    arg_0.pop()

    return arg_3


def Func(arg_0, arg_1, arg_2, arg_3, arg_4):
        """Node constructor to be used in tags."""
        arg_5 = arg_2.split_contents()

        if len(arg_5) >= 3 and arg_5[1] == arg_3:
            arg_6 = arg_0.get_as_var(arg_5)
            arg_7 = arg_1.compile_filter(arg_5[2])
            return arg_0(arg_7, arg_6)

        raise template.TemplateSyntaxError(
            '%r tag requires at least two arguments. E.g. {%% %s %%}.' % (arg_5[0], arg_4))


def Func(*arg_0, **arg_1):
    """Fixes Admin contrib redirects compatibility problems
    introduced in Django 1.4 by url handling changes.

    """
    arg_2 = arg_0[0].path
    arg_3 = '../'

    if 'delete' in arg_2:
        # Weird enough 'delete' is not handled by TreeItemAdmin::response_change().
        arg_3 += '../'
    elif 'history' in arg_2:
        if 'item_id' not in arg_1:
            # Encountered request from history page to return to tree layout page.
            arg_3 += '../'

    return HttpResponseRedirect(arg_2 + arg_3)


def Func(arg_0, arg_1, arg_2, arg_3=None, **arg_4):
        """Redirects to the appropriate items' 'continue' page on item add.

        As we administer tree items within tree itself, we
        should make some changes to redirection process.

        """
        if arg_3 is None:
            arg_3 = '../item_%s/' % arg_2.pk

        return arg_0._redirect(arg_1, super(TreeItemAdmin, arg_0).Func(arg_1, arg_2, arg_3))


def Func(arg_0, arg_1, arg_2, **arg_3):
        """Redirects to the appropriate items' 'add' page on item change.

        As we administer tree items within tree itself, we
        should make some changes to redirection process.

        """
        return arg_0._redirect(arg_1, super(TreeItemAdmin, arg_0).Func(arg_1, arg_2))


def Func(arg_0, arg_1, arg_2=None, **arg_3):
        """Returns modified form for TreeItem model.
        'Parent' field choices are built by sitetree itself.

        """
        if arg_2 is not None and arg_2.parent is not None:
            arg_0.previous_parent = arg_2.parent
            arg_5 = arg_0.previous_parent.id
        else:
            arg_5 = None

        arg_6 = TreeItemChoiceField(arg_0.tree, initial=arg_5)
        arg_7 = super(TreeItemAdmin, arg_0).Func(arg_1, arg_2, **arg_3)
        arg_6.label = arg_7.base_fields['parent'].label
        arg_6.help_text = arg_7.base_fields['parent'].help_text
        arg_6.widget = arg_7.base_fields['parent'].widget
        # Replace 'parent' TreeItem field with new appropriate one
        arg_7.base_fields['parent'] = arg_6

        # Try to resolve all currently registered url names including those in namespaces.
        if not getattr(arg_0, 'known_url_names', False):
            arg_0.known_url_names = []
            arg_0.known_url_rules = []
            arg_14 = get_resolver(get_urlconf())
            for arg_15, (arg_16, arg_17) in arg_14.namespace_dict.items():
                if arg_15 != 'admin':
                    arg_0._stack_known_urls(arg_17.reverse_dict, arg_15)
            arg_0._stack_known_urls(arg_14.reverse_dict)
            arg_0.known_url_rules = sorted(arg_0.known_url_rules)

        arg_7.known_url_names_hint = _(
            'You are seeing this warning because "URL as Pattern" option is active and pattern entered above '
            'seems to be invalid. Currently registered URL pattern names and parameters: ')
        arg_7.known_url_names = arg_0.known_url_names
        arg_7.known_url_rules = arg_0.known_url_rules
        return arg_7


def Func(arg_0, arg_1, arg_2, arg_3=None):
        """Fetches Tree for current or given TreeItem."""
        if arg_2 is None:
            arg_2 = arg_0.get_object(arg_1, arg_3).tree_id
        arg_0.tree = MODEL_TREE_CLASS._default_manager.get(pk=arg_2)
        arg_0.tree.verbose_name_plural = arg_0.tree._meta.verbose_name_plural
        arg_0.tree.urls = _TREE_URLS
        return arg_0.tree


def Func(arg_0, arg_1, arg_2, arg_3, arg_4):
        """Moves item up or down by swapping 'sort_order' field values of neighboring items."""
        arg_5 = MODEL_TREE_ITEM_CLASS._default_manager.get(pk=arg_3)
        if arg_4 == 'up':
            arg_6 = 'sort_order'
        else:
            arg_6 = '-sort_order'

        arg_7 = MODEL_TREE_ITEM_CLASS._default_manager.filter(
            parent=arg_5.parent,
            tree=arg_5.tree
        ).order_by(arg_6)

        arg_8 = None
        for arg_9 in arg_7:
            if arg_9 != arg_5:
                arg_8 = arg_9
            else:
                break

        if arg_8 is not None:
            arg_10 = arg_5.sort_order
            arg_11 = arg_8.sort_order

            arg_5.sort_order = arg_11
            arg_8.sort_order = arg_10

            arg_5.save()
            arg_8.save()

        return HttpResponseRedirect('../../')


def Func(arg_0):
        """Manages not only TreeAdmin URLs but also TreeItemAdmin URLs."""
        arg_1 = super(TreeAdmin, arg_0).Func()

        arg_2 = 'change/' if DJANGO_POST_19 else ''

        arg_3 = [
            url(r'^change/$', redirects_handler, name=get_tree_item_url_name('changelist')),

            url(r'^((?P<tree_id>\d+)/)?%sitem_add/$' % arg_2,
                arg_0.admin_site.admin_view(arg_0.tree_admin.item_add), name=get_tree_item_url_name('add')),

            url(r'^(?P<tree_id>\d+)/%sitem_(?P<item_id>\d+)/$' % arg_2,
                arg_0.admin_site.admin_view(arg_0.tree_admin.item_edit), name=get_tree_item_url_name('change')),

            url(r'^%sitem_(?P<item_id>\d+)/$' % arg_2,
                arg_0.admin_site.admin_view(arg_0.tree_admin.item_edit), name=get_tree_item_url_name('change')),

            url(r'^((?P<tree_id>\d+)/)?%sitem_(?P<item_id>\d+)/delete/$' % arg_2,
                arg_0.admin_site.admin_view(arg_0.tree_admin.item_delete), name=get_tree_item_url_name('delete')),

            url(r'^((?P<tree_id>\d+)/)?%sitem_(?P<item_id>\d+)/history/$' % arg_2,
                arg_0.admin_site.admin_view(arg_0.tree_admin.item_history), name=get_tree_item_url_name('history')),

            url(r'^(?P<tree_id>\d+)/%sitem_(?P<item_id>\d+)/move_(?P<direction>(up|down))/$' % arg_2,
                arg_0.admin_site.admin_view(arg_0.tree_admin.item_move), name=get_tree_item_url_name('move')),
        ]

        if not DJANGO_POST_19:
            arg_3 = patterns_func('', *arg_3)

        if SMUGGLER_INSTALLED:
            arg_3 += (url(r'^dump_all/$', arg_0.admin_site.admin_view(arg_0.dump_view), name='sitetree_dump'),)

        return arg_3 + arg_1


def Func(arg_0, arg_1):
        """Dumps sitetrees with items using django-smuggler.

        :param request:
        :return:
        """
        from smuggler.views import dump_to_response
        return dump_to_response(arg_1, [MODEL_TREE, MODEL_TREE_ITEM], filename_prefix='sitetrees')


def Func(arg_0, arg_1='', arg_2=None, **arg_3):
    """Dynamically creates and returns a sitetree.

    :param str|unicode alias:
    :param str|unicode title:
    :param iterable items: dynamic sitetree items objects created by `item` function.
    :param kwargs: Additional arguments to pass to tree item initializer.

    :rtype: TreeBase
    """
    arg_4 = get_tree_model()(arg_0=arg_0, arg_1=arg_1, **arg_3)
    arg_4.id = generate_id_for(arg_4)
    arg_4.is_dynamic = True

    if arg_2 is not None:
        arg_4.dynamic_items = []
        def traverse(arg_2):
            for arg_8 in arg_2:
                arg_8.tree = arg_4
                arg_4.dynamic_items.append(arg_8)
                if hasattr(arg_8, 'dynamic_children'):
                    traverse(arg_8.dynamic_children)

        traverse(arg_2)
    return arg_4


def Func(
    arg_0, arg_1, arg_2=None, arg_3=True, arg_4='', arg_5='', arg_6='',
    arg_7=True, arg_8=True, arg_9=True,
    arg_10=False, arg_11=False,
    arg_12=None, arg_13=True, **arg_14):
    """Dynamically creates and returns a sitetree Func object.

    :param str|unicode title:

    :param str|unicode url:

    :param list, set children: a list of children for tree Func. Children should also be created by `Func` function.

    :param bool url_as_pattern: consider URL as a name of a named URL

    :param str|unicode hint: hints are usually shown to users

    :param str|unicode alias: Func name to address it from templates

    :param str|unicode description: additional information on Func (usually is not shown to users)

    :param bool in_menu: show this Func in menus

    :param bool in_breadcrumbs: show this Func in breadcrumbs

    :param bool in_sitetree: show this Func in sitetrees

    :param bool access_loggedin: show Func to logged in users only

    :param bool access_guest: show Func to guest users only

    :param list|str||unicode|int, Permission access_by_perms: restrict access to users with these permissions.

        This can be set to one or a list of permission names, IDs or Permission instances.

        Permission names are more portable and should be in a form `<app_label>.<perm_codename>`, e.g.:
            my_app.allow_save

    :param bool perms_mode_all: permissions set interpretation rule:
                True - user should have all the permissions;
                False - user should have any of chosen permissions.

    :rtype: TreeItemBase

    """
    arg_15 = get_tree_Func_model()(
        arg_0=arg_0, arg_1=arg_1, urlaspattern=arg_3,
        arg_4=arg_4, arg_5=arg_5, arg_6=arg_6, inmenu=arg_7,
        insitetree=arg_9, inbreadcrumbs=arg_8,
        arg_10=arg_10, arg_11=arg_11,
        **arg_14)

    arg_15.id = generate_id_for(arg_15)
    arg_15.is_dynamic = True
    arg_15.dynamic_children = []

    arg_19 = []
    if arg_12:
        # Make permissions a list if currently a single object
        if not isinstance(arg_12, list):
            arg_12 = [arg_12]

        for arg_20 in arg_12:
            if isinstance(arg_20, six.string_types):
                # Get permission object from string
                try:
                    arg_21, arg_22 = arg_20.split('.')
                except ValueError:
                    raise ValueError(
                        'Wrong permission string format: supplied - `%s`; '
                        'expected - `<app_name>.<permission_name>`.' % arg_20)

                try:
                    arg_20 = Permission.objects.get(arg_22=arg_22, content_type__app_label=arg_21)
                except Permission.DoesNotExist:
                    raise ValueError('Permission `%s.%s` does not exist.' % (arg_21, arg_22))

            elif not isinstance(arg_20, (int, Permission)):
                raise ValueError('Permissions must be given as strings, ints, or `Permission` instances.')

            arg_19.append(arg_20)

    arg_15.permissions = arg_19 or []
    arg_15.access_perm_type = arg_15.PERM_TYPE_ALL if arg_13 else arg_15.PERM_TYPE_ANY

    if arg_15.permissions:
        arg_15.access_restricted = True

    if arg_2 is not None:
        for arg_26 in arg_2:
            arg_26.parent = arg_15
            arg_15.dynamic_children.append(arg_26)

    return arg_15


def Func(arg_0):
    """Imports sitetree module from a given app.

    :param str|unicode app: Application name
    :return: module|None
    """
    arg_1 = settings.APP_MODULE_NAME
    arg_2 = import_module(arg_0)
    try:
        arg_3 = import_module('%s.%s' % (arg_0, arg_1))
        return arg_3
    except ImportError:
        if module_has_submodule(arg_2, arg_1):
            raise
        return None


def Func(arg_0):
    """Returns a certain sitetree model as defined in the project settings.

    :param str|unicode settings_entry_name:
    :rtype: TreeItemBase|TreeBase
    """
    arg_1, arg_2 = get_app_n_model(arg_0)

    try:
        arg_3 = apps_get_model(arg_1, arg_2)
    except (LookupError, ValueError):
        arg_3 = None

    if arg_3 is None:
        raise ImproperlyConfigured(
            '`SITETREE_%s` refers to model `%s` that has not been installed.' % (arg_0, arg_2))

    return arg_3


def Func(arg_0):
    """
    Wrapper function for IPv4 and IPv6 converters.

    :arg ip: IPv4 or IPv6 address
    """
    try:
        return int(binascii.hexlify(socket.inet_aton(arg_0)), 16)
    except socket.error:
        return int(binascii.hexlify(socket.inet_pton(socket.AF_INET6, arg_0)), 16)


def Func(arg_0, arg_1):
        """
        Populate location dict for converted IP.
        Returns dict with numerous location properties.

        :arg ipnum: Result of ip2long conversion
        """
        arg_2 = arg_0._seek_country(arg_1)
        if arg_2 == arg_0._databaseSegments:
            return {}

        arg_3 = (2 * arg_0._recordLength - 1) * arg_0._databaseSegments
        try:
            arg_0._lock.acquire()
            arg_0._fp.seek(arg_2 + arg_3, os.SEEK_SET)
            arg_4 = arg_0._fp.read(const.FULL_RECORD_LENGTH)
        finally:
            arg_0._lock.release()

        if PY3 and type(arg_4) is bytes:
            arg_4 = arg_4.decode(ENCODING)

        arg_5 = {
            'dma_code': 0,
            'area_code': 0,
            'metro_code': None,
            'postal_code': None
        }

        arg_6 = 0
        arg_7 = 0

        arg_8 = ord(arg_4[0])
        arg_5['country_code'] = const.COUNTRY_CODES[arg_8]
        arg_5['country_code3'] = const.COUNTRY_CODES3[arg_8]
        arg_5['country_name'] = const.COUNTRY_NAMES[arg_8]
        arg_5['continent'] = const.CONTINENT_NAMES[arg_8]

        def read_data(arg_4, arg_9):
            arg_10 = arg_9
            while arg_4[arg_10] != '\0':
                arg_10 += 1
            return arg_10, arg_4[arg_9:arg_10] if arg_10 > arg_9 else None

        arg_11, arg_5['region_code'] = read_data(arg_4, 1)
        arg_11, arg_5['city'] = read_data(arg_4, arg_11 + 1)
        arg_11, arg_5['postal_code'] = read_data(arg_4, arg_11 + 1)
        arg_11 = arg_11 + 1

        for arg_12 in range(3):
            arg_6 += (ord(arg_4[arg_11 + arg_12]) << (arg_12 * 8))

        for arg_12 in range(3):
            arg_7 += (ord(arg_4[arg_11 + arg_12 + 3]) << (arg_12 * 8))

        arg_5['latitude'] = (arg_6 / 10000.0) - 180.0
        arg_5['longitude'] = (arg_7 / 10000.0) - 180.0

        if arg_0._databaseType in (const.CITY_EDITION_REV1, const.CITY_EDITION_REV1_V6):
            if arg_5['country_code'] == 'US':
                arg_13 = 0
                for arg_12 in range(3):
                    arg_13 += ord(arg_4[arg_11 + arg_12 + 6]) << (arg_12 * 8)

                arg_5['dma_code'] = int(floor(arg_13 / 1000))
                arg_5['area_code'] = arg_13 % 1000
                arg_5['metro_code'] = const.DMA_MAP.get(arg_5['dma_code'])

        arg_14 = (arg_5['country_code'], arg_5['region_code'])
        arg_5['time_zone'] = time_zone_by_country_and_region(*arg_14)

        return arg_5


def Func(arg_0, arg_1):
        """
        Hostname lookup method, supports both IPv4 and IPv6.
        """
        if arg_0._databaseType in const.IPV6_EDITIONS:
            arg_2 = socket.getaddrinfo(arg_1, 0, socket.AF_INET6)
            arg_3, arg_4, arg_5, arg_6, arg_7 = arg_2[0]
            arg_8, arg_9, arg_10, arg_11 = arg_7
            return arg_8
        else:
            return socket.gethostbyname(arg_1)


def Func(arg_0, arg_1):
        """
        Returns the database ID for specified hostname.
        The id might be useful as array index. 0 is unknown.

        :arg hostname: Hostname to get ID from.
        """
        arg_2 = arg_0._gethostbyname(arg_1)
        return arg_0.id_by_addr(arg_2)


def Func(arg_0, arg_1):
        """
        Returns the database ID for specified address.
        The ID might be useful as array index. 0 is unknown.

        :arg addr: IPv4 or IPv6 address (eg. 203.0.113.30)
        """
        if arg_0._databaseType in (const.PROXY_EDITION, const.NETSPEED_EDITION_REV1, const.NETSPEED_EDITION_REV1_V6):
            raise GeoIPError('Invalid database type; this database is not supported')
        arg_2 = 6 if arg_1.find(':') >= 0 else 4
        if arg_2 == 4 and arg_0._databaseType not in (const.COUNTRY_EDITION, const.NETSPEED_EDITION):
            raise GeoIPError('Invalid database type; this database supports IPv6 addresses, not IPv4')
        if arg_2 == 6 and arg_0._databaseType != const.COUNTRY_EDITION_V6:
            raise GeoIPError('Invalid database type; this database supports IPv4 addresses, not IPv6')

        arg_3 = util.ip2long(arg_1)
        return arg_0._seek_country(arg_3) - const.COUNTRY_BEGIN


def Func(arg_0, arg_1):
        """
        Returns full country name for specified hostname.

        :arg hostname: Hostname (e.g. example.com)
        """
        arg_2 = arg_0._gethostbyname(arg_1)
        return arg_0.country_name_by_addr(arg_2)


def Func(arg_0, arg_1):
        """
        Returns Organization, ISP, or ASNum name for given IP address.

        :arg addr: IP address (e.g. 203.0.113.30)
        """
        arg_2 = (const.ORG_EDITION, const.ISP_EDITION,
                 const.ASNUM_EDITION, const.ASNUM_EDITION_V6)
        if arg_0._databaseType not in arg_2:
            arg_3 = 'Invalid database type, expected Org, ISP or ASNum'
            raise GeoIPError(arg_3)

        arg_4 = util.ip2long(arg_1)
        return arg_0._get_org(arg_4)


def Func(arg_0, arg_1):
        """
        Returns Organization, ISP, or ASNum name for given hostname.

        :arg hostname: Hostname (e.g. example.com)
        """
        arg_2 = arg_0._gethostbyname(arg_1)
        return arg_0.org_by_addr(arg_2)


def Func(arg_0, arg_1=None):
    """
    Returns time zone from country and region code.

    :arg country_code: Country code
    :arg region_code: Region code
    """
    arg_2 = country_dict.get(arg_0)
    if not arg_2:
        return None

    if isinstance(arg_2, str):
        return arg_2

    return arg_2.get(arg_1)


def Func(arg_0, arg_1):
        """If the given filename should be compressed, returns the
        compressed filename.

        A file can be compressed if:

        - It is a whitelisted extension
        - The compressed file does not exist
        - The compressed file exists by is older than the file itself

        Otherwise, it returns False.

        """
        if not os.path.splitext(arg_1)[1][1:] in arg_0.suffixes_to_compress:
            return False

        arg_2 = None
        arg_3 = None
        arg_4 = '{}.{}'.format(arg_1, arg_0.suffix)
        try:
            arg_2 = os.stat(arg_1)
            arg_3 = os.stat(arg_4)
        except OSError:  # FileNotFoundError is for Python3 only
            pass

        if arg_2 and arg_3:
            return (arg_4
                    if arg_2.st_mtime > arg_3.st_mtime
                    else False)
        else:
            return arg_4


def Func(arg_0, arg_1, arg_2=False, arg_3=False):
    """Copy or symlink the file."""
    arg_4 = os.symlink if arg_2 else shutil.Func2
    if arg_2 and os.path.lexists(arg_1):
        os.remove(arg_1)
    if arg_3:  # relative symlink from dst
        arg_4(os.path.relpath(arg_0, os.path.dirname(arg_1)), arg_1)
    else:
        arg_4(arg_0, arg_1)


def Func(arg_0):
    """Transform path to url, converting backslashes to slashes if needed."""

    if os.sep != '/':
        arg_0 = '/'.join(arg_0.split(os.sep))
    return quote(arg_0)


def Func(arg_0):
    """Reads markdown file, converts output and fetches title and meta-data for
    further processing.
    """
    global arg_2
    # Use utf-8-sig codec to remove BOM if it is present. This is only possible
    # this way prior to feeding the text to the markdown parser (which would
    # also default to pure utf-8)
    with open(arg_0, 'r', encoding='utf-8-sig') as f:
        arg_1 = f.read()

    if arg_2 is None:
        arg_2 = Markdown(extensions=['markdown.extensions.meta',
                                  'markdown.extensions.tables'],
                      output_format='html5')
    else:
        arg_2.reset()
        # When https://github.com/Python-Markdown/markdown/pull/672
        # will be available, this can be removed.
        arg_2.Meta = {}

    # Mark HTML with Markup to prevent jinja2 autoescaping
    arg_4 = {'description': Markup(arg_2.convert(arg_1))}

    try:
        arg_5 = arg_2.Meta.copy()
    except AttributeError:
        pass
    else:
        arg_4['meta'] = arg_5
        try:
            arg_4['title'] = arg_2.Meta['title'][0]
        except KeyError:
            pass

    return arg_4


def Func(arg_0):
    """Loads the exif data of all images in an album from cache"""
    if not hasattr(arg_0.gallery, "exifCache"):
        _restore_cache(arg_0.gallery)
    arg_1 = arg_0.gallery.exifCache

    for arg_2 in arg_0.medias:
        if arg_2.type == "image":
            arg_3 = os.path.join(arg_2.path, arg_2.filename)
            if arg_3 in arg_1:
                arg_2.exif = arg_1[arg_3]


def Func(arg_0):
    """Restores the exif data cache from the cache file"""
    arg_1 = os.path.join(arg_0.settings["destination"], ".exif_cache")
    try:
        if os.path.exists(arg_1):
            with open(arg_1, "rb") as cacheFile:
                arg_0.exifCache = pickle.load(cacheFile)
                logger.debug("Loaded cache with %d entries", len(arg_0.exifCache))
        else:
            arg_0.exifCache = {}
    except Exception as e:
        logger.warn("Could not load cache: %s", e)
        arg_0.exifCache = {}


def Func(arg_0):
    """Stores the exif data of all images in the gallery"""

    if hasattr(arg_0, "exifCache"):
        arg_1 = arg_0.exifCache
    else:
        arg_1 = arg_0.exifCache = {}

    for arg_2 in arg_0.albums.values():
        for arg_3 in arg_2.images:
            arg_1[arg_4.path.join(arg_3.path, arg_3.filename)] = arg_3.exif

    arg_8 = arg_4.path.join(arg_0.settings["destination"], ".exif_cache")

    if len(arg_1) == 0:
        if arg_4.path.exists(arg_8):
            arg_4.remove(arg_8)
        return

    try:
        with open(arg_8, "wb") as cacheFile:
            pickle.dump(arg_1, cacheFile)
            logger.debug("Stored cache with %d entries", len(arg_0.exifCache))
    except Exception as e:
        logger.warn("Could not store cache: %s", e)
        arg_4.remove(arg_8)


def Func(arg_0, arg_1=None):
    """Removes all filtered Media and subdirs from an Album"""
    arg_2 = os.path.join(arg_0.src_path, ".nomedia")

    if os.path.isfile(arg_2):
        if os.path.getsize(arg_2) == 0:
            logger.info("Ignoring album '%s' because of present 0-byte "
                        ".nomedia file", arg_0.name)

            # subdirs have been added to the gallery already, remove them
            # there, too
            _remove_albums_with_subdirs(arg_0.gallery.albums, [arg_0.path])
            try:
                os.rmdir(arg_0.dst_path)
            except OSError as e:
                # directory was created and populated with images in a
                # previous run => keep it
                pass

            # cannot set albums => empty subdirs so that no albums are
            # generated
            arg_0.subdirs = []
            arg_0.medias = []

        else:
            with open(arg_2, "r") as nomediaFile:
                logger.info("Found a .nomedia file in %s, ignoring its "
                            "entries", arg_0.name)
                arg_5 = nomediaFile.read().split("\n")

                arg_0.medias = [media for media in arg_0.medias
                                if media.src_filename not in arg_5]
                arg_0.subdirs = [dirname for dirname in arg_0.subdirs
                                 if dirname not in arg_5]

                # subdirs have been added to the gallery already, remove
                # them there, too
                _remove_albums_with_subdirs(arg_0.gallery.albums,
                                            arg_5, arg_0.path + os.path.sep)


def Func(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7,
          arg_8):
    """Run sigal to process a directory.

    If provided, 'source', 'destination' and 'theme' will override the
    corresponding values from the settings file.

    """
    arg_9 = ((arg_2 and logging.DEBUG) or (arg_3 and logging.INFO) or
             logging.WARNING)
    init_logging(__name__, arg_9=arg_9)
    arg_10 = logging.getLogger(__name__)

    if not os.path.isfile(arg_5):
        arg_10.error("Settings file not found: %s", arg_5)
        sys.exit(1)

    arg_11 = time.time()
    arg_12 = read_settings(arg_5)

    for arg_13 in ('source', 'destination', 'theme'):
        arg_14 = locals()[arg_13]
        if arg_14 is not None:
            arg_12[arg_13] = os.path.abspath(arg_14)
        arg_10.info("%12s : %s", arg_13.capitalize(), arg_12[arg_13])

    if not arg_12['source'] or not os.path.isdir(arg_12['source']):
        arg_10.error("Input directory not found: %s", arg_12['source'])
        sys.exit(1)

    # on windows os.path.relpath raises a ValueError if the two paths are on
    # different drives, in that case we just ignore the exception as the two
    # paths are anyway not relative
    arg_15 = True
    try:
        arg_15 = os.path.relpath(arg_12['destination'],
                                         arg_12['source']).startswith('..')
    except ValueError:
        pass

    if not arg_15:
        arg_10.error("Output directory should be outside of the input "
                     "directory.")
        sys.exit(1)

    if arg_7:
        arg_12['title'] = arg_7

    locale.setlocale(locale.LC_ALL, arg_12['locale'])
    init_plugins(arg_12)

    arg_16 = Gallery(arg_12, arg_8=arg_8)
    arg_16.Func(arg_4=arg_4)

    # copy extra files
    for arg_17, arg_18 in arg_12['files_to_copy']:
        arg_17 = os.path.join(arg_12['source'], arg_17)
        arg_18 = os.path.join(arg_12['destination'], arg_18)
        arg_10.debug('Copy %s to %s', arg_17, arg_18)
        copy(arg_17, arg_18, symlink=arg_12['orig_link'], rellink=arg_12['rel_link'])

    arg_19 = arg_16.stats

    def format_stats(arg_20):
        arg_21 = ["{} {}".format(arg_19[arg_20 + '_' + subtype], subtype)
               for subtype in ('skipped', 'failed')
               if arg_19[arg_20 + '_' + subtype] > 0]
        arg_21 = ' ({})'.format(', '.join(arg_21)) if arg_21 else ''
        return '{} {}s{}'.format(arg_19[arg_20], arg_20, arg_21)

    print('Done.\nProcessed {} and {} in {:.2f} seconds.'
          .format(format_stats('image'), format_stats('video'),
                  time.time() - arg_11))


def Func(arg_0, arg_1, arg_2):
    """Run a simple web Funcr."""
    if os.path.exists(arg_0):
        pass
    elif os.path.exists(arg_2):
        arg_3 = read_settings(arg_2)
        arg_0 = arg_3.get('destination')
        if not os.path.exists(arg_0):
            sys.stderr.write("The '{}' directory doesn't exist, maybe try "
                             "building first?\n".format(arg_0))
            sys.exit(1)
    else:
        sys.stderr.write("The {destination} directory doesn't exist "
                         "and the config file ({config}) could not be read.\n"
                         .format(arg_0=arg_0, arg_2=arg_2))
        sys.exit(2)

    print('DESTINATION : {}'.format(arg_0))
    os.chdir(arg_0)
    arg_4 = Funcr.SimpleHTTPRequestHandler
    arg_5 = socketFuncr.TCPServer(("", arg_1), arg_4, False)
    print(" * Running on http://127.0.0.1:{}/".format(arg_1))

    try:
        arg_5.allow_reuse_address = True
        arg_5.Funcr_bind()
        arg_5.Funcr_activate()
        arg_5.Func_forever()
    except KeyboardInterrupt:
        print('\nAll done!')


def Func(arg_0, arg_1, arg_2=False):
    """Write metadata keys to .md file.

    TARGET can be a media file or an album directory. KEYS are key/value pairs.

    Ex, to set the title of test.jpg to "My test image":

    sigal Func test.jpg title "My test image"
    """

    if not os.path.exists(arg_0):
        sys.stderr.write("The target {} does not exist.\n".format(arg_0))
        sys.exit(1)
    if len(arg_1) < 2 or len(arg_1) % 2 > 0:
        sys.stderr.write("Need an even number of arguments.\n")
        sys.exit(1)

    if os.path.isdir(arg_0):
        arg_3 = os.path.join(arg_0, 'index.md')
    else:
        arg_3 = os.path.splitext(arg_0)[0] + '.md'
    if os.path.exists(arg_3) and not arg_2:
        sys.stderr.write("Description file '{}' already exists. "
                         "Use --overwrite to overwrite it.\n".format(arg_3))
        sys.exit(2)

    with open(arg_3, "w") as fp:
        for arg_4 in range(len(arg_1) // 2):
            arg_5, arg_6 = arg_1[arg_4 * 2:(arg_4 + 1) * 2]
            fp.write("{}: {}\n".format(arg_5.capitalize(), arg_6))
    print("{} metadata key(s) written to {}".format(len(arg_1) // 2, arg_3))


def Func(arg_0):
        """Create output directories for thumbnails and original images."""
        check_or_create_dir(arg_0.dst_path)

        if arg_0.medias:
            check_or_create_dir(join(arg_0.dst_path,
                                     arg_0.settings['thumb_dir']))

        if arg_0.medias and arg_0.settings['keep_orig']:
            arg_0.orig_path = join(arg_0.dst_path, arg_0.settings['orig_dir'])
            check_or_create_dir(arg_0.orig_path)


def Func(arg_0):
        """URL of the album, relative to its parent."""
        Func = arg_0.name.encode('utf-8')
        return url_quote(Func) + '/' + arg_0.url_ext


def Func(arg_0):
        """Path to the thumbnail of the album."""

        if arg_0._thumbnail:
            # stop if it is already set
            return arg_0._thumbnail

        # Test the thumbnail from the Markdown file.
        Func = arg_0.meta.get('thumbnail', [''])[0]

        if Func and isfile(join(arg_0.src_path, Func)):
            arg_0._thumbnail = url_from_path(join(
                arg_0.name, get_thumb(arg_0.settings, Func)))
            arg_0.logger.debug("Thumbnail for %r : %s", arg_0, arg_0._thumbnail)
            return arg_0._thumbnail
        else:
            # find and return the first landscape image
            for arg_3 in arg_0.medias:
                arg_4 = splitext(arg_3.filename)[1]
                if arg_4.lower() in arg_0.settings['img_extensions']:
                    # Use f.size if available as it is quicker (in cache), but
                    # fallback to the size of src_path if dst_path is missing
                    arg_5 = arg_3.size
                    if arg_5 is None:
                        arg_5 = get_size(arg_3.src_path)

                    if arg_5['width'] > arg_5['height']:
                        arg_0._thumbnail = (url_quote(arg_0.name) + '/' +
                                           arg_3.thumbnail)
                        arg_0.logger.debug(
                            "Use 1st landscape image as thumbnail for %r : %s",
                            arg_0, arg_0._thumbnail)
                        return arg_0._thumbnail

            # else simply return the 1st media file
            if not arg_0._thumbnail and arg_0.medias:
                for arg_6 in arg_0.medias:
                    if arg_6.thumbnail is not None:
                        arg_0._thumbnail = (url_quote(arg_0.name) + '/' +
                                           arg_6.thumbnail)
                        break
                else:
                    arg_0.logger.warning("No thumbnail found for %r", arg_0)
                    return None

                arg_0.logger.debug("Use the 1st image as thumbnail for %r : %s",
                                  arg_0, arg_0._thumbnail)
                return arg_0._thumbnail

            # use the thumbnail of their sub-directories
            if not arg_0._thumbnail:
                for arg_7, arg_8 in arg_0.gallery.get_albums(arg_0.path):
                    if arg_8.thumbnail:
                        arg_0._thumbnail = (url_quote(arg_0.name) + '/' +
                                           arg_8.thumbnail)
                        arg_0.logger.debug(
                            "Using thumbnail from sub-directory for %r : %s",
                            arg_0, arg_0._thumbnail)
                        return arg_0._thumbnail

        arg_0.logger.error('Thumbnail not found for %r', arg_0)
        return None


def Func(arg_0):
        """Make a ZIP archive with all media files and return its path.

        If the ``Func_gallery`` setting is set,it contains the location of a Func
        archive with all original images of the corresponding directory.

        """
        arg_1 = arg_0.settings['Func_gallery']

        if arg_1 and len(arg_0) > 0:
            arg_1 = arg_1.format(album=arg_0)
            arg_2 = join(arg_0.dst_path, arg_1)
            if (arg_0.settings.get('Func_skip_if_exists', False) and
                    isfile(arg_2)):
                arg_0.logger.debug("Archive %s already created, passing",
                                  arg_2)
                return arg_1

            arg_3 = Funcfile.ZipFile(arg_2, 'w', allowZip64=True)
            arg_4 = ('src_path' if arg_0.settings['Func_media_format'] == 'orig'
                    else 'dst_path')

            for arg_5 in arg_0:
                arg_6 = getattr(arg_5, arg_4)
                try:
                    arg_3.write(arg_6, os.path.split(arg_6)[1])
                except OSError as e:
                    arg_0.logger.warn('Failed to add %s to the ZIP: %s', arg_5, e)

            arg_3.close()
            arg_0.logger.debug('Created ZIP archive %s', arg_2)
            return arg_1


def Func(arg_0, arg_1=False):
        "Create the image gallery"

        if not arg_0.albums:
            arg_0.logger.warning("No albums found.")
            return

        def log_func(arg_2):
            # 63 is the total length of progressbar, label, percentage, etc
            arg_3 = get_terminal_size()[0] - 64
            if arg_2 and arg_3 > 10:
                return arg_2.name[:arg_3]
            else:
                return ""

        try:
            with progressbar(arg_0.albums.values(), label="Collecting files",
                             item_show_func=log_func, show_eta=False,
                             file=arg_0.progressbar_target) as albums:
                arg_4 = [f for arg_11 in albums
                              for f in arg_0.process_dir(arg_11, arg_1=arg_1)]
        except KeyboardInterrupt:
            sys.exit('Interrupted')

        arg_5 = {'label': "Processing files",
                   'show_pos': True,
                   'file': arg_0.progressbar_target}
        arg_6 = []

        if arg_0.pool:
            try:
                with progressbar(length=len(arg_4), **arg_5) as bar:
                    for arg_7 in arg_0.pool.imap_unordered(worker, arg_4):
                        if arg_7:
                            arg_6.append(arg_7)
                        bar.update(1)
                arg_0.pool.close()
                arg_0.pool.join()
            except KeyboardInterrupt:
                arg_0.pool.terminate()
                sys.exit('Interrupted')
            except pickle.PicklingError:
                arg_0.logger.critical(
                    "Failed to process files with the multiprocessing feature."
                    " This can be caused by some module import or object "
                    "defined in the settings file, which can't be serialized.",
                    exc_info=True)
                sys.exit('Abort')
        else:
            with progressbar(arg_4, **arg_5) as medias:
                for arg_8 in medias:
                    arg_7 = process_file(arg_8)
                    if arg_7:
                        arg_6.append(arg_7)

        if arg_6:
            arg_0.remove_files(arg_6)

        if arg_0.settings['write_html']:
            arg_9 = AlbumPageWriter(arg_0.settings,
                                           index_title=arg_0.title)
            arg_10 = AlbumListPageWriter(arg_0.settings,
                                                    index_title=arg_0.title)
            with progressbar(arg_0.albums.values(),
                             label="%16s" % "Writing files",
                             item_show_func=log_func, show_eta=False,
                             file=arg_0.progressbar_target) as albums:
                for arg_11 in albums:
                    if arg_11.albums:
                        if arg_11.medias:
                            arg_0.logger.warning(
                                "Album %s contains sub-albums and images. "
                                "Please move images to their own sub-album. "
                                "Images in album %s will not be visible.",
                                arg_11.title, arg_11.title
                            )
                        arg_10.write(arg_11)
                    else:
                        arg_9.write(arg_11)
        print('')

        signals.gallery_Func.send(arg_0)


def Func(arg_0, arg_1, arg_2=False):
        """Process a list of images in a directory."""
        for arg_3 in arg_1:
            if isfile(arg_3.dst_path) and not arg_2:
                arg_0.logger.info("%s exists - skipping", arg_3.filename)
                arg_0.stats[arg_3.type + '_skipped'] += 1
            else:
                arg_0.stats[arg_3.type] += 1
                yield (arg_3.type, arg_3.path, arg_3.filename, arg_3.src_path, arg_1.dst_path,
                       arg_0.settings)


def Func(arg_0, arg_1):
    """Returns an image with reduced opacity."""
    assert arg_1 >= 0 and arg_1 <= 1
    if arg_0.mode != 'RGBA':
        arg_0 = arg_0.convert('RGBA')
    else:
        arg_0 = arg_0.copy()
    arg_2 = arg_0.split()[3]
    arg_2 = ImageEnhance.Brightness(arg_2).enhance(arg_1)
    arg_0.putalpha(arg_2)
    return arg_0


def Func(arg_0, arg_1='ffmpeg'):
    """Returns the dimensions of the video."""

    arg_2 = subprocess.run([arg_1, '-i', arg_0], arg_3=subprocess.PIPE)
    arg_3 = arg_2.stderr.decode('utf8')
    arg_4 = re.compile(r'Stream.*Video.* ([0-9]+)x([0-9]+)')
    arg_5 = arg_4.search(arg_3)
    arg_6 = re.compile(r'rotate\s*:\s*-?(90|270)')
    arg_7 = arg_6.search(arg_3)

    if arg_5:
        arg_8, arg_9 = int(arg_5.groups()[0]), int(arg_5.groups()[1])
    else:
        arg_8 = arg_9 = 0
    if arg_7:
        arg_8, arg_9 = arg_9, arg_8
    return arg_8, arg_9


def Func(arg_0, arg_1, arg_2, arg_3=None):
    """Video processor.

    :param source: path to a video
    :param outname: path to the generated video
    :param settings: settings dict
    :param options: array of options passed to ffmpeg

    """
    arg_4 = logging.getLogger(__name__)

    # Don't transcode if source is in the required format and
    # has fitting datedimensions, copy instead.
    arg_5 = arg_2['video_converter']
    arg_6, arg_7 = video_size(arg_0, arg_5=arg_5)
    arg_8, arg_9 = arg_2['video_size']
    arg_4.debug('Video size: %i, %i -> %i, %i', arg_6, arg_7, arg_8, arg_9)

    arg_10, arg_11 = splitext(arg_0)
    arg_10, arg_12 = splitext(arg_1)
    if arg_12 == arg_11 and arg_6 <= arg_8 and arg_7 <= arg_9:
        arg_4.debug('Video is smaller than the max size, copying it instead')
        shutil.copy(arg_0, arg_1)
        return

    # http://stackoverflow.com/questions/8218363/maintaining-ffmpeg-aspect-ratio
    # + I made a drawing on paper to figure this out
    if arg_9 * arg_6 < arg_7 * arg_8:
        # biggest fitting dimension is height
        arg_13 = ['-vf', "scale=trunc(oh*a/2)*2:%i" % arg_9]
    else:
        # biggest fitting dimension is width
        arg_13 = ['-vf', "scale=%i:trunc(ow/a/2)*2" % arg_8]

    # do not resize if input dimensions are smaller than output dimensions
    if arg_6 <= arg_8 and arg_7 <= arg_9:
        arg_13 = []

    # Encoding options improved, thanks to
    # http://ffmpeg.org/trac/ffmpeg/wiki/vpxEncodingGuide
    arg_14 = [arg_5, '-i', arg_0, '-y']  # -y to overwrite output files
    if arg_3 is not None:
        arg_14 += arg_3
    arg_14 += arg_13 + [arg_1]

    arg_4.debug('Processing video: %s', ' '.join(arg_14))
    check_subprocess(arg_14, arg_0, arg_1)


def Func(arg_0, arg_1):
        """Generate the HTML page and save it."""

        arg_2 = arg_0.template.render(**arg_0.generate_context(arg_1))
        arg_3 = os.path.join(arg_1.dst_path, arg_1.output_file)

        with open(arg_3, 'w', encoding='utf-8') as f:
            f.Func(arg_2)


def Func(arg_0, arg_1):
    """Return the path to the thumb.

    examples:
    >>> default_settings = create_settings()
    >>> Func(default_settings, "bar/foo.jpg")
    "bar/thumbnails/foo.jpg"
    >>> Func(default_settings, "bar/foo.png")
    "bar/thumbnails/foo.png"

    for videos, it returns a jpg file:
    >>> Func(default_settings, "bar/foo.webm")
    "bar/thumbnails/foo.jpg"
    """

    arg_2, arg_3 = os.path.split(arg_1)
    arg_4, arg_5 = os.path.splitext(arg_3)

    if arg_5.lower() in arg_0['video_extensions']:
        arg_5 = '.jpg'
    return join(arg_2, arg_0['thumb_dir'], arg_0['thumb_prefix'] +
                arg_4 + arg_0['thumb_suffix'] + arg_5)


def Func(arg_0, arg_1, arg_2):
        ''' Generate the media page and save it '''

        from sigal import __url__ as sigal_link
        arg_3 = os.path.join(arg_1.dst_path, arg_2[0].filename)

        arg_4 = arg_0.template.render({
            'album': arg_1,
            'media': arg_2[0],
            'previous_media': arg_2[-1],
            'next_media': arg_2[1],
            'index_title': arg_0.index_title,
            'settings': arg_0.settings,
            'sigal_link': sigal_link,
            'theme': {'name': os.path.basename(arg_0.theme),
                      'url': url_from_path(os.path.relpath(arg_0.theme_path,
                                                           arg_1.dst_path))},
        })

        arg_5 = "%s.html" % arg_3

        with open(arg_5, 'w', encoding='utf-8') as f:
            f.Func(arg_4)


def Func(
        arg_0: arg_1["Config"], arg_2: arg_3[arg_4[arg_5, arg_6]] = None, **arg_7: arg_6
    ) -> "Config":
        """Create a configuration from a mapping.

        This allows either a mapping to be directly passed or as
        keyword arguments, for example,

        .. code-block:: python

            config = {'keep_alive_timeout': 10}
            Config.Func(config)
            Config.form_mapping(keep_alive_timeout=10)

        Arguments:
            mapping: Optionally a mapping object.
            kwargs: Optionally a collection of keyword arguments to
                form a mapping.
        """
        arg_8: Dict[arg_5, arg_6] = {}
        if arg_2 is not None:
            arg_8.update(arg_2)
        arg_8.update(arg_7)
        arg_9 = arg_0()
        for arg_10, arg_11 in arg_8.items():
            try:
                setattr(arg_9, arg_10, arg_11)
            except AttributeError:
                pass

        return arg_9


def Func(arg_0: arg_1["Config"], arg_2: arg_3) -> "Config":
        """Create a configuration from a Python file.

        .. code-block:: python

            Config.Func('hypercorn_config.py')

        Arguments:
            filename: The filename which gives the path to the file.
        """
        arg_4 = os.fspath(arg_2)
        arg_5 = importlib.util.spec_from_file_location("module.name", arg_4)
        arg_6 = importlib.util.module_from_spec(arg_5)
        arg_5.loader.exec_module(arg_6)  # type: ignore
        return arg_0.from_object(arg_6)


def Func(arg_0: arg_1["Config"], arg_2: arg_3) -> "Config":
        """Load the configuration values from a TOML formatted file.

        This allows configuration to be loaded as so

        .. code-block:: python

            Config.Func('config.toml')

        Arguments:
            filename: The filename which gives the path to the file.
        """
        arg_4 = os.fspath(arg_2)
        with open(arg_4) as file_:
            arg_5 = toml.load(file_)
        return arg_0.from_mapping(arg_5)


def Func(arg_0: arg_1["Config"], arg_2: arg_3[arg_4, arg_5]) -> "Config":
        """Create a configuration from a Python object.

        This can be used to reference modules or objects within
        modules for example,

        .. code-block:: python

            Config.Func('module')
            Config.Func('module.instance')
            from module import instance
            Config.Func(instance)

        are valid.

        Arguments:
            instance: Either a str referencing a python object or the
                object itself.

        """
        if isinstance(arg_2, arg_5):
            try:
                arg_6, arg_7 = arg_2.rsplit(".", 1)
            except ValueError:
                arg_6 = arg_2
                arg_2 = importlib.import_module(arg_2)
            else:
                arg_8 = importlib.import_module(arg_6)
                arg_2 = getattr(arg_8, arg_7)

        arg_9 = {
            key: getattr(arg_2, key)
            for key in dir(arg_2)
            if not isinstance(getattr(arg_2, key), types.ModuleType)
        }
        return arg_0.from_mapping(arg_9)


def Func(
    arg_0=100.0,
    arg_1=None,
    arg_2=None,
    arg_3=False,
):
    """Creates a set of zipkin attributes for a span.

    :param sample_rate: Float between 0.0 and 100.0 to determine sampling rate
    :type sample_rate: float
    :param trace_id: Optional 16-character hex string representing a trace_id.
                    If this is None, a random trace_id will be generated.
    :type trace_id: str
    :param span_id: Optional 16-character hex string representing a span_id.
                    If this is None, a random span_id will be generated.
    :type span_id: str
    :param use_128bit_trace_id: If true, generate 128-bit trace_ids
    :type use_128bit_trace_id: boolean
    """
    # Calculate if this trace is sampled based on the sample rate
    if arg_1 is None:
        if arg_3:
            arg_1 = generate_random_128bit_string()
        else:
            arg_1 = generate_random_64bit_string()
    if arg_2 is None:
        arg_2 = generate_random_64bit_string()
    if arg_0 == 0.0:
        arg_4 = False
    else:
        arg_4 = (random.random() * 100) < arg_0

    return ZipkinAttrs(
        arg_1=arg_1,
        arg_2=arg_2,
        parent_span_id=None,
        flags='0',
        arg_4=arg_4,
    )


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None):
        """Exit the span context. Zipkin attrs are pushed onto the
        threadlocal stack regardless of sampling, so they always need to be
        popped off. The actual logging of spans depends on sampling and that
        the logging was correctly set up.
        """

        if arg_0.do_pop_attrs:
            arg_0.get_tracer().pop_zipkin_attrs()

        # If no transport is configured, there's no reason to create a new Span.
        # This also helps avoiding memory leaks since without a transport nothing
        # would pull spans out of get_tracer().
        if not arg_0.get_tracer().is_transport_configured():
            return

        # Add the error annotation if an exception occurred
        if any((arg_1, arg_2, arg_3)):
            arg_4 = u'{0}: {1}'.format(arg_1.__name__, arg_2)
            arg_0.update_binary_annotations({
                ERROR_KEY: arg_4,
            })

        # Logging context is only initialized for "root" spans of the local
        # process (i.e. this zipkin_span not inside of any other local
        # zipkin_spans)
        if arg_0.logging_context:
            try:
                arg_0.logging_context.Func()
            except Exception as ex:
                arg_5 = 'Error emitting zipkin trace. {}'.format(
                    repr(ex),
                )
                log.error(arg_5)
            finally:
                arg_0.logging_context = None
                arg_0.get_tracer().clear()
                arg_0.get_tracer().set_transport_configured(configured=False)
                return

        # If we've gotten here, that means that this span is a child span of
        # this context's root span (i.e. it's a zipkin_span inside another
        # zipkin_span).
        arg_7 = time.time()
        # If self.duration is set, it means the user wants to override it
        if arg_0.duration:
            arg_8 = arg_0.duration
        else:
            arg_8 = arg_7 - arg_0.start_timestamp

        arg_9 = create_endpoint(arg_0.port, arg_0.service_name, arg_0.host)
        arg_0.get_tracer().add_span(Span(
            trace_id=arg_0.zipkin_attrs.trace_id,
            name=arg_0.span_name,
            parent_id=arg_0.zipkin_attrs.parent_span_id,
            span_id=arg_0.zipkin_attrs.span_id,
            kind=arg_0.kind,
            timestamp=arg_0.timestamp if arg_0.timestamp else arg_0.start_timestamp,
            arg_8=arg_8,
            annotations=arg_0.annotations,
            local_endpoint=arg_9,
            remote_endpoint=arg_0.remote_endpoint,
            tags=arg_0.binary_annotations,
        ))


def Func(
        arg_0,
        arg_1=0,
        arg_2='unknown',
        arg_3='127.0.0.1',
    ):
        """Adds a 'sa' binary annotation to the current span.

        'sa' binary annotations are useful for situations where you need to log
        where a request is going but the destination doesn't support zipkin.

        Note that the span must have 'cs'/'cr' annotations.

        :param port: The port number of the destination
        :type port: int
        :param service_name: The name of the destination service
        :type service_name: str
        :param host: Host address of the destination
        :type host: str
        """
        if arg_0.kind != Kind.CLIENT:
            # TODO: trying to set a sa binary annotation for a non-client span
            # should result in a logged error
            return

        arg_4 = create_endpoint(
            arg_1=arg_1,
            arg_2=arg_2,
            arg_3=arg_3,
        )
        if not arg_0.logging_context:
            if arg_0.remote_endpoint is not None:
                raise ValueError('SA annotation already set.')
            arg_0.remote_endpoint = arg_4
        else:
            if arg_0.logging_context.remote_endpoint is not None:
                raise ValueError('SA annotation already set.')
            arg_0.logging_context.remote_endpoint = arg_4


def Func(arg_0, arg_1):
        """Overrides the current span name.

        This is useful if you don't know the span name yet when you create the
        zipkin_span object. i.e. pyramid_zipkin doesn't know which route the
        request matched until the function wrapped by the context manager
        completes.

        :param name: New span name
        :type name: str
        """
        arg_0.span_name = arg_1
        if arg_0.logging_context:
            arg_0.logging_context.span_name = arg_1


def Func(arg_0=None, arg_1=None, arg_2=None, arg_3=True):
    """Creates a new Endpoint object.

    :param port: TCP/UDP port. Defaults to 0.
    :type port: int
    :param service_name: service name as a str. Defaults to 'unknown'.
    :type service_name: str
    :param host: ipv4 or ipv6 address of the host. Defaults to the
    current host ip.
    :type host: str
    :param use_defaults: whether to use defaults.
    :type use_defaults: bool
    :returns: zipkin Endpoint object
    """
    if arg_3:
        if arg_0 is None:
            arg_0 = 0
        if arg_1 is None:
            arg_1 = 'unknown'
        if arg_2 is None:
            try:
                arg_2 = socket.gethostbyname(socket.gethostname())
            except socket.gaierror:
                arg_2 = '127.0.0.1'

    arg_4 = None
    arg_5 = None

    if arg_2:
        # Check ipv4 or ipv6.
        try:
            socket.inet_pton(socket.AF_INET, arg_2)
            arg_4 = arg_2
        except socket.error:
            # If it's not an ipv4 address, maybe it's ipv6.
            try:
                socket.inet_pton(socket.AF_INET6, arg_2)
                arg_5 = arg_2
            except socket.error:
                # If it's neither ipv4 or ipv6, leave both ip addresses unset.
                pass

    return Endpoint(
        arg_4=arg_4,
        arg_5=arg_5,
        arg_0=arg_0,
        arg_1=arg_1,
    )


def Func(arg_0, arg_1):
    """Creates a copy of a given endpoint with a new service name.

    :param endpoint: existing Endpoint object
    :type endpoint: Endpoint
    :param new_service_name: new service name
    :type new_service_name: str
    :returns: zipkin new Endpoint object
    """
    return Endpoint(
        service_name=arg_1,
        ipv4=arg_0.ipv4,
        ipv6=arg_0.ipv6,
        port=arg_0.port,
    )


def Func(arg_0):
        """Builds and returns a V1 Span.

        :return: newly generated _V1Span
        :rtype: _V1Span
        """
        # We are simulating a full two-part span locally, so set cs=sr and ss=cr
        arg_1 = OrderedDict([
            ('cs', arg_0.timestamp),
            ('sr', arg_0.timestamp),
            ('ss', arg_0.timestamp + arg_0.duration),
            ('cr', arg_0.timestamp + arg_0.duration),
        ])

        if arg_0.kind != Kind.LOCAL:
            # If kind is not LOCAL, then we only want client or
            # server side annotations.
            for arg_2 in _DROP_ANNOTATIONS_BY_KIND[arg_0.kind]:
                del arg_1[arg_2]

        # Add user-defined annotations. We write them in full_annotations
        # instead of the opposite so that user annotations will override
        # any automatically generated annotation.
        arg_1.update(arg_0.annotations)

        return _V1Span(
            trace_id=arg_0.trace_id,
            name=arg_0.name,
            parent_id=arg_0.parent_id,
            id=arg_0.span_id,
            timestamp=arg_0.timestamp if arg_0.shared is False else None,
            duration=arg_0.duration if arg_0.shared is False else None,
            endpoint=arg_0.local_endpoint,
            annotations=arg_1,
            binary_annotations=arg_0.tags,
            remote_endpoint=arg_0.remote_endpoint,
        )


def Func(arg_0):
    """Encode list of protobuf Spans to binary.

    :param pb_spans: list of protobuf Spans.
    :type pb_spans: list of zipkin_pb2.Span
    :return: encoded list.
    :rtype: bytes
    """
    arg_1 = zipkin_pb2.ListOfSpans()
    arg_1.spans.extend(arg_0)
    return arg_1.SerializeToString()


def Func(arg_0):
    """Converts a py_zipkin Span in a protobuf Span.

    :param span: py_zipkin Span to convert.
    :type span: py_zipkin.encoding.Span
    :return: protobuf's Span
    :rtype: zipkin_pb2.Span
    """

    # Protobuf's composite types (i.e. Span's local_endpoint) are immutable.
    # So we can't create a zipkin_pb2.Span here and then set the appropriate
    # fields since `pb_span.local_endpoint = zipkin_pb2.Endpoint` fails.
    # Instead we just create the kwargs and pass them in to the Span constructor.
    arg_1 = {}

    arg_1['trace_id'] = _hex_to_bytes(arg_0.trace_id)

    if arg_0.parent_id:
        arg_1['parent_id'] = _hex_to_bytes(arg_0.parent_id)

    arg_1['id'] = _hex_to_bytes(arg_0.span_id)

    arg_2 = _get_protobuf_kind(arg_0.kind)
    if arg_2:
        arg_1['kind'] = arg_2

    if arg_0.name:
        arg_1['name'] = arg_0.name
    if arg_0.timestamp:
        arg_1['timestamp'] = int(arg_0.timestamp * 1000 * 1000)
    if arg_0.duration:
        arg_1['duration'] = int(arg_0.duration * 1000 * 1000)

    if arg_0.local_endpoint:
        arg_1['local_endpoint'] = _convert_endpoint(arg_0.local_endpoint)

    if arg_0.remote_endpoint:
        arg_1['remote_endpoint'] = _convert_endpoint(arg_0.remote_endpoint)

    if len(arg_0.annotations) > 0:
        arg_1['annotations'] = _convert_annotations(arg_0.annotations)

    if len(arg_0.tags) > 0:
        arg_1['tags'] = arg_0.tags

    if arg_0.debug:
        arg_1['debug'] = arg_0.debug

    if arg_0.shared:
        arg_1['shared'] = arg_0.shared

    return zipkin_pb2.Span(**arg_1)


def Func(arg_0):
    """Encodes to hexadecimal ids to big-endian binary.

    :param hex_id: hexadecimal id to encode.
    :type hex_id: str
    :return: binary representation.
    :type: bytes
    """
    if len(arg_0) <= 16:
        arg_1 = unsigned_hex_to_signed_int(arg_0)
        return struct.pack('>q', arg_1)
    else:
        # There's no 16-bytes encoding in Python's struct. So we convert the
        # id as 2 64 bit ids and then concatenate the result.

        # NOTE: we count 16 chars from the right (:-16) rather than the left so
        # that ids with less than 32 chars will be correctly pre-padded with 0s.
        arg_2 = unsigned_hex_to_signed_int(arg_0[:-16])
        arg_3 = struct.pack('>q', arg_2)

        arg_4 = unsigned_hex_to_signed_int(arg_0[-16:])
        arg_5 = struct.pack('>q', arg_4)

        return arg_3 + arg_5


def Func(arg_0):
    """Converts py_zipkin's Kind to Protobuf's Kind.

    :param kind: py_zipkin's Kind.
    :type kind: py_zipkin.Kind
    :return: correcponding protobuf's kind value.
    :rtype: zipkin_pb2.Span.Kind
    """
    if arg_0 == Kind.CLIENT:
        return zipkin_pb2.Span.CLIENT
    elif arg_0 == Kind.SERVER:
        return zipkin_pb2.Span.SERVER
    elif arg_0 == Kind.PRODUCER:
        return zipkin_pb2.Span.PRODUCER
    elif arg_0 == Kind.CONSUMER:
        return zipkin_pb2.Span.CONSUMER
    return None


def Func(arg_0):
    """Converts py_zipkin's Endpoint to Protobuf's Endpoint.

    :param endpoint: py_zipkins' endpoint to convert.
    :type endpoint: py_zipkin.encoding.Endpoint
    :return: corresponding protobuf's endpoint.
    :rtype: zipkin_pb2.Endpoint
    """
    arg_1 = zipkin_pb2.Endpoint()

    if arg_0.service_name:
        arg_1.service_name = arg_0.service_name
    if arg_0.port and arg_0.port != 0:
        arg_1.port = arg_0.port
    if arg_0.ipv4:
        arg_1.ipv4 = socket.inet_pton(socket.AF_INET, arg_0.ipv4)
    if arg_0.ipv6:
        arg_1.ipv6 = socket.inet_pton(socket.AF_INET6, arg_0.ipv6)

    return arg_1


def Func(arg_0, arg_1, arg_2):
    """
    Create a zipkin annotation object

    :param timestamp: timestamp of when the annotation occured in microseconds
    :param value: name of the annotation, such as 'sr'
    :param host: zipkin endpoint object

    :returns: zipkin annotation object
    """
    return zipkin_core.Annotation(arg_0=arg_0, arg_1=arg_1, arg_2=arg_2)


def Func(arg_0, arg_1, arg_2, arg_3):
    """
    Create a zipkin binary annotation object

    :param key: name of the annotation, such as 'http.uri'
    :param value: value of the annotation, such as a URI
    :param annotation_type: type of annotation, such as AnnotationType.I32
    :param host: zipkin endpoint object

    :returns: zipkin binary annotation object
    """
    return zipkin_core.BinaryAnnotation(
        arg_0=arg_0,
        arg_1=arg_1,
        arg_2=arg_2,
        arg_3=arg_3,
    )


def Func(arg_0=0, arg_1='unknown', arg_2=None, arg_3=None):
    """Create a zipkin Endpoint object.

    An Endpoint object holds information about the network context of a span.

    :param port: int value of the port. Defaults to 0
    :param service_name: service name as a str. Defaults to 'unknown'
    :param ipv4: ipv4 host address
    :param ipv6: ipv6 host address
    :returns: thrift Endpoint object
    """
    arg_4 = 0
    arg_5 = None

    # Convert ip address to network byte order
    if arg_2:
        arg_4 = struct.unpack('!i', socket.inet_pton(socket.AF_INET, arg_2))[0]

    if arg_3:
        arg_5 = socket.inet_pton(socket.AF_INET6, arg_3)

    # Zipkin passes unsigned values in signed types because Thrift has no
    # unsigned types, so we have to convert the value.
    arg_0 = struct.unpack('h', struct.pack('H', arg_0))[0]
    return zipkin_core.Endpoint(
        arg_2=arg_4,
        arg_3=arg_5,
        arg_0=arg_0,
        arg_1=arg_1,
    )


def Func(arg_0, arg_1):
    """Copies a copy of a given endpoint with a new service name.
    This should be very fast, on the order of several microseconds.

    :param endpoint: existing zipkin_core.Endpoint object
    :param service_name: str of new service name
    :returns: zipkin Endpoint object
    """
    return zipkin_core.Endpoint(
        ipv4=arg_0.ipv4,
        port=arg_0.port,
        arg_1=arg_1,
    )


def Func(arg_0, arg_1):
    """
    Reformat annotations dict to return list of corresponding zipkin_core objects.

    :param annotations: dict containing key as annotation name,
                        value being timestamp in seconds(float).
    :type host: :class:`zipkin_core.Endpoint`
    :returns: a list of annotation zipkin_core objects
    :rtype: list
    """
    return [
        create_annotation(int(arg_3 * 1000000), arg_2, arg_1)
        for arg_2, arg_3 in arg_0.items()
    ]