def Func(arg_0):
    """Decorator that produces DEBUG level log messages before and after
    calling a parser method.

    If a callback raises an IgnoredMatchException the log will show 'IGNORED'
    instead to indicate that the parser will not create any objects from
    the matched string.

    Example:
        DEBUG:poyo.parser:parse_simple <-     123: 456.789
        DEBUG:poyo.parser:parse_int <- 123
        DEBUG:poyo.parser:parse_int -> 123
        DEBUG:poyo.parser:parse_float <- 456.789
        DEBUG:poyo.parser:parse_float -> 456.789
        DEBUG:poyo.parser:parse_simple -> <Simple name: 123, value: 456.789>
    """

    def debug_log(arg_1):
        """Helper to log an escaped version of the given message to DEBUG"""
        logger.debug(arg_1.encode('unicode_escape').decode())

    @functools.wraps(arg_0)
    def _wrapper(arg_2, arg_3, **arg_4):
        arg_5 = arg_0.__name__

        debug_log(u'{func_name} <- {matched_string}'.format(
            arg_5=arg_5,
            matched_string=arg_3.group(),
        ))

        try:
            arg_6 = arg_0(arg_2, arg_3, **arg_4)
        except IgnoredMatchException:
            debug_log(u'{func_name} -> IGNORED'.format(arg_5=arg_5))
            raise

        debug_log(u'{func_name} -> {result}'.format(
            arg_5=arg_5,
            arg_6=arg_6,
        ))

        return arg_6
    return _wrapper


def Func(arg_0):
        """Try to find a pattern that matches the source and calll a parser
        method to create Python objects.

        A callback that raises an IgnoredMatchException indicates that the
        given string data is ignored by the parser and no objects are created.

        If none of the pattern match a NoMatchException is raised.
        """
        for arg_1, arg_2 in arg_0.rules:
            arg_3 = arg_1.match(arg_0.source, pos=arg_0.pos)

            if not arg_3:
                continue

            try:
                arg_4 = arg_2(arg_3)
            except IgnoredMatchException:
                pass
            else:
                arg_0.seen.append(arg_4)

            return arg_3

        raise NoMatchException(
            'None of the known patterns match for {}'
            ''.format(arg_0.source[arg_0.pos:])
        )


def Func(arg_0):
        """ get stats & show them """
        arg_0._output.write('\r')

        arg_1 = 'avg'
        arg_2 = {}
        for arg_3, arg_4 in arg_0._latencies_by_method.items():
            arg_5 = {}
            arg_5['count'] = len(arg_4)
            arg_5['avg'] = sum(arg_4) / len(arg_4)
            arg_5['min'] = min(arg_4)
            arg_5['max'] = max(arg_4)
            arg_4 = sorted(arg_4)
            arg_5['p90'] = percentile(arg_4, 0.90)
            arg_5['p95'] = percentile(arg_4, 0.95)
            arg_5['p99'] = percentile(arg_4, 0.99)
            arg_5['p999'] = percentile(arg_4, 0.999)
            arg_2[arg_3] = arg_5

        arg_6 = ['method', 'count', 'avg', 'min', 'max', 'p90', 'p95', 'p99', 'p999']
        arg_7 = []
        arg_2 = sorted(arg_2.items(), arg_3=lambda it: it[1][arg_1], reverse=True)

        def row(arg_3, arg_8):
            arg_7 = [arg_3] + [arg_8[header] for header in arg_6[1:]]
            return tuple(arg_7)

        arg_7 = [row(arg_3, arg_5) for arg_3, arg_5 in arg_2]

        arg_0._output.write('%s\n' % tabulate(arg_7, arg_6=arg_6))
        arg_0._output.flush()


def Func(arg_0, arg_1, arg_2):
        """
        Diff two thrift structs and return the result as a ThriftDiff instance
        """
        arg_3 = ThriftDiff(arg_1, arg_2)
        arg_3._do_diff()
        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Diff two thrift messages by comparing their args, raises exceptions if
        for some reason the messages can't be diffed. Only args of type 'struct'
        are compared.

        Returns a list of ThriftDiff results - one for each struct arg
        """
        arg_3, arg_4 = arg_0.can_diff(arg_1, arg_2)
        if not arg_3:
            raise ValueError(arg_4)
        return [arg_0.of_structs(arg_5.value, arg_6.value)
                for arg_5, arg_6 in zip(arg_1.args, arg_2.args)
                if arg_5.field_type == 'struct']


def Func(arg_0, arg_1):
        """
        Check if two thrift messages are diff ready.

        Returns a tuple of (boolean, reason_string), i.e. (False, reason_string)
        if the messages can not be diffed along with the reason and
        (True, None) for the opposite case
        """
        if arg_0.method != arg_1.method:
            return False, 'method name of messages do not match'
        if len(arg_0.args) != len(arg_1.args) \
                or not arg_0.args.is_isomorphic_to(arg_1.args):
            return False, 'argument signature of methods do not match'
        return True, None


def Func(arg_0, arg_1):
        """ Funcs packets with _at least_ nbytes of payload """
        arg_2 = 0
        arg_3 = []
        with arg_0._lock_packets:
            while arg_2 < arg_1:
                try:
                    arg_4 = arg_0._packets.Func(0)
                    arg_2 += len(arg_4.data.data)
                    arg_0._remaining -= len(arg_4.data.data)
                    arg_3.append(arg_4)
                except IndexError:
                    break
        return arg_3


def Func(arg_0, arg_1):
        """ similar to pop, but returns payload + last timestamp """
        arg_2 = 0
        arg_3 = []
        for arg_4 in arg_0.pop(arg_1):
            arg_2 = arg_4.timestamp
            arg_3.append(arg_4.data.data)

        return ''.join(arg_3), arg_2


def Func(arg_0, arg_1=None):
        """
        Save the given user configuration.
        """
        if arg_1 is None:
            arg_1 = arg_0._config_filename
        arg_2 = os.path.dirname(arg_1)
        if not os.path.isdir(arg_2):
            os.makedirs(arg_2)
        with open(arg_1, "w") as configfile:
            arg_0._config.write(configfile)


def Func(arg_0, arg_1=None, arg_2=True, arg_3=None):
        """Determine the username

        If a username is given, this name is used. Otherwise the configuration
        file will be consulted if `use_config` is set to True. The user is asked
        for the username if the username is not available. Then the username is
        stored in the configuration file.

        :param      username: Username (used directly if given)
        :type       username: ``str``

        :param      use_config: Whether to read username from configuration file
        :type       use_config: ``bool``

        :param      config_filename: Path to the configuration file
        :type       config_filename: ``str``

        """
        if not arg_1 and arg_2:
            if arg_0._config is None:
                arg_0._read_config(arg_3)
            arg_1 = arg_0._config.get("credentials", "username", fallback=None)

        if not arg_1:
            arg_1 = input("Please enter your username: ").strip()
            while not arg_1:
                arg_1 = input("No username specified. Please enter your username: ").strip()
            if 'credendials' not in arg_0._config:
                arg_0._config.add_section('credentials')
            arg_0._config.set("credentials", "username", arg_1)
            arg_0._save_config()

        return arg_1


def Func(arg_0, arg_1, arg_2=True, arg_3=None,
                      arg_4=arg_5):
        """
        Determine the user password

        If the password is given, this password is used. Otherwise
        this function will try to get the password from the user's keyring
        if `use_keyring` is set to True.

        :param      username: Username (used directly if given)
        :type       username: ``str``

        :param      use_config: Whether to read username from configuration file
        :type       use_config: ``bool``

        :param      config_filename: Path to the configuration file
        :type       config_filename: ``str``

        """
        if not arg_1 and arg_2:
            if arg_0._config is None:
                arg_0._read_config(arg_3)
            arg_1 = arg_0._config.get("credentials", "password", fallback=None)

        if not arg_1 and arg_4:
            arg_6 = logging.getLogger(__name__)
            arg_7 = ("Please enter your password for {} on {}: "
                        .format(arg_0.username, arg_0.host_base))
            if arg_5:
                arg_1 = keyring.get_password(arg_0.keyring_identificator, arg_0.username)
                if arg_1 is None:
                    arg_1 = getpass.getpass(arg_7)
                    try:
                        keyring.set_password(arg_0.keyring_identificator, arg_0.username, arg_1)
                    except keyring.errors.PasswordSetError as error:
                        arg_6.warning("Storing password in keyring '%s' failed: %s",
                                       arg_0.keyring_identificator, error)
            else:
                arg_6.warning("Install the 'keyring' Python module to store your password "
                               "securely in your keyring!")
                arg_1 = arg_0._config.get("credentials", "password", fallback=None)
                if arg_1 is None:
                    arg_1 = getpass.getpass(arg_7)
                    arg_8 = arg_0._config.get(
                        "preferences", "store-plaintext-passwords", fallback=None)
                    if arg_8 != "no":
                        arg_7 = ("Do you want to store your password in plain text in " +
                                    arg_0._config_filename())
                        arg_9 = ask(arg_7, ["yes", "no", "never"], "no")
                        if arg_9 == "yes":
                            arg_0._config.set("credentials", "password", arg_1)
                            arg_0._save_config()
                        elif arg_9 == "never":
                            if "preferences" not in arg_0._config:
                                arg_0._config.add_section("preferences")
                            arg_0._config.set("preferences", "store-plaintext-passwords", "no")
                            arg_0._save_config()

        return arg_1


def Func(arg_0, arg_1, arg_2=1):
        """
        Retrieves a data center by its ID.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_3 = arg_0._perform_request(
            '/datacenters/%s?depth=%s' % (arg_1, str(arg_2)))

        return arg_3


def Func(arg_0, arg_1, arg_2=1):
        """
        Retrieves a data center by its name.

        Either returns the data center response or raises an Exception
        if no or more than one data center was found with the name.
        The search for the name is done in this relaxing way:

        - exact name match
        - case-insentive name match
        - data center starts with the name
        - data center starts with the name  (case insensitive)
        - name appears in the data center name
        - name appears in the data center name (case insensitive)

        :param      name: The name of the data center.
        :type       name: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``
        """
        arg_3 = arg_0.list_datacenters(arg_2=arg_2)['items']
        arg_4 = find_item_by_name(arg_3, lambda i: i['properties']['name'], arg_1)
        if not arg_4:
            raise NameError("No data center found with name "
                            "containing '{name}'.".format(arg_1=arg_1))
        if len(arg_4) > 1:
            raise NameError("Found {n} data centers with the name '{name}': {names}".format(
                n=len(arg_4),
                arg_1=arg_1,
                names=", ".join(arg_5['properties']['name'] for arg_5 in arg_4)
            ))
        return arg_4[0]


def Func(arg_0, arg_1,
                          arg_2, arg_3, arg_4):
        """
        Retrieves a single firewall rule by ID.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      nic_id: The unique ID of the NIC.
        :type       nic_id: ``str``

        :param      firewall_rule_id: The unique ID of the firewall rule.
        :type       firewall_rule_id: ``str``

        """
        arg_5 = arg_0._perform_request(
            '/datacenters/%s/servers/%s/nics/%s/firewallrules/%s' % (
                arg_1,
                arg_2,
                arg_3,
                arg_4))

        return arg_5


def Func(arg_0, arg_1, arg_2,
                             arg_3, arg_4):
        """
        Removes a firewall rule from the NIC.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      nic_id: The unique ID of the NIC.
        :type       nic_id: ``str``

        :param      firewall_rule_id: The unique ID of the firewall rule.
        :type       firewall_rule_id: ``str``

        """
        arg_5 = arg_0._perform_request(
            url='/datacenters/%s/servers/%s/nics/%s/firewallrules/%s' % (
                arg_1,
                arg_2,
                arg_3,
                arg_4),
            method='DELETE')

        return arg_5


def Func(arg_0, arg_1, arg_2,
                             arg_3, arg_4):
        """
        Creates a firewall rule on the specified NIC and server.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      nic_id: The unique ID of the NIC.
        :type       nic_id: ``str``

        :param      firewall_rule: A firewall rule dict.
        :type       firewall_rule: ``dict``

        """
        arg_5 = {
            "name": arg_4.name
        }

        if arg_4.protocol:
            arg_5['protocol'] = arg_4.protocol

        # Optional Properties
        if arg_4.source_mac:
            arg_5['sourceMac'] = arg_4.source_mac

        if arg_4.source_ip:
            arg_5['sourceIp'] = arg_4.source_ip

        if arg_4.target_ip:
            arg_5['targetIp'] = arg_4.target_ip

        if arg_4.port_range_start:
            arg_5['portRangeStart'] = arg_4.port_range_start

        if arg_4.port_range_end:
            arg_5['portRangeEnd'] = arg_4.port_range_end

        if arg_4.icmp_type:
            arg_5['icmpType'] = arg_4.icmp_type

        if arg_4.icmp_code:
            arg_5['icmpCode'] = arg_4.icmp_code

        arg_6 = {
            "properties": arg_5
        }

        arg_7 = arg_0._perform_request(
            url='/datacenters/%s/servers/%s/nics/%s/firewallrules' % (
                arg_1,
                arg_2,
                arg_3),
            method='POST',
            arg_6=json.dumps(arg_6))

        return arg_7


def Func(arg_0, arg_1, arg_2,
                             arg_3, arg_4, **arg_5):
        """
        Updates a firewall rule.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      nic_id: The unique ID of the NIC.
        :type       nic_id: ``str``

        :param      firewall_rule_id: The unique ID of the firewall rule.
        :type       firewall_rule_id: ``str``

        """
        arg_6 = {}

        for arg_7, arg_8 in arg_5.items():
            arg_6[arg_0._underscore_to_camelcase(arg_7)] = arg_8

            if arg_7 == 'source_mac':
                arg_6['sourceMac'] = arg_8
            elif arg_7 == 'source_ip':
                arg_6['sourceIp'] = arg_8
            elif arg_7 == 'target_ip':
                arg_6['targetIp'] = arg_8
            elif arg_7 == 'port_range_start':
                arg_6['portRangeStart'] = arg_8
            elif arg_7 == 'port_range_end':
                arg_6['portRangeEnd'] = arg_8
            elif arg_7 == 'icmp_type':
                arg_6['icmpType'] = arg_8
            elif arg_7 == 'icmp_code':
                arg_6['icmpCode'] = arg_8
            else:
                arg_6[arg_0._underscore_to_camelcase(arg_7)] = arg_8

        arg_10 = arg_0._perform_request(
            url='/datacenters/%s/servers/%s/nics/%s/firewallrules/%s' % (
                arg_1,
                arg_2,
                arg_3,
                arg_4),
            method='PATCH',
            arg_6=json.dumps(arg_6))

        return arg_10


def Func(arg_0, arg_1):
        """
        Removes only user created images.

        :param      image_id: The unique ID of the image.
        :type       image_id: ``str``

        """
        arg_2 = arg_0._perform_request(url='/images/' + arg_1,
                                         method='DELETE')
        return arg_2


def Func(arg_0, arg_1, **arg_2):
        """
        Replace all properties of an image.

        """
        arg_3 = {}

        for arg_4, arg_5 in arg_2.items():
            arg_3[arg_0._underscore_to_camelcase(arg_4)] = arg_5

        arg_7 = arg_0._perform_request(url='/images/' + arg_1,
                                         method='PATCH',
                                         arg_3=json.dumps(arg_3))
        return arg_7


def Func(arg_0, arg_1):
        """
        Reserves an IP block within your account.

        """
        arg_2 = {
            "name": arg_1.name
        }

        if arg_1.location:
            arg_2['location'] = arg_1.location

        if arg_1.size:
            arg_2['size'] = str(arg_1.size)

        arg_3 = {
            "properties": arg_2,
        }

        arg_4 = arg_0._perform_request(
            url='/ipblocks', method='POST', data=json.dumps(arg_3))

        return arg_4


def Func(arg_0, arg_1, arg_2, arg_3=1):
        """
        Retrieves a single LAN by ID.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      lan_id: The unique ID of the LAN.
        :type       lan_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_4 = arg_0._perform_request(
            '/datacenters/%s/lans/%s?depth=%s' % (
                arg_1,
                arg_2,
                str(arg_3)))

        return arg_4


def Func(arg_0, arg_1, arg_2=1):
        """
        Retrieves a list of LANs available in the account.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_3 = arg_0._perform_request(
            '/datacenters/%s/lans?depth=%s' % (
                arg_1,
                str(arg_2)))

        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Removes a LAN from the data center.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      lan_id: The unique ID of the LAN.
        :type       lan_id: ``str``

        """
        arg_3 = arg_0._perform_request(
            url='/datacenters/%s/lans/%s' % (
                arg_1, arg_2), method='DELETE')

        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Creates a LAN in the data center.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      lan: The LAN object to be created.
        :type       lan: ``dict``

        """
        arg_3 = json.dumps(arg_0._Func_dict(arg_2))

        arg_4 = arg_0._perform_request(
            url='/datacenters/%s/lans' % arg_1,
            method='POST',
            arg_3=arg_3)

        return arg_4


def Func(arg_0, arg_1, arg_2, arg_3=1):
        """
        Retrieves the list of NICs that are part of the LAN.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      lan_id: The unique ID of the LAN.
        :type       lan_id: ``str``

        """
        arg_4 = arg_0._perform_request(
            '/datacenters/%s/lans/%s/nics?depth=%s' % (
                arg_1,
                arg_2,
                str(arg_3)))

        return arg_4


def Func(arg_0, arg_1, arg_2):
        """
        Retrieves a single load balancer by ID.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      loadbalancer_id: The unique ID of the load balancer.
        :type       loadbalancer_id: ``str``

        """
        arg_3 = arg_0._perform_request(
            '/datacenters/%s/loadbalancers/%s' % (
                arg_1, arg_2))

        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Removes the load balancer from the data center.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      loadbalancer_id: The unique ID of the load balancer.
        :type       loadbalancer_id: ``str``

        """
        arg_3 = arg_0._perform_request(
            url='/datacenters/%s/loadbalancers/%s' % (
                arg_1, arg_2), method='DELETE')

        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Creates a load balancer within the specified data center.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      loadbalancer: The load balancer object to be created.
        :type       loadbalancer: ``dict``

        """
        arg_3 = json.dumps(arg_0._Func_dict(arg_2))

        arg_4 = arg_0._perform_request(
            url='/datacenters/%s/loadbalancers' % arg_1,
            method='POST',
            arg_3=arg_3)

        return arg_4


def Func(arg_0, arg_1,
                            arg_2, **arg_3):
        """
        Updates a load balancer

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      loadbalancer_id: The unique ID of the load balancer.
        :type       loadbalancer_id: ``str``

        """
        arg_4 = {}

        for arg_5, arg_6 in arg_3.items():
            arg_4[arg_0._underscore_to_camelcase(arg_5)] = arg_6

        arg_8 = arg_0._perform_request(
            url='/datacenters/%s/loadbalancers/%s' % (arg_1,
                                                      arg_2),
            method='PATCH',
            arg_4=json.dumps(arg_4))

        return arg_8


def Func(arg_0, arg_1,
                              arg_2, arg_3):
        """
        Associates a NIC with the given load balancer.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      loadbalancer_id: The unique ID of the load balancer.
        :type       loadbalancer_id: ``str``

        :param      nic_id: The ID of the NIC.
        :type       nic_id: ``str``

        """
        arg_4 = '{ "id": "' + arg_3 + '" }'

        arg_5 = arg_0._perform_request(
            url='/datacenters/%s/loadbalancers/%s/balancednics' % (
                arg_1,
                arg_2),
            method='POST',
            arg_4=arg_4)

        return arg_5


def Func(arg_0, arg_1,
                             arg_2, arg_3, arg_4=1):
        """
        Gets the properties of a load balanced NIC.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      loadbalancer_id: The unique ID of the load balancer.
        :type       loadbalancer_id: ``str``

        :param      nic_id: The unique ID of the NIC.
        :type       nic_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_5 = arg_0._perform_request(
            '/datacenters/%s/loadbalancers/%s/balancednics/%s?depth=%s' % (
                arg_1,
                arg_2,
                arg_3,
                str(arg_4)))

        return arg_5


def Func(arg_0, arg_1, arg_2, arg_3, arg_4=1):
        """
        Retrieves a NIC by its ID.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      nic_id: The unique ID of the NIC.
        :type       nic_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_5 = arg_0._perform_request(
            '/datacenters/%s/servers/%s/nics/%s?depth=%s' % (
                arg_1,
                arg_2,
                arg_3,
                str(arg_4)))

        return arg_5


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Creates a NIC on the specified server.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      nic: A NIC dict.
        :type       nic: ``dict``

        """

        arg_4 = json.dumps(arg_0._Func_dict(arg_3))

        arg_5 = arg_0._perform_request(
            url='/datacenters/%s/servers/%s/nics' % (
                arg_1,
                arg_2),
            method='POST',
            arg_4=arg_4)

        return arg_5


def Func(arg_0, arg_1, arg_2=False):
        """
        Retrieves a single request by ID.

        :param      request_id: The unique ID of the request.
        :type       request_id: ``str``

        :param      status: Retreive the full status of the request.
        :type       status: ``bool``

        """
        if arg_2:
            arg_3 = arg_0._perform_request(
                '/requests/' + arg_1 + '/status')
        else:
            arg_3 = arg_0._perform_request(
                '/requests/%s' % arg_1)

        return arg_3


def Func(arg_0, arg_1, arg_2, arg_3=1):
        """
        Retrieves a server by its ID.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_4 = arg_0._perform_request(
            '/datacenters/%s/servers/%s?depth=%s' % (
                arg_1,
                arg_2,
                str(arg_3)))

        return arg_4


def Func(arg_0, arg_1, arg_2):
        """
        Removes the server from your data center.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        """
        arg_3 = arg_0._perform_request(
            url='/datacenters/%s/servers/%s' % (
                arg_1,
                arg_2),
            method='DELETE')

        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Creates a server within the data center.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server: A dict of the server to be created.
        :type       server: ``dict``

        """

        arg_3 = json.dumps(arg_0._Func_dict(arg_2))

        arg_4 = arg_0._perform_request(
            url='/datacenters/%s/servers' % (arg_1),
            method='POST',
            arg_3=arg_3)

        return arg_4


def Func(arg_0, arg_1, arg_2, **arg_3):
        """
        Updates a server with the parameters provided.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        """
        arg_4 = {}

        for arg_5, arg_6 in arg_3.items():
            if arg_5 == 'boot_volume':
                arg_7 = {
                    "id": arg_6
                }
                arg_8 = {
                    "bootVolume": arg_7
                }
                arg_4.update(arg_8)
            else:
                arg_4[arg_0._underscore_to_camelcase(arg_5)] = arg_6

        arg_10 = arg_0._perform_request(
            url='/datacenters/%s/servers/%s' % (
                arg_1,
                arg_2),
            method='PATCH',
            arg_4=json.dumps(arg_4))

        return arg_10


def Func(arg_0, arg_1, arg_2, arg_3=1):
        """
        Retrieves a list of volumes attached to the server.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_4 = arg_0._perform_request(
            '/datacenters/%s/servers/%s/volumes?depth=%s' % (
                arg_1,
                arg_2,
                str(arg_3)))

        return arg_4


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Retrieves volume information.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      volume_id: The unique ID of the volume.
        :type       volume_id: ``str``

        """
        arg_4 = arg_0._perform_request(
            '/datacenters/%s/servers/%s/volumes/%s' % (
                arg_1,
                arg_2,
                arg_3))

        return arg_4


def Func(arg_0, arg_1, arg_2, arg_3=1):
        """
        Retrieves a list of CDROMs attached to the server.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_4 = arg_0._perform_request(
            '/datacenters/%s/servers/%s/cdroms?depth=%s' % (
                arg_1,
                arg_2,
                str(arg_3)))

        return arg_4


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Retrieves an attached CDROM.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        :param      cdrom_id: The unique ID of the CDROM.
        :type       cdrom_id: ``str``

        """
        arg_4 = arg_0._perform_request(
            '/datacenters/%s/servers/%s/cdroms/%s' % (
                arg_1,
                arg_2,
                arg_3))

        return arg_4


def Func(arg_0, arg_1, arg_2):
        """
        Starts the server.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        """
        arg_3 = arg_0._perform_request(
            url='/datacenters/%s/servers/%s/start' % (
                arg_1,
                arg_2),
            method='POST-ACTION')

        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Stops the server.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      server_id: The unique ID of the server.
        :type       server_id: ``str``

        """
        arg_3 = arg_0._perform_request(
            url='/datacenters/%s/servers/%s/stop' % (
                arg_1,
                arg_2),
            method='POST-ACTION')

        return arg_3


def Func(arg_0, arg_1, arg_2,
                        arg_3=None, arg_4=None):
        """
        Creates a snapshot of the specified volume.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      volume_id: The unique ID of the volume.
        :type       volume_id: ``str``

        :param      name: The name given to the volume.
        :type       name: ``str``

        :param      description: The description given to the volume.
        :type       description: ``str``

        """

        arg_5 = {'name': arg_3, 'description': arg_4}

        arg_6 = arg_0._perform_request(
            '/datacenters/%s/volumes/%s/create-snapshot' % (
                arg_1, arg_2),
            method='POST-ACTION-JSON',
            arg_5=urlencode(arg_5))

        return arg_6


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Restores a snapshot to the specified volume.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      volume_id: The unique ID of the volume.
        :type       volume_id: ``str``

        :param      snapshot_id: The unique ID of the snapshot.
        :type       snapshot_id: ``str``

        """
        arg_4 = {'snapshotId': arg_3}

        arg_5 = arg_0._perform_request(
            url='/datacenters/%s/volumes/%s/restore-snapshot' % (
                arg_1,
                arg_2),
            method='POST-ACTION',
            arg_4=urlencode(arg_4))

        return arg_5


def Func(arg_0, arg_1):
        """
        Removes a snapshot.

        :param      snapshot_id: The ID of the snapshot
                                 you wish to remove.
        :type       snapshot_id: ``str``

        """
        arg_2 = arg_0._perform_request(
            url='/snapshots/' + arg_1, method='DELETE')

        return arg_2


def Func(arg_0, arg_1, arg_2=1):
        """
        Retrieves a single group by ID.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_3 = arg_0._perform_request(
            '/um/groups/%s?depth=%s' % (arg_1, str(arg_2)))

        return arg_3


def Func(arg_0, arg_1):
        """
        Creates a new group and set group privileges.

        :param      group: The group object to be created.
        :type       group: ``dict``

        """
        arg_2 = json.dumps(arg_0._Func_dict(arg_1))

        arg_3 = arg_0._perform_request(
            url='/um/groups',
            method='POST',
            arg_2=arg_2)

        return arg_3


def Func(arg_0, arg_1, **arg_2):
        """
        Updates a group.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        """
        arg_3 = {}

        # make the key camel-case transformable
        if 'create_datacenter' in arg_2:
            arg_2['create_data_center'] = arg_2.pop('create_datacenter')

        for arg_4, arg_5 in arg_2.items():
            arg_3[arg_0._underscore_to_camelcase(arg_4)] = arg_5

        arg_7 = {
            "properties": arg_3
        }

        arg_8 = arg_0._perform_request(
            url='/um/groups/%s' % arg_1,
            method='PUT',
            arg_7=json.dumps(arg_7))

        return arg_8


def Func(arg_0, arg_1):
        """
        Removes a group.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        """
        arg_2 = arg_0._perform_request(
            url='/um/groups/%s' % arg_1,
            method='DELETE')

        return arg_2


def Func(arg_0, arg_1, arg_2=1):
        """
        Retrieves a list of all shares though a group.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_3 = arg_0._perform_request(
            '/um/groups/%s/shares?depth=%s' % (arg_1, str(arg_2)))

        return arg_3


def Func(arg_0, arg_1, arg_2, arg_3=1):
        """
        Retrieves a specific resource share available to a group.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        :param      resource_id: The unique ID of the resource.
        :type       resource_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_4 = arg_0._perform_request(
            '/um/groups/%s/shares/%s?depth=%s'
            % (arg_1, arg_2, str(arg_3)))

        return arg_4


def Func(arg_0, arg_1, arg_2, **arg_3):
        """
        Shares a resource through a group.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        :param      resource_id: The unique ID of the resource.
        :type       resource_id: ``str``

        """
        arg_4 = {}

        for arg_5, arg_6 in arg_3.items():
            arg_4[arg_0._underscore_to_camelcase(arg_5)] = arg_6

        arg_8 = {
            "properties": arg_4
        }

        arg_9 = arg_0._perform_request(
            url='/um/groups/%s/shares/%s' % (arg_1, arg_2),
            method='POST',
            arg_8=json.dumps(arg_8))

        return arg_9


def Func(arg_0, arg_1, arg_2):
        """
        Removes a resource share from a group.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        :param      resource_id: The unique ID of the resource.
        :type       resource_id: ``str``

        """
        arg_3 = arg_0._perform_request(
            url='/um/groups/%s/shares/%s' % (arg_1, arg_2),
            method='DELETE')

        return arg_3


def Func(arg_0, arg_1, arg_2=1):
        """
        Retrieves a single user by ID.

        :param      user_id: The unique ID of the user.
        :type       user_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_3 = arg_0._perform_request(
            '/um/users/%s?depth=%s' % (arg_1, str(arg_2)))

        return arg_3


def Func(arg_0, arg_1):
        """
        Creates a new user.

        :param      user: The user object to be created.
        :type       user: ``dict``

        """
        arg_2 = arg_0._Func_dict(arg_1=arg_1)

        arg_3 = arg_0._perform_request(
            url='/um/users',
            method='POST',
            arg_2=json.dumps(arg_2))

        return arg_3


def Func(arg_0, arg_1):
        """
        Removes a user.

        :param      user_id: The unique ID of the user.
        :type       user_id: ``str``

        """
        arg_2 = arg_0._perform_request(
            url='/um/users/%s' % arg_1,
            method='DELETE')

        return arg_2


def Func(arg_0, arg_1, arg_2=1):
        """
        Retrieves a list of all users that are members of a particular group.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_3 = arg_0._perform_request(
            '/um/groups/%s/users?depth=%s' % (arg_1, str(arg_2)))

        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Adds an existing user to a group.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        :param      user_id: The unique ID of the user.
        :type       user_id: ``str``

        """
        arg_3 = {
            "id": arg_2
        }

        arg_4 = arg_0._perform_request(
            url='/um/groups/%s/users' % arg_1,
            method='POST',
            arg_3=json.dumps(arg_3))

        return arg_4


def Func(arg_0, arg_1, arg_2):
        """
        Removes a user from a group.

        :param      group_id: The unique ID of the group.
        :type       group_id: ``str``

        :param      user_id: The unique ID of the user.
        :type       user_id: ``str``

        """
        arg_3 = arg_0._perform_request(
            url='/um/groups/%s/users/%s' % (arg_1, arg_2),
            method='DELETE')

        return arg_3


def Func(arg_0, arg_1=None, arg_2=1):
        """
        Retrieves a list of all resources.

        :param      resource_type: The resource type: datacenter, image,
                                   snapshot or ipblock. Default is None,
                                   i.e., all resources are listed.
        :type       resource_type: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        if arg_1 is not None:
            arg_3 = arg_0._perform_request(
                '/um/resources/%s?depth=%s' % (arg_1, str(arg_2)))
        else:
            arg_3 = arg_0._perform_request(
                '/um/resources?depth=' + str(arg_2))

        return arg_3


def Func(arg_0, arg_1, arg_2, arg_3=1):
        """
        Retrieves a single resource of a particular type.

        :param      resource_type: The resource type: datacenter, image,
                                   snapshot or ipblock.
        :type       resource_type: ``str``

        :param      resource_id: The unique ID of the resource.
        :type       resource_id: ``str``

        :param      depth: The depth of the response data.
        :type       depth: ``int``

        """
        arg_4 = arg_0._perform_request(
            '/um/resources/%s/%s?depth=%s' % (
                arg_1, arg_2, str(arg_3)))

        return arg_4


def Func(arg_0, arg_1, arg_2):
        """
        Retrieves a single volume by ID.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      volume_id: The unique ID of the volume.
        :type       volume_id: ``str``

        """
        arg_3 = arg_0._perform_request(
            '/datacenters/%s/volumes/%s' % (arg_1, arg_2))

        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Creates a volume within the specified data center.

        :param      datacenter_id: The unique ID of the data center.
        :type       datacenter_id: ``str``

        :param      volume: A volume dict.
        :type       volume: ``dict``

        """

        arg_3 = (json.dumps(arg_0._Func_dict(arg_2)))

        arg_4 = arg_0._perform_request(
            url='/datacenters/%s/volumes' % arg_1,
            method='POST',
            arg_3=arg_3)

        return arg_4


def Func(arg_0, arg_1, arg_2=3600, arg_3=5, arg_4=10):
        """
        Poll resource request status until resource is provisioned.

        :param      response: A response dict, which needs to have a 'requestId' item.
        :type       response: ``dict``

        :param      timeout: Maximum waiting time in seconds. None means infinite waiting time.
        :type       timeout: ``int``

        :param      initial_wait: Initial polling interval in seconds.
        :type       initial_wait: ``int``

        :param      scaleup: Double polling interval every scaleup steps, which will be doubled.
        :type       scaleup: ``int``

        """
        if not arg_1:
            return
        arg_5 = logging.getLogger(__name__)
        arg_6 = arg_3
        arg_7 = time.time() + arg_6 * arg_4
        if arg_2:
            arg_2 = time.time() + arg_2
        while True:
            arg_8 = arg_0.get_request(request_id=arg_1['requestId'], status=True)

            if arg_8['metadata']['status'] == 'DONE':
                break
            elif arg_8['metadata']['status'] == 'FAILED':
                raise PBFailedRequest(
                    'Request {0} failed to complete: {1}'.format(
                        arg_1['requestId'], arg_8['metadata']['message']),
                    arg_1['requestId']
                )

            arg_9 = time.time()
            if arg_2 and arg_9 > arg_2:
                raise PBTimeoutError('Timed out waiting for request {0}.'.format(
                    arg_1['requestId']), arg_1['requestId'])

            if arg_9 > arg_7:
                arg_6 *= 2
                arg_7 = time.time() + arg_6 * arg_4
                arg_4 *= 2

            arg_5.info("Request %s is in state '%s'. Sleeping for %i seconds...",
                        arg_1['requestId'], arg_8['metadata']['status'], arg_6)
            time.sleep(arg_6)


def Func(arg_0):
        """
        Convert Python snake case back to mixed case.
        """
        def camelcase():
            yield str.lower
            while True:
                yield str.capitalize

        arg_1 = camelcase()
        return "".join(next(arg_1)(arg_2) if arg_2 else '_' for arg_2 in arg_0.split("_"))


def Func(arg_0, arg_1, arg_2):
    """
    Find a item a given list by a matching name.

    The search for the name is done in this relaxing way:

    - exact name match
    - case-insentive name match
    - attribute starts with the name
    - attribute starts with the name (case insensitive)
    - name appears in the attribute
    - name appears in the attribute (case insensitive)

    :param    list_: A list of elements
    :type     list_: ``list``

    :param    namegetter: Function that returns the name for a given
                          element in the list
    :type     namegetter: ``function``

    :param    name: Name to search for
    :type     name: ``str``

    """
    arg_3 = [i for i in arg_0 if arg_1(i) == arg_2]
    if not arg_3:
        arg_4 = re.compile(re.escape(arg_2) + '$', re.IGNORECASE)
        arg_3 = [i for i in arg_0 if arg_4.match(arg_1(i))]
    if not arg_3:
        arg_4 = re.compile(re.escape(arg_2))
        arg_3 = [i for i in arg_0 if arg_4.match(arg_1(i))]
    if not arg_3:
        arg_4 = re.compile(re.escape(arg_2), re.IGNORECASE)
        arg_3 = [i for i in arg_0 if arg_4.match(arg_1(i))]
    if not arg_3:
        arg_4 = re.compile(re.escape(arg_2))
        arg_3 = [i for i in arg_0 if arg_4.search(arg_1(i))]
    if not arg_3:
        arg_4 = re.compile(re.escape(arg_2), re.IGNORECASE)
        arg_3 = [i for i in arg_0 if arg_4.search(arg_1(i))]
    return arg_3


def Func(arg_0=None, arg_1=None):
    ''' gets info of servers of a data center'''
    if arg_0 is None:
        raise ValueError("argument 'pbclient' must not be None")
    if arg_1 is None:
        raise ValueError("argument 'dc_id' must not be None")
    # list of all found server's info
    arg_2 = []
    # depth 1 is enough for props/meta
    arg_3 = arg_0.list_servers(arg_1, 1)
    for arg_4 in arg_3['items']:
        arg_5 = arg_4['properties']
        arg_6 = dict(id=arg_4['id'], name=arg_5['name'],
                    state=arg_4['metadata']['state'],
                    vmstate=arg_5['vmState'])
        arg_2.append(arg_6)
    # end for(servers)
    return arg_2


def Func(arg_0=None, arg_1=None, arg_2=None, arg_3=None):
    ''' gets states of a server'''
    if arg_0 is None:
        raise ValueError("argument 'pbclient' must not be None")
    if arg_1 is None:
        raise ValueError("argument 'dc_id' must not be None")
    arg_4 = None
    if arg_2 is None:
        if arg_3 is None:
            raise ValueError("one of 'serverid' or 'servername' must be specified")
        # so, arg.servername is set (to whatever)
        arg_5 = select_where(getServerInfo(arg_0, arg_1),
                                   ['id', 'name', 'state', 'vmstate'],
                                   name=arg_3)
        if len(arg_5) > 1:
            raise NameError("ambiguous server name '{}'".format(arg_3))
        if len(arg_5) == 1:
            arg_4 = arg_5[0]
    else:
        # get by ID may also fail if it's removed
        # in this case, catch exception (message 404) and be quiet for a while
        # unfortunately this has changed from Py2 to Py3
        try:
            arg_5 = arg_0.get_server(arg_1, arg_2, 1)
            arg_4 = dict(id=arg_5['id'],
                          name=arg_5['properties']['name'],
                          state=arg_5['metadata']['state'],
                          vmstate=arg_5['properties']['vmState'])
        except Exception:
            arg_6 = sys.exc_info()[1]
            if arg_6.args[0] is not None and arg_6.args[0] == 404:
                print("Server w/ ID {} not found".format(arg_2))
                arg_4 = None
            else:
                raise arg_6
        # end try/except
    # end if/else(serverid)
    return arg_4


def Func(arg_0):
    """
    Get the currently authenticated user ID
    """
    arg_1 = make_get_request(arg_0, 'self')
    if arg_1.status_code == 200:
        return arg_1.json()['result']['id']
    else:
        raise UserIdNotRetrievedException(
            'Error retrieving user id: %s' % arg_1.text, arg_1.text)


def Func(arg_0, arg_1):
    """
    Add a list of jobs to the currently authenticated user
    """
    arg_2 = {
        'jobs[]': arg_1
    }
    arg_3 = make_post_request(arg_0, 'self/jobs', arg_4=arg_2)
    arg_4 = arg_3.json()
    if arg_3.status_code == 200:
        return arg_4['status']
    else:
        raise UserJobsNotAddedException(
            message=arg_4['message'],
            error_code=arg_4['error_code'],
            request_id=arg_4['request_id'])


def Func(arg_0, arg_1):
    """
    Remove a list of jobs from the currently authenticated user
    """
    arg_2 = {
        'jobs[]': arg_1
    }
    arg_3 = make_delete_request(arg_0, 'self/jobs', arg_4=arg_2)
    arg_4 = arg_3.json()
    if arg_3.status_code == 200:
        return arg_4['status']
    else:
        raise UserJobsNotDeletedException(
            message=arg_4['message'],
            error_code=arg_4['error_code'],
            request_id=arg_4['request_id'])


def Func(arg_0, arg_1):
    """
    Get one or more users
    """
    # GET /api/users/0.1/users
    arg_2 = make_get_request(arg_0, 'users', params_data=arg_1)
    arg_3 = arg_2.json()
    if arg_2.status_code == 200:
        return arg_3['result']
    else:
        raise UsersNotFoundException(
            message=arg_3['message'],
            error_code=arg_3['error_code'],
            request_id=arg_3['request_id'])


def Func(arg_0, arg_1, arg_2,
                          arg_3, arg_4, arg_5, arg_6):
    """
    Create a fixed project
    """
    arg_5.append(create_job_object(id=417))  # Hire Me job, required

    arg_7 = {'title': arg_1,
                    'description': arg_2,
                    'currency': arg_3,
                    'budget': arg_4,
                    'jobs': arg_5,
                    'hireme': True,
                    'hireme_initial_bid': arg_6
                    }

    # POST /api/projects/0.1/projects/
    arg_8 = make_post_request(arg_0, 'projects', arg_9=arg_7)
    arg_9 = arg_8.json()
    if arg_8.status_code == 200:
        arg_7 = arg_9['result']
        arg_10 = Project(arg_7)
        arg_10.url = urljoin(arg_0.url, 'projects/%s' % arg_10.seo_url)
        return arg_10
    else:
        raise ProjectNotCreatedException(message=arg_9['message'],
                                         error_code=arg_9['error_code'],
                                         request_id=arg_9['request_id'],
                                         )


def Func(arg_0, arg_1):
    """
    Get one or more projects
    """
    # GET /api/projects/0.1/projects
    arg_2 = make_get_request(arg_0, 'projects', params_data=arg_1)
    arg_3 = arg_2.json()
    if arg_2.status_code == 200:
        return arg_3['result']
    else:
        raise ProjectsNotFoundException(
            message=arg_3['message'],
            error_code=arg_3['error_code'],
            request_id=arg_3['request_id'])


def Func(arg_0, arg_1, arg_2=None, arg_3=None):
    """
    Get a single project by ID
    """
    # GET /api/projects/0.1/projects/<int:project_id>
    arg_4 = {}
    if arg_2:
        arg_4.update(arg_2)
    if arg_3:
        arg_4.update(arg_3)
    arg_5 = make_get_request(
        arg_0, 'projects/{}'.format(arg_1), params_data=arg_4)
    arg_6 = arg_5.json()
    if arg_5.status_code == 200:
        return arg_6['result']
    else:
        raise ProjectsNotFoundException(
            message=arg_6['message'],
            error_code=arg_6['error_code'],
            request_id=arg_6['request_id']
        )


def Func(arg_0,
                    arg_1,
                    arg_2=None,
                    arg_3=None,
                    arg_4=None,
                    arg_5=10,
                    arg_6=0,
                    arg_7=None):
    """
    Search for all projects
    """
    arg_8 = {
        'query': arg_1,
        'limit': arg_5,
        'offset': arg_6,
    }
    if arg_2:
        arg_8.update(arg_2)
    if arg_3:
        arg_8.update(arg_3)
    if arg_4:
        arg_8.update(arg_4)

    # GET /api/projects/0.1/projects/all/
    # GET /api/projects/0.1/projects/active/
    arg_9 = 'projects/{}'.format('active' if arg_7 else 'all')
    arg_10 = make_get_request(arg_0, arg_9, params_data=arg_8)
    arg_11 = arg_10.json()
    if arg_10.status_code == 200:
        return arg_11['result']
    else:
        raise ProjectsNotFoundException(
            message=arg_11['message'],
            error_code=arg_11['error_code'],
            request_id=arg_11['request_id'])


def Func(arg_0, arg_1, arg_2, arg_3, arg_4,
                      arg_5, arg_6):
    """
    Place a bid on a project
    """
    arg_7 = {
        'project_id': arg_1,
        'bidder_id': arg_2,
        'description': arg_3,
        'amount': arg_4,
        'period': arg_5,
        'milestone_percentage': arg_6,
    }
    # POST /api/projects/0.1/bids/
    arg_8 = make_post_request(arg_0, 'bids', arg_9=arg_7)
    arg_9 = arg_8.json()
    if arg_8.status_code == 200:
        arg_7 = arg_9['result']
        return Bid(arg_7)
    else:
        raise BidNotPlacedException(message=arg_9['message'],
                                    error_code=arg_9['error_code'],
                                    request_id=arg_9['request_id'])


def Func(arg_0, arg_1, arg_2=None):
    """
    Get a specific milestone
    """
    # GET /api/projects/0.1/milestones/{milestone_id}/
    arg_3 = 'milestones/{}'.format(arg_1)

    arg_4 = make_get_request(arg_0, arg_3, params_data=arg_2)
    arg_5 = arg_4.json()
    if arg_4.status_code == 200:
        return arg_5['result']
    else:
        raise MilestonesNotFoundException(
            message=arg_5['message'],
            error_code=arg_5['error_code'],
            request_id=arg_5['request_id']
        )


def Func(arg_0, arg_1):
    """
    Accept a bid on a project
    """
    arg_2 = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    arg_3 = {
        'action': 'accept'
    }
    # POST /api/projects/0.1/bids/{bid_id}/?action=revoke
    arg_4 = 'bids/{}'.format(arg_1)
    arg_5 = make_put_request(arg_0, arg_4, arg_2=arg_2,
                                params_data=arg_3)
    arg_6 = arg_5.json()
    if arg_5.status_code == 200:
        return arg_6['status']
    else:
        arg_6 = arg_5.json()
        raise BidNotAcceptedException(message=arg_6['message'],
                                      error_code=arg_6['error_code'],
                                      request_id=arg_6['request_id'])


def Func(arg_0, arg_1):
    """
    Retract a bid on a project
    """
    arg_2 = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    arg_3 = {
        'action': 'retract'
    }
    # POST /api/projects/0.1/bids/{bid_id}/?action=revoke
    arg_4 = 'bids/{}'.format(arg_1)
    arg_5 = make_put_request(arg_0, arg_4, arg_2=arg_2,
                                params_data=arg_3)
    arg_6 = arg_5.json()
    if arg_5.status_code == 200:
        return arg_6['status']
    else:
        arg_6 = arg_5.json()
        raise BidNotRetractedException(message=arg_6['message'],
                                       error_code=arg_6['error_code'],
                                       request_id=arg_6['request_id'])


def Func(arg_0, arg_1):
    """
    Highlight a bid on a project
    """
    arg_2 = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    arg_3 = {
        'action': 'highlight'
    }
    # POST /api/projects/0.1/bids/{bid_id}/?action=revoke
    arg_4 = 'bids/{}'.format(arg_1)
    arg_5 = make_put_request(arg_0, arg_4, arg_2=arg_2,
                                params_data=arg_3)
    arg_6 = arg_5.json()
    if arg_5.status_code == 200:
        return arg_6['status']
    else:
        arg_6 = arg_5.json()
        raise BidNotHighlightedException(message=arg_6['message'],
                                         error_code=arg_6['error_code'],
                                         request_id=arg_6['request_id'])


def Func(arg_0, arg_1, arg_2, arg_3,
                             arg_4, arg_5):
    """
    Create a milestone payment
    """
    arg_6 = {
        'project_id': arg_1,
        'bidder_id': arg_2,
        'amount': arg_3,
        'reason': arg_4,
        'description': arg_5
    }
    # POST /api/projects/0.1/milestones/
    arg_7 = make_post_request(arg_0, 'milestones',
                                 arg_8=arg_6)
    arg_8 = arg_7.json()
    if arg_7.status_code == 200:
        arg_6 = arg_8['result']
        return Milestone(arg_6)
    else:
        raise MilestoneNotCreatedException(message=arg_8['message'],
                                           error_code=arg_8['error_code'],
                                           request_id=arg_8['request_id'])


def Func(arg_0, arg_1, arg_2, arg_3, arg_4):
    """
    Start tracking a project by creating a track
    """
    arg_5 = {
        'user_id': arg_1,
        'project_id': arg_2,
        'track_point': {
            'latitude': arg_3,
            'longitude': arg_4
        }
    }

    # POST /api/projects/0.1/tracks/
    arg_6 = make_post_request(arg_0, 'tracks',
                                 arg_7=arg_5)
    arg_7 = arg_6.json()
    if arg_6.status_code == 200:
        return arg_7['result']
    else:
        raise TrackNotCreatedException(message=arg_7['message'],
                                       error_code=arg_7['error_code'],
                                       request_id=arg_7['request_id'])


def Func(arg_0, arg_1, arg_2, arg_3, arg_4=False):
    """
    Updates the current location by creating a new track point and appending
    it to the given track
    """

    arg_5 = {
        'track_point': {
            'latitude': arg_2,
            'longitude': arg_3,
        },
        'stop_tracking': arg_4
    }

    # PUT /api/projects/0.1/tracks/{track_id}/

    arg_6 = make_put_request(arg_0, 'tracks/{}'.format(arg_1),
                                arg_7=arg_5)
    arg_7 = arg_6.json()
    if arg_6.status_code == 200:
        return arg_7['result']
    else:
        raise TrackNotUpdatedException(message=arg_7['message'],
                                       error_code=arg_7['error_code'],
                                       request_id=arg_7['request_id'])


def Func(arg_0, arg_1, arg_2=None, arg_3=None):
    """
    Gets a specific track
    """

    arg_4 = {}
    if arg_2:
        arg_4['track_point_limit'] = arg_2
    if arg_3:
        arg_4['track_point_offset'] = arg_3

    # GET /api/projects/0.1/tracks/{track_id}/

    arg_5 = make_get_request(arg_0, 'tracks/{}'.format(arg_1),
                                params_data=arg_4)
    arg_6 = arg_5.json()
    if arg_5.status_code == 200:
        return arg_6['result']
    else:
        raise TrackNotFoundException(message=arg_6['message'],
                                     error_code=arg_6['error_code'],
                                     request_id=arg_6['request_id'])


def Func(arg_0, arg_1, arg_2, arg_3, arg_4):
    """
    Create a milestone request
    """
    arg_5 = {
        'project_id': arg_1,
        'bid_id': arg_2,
        'description': arg_3,
        'amount': arg_4,
    }
    # POST /api/projects/0.1/milestone_requests/
    arg_6 = make_post_request(arg_0, 'milestone_requests',
                                 arg_7=arg_5)
    arg_7 = arg_6.json()
    if arg_6.status_code == 200:
        arg_5 = arg_7['result']
        return MilestoneRequest(arg_5)
    else:
        raise MilestoneRequestNotCreatedException(
            message=arg_7['message'],
            error_code=arg_7['error_code'],
            request_id=arg_7['request_id'])


def Func(arg_0, arg_1):
    """
    Accept a milestone request
    """
    arg_2 = {
        'action': 'accept',
    }
    # POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=
    # accept
    arg_3 = 'milestone_requests/{}'.format(arg_1)
    arg_4 = make_put_request(arg_0, arg_3, arg_2=arg_2)
    arg_5 = arg_4.json()
    if arg_4.status_code == 200:
        return arg_5['status']
    else:
        raise MilestoneRequestNotAcceptedException(
            message=arg_5['message'],
            error_code=arg_5['error_code'],
            request_id=arg_5['request_id'])


def Func(arg_0, arg_1):
    """
    Reject a milestone request
    """
    arg_2 = {
        'action': 'reject',
    }
    # POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=
    # reject
    arg_3 = 'milestone_requests/{}'.format(arg_1)
    arg_4 = make_put_request(arg_0, arg_3, arg_2=arg_2)
    arg_5 = arg_4.json()
    if arg_4.status_code == 200:
        return arg_5['status']
    else:
        raise MilestoneRequestNotRejectedException(
            message=arg_5['message'],
            error_code=arg_5['error_code'],
            request_id=arg_5['request_id'])


def Func(arg_0, arg_1, arg_2, arg_3):
    """
    Get a list of jobs
    """
    arg_4 = {
        'jobs[]': arg_1,
        'seo_details': arg_2,
        'lang': arg_3,
    }
    # GET /api/projects/0.1/jobs/
    arg_5 = make_get_request(arg_0, 'jobs', params_data=arg_4)
    arg_6 = arg_5.json()
    if arg_5.status_code == 200:
        return arg_6['result']
    else:
        raise JobsNotFoundException(
            message=arg_6['message'],
            error_code=arg_6['error_code'],
            request_id=arg_6['request_id'])


def Func(arg_0, arg_1, arg_2, arg_3, arg_4):
    """
    Create a thread
    """
    arg_5 = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    arg_6 = {
        'members[]': arg_1,
        'context_type': arg_2,
        'context': arg_3,
        'message': arg_4,
    }

    # POST /api/messages/0.1/threads/
    arg_7 = make_post_request(arg_0, 'threads', arg_5,
                                 form_data=arg_6)
    arg_8 = arg_7.json()
    if arg_7.status_code == 200:
        return Thread(arg_8['result'])
    else:
        raise ThreadNotCreatedException(arg_4=arg_8['message'],
                                        error_code=arg_8['error_code'],
                                        request_id=arg_8['request_id'])


def Func(arg_0, arg_1, arg_2, arg_3):
    """
    Create a project thread
    """
    return create_thread(arg_0, arg_1, 'project', arg_2, arg_3)


def Func(arg_0, arg_1, arg_2=10, arg_3=0):
    """
    Get one or more messages
    """
    arg_1['limit'] = arg_2
    arg_1['offset'] = arg_3

    # GET /api/messages/0.1/messages
    arg_4 = make_get_request(arg_0, 'messages', params_data=arg_1)
    arg_5 = arg_4.json()
    if arg_4.status_code == 200:
        return arg_5['result']
    else:
        raise MessagesNotFoundException(
            message=arg_5['message'],
            error_code=arg_5['error_code'],
            request_id=arg_5['request_id']
        )


def Func(arg_0, arg_1):
    """
    Get one or more threads
    """
    # GET /api/messages/0.1/threads
    arg_2 = make_get_request(arg_0, 'threads', params_data=arg_1)
    arg_3 = arg_2.json()
    if arg_2.status_code == 200:
        return arg_3['result']
    else:
        raise ThreadsNotFoundException(
            message=arg_3['message'],
            error_code=arg_3['error_code'],
            request_id=arg_3['request_id']
        )


def Func(arg_0, arg_1):
    """ meaning pvalues presorted i descending order"""

    arg_2 = len(arg_0)
    arg_3 = (arg_0 > arg_1).sum() / ((1 - arg_1)*arg_2)

    arg_4 = np.ones(arg_2)
    print("pFDR    y        Pr     fastPow")
    for arg_5 in range(arg_2):
        arg_6 = arg_0[arg_5]
        arg_7 = max(1, arg_2 - arg_5) / float(arg_2)
        arg_4[arg_5] = (arg_3 * arg_6) / (arg_7 * (1 - math.pow(1-arg_6, arg_2)))
        print(arg_5, arg_4[arg_5], arg_6, arg_7, 1.0 - math.pow(1-arg_6, arg_2))

    arg_8 = arg_3*arg_2
    arg_9 = arg_2 - arg_8
    arg_10 = np.array(range(arg_2))
    arg_11 = arg_2 - arg_10
    arg_12 = arg_11 / float(arg_2)

    arg_13 = np.ones(arg_2)
    arg_13[0] = arg_4[0]
    for arg_5 in range(arg_2-1):
        arg_13[arg_5+1] = min(arg_13[arg_5], arg_4[arg_5+1])

    arg_14 = ((1.0 - arg_13) * arg_11) / arg_9
    arg_14[arg_14 > 1.0] = 1.0

    arg_15 = pd.DataFrame(dict(
        pvalue=arg_0,
        qvalue=arg_13,
        FDR=arg_4,
        percentile_positive=arg_12,
        arg_14=arg_14
    ))

    arg_15["svalue"] = arg_15.sens[::-1].cummax()[::-1]

    return arg_15, arg_8, arg_2


def Func(arg_0, arg_1):
    """ Compute posterior probabilities for each chromatogram

    For each chromatogram (each group_id / peptide precursor), all hypothesis of all peaks
    being correct (and all others false) as well as the h0 (all peaks are
    false) are computed.

    The prior probability that the  are given in the function

    This assumes that the input data is sorted by tg_num_id

        Args:
            experiment(:class:`data_handling.Multipeptide`): the data of one experiment
            prior_chrom_null(float): the prior probability that any precursor
                is absent (all peaks are false)

        Returns:
            tuple(hypothesis, h0): two vectors that contain for each entry in
            the input dataframe the probabilities for the hypothesis that the
            peak is correct and the probability for the h0
    """

    arg_2 = arg_0.df.tg_num_id.values
    arg_3 = 1-arg_0.df["pep"].values

    arg_4 = arg_2[0]
    arg_5 = []
    arg_6 = []
    arg_7 = []
    for arg_8 in range(arg_2.shape[0]):

        arg_9 = arg_2[arg_8]
        if arg_9 != arg_4:

            # Actual computation for a single transition group (chromatogram)
            arg_10 = (1.0 - arg_1) / len(arg_5)
            arg_11 = single_chromatogram_hypothesis_fast(
                np.array(arg_5), arg_1, arg_10)
            arg_6.extend(arg_11[1:])
            arg_7.extend(arg_11[0] for arg_8 in range(len(arg_5)))

            # Reset for next cycle
            arg_5 = []
            arg_4 = arg_9

        arg_5.append(1.0 - arg_3[arg_8])

    # Last cycle
    arg_10 = (1.0 - arg_1) / len(arg_5)
    arg_11 = single_chromatogram_hypothesis_fast(np.array(arg_5), arg_1, arg_10)
    arg_6.extend(arg_11[1:])
    arg_7.extend([arg_11[0]] * len(arg_5))

    return arg_6, arg_7


def Func(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7, arg_8):
    """ Finds cut off target score for specified false discovery rate fdr """

    arg_9, arg_10 = error_statistics(arg_0, arg_1, arg_3, arg_4, arg_5, arg_6, arg_7, arg_8, False)
    if not len(arg_9):
        raise click.ClickException("Too little data for calculating error statistcs.")
    arg_11 = (arg_9.qvalue - arg_2).abs().idxmin()
    arg_12 = arg_9.iloc[arg_11]["cutoff"]
    return arg_12


def Func(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7, arg_8, arg_9, arg_10, arg_11, arg_12, arg_13, arg_14, arg_15, arg_16, arg_17, arg_18, arg_19, arg_20, arg_21, arg_22, arg_23, arg_24, arg_25, arg_26, arg_27, arg_28, arg_29, arg_30):
    """
    Conduct semi-supervised learning and error-rate estimation for MS1, MS2 and transition-level data.
    """

    if arg_1 is None:
        arg_1 = arg_0
    else:
        arg_1 = arg_1

    # Prepare XGBoost-specific parameters
    arg_31 = {'autotune': arg_3, 'autotune_num_rounds': 10, 'num_boost_round': 100, 'early_stopping_rounds': 10, 'test_size': 0.33}

    arg_32 = {'eta': 0.3, 'gamma': 0, 'max_depth': 6, 'min_child_weight': 1, 'subsample': 1, 'colsample_bytree': 1, 'colsample_bylevel': 1, 'colsample_bynode': 1, 'lambda': 1, 'alpha': 0, 'scale_pos_weight': 1, 'silent': 1, 'objective': 'binary:logitraw', 'nthread': 1, 'eval_metric': 'auc'}

    arg_33 = {'eta': hp.uniform('eta', 0.0, 0.3), 'gamma': hp.uniform('gamma', 0.0, 0.5), 'max_depth': hp.quniform('max_depth', 2, 8, 1), 'min_child_weight': hp.quniform('min_child_weight', 1, 5, 1), 'subsample': 1, 'colsample_bytree': 1, 'colsample_bylevel': 1, 'colsample_bynode': 1, 'lambda': hp.uniform('lambda', 0.0, 1.0), 'alpha': hp.uniform('alpha', 0.0, 1.0), 'scale_pos_weight': 1.0, 'silent': 1, 'objective': 'binary:logitraw', 'nthread': 1, 'eval_metric': 'auc'}

    if not arg_4:
        PyProphetLearner(arg_0, arg_1, arg_2, arg_31, arg_32, arg_33, arg_5, arg_6, arg_7, arg_8, arg_9, arg_10, arg_11, arg_12, arg_13, arg_14, arg_15, arg_16, arg_17, arg_18, arg_19, arg_20, arg_21, arg_22, arg_23, arg_24, arg_25, arg_26, arg_27, arg_28, arg_29, arg_30).run()
    else:
        PyProphetWeightApplier(arg_0, arg_1, arg_2, arg_31, arg_32, arg_33, arg_5, arg_6, arg_7, arg_8, arg_9, arg_10, arg_11, arg_12, arg_13, arg_14, arg_15, arg_16, arg_17, arg_18, arg_19, arg_20, arg_21, arg_22, arg_23, arg_24, arg_25, arg_26, arg_27, arg_28, arg_29, arg_30, arg_4).run()


def Func(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7, arg_8, arg_9):
    """
    Infer peptidoforms after scoring of MS1, MS2 and transition-level data.
    """

    if arg_1 is None:
        arg_1 = arg_0
    else:
        arg_1 = arg_1

    infer_peptidoforms(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7, arg_8, arg_9)


def Func(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7, arg_8, arg_9, arg_10, arg_11, arg_12, arg_13):
    """
    Infer Funcs and conduct error-rate estimation in different contexts.
    """

    if arg_1 is None:
        arg_1 = arg_0
    else:
        arg_1 = arg_1

    infer_Funcs(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7, arg_8, arg_9, arg_10, arg_11, arg_12, arg_13)


def Func(arg_0, arg_1, arg_2, arg_3):
    """
    Subsample OpenSWATH file to minimum for integrated scoring
    """

    if arg_1 is None:
        arg_1 = arg_0
    else:
        arg_1 = arg_1

    Func_osw(arg_0, arg_1, arg_2, arg_3)


def Func(arg_0, arg_1):
    """
    Reduce scored PyProphet file to minimum for global scoring
    """

    if arg_1 is None:
        arg_1 = arg_0
    else:
        arg_1 = arg_1

    Func_osw(arg_0, arg_1)


def Func(arg_0, arg_1=arg_2):
    """ Assumes zipcode is of type `str` """
    arg_0 = arg_0.split("-")[0]  # Convert #####-#### to #####

    if len(arg_0) != arg_1:
        raise ValueError(
            'Invalid format, zipcode must be of the format: "#####" or "#####-####"'
        )

    if _contains_nondigits(arg_0):
        raise ValueError('Invalid characters, zipcode may only contain digits and "-".')

    return arg_0


def Func(arg_0, arg_1=arg_2):
    """ List of zipcode dicts where zipcode prefix matches `partial_zipcode` """
    return [arg_3 for arg_3 in arg_1 if arg_3["zip_code"].startswith(arg_0)]


def Func(arg_0, arg_1):
        """
        Returns a restclients.Group object for the group identified by the
        passed group ID.
        """
        arg_0._valid_group_id(arg_1)

        arg_2 = "{}/group/{}".format(arg_0.API, arg_1)

        arg_3 = arg_0._get_resource(arg_2)

        return arg_0._group_from_json(arg_3.get("data"))


def Func(arg_0, arg_1):
        """
        Creates a group from the passed restclients.Group object.
        """
        arg_0._valid_group_id(arg_1.id)

        arg_2 = {"data": arg_1.json_data()}
        arg_3 = "{}/group/{}".format(arg_0.API, arg_1.name)

        arg_4 = arg_0._put_resource(arg_3, headers={}, arg_2=arg_2)

        return arg_0._group_from_json(arg_4.get("data"))


def Func(arg_0, arg_1):
        """
        Deletes the group identified by the passed group ID.
        """
        arg_0._valid_group_id(arg_1)

        arg_2 = "{}/group/{}".format(arg_0.API, arg_1)

        arg_0._delete_resource(arg_2)

        return True


def Func(arg_0, arg_1):
        """
        Returns a list of restclients.GroupMember objects for the group
        identified by the passed group ID.
        """
        arg_0._valid_group_id(arg_1)

        arg_2 = "{}/group/{}/member".format(arg_0.API, arg_1)

        arg_3 = arg_0._get_resource(arg_2)

        arg_4 = []
        for arg_5 in arg_3.get("data"):
            arg_4.append(arg_0._group_member_from_json(arg_5))
        return arg_4


def Func(arg_0, arg_1, arg_2):
        """
        Updates the membership of the group represented by the passed group id.
        Returns a list of members not found.
        """
        arg_0._valid_group_id(arg_1)

        arg_3 = {"data": [m.json_data() for m in arg_2]}
        arg_4 = {"If-Match": "*"}
        arg_5 = "{}/group/{}/member".format(arg_0.API, arg_1)

        arg_6 = arg_0._put_resource(arg_5, arg_4, arg_3)

        arg_7 = arg_6.get("errors", [])
        if len(arg_7):
            return arg_7[0].get("notFound", [])
        return []


def Func(arg_0, arg_1, arg_2):
        """
        Returns True if the netid is in the group, False otherwise.
        """
        arg_0._valid_group_id(arg_1)

        # GWS doesn't accept EPPNs on effective member checks, for UW users
        arg_2 = re.sub('@washington.edu', '', arg_2)

        arg_3 = "{}/group/{}/effective_member/{}".format(arg_0.API,
                                                       arg_1,
                                                       arg_2)

        try:
            arg_4 = arg_0._get_resource(arg_3)
            return True  # 200
        except DataFailureException as ex:
            if ex.status == 404:
                return False
            else:
                raise


def Func(arg_0, arg_1, arg_2=None, arg_3=None, arg_4=None,
                       arg_5=None, arg_6=arg_7.int64, arg_9=arg_7.int32,
                       **arg_11):
        """Create 3 datasets in a group to represent the sparse array.

        Parameters
        ----------
        sparse_format:
        """
        if isinstance(arg_4, Dataset):
            assert arg_5 is None
            arg_12 = arg_0.create_group(arg_1)
            arg_12.attrs['h5sparse_format'] = arg_4.attrs['h5sparse_format']
            arg_12.attrs['h5sparse_shape'] = arg_4.attrs['h5sparse_shape']
            arg_12.Func('data', arg_4=arg_4.h5py_group['data'],
                                 arg_3=arg_3, **arg_11)
            arg_12.Func('indices', arg_4=arg_4.h5py_group['indices'],
                                 arg_3=arg_9, **arg_11)
            arg_12.Func('indptr', arg_4=arg_4.h5py_group['indptr'],
                                 arg_3=arg_6, **arg_11)
        elif ss.issparse(arg_4):
            if arg_5 is not None:
                arg_14 = get_format_class(arg_5)
                arg_4 = arg_14(arg_4)
            arg_12 = arg_0.create_group(arg_1)
            arg_12.attrs['h5sparse_format'] = get_format_str(arg_4)
            arg_12.attrs['h5sparse_shape'] = arg_4.shape
            arg_12.Func('data', arg_4=arg_4.data, arg_3=arg_3, **arg_11)
            arg_12.Func('indices', arg_4=arg_4.indices, arg_3=arg_9, **arg_11)
            arg_12.Func('indptr', arg_4=arg_4.indptr, arg_3=arg_6, **arg_11)
        elif arg_4 is None and arg_5 is not None:
            arg_14 = get_format_class(arg_5)
            if arg_3 is None:
                arg_3 = arg_7.float64
            if arg_2 is None:
                arg_2 = (0, 0)
            arg_4 = arg_14(arg_2, arg_3=arg_3)
            arg_12 = arg_0.create_group(arg_1)
            arg_12.attrs['h5sparse_format'] = get_format_str(arg_4)
            arg_12.attrs['h5sparse_shape'] = arg_4.shape
            arg_12.Func('data', arg_4=arg_4.data, arg_3=arg_3, **arg_11)
            arg_12.Func('indices', arg_4=arg_4.indices, arg_3=arg_9, **arg_11)
            arg_12.Func('indptr', arg_4=arg_4.indptr, arg_3=arg_6, **arg_11)
        else:
            # forward the arguments to h5py
            assert arg_5 is None
            return super(Group, arg_0).Func(
                arg_1, arg_4=arg_4, arg_2=arg_2, arg_3=arg_3, **arg_11)
        return Dataset(arg_12)


def Func(arg_0):
    """Pedantic yet imperfect. Test to see if "name" is a valid python identifier
    """
    if not isinstance(arg_0, str):
        return False
    if '\n' in arg_0:
        return False
    if arg_0.strip() != arg_0:
        return False
    try:
        arg_1 = compile('\n{0}=None'.format(arg_0), filename='<string>', mode='single')
        exec(arg_1)
        return True
    except SyntaxError:
        return False


def Func(
            arg_0, arg_1,
            arg_2=arg_3, arg_4=arg_5,
            arg_6=arg_7, arg_8=arg_9,
            arg_10=2**24
    ):
        """
        Build a palette definition from either a simple string or a dictionary,
        filling in defaults for items not specified.

        e.g.:
            "dark green"
                dark green foreground, black background

            {lo: dark gray, hi: "#666"}
                dark gray on 16-color terminals, #666 for 256+ color

        """
        # TODO: mono

        arg_11 = PaletteEntry(mono = arg_2,
                         arg_13=arg_2,
                         arg_17=arg_4,
                         arg_12=arg_6,
                         arg_16=arg_8)

        if isinstance(arg_1, str):
            arg_11.foreground_high = arg_1
            if arg_11.allowed(arg_1, 16):
                arg_11.foreground = arg_1
            else:
                arg_14 = AttrSpec(arg_18=arg_1, arg_15="", colors=arg_10).get_rgb_values()[0:3]
                arg_11.foreground = nearest_basic_color(arg_14)

        elif isinstance(arg_1, dict):

            arg_15 = arg_1.get("bg", None)
            if isinstance(arg_15, str):
                arg_11.background_high = arg_15
                if arg_11.allowed(arg_15, 16):
                    arg_11.background = arg_15
                else:
                    arg_14 = AttrSpec(arg_18=arg_15, arg_15="", colors=arg_10).get_rgb_values()[0:3]
                    arg_11.background = nearest_basic_color(arg_14)
            elif isinstance(arg_15, dict):
                arg_11.background_high = arg_15.get("hi", arg_8)
                if "lo" in arg_15:
                    if arg_11.allowed(arg_15["lo"], 16):
                        arg_11.background = arg_15["lo"]
                    else:
                        arg_14 = AttrSpec(arg_18=arg_15["lo"], arg_15="", colors=arg_10).get_rgb_values()[0:3]
                        arg_11.background = nearest_basic_color(arg_14)

            arg_18 = arg_1.get("fg", arg_1)
            if isinstance(arg_18, str):
                arg_11.foreground_high = arg_18
                if arg_11.allowed(arg_18, 16):
                    arg_11.foreground = arg_18
                else:
                    arg_14 = AttrSpec(arg_18=arg_18, arg_15="", colors=arg_10).get_rgb_values()[0:3]
                    arg_11.foreground = nearest_basic_color(arg_14)

            elif isinstance(arg_18, dict):
                arg_11.foreground_high = arg_18.get("hi", arg_6)
                if "lo" in arg_18:
                    if arg_11.allowed(arg_18["lo"], 16):
                        arg_11.foreground = arg_18["lo"]
                    else:
                        arg_14 = AttrSpec(arg_18=arg_18["lo"], arg_15="", colors=arg_10).get_rgb_values()[0:3]
                        arg_11.foreground = nearest_basic_color(arg_14)
        return arg_11


def Func(arg_0, arg_1):
    """
    Decrypts context.io_manager's stdin and sends that to
    context.io_manager's stdout.

    See :py:mod:`swiftly.cli.decrypt` for context usage information.

    See :py:class:`CLIDecrypt` for more information.
    """
    with arg_0.io_manager.with_stdout() as stdout:
        with arg_0.io_manager.with_stdin() as stdin:
            arg_2 = stdin.read(1)
            if arg_2 == AES256CBC:
                for arg_3 in aes_decrypt(arg_1, stdin):
                    stdout.write(arg_3)
                stdout.flush()
            else:
                raise ReturnCode(
                    'contents encrypted with unsupported type %r' % arg_2)


def Func(arg_0, arg_1=None, arg_2=False):
        """
        Returns a stdout-suitable file-like object based on the
        optional os_path and optionally skipping any configured
        sub-command.
        """
        arg_3 = None if arg_2 else arg_0.stdout_sub_command
        arg_4, arg_5 = arg_0._get_out_and_path(
            arg_0.stdout, arg_0.stdout_root, arg_3, arg_1)
        if hasattr(arg_4, 'stdin'):
            return arg_4.stdin
        return arg_4


def Func(arg_0, arg_1=None, arg_2=False):
        """
        Returns a debug-output-suitable file-like object based on the
        optional os_path and optionally skipping any configured
        sub-command.
        """
        arg_3 = None if arg_2 else arg_0.debug_sub_command
        arg_4, arg_5 = arg_0._get_out_and_path(
            arg_0.debug, arg_0.debug_root, arg_3, arg_1)
        if hasattr(arg_4, 'stdin'):
            return arg_4.stdin
        return arg_4


def Func(arg_0, arg_1=None, arg_2=False,
                   arg_3=None):
        """
        A context manager yielding a stdin-suitable file-like object
        based on the optional os_path and optionally skipping any
        configured sub-command.

        :param os_path: Optional path to base the file-like object
            on.
        :param skip_sub_command: Set True to skip any configured
            sub-command filter.
        :param disk_closed_callback: If the backing of the file-like
            object is an actual file that will be closed,
            disk_closed_callback (if set) will be called with the
            on-disk path just after closing it.
        """
        arg_4 = None if arg_2 else arg_0.stdin_sub_command
        arg_5, arg_6 = arg_0._get_in_and_path(
            arg_0.stdin, arg_0.stdin_root, arg_4, arg_1)
        try:
            if hasattr(arg_5, 'stdout'):
                yield arg_5.stdout
            else:
                yield arg_5
        finally:
            if hasattr(arg_5, 'stdout'):
                arg_0._close(arg_5.stdout)
            arg_0._wait(arg_5, arg_6)
            arg_0._close(arg_5)
            if arg_3 and arg_6:
                arg_3(arg_6)


def Func(arg_0, arg_1=None, arg_2=False,
                    arg_3=None):
        """
        A context manager yielding a stdout-suitable file-like object
        based on the optional os_path and optionally skipping any
        configured sub-command.

        :param os_path: Optional path to base the file-like object
            on.
        :param skip_sub_command: Set True to skip any configured
            sub-command filter.
        :param disk_closed_callback: If the backing of the file-like
            object is an actual file that will be closed,
            disk_closed_callback (if set) will be called with the
            on-disk path just after closing it.
        """
        arg_4 = None if arg_2 else arg_0.stdout_sub_command
        arg_5, arg_6 = arg_0._get_out_and_path(
            arg_0.stdout, arg_0.stdout_root, arg_4, arg_1)
        try:
            if hasattr(arg_5, 'stdin'):
                yield arg_5.stdin
            else:
                yield arg_5
        finally:
            if hasattr(arg_5, 'stdin'):
                arg_0._close(arg_5.stdin)
            arg_0._wait(arg_5, arg_6)
            arg_0._close(arg_5)
            if arg_3 and arg_6:
                arg_3(arg_6)


def Func(arg_0, arg_1=None, arg_2=False,
                   arg_3=None):
        """
        A context manager yielding a debug-output-suitable file-like
        object based on the optional os_path and optionally skipping
        any configured sub-command.

        :param os_path: Optional path to base the file-like object
            on.
        :param skip_sub_command: Set True to skip any configured
            sub-command filter.
        :param disk_closed_callback: If the backing of the file-like
            object is an actual file that will be closed,
            disk_closed_callback (if set) will be called with the
            on-disk path just after closing it.
        """
        arg_4 = None if arg_2 else arg_0.debug_sub_command
        arg_5, arg_6 = arg_0._get_out_and_path(
            arg_0.debug, arg_0.debug_root, arg_4, arg_1)
        try:
            if hasattr(arg_5, 'stdin'):
                yield arg_5.stdin
            else:
                yield arg_5
        finally:
            if hasattr(arg_5, 'stdin'):
                arg_0._close(arg_5.stdin)
            arg_0._wait(arg_5, arg_6)
            arg_0._close(arg_5)
            if arg_3 and arg_6:
                arg_3(arg_6)


def Func(arg_0, arg_1, arg_2=False):
    """
    Deletes all objects in the container.

    By default, this will perform one pass at deleting all objects in
    the container; so if objects revert to previous versions or if new
    objects otherwise arise during the process, the container may not be
    empty once done.

    Set `until_empty` to True if you want multiple passes to keep trying
    to fully empty the container. Note until_empty=True could run
    forever if something else is making new objects faster than they're
    being deleted.

    See :py:mod:`swiftly.cli.delete` for context usage information.

    See :py:class:`CLIDelete` for more information.
    """
    arg_1 = arg_1.rstrip('/').decode('utf8')
    arg_3 = Concurrency(arg_0.concurrency)

    def check_conc():
        for (arg_4, arg_5, arg_6, arg_7) in \
                six.itervalues(arg_3.get_results()):
            if arg_5:
                with arg_0.io_manager.with_stderr() as fp:
                    fp.write(str(arg_5))
                    fp.write('\n')
                    fp.flush()

    arg_8 = None
    while True:
        with arg_0.client_manager.with_client() as client:
            arg_9, arg_10, arg_11, arg_12 = client.get_container(
                arg_1, arg_8=arg_8, arg_11=arg_0.headers,
                query=arg_0.query, cdn=arg_0.cdn)
        if arg_9 // 100 != 2:
            if arg_9 == 404 and arg_0.ignore_404:
                return
            raise ReturnCode(
                'listing container %r: %s %s' % (arg_1, arg_9, arg_10))
        if not arg_12:
            if arg_2 and arg_8:
                arg_8 = None
                continue
            break
        for arg_13 in arg_12:
            arg_14 = '%s/%s' % (arg_1, arg_13['name'])
            arg_15 = arg_0.copy()
            arg_15.ignore_404 = True
            check_conc()
            arg_3.spawn(arg_14, cli_delete, arg_15, arg_14)
        arg_8 = arg_13['name']
        arg_3.join()
        check_conc()


def Func(arg_0):
    """
    Instance method decorator to convert an optional file keyword
    argument into an actual value, whether it be a passed value, a
    value obtained from an io_manager, or sys.stderr.
    """
    def arg_4(arg_1, arg_2, arg_3=None):
        if arg_3:
            return arg_0(arg_1, arg_2, arg_3=arg_3)
        elif arg_1.io_manager:
            with arg_1.io_manager.with_stderr() as stderr:
                return arg_0(arg_1, arg_2, arg_3=stderr)
        else:
            return arg_0(arg_1, arg_2, arg_3=sys.stderr)
    arg_4.__doc__ = arg_0.__doc__
    return arg_4


def Func(arg_0, arg_1, arg_2=None):
        """
        Outputs the Func msg to the file if specified, or to the
        io_manager's stderr if available, or to sys.stderr.
        """
        arg_0.Func_encountered = True
        arg_2.write(arg_0.Func_prefix)
        arg_2.write(arg_1)
        arg_2.write('\n')
        arg_2.flush()


def Func(arg_0, arg_1=None):
        """
        Outputs help information to the file if specified, or to the
        io_manager's stdout if available, or to sys.stdout.
        """
        optparse.OptionParser.Func(arg_0, arg_1)
        if arg_0.raw_epilog:
            arg_1.write(arg_0.raw_epilog)
        arg_1.flush()


def Func(arg_0, arg_1=None):
        """
        Outputs version information to the file if specified, or to
        the io_manager's stdout if available, or to sys.stdout.
        """
        optparse.OptionParser.Func(arg_0, arg_1)
        arg_1.flush()


def Func(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5=False,
                arg_6=False, arg_7=None, arg_8=False):
        """
        Performs a direct HTTP Func to the Swift service.

        :param method: The Func method ('GET', 'HEAD', etc.)
        :param path: The Func path.
        :param contents: The body of the Func. May be a string or
            a file-like object.
        :param headers: A dict of Func headers and values.
        :param decode_json: If set True, the response body will be
            treated as JSON and decoded result returned instead of
            the raw contents.
        :param stream: If set True, the response body will return as
            a file-like object; otherwise, the response body will be
            read in its entirety and returned as a string. Overrides
            decode_json.
        :param query: A dict of query parameters and values to append
            to the path.
        :param cdn: If set True, the Func will be sent to the CDN
            management endpoint instead of the default storage
            endpoint.
        :returns: A tuple of (status, reason, headers, contents).

            :status: An int for the HTTP status code.
            :reason: The str for the HTTP status (ex: "Ok").
            :headers: A dict with all lowercase keys of the HTTP
                headers; if a header has multiple values, it will be
                a list.
            :contents: Depending on the decode_json and stream
                settings, this will either be the raw response
                string, the JSON decoded object, or a file-like
                object.
        """
        raise Exception('Func method not implemented')


def Func(arg_0, arg_1=None, arg_2=None, arg_3=False, arg_4=None):
        """
        POSTs the account and returns the results. This is usually
        done to set X-Account-Meta-xxx headers. Note that any existing
        X-Account-Meta-xxx headers will remain untouched. To remove an
        X-Account-Meta-xxx header, send the header with an empty
        string as its value.

        :param headers: Additional headers to send with the request.
        :param query: Set to a dict of query values to send on the
            query string of the request.
        :param cdn: If set True, the CDN management interface will be
            used.
        :param body: No known Swift POSTs take a body; but the option
            is there for the future.
        :returns: A tuple of (status, reason, headers, contents).

            :status: is an int for the HTTP status code.
            :reason: is the str for the HTTP status (ex: "Ok").
            :headers: is a dict with all lowercase keys of the HTTP
                headers; if a header has multiple values, it will be a
                list.
            :contents: is the str for the HTTP body.
        """
        return arg_0.request(
            'POST', '', arg_4 or '', arg_1, arg_2=arg_2, arg_3=arg_3)


def Func(arg_0, arg_1=None,
                       arg_2=False, arg_3=None,
                       arg_4=False, arg_5=None):
        """
        Sends a DELETE request to the account and returns the results.

        With ``query['bulk-delete'] = ''`` this might mean a bulk
        delete request where the body of the request is new-line
        separated, url-encoded list of names to delete. Be careful
        with this! One wrong move and you might mark your account for
        deletion of you have the access to do so!

        For a plain DELETE to the account, on clusters that support
        it and, assuming you have permissions to do so, the account
        will be marked as deleted and immediately begin removing the
        objects from the cluster in the backgound.

        THERE IS NO GOING BACK!

        :param headers: Additional headers to send with the request.
        :param yes_i_mean_delete_the_account: Set to True to verify
            you really mean to delete the entire account. This is
            required unless ``body and 'bulk-delete' in query``.
        :param query: Set to a dict of query values to send on the
            query string of the request.
        :param cdn: If set True, the CDN management interface will be
            used.
        :param body: Some account DELETE requests, like the bulk
            delete request, take a body.
        :returns: A tuple of (status, reason, headers, contents).

            :status: is an int for the HTTP status code.
            :reason: is the str for the HTTP status (ex: "Ok").
            :headers: is a dict with all lowercase keys of the HTTP
                headers; if a header has multiple values, it will be
                a list.
            :contents: is the str for the HTTP body.
        """
        if not arg_2 and (
                not arg_5 or not arg_3 or 'bulk-delete' not in arg_3):
            return (0, 'yes_i_mean_delete_the_account was not set to True', {},
                    '')
        return arg_0.request(
            'DELETE', '', arg_5 or '', arg_1, arg_3=arg_3, arg_4=arg_4)


def Func(arg_0, arg_1, arg_2, arg_3=None, arg_4=None, arg_5=False,
                    arg_6=None):
        """
        POSTs the object and returns the results. This is used to
        update the object's header values. Note that all headers must
        be sent with the POST, unlike the account and container POSTs.
        With account and container POSTs, existing headers are
        untouched. But with object POSTs, any existing headers are
        removed. The full list of supported headers depends on the
        Swift cluster, but usually include Content-Type,
        Content-Encoding, and any X-Object-Meta-xxx headers.

        :param container: The name of the container.
        :param obj: The name of the object.
        :param headers: Additional headers to send with the request.
        :param query: Set to a dict of query values to send on the
            query string of the request.
        :param cdn: If set True, the CDN management interface will be
            used.
        :param body: No known Swift POSTs take a body; but the option
            is there for the future.
        :returns: A tuple of (status, reason, headers, contents).

            :status: is an int for the HTTP status code.
            :reason: is the str for the HTTP status (ex: "Ok").
            :headers: is a dict with all lowercase keys of the HTTP
                headers; if a header has multiple values, it will be a
                list.
            :contents: is the str for the HTTP body.
        """
        arg_7 = arg_0._object_path(arg_1, arg_2)
        return arg_0.request(
            'POST', arg_7, arg_6 or '', arg_3, arg_4=arg_4, arg_5=arg_5)


def Func(arg_0):
        """
        Returns a new CLIContext instance that is a shallow Func of
        the original, much like dict's Func method.
        """
        arg_1 = CLIContext()
        for arg_2 in dir(arg_0):
            if arg_2[0] != '_' and arg_2 not in ('Func', 'write_headers'):
                setattr(arg_1, arg_2, getattr(arg_0, arg_2))
        return arg_1


def Func(arg_0, arg_1, arg_2, arg_3=None):
        """
        Convenience function to output headers in a formatted fashion
        to a file-like fp, optionally muting any headers in the mute
        list.
        """
        if arg_2:
            if not arg_3:
                arg_3 = []
            arg_4 = '%%-%ds %%s\n' % (max(len(k) for k in arg_2) + 1)
            for arg_5 in sorted(arg_2):
                if arg_5 in arg_3:
                    continue
                arg_1.write(arg_4 % (arg_5.title() + ':', arg_2[arg_5]))
            arg_1.flush()


def Func(arg_0):
    """
    Authenticates and then outputs the resulting information.

    See :py:mod:`swiftly.cli.auth` for context usage information.

    See :py:class:`CLIAuth` for more information.
    """
    with arg_0.io_manager.with_stdout() as fp:
        with arg_0.client_manager.with_client() as client:
            arg_1 = []
            client.auth()
            if getattr(client, 'auth_cache_path', None):
                arg_1.append(('Auth Cache', client.auth_cache_path))
            if getattr(client, 'auth_url', None):
                arg_1.append(('Auth URL', client.auth_url))
            if getattr(client, 'auth_user', None):
                arg_1.append(('Auth User', client.auth_user))
            if getattr(client, 'auth_key', None):
                arg_1.append(('Auth Key', client.auth_key))
            if getattr(client, 'auth_tenant', None):
                arg_1.append(('Auth Tenant', client.auth_tenant))
            if getattr(client, 'auth_methods', None):
                arg_1.append(('Auth Methods', client.auth_methods))
            if getattr(client, 'storage_path', None):
                arg_1.append(('Direct Storage Path', client.storage_path))
            if getattr(client, 'cdn_path', None):
                arg_1.append(('Direct CDN Path', client.cdn_path))
            if getattr(client, 'local_path', None):
                arg_1.append(('Local Path', client.local_path))
            if getattr(client, 'regions', None):
                arg_1.append(('Regions', ' '.join(client.regions)))
            if getattr(client, 'default_region', None):
                arg_1.append(('Default Region', client.default_region))
            if getattr(client, 'region', None):
                arg_1.append(('Selected Region', client.region))
            if getattr(client, 'snet', None):
                arg_1.append(('SNet', client.snet))
            if getattr(client, 'storage_url', None):
                arg_1.append(('Storage URL', client.storage_url))
            if getattr(client, 'cdn_url', None):
                arg_1.append(('CDN URL', client.cdn_url))
            if getattr(client, 'auth_token', None):
                arg_1.append(('Auth Token', client.auth_token))
            if not arg_1:
                arg_1.append((
                    'No auth information available',
                    'Maybe no credentials were provided?'))
            arg_2 = '%%-%ds %%s\n' % (max(len(arg_3) for arg_3, arg_4 in arg_1) + 1)
            for arg_3, arg_4 in arg_1:
                fp.write(arg_2 % (arg_3 + ':', arg_4))
            fp.flush()