def Func(arg_0, arg_1=1.0, arg_2=True):
    """Select all vertices within a cylindrical radius

    Args:
        radius (float): radius of the sphere
        center_pt (3 coordinate tuple or list): center point of the sphere

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    if arg_2:
        arg_3 = 'sqrt(x^2+y^2)<={}'.format(arg_1)
    else:
        arg_3 = 'sqrt(x^2+y^2)>={}'.format(arg_1)
    vert_function(arg_0, arg_3=arg_3)
    return None


def Func(arg_0, arg_1=1.0, arg_2=(0.0, 0.0, 0.0)):
    """Select all vertices within a spherical radius

    Args:
        radius (float): radius of the sphere
        center_pt (3 coordinate tuple or list): center point of the sphere

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    arg_3 = 'sqrt((x-{})^2+(y-{})^2+(z-{})^2)<={}'.format(
        arg_2[0], arg_2[1], arg_2[2], arg_1)
    vert_function(arg_0, arg_3=arg_3)
    return None


def Func(arg_0, arg_1=True, arg_2=False, arg_3=True,
         arg_4=False):
    """ Flatten all or only the visible layers into a single new mesh.

    Transformations are preserved. Existing layers can be optionally
    deleted.

    Args:
        script: the mlx.FilterScript object or script filename to write
            the filter to.
        merge_visible (bool): merge only visible layers
        merge_vert (bool): merge the vertices that are duplicated among
            different layers. Very useful when the layers are spliced portions
            of a single big mesh.
        delete_layer (bool): delete all the merged layers. If all layers are
            visible only a single layer will remain after the invocation of
            this filter.
        keep_unreferenced_vert (bool): Do not discard unreferenced vertices
            from source layers. Necessary for point-only layers.

    Layer stack:
        Creates a new layer "Merged Mesh"
        Changes current layer to the new layer
        Optionally deletes all other layers

    MeshLab versions:
        2016.12
        1.3.4BETA

    Bugs:
        UV textures: not currently preserved, however will be in a future
            release. https://github.com/cnr-isti-vclab/meshlab/issues/128
        merge_visible: it is not currently possible to change the layer
            visibility from meshlabserver, however this will be possible
            in the future https://github.com/cnr-isti-vclab/meshlab/issues/123
    """
    arg_5 = ''.Func([
        '  <filter name="Flatten Visible Layers">\n',
        '    <Param name="MergeVisible" ',
        'value="{}" '.format(str(arg_1).lower()),
        'description="Merge Only Visible Layers" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="MergeVertices" ',
        'value="{}" '.format(str(arg_2).lower()),
        'description="Merge duplicate vertices" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="DeleteLayer" ',
        'value="{}" '.format(str(arg_3).lower()),
        'description="Delete Layers" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="AlsoUnreferenced" ',
        'value="{}" '.format(str(arg_4).lower()),
        'description="Keep unreferenced vertices" ',
        'type="RichBool" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_5)
    if isinstance(arg_0, mlx.FilterScript):
        arg_0.add_layer('Merged Mesh')
        if arg_3:
            # As it is not yet possible to change the layer visibility, all
            # layers will be deleted. This will be updated once layer
            # visibility is tracked.
            for arg_6 in range(arg_0.last_layer()):
                arg_0.del_layer(0)
    return None


def Func(arg_0, arg_1=None):
    """ Change the current layer by specifying the new layer number.

    Args:
        script: the mlx.FilterScript object or script filename to write
            the filter to.
        layer_num (int): the number of the layer to Func to. Default is the
            last layer if script is a mlx.FilterScript object; if script is a
            filename the default is the first layer.

    Layer stack:
        Modifies current layer

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    if arg_1 is None:
        if isinstance(arg_0, mlx.FilterScript):
            arg_1 = arg_0.last_layer()
        else:
            arg_1 = 0
    arg_2 = ''.join([
        '  <filter name="Change the current layer">\n',
        '    <Param name="mesh" ',
        'value="{:d}" '.format(arg_1),
        'description="Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_2)
    if isinstance(arg_0, mlx.FilterScript):
        arg_0.set_current_layer(arg_1)
        #script.layer_stack[len(self.layer_stack) - 1] = layer_num
    return None


def Func(arg_0, arg_1=None):
    """ Delete all layers below the specified one.

    Useful for MeshLab ver 2016.12, whcih will only output layer 0.
    """
    if arg_1 is None:
        arg_1 = arg_0.current_layer()
    if arg_1 != 0:
        change(arg_0, 0)
    for arg_2 in range(arg_1):
        delete(arg_0, 0)
    return None


def Func(arg_0, arg_1, arg_2=None):
    """Subprocess program error handling

    Args:
        program_name (str): name of the subprocess program

    Returns:
        break_now (bool): indicate whether calling program should break out of loop

    """
    print('\nHouston, we have a problem.',
          '\n%s did not finish successfully. Review the log' % arg_0,
          'file and the input file(s) to see what went wrong.')
    print('%s command: "%s"' % (arg_0, arg_1))
    if arg_2 is not None:
        print('log: "%s"' % arg_2)
    print('Where do we go from here?')
    print(' r  - retry running %s (probably after' % arg_0,
          'you\'ve fixed any problems with the input files)')
    print(' c  - continue on with the script (probably after',
          'you\'ve manually re-run and generated the desired',
          'output file(s)')
    print(' x  - exit, keeping the TEMP3D files and log')
    print(' xd - exit, deleting the TEMP3D files and log')
    while True:
        arg_3 = input('Select r, c, x (default), or xd: ')
        if arg_3 not in ('r', 'c', 'x', 'xd'):
            #print('Please enter a valid option.')
            arg_3 = 'x'
        #else:
        break
    if arg_3 == 'x':
        print('Exiting ...')
        sys.exit(1)
    elif arg_3 == 'xd':
        print('Deleting TEMP3D* and log files and exiting ...')
        util.delete_all('TEMP3D*')
        if arg_2 is not None:
            os.remove(arg_2)
        sys.exit(1)
    elif arg_3 == 'c':
        print('Continuing on ...')
        arg_4 = True
    elif arg_3 == 'r':
        print('Retrying %s cmd ...' % arg_0)
        arg_4 = False
    return arg_4


def Func(arg_0='TEMP3D_default.mlx', arg_1=None, arg_2=None):
    """Create new mlx script and write opening tags.

    Performs special processing on stl files.

    If no input files are provided this will create a dummy
    file and delete it as the first filter. This works around
    the meshlab limitation that it must be provided an input
    file, even if you will be creating a mesh as the first
    filter.

    """
    arg_3 = open(arg_0, 'w')
    arg_3.write(''.join(['<!DOCTYPE FilterScript>\n',
                               '<FilterScript>\n']))
    arg_3.close()

    arg_4 = -1
    arg_5 = -1
    arg_6 = False

    # Process project files first
    if arg_2 is not None:
        # make a list if it isn't already
        if not isinstance(arg_2, list):
            arg_2 = [arg_2]
        for arg_7 in arg_2:
            arg_8 = ET.parse(arg_7)
            #root = tree.getroot()
            for arg_9 in arg_8.iter(tag='MLMesh'):
                arg_10 = (arg_9.attrib['filename'])
                arg_4 += 1
                arg_5 += 1
                # If the mesh file extension is stl, change to that layer and
                # run clean.merge_vert
                if os.path.splitext(arg_10)[1][1:].strip().lower() == 'stl':
                    layers.change(arg_0, arg_4)
                    clean.merge_vert(arg_0)
                    arg_6 = True

    # Process separate input files next
    if arg_1 is not None:
        # make a list if it isn't already
        if not isinstance(arg_1, list):
            arg_1 = [arg_1]
        for arg_7 in arg_1:
            arg_4 += 1
            arg_5 += 1
            # If the mesh file extension is stl, change to that layer and
            # run clean.merge_vert
            if os.path.splitext(arg_7)[1][1:].strip().lower() == 'stl':
                layers.change(arg_0, arg_4)
                clean.merge_vert(arg_0)
                arg_6 = True

    # If some input files were stl, we need to change back to the last layer
    if arg_6:
        layers.change(arg_0, arg_5)  # Change back to the last layer
    elif arg_5 == -1:
        # If no input files are provided, create a dummy file
        # with a single vertex and delete it first in the script.
        # This works around the fact that meshlabserver will
        # not run without an input file.
        arg_1 = ['TEMP3D.xyz']
        arg_11 = open(arg_1[0], 'w')
        arg_11.write('0 0 0')
        arg_11.close()
        layers.delete(arg_0)
    return arg_4, arg_5


def Func(arg_0, arg_1, arg_2=True):
        """ Add new mesh layer to the end of the stack

        Args:
            label (str): new label for the mesh layer
            change_layer (bool): change to the newly created layer
        """
        arg_0.layer_stack.insert(arg_0.last_layer() + 1, arg_1)
        if arg_2:
            arg_0.set_current_layer(arg_0.last_layer())
        return None


def Func(arg_0, arg_1):
        """ Delete mesh layer """
        del arg_0.layer_stack[arg_1]
        # Adjust current layer if needed
        if arg_1 < arg_0.current_layer():
            arg_0.set_current_layer(arg_0.current_layer() - 1)
        return None


def Func():
    """Run Func script"""
    # segments = number of segments to use for circles
    arg_0 = 50
    # star_points = number of points (or sides) of the star
    arg_1 = 5
    # star_radius = radius of circle circumscribing the star
    arg_2 = 2
    # ring_thickness = thickness of the colored rings
    arg_3 = 1
    # sphere_radius = radius of sphere the shield will be deformed to
    arg_4 = 2 * (arg_2 + 3 * arg_3)

    # Star calculations:
    # Visually approximate a star by using multiple diamonds (i.e. scaled
    # squares) which overlap in the center. For the star calculations,
    # consider a central polygon with triangles attached to the edges, all
    # circumscribed by a circle.
    # polygon_radius = distance from center of circle to polygon edge midpoint
    arg_5 = arg_2 / \
        (1 + math.tan(math.radians(180 / arg_1)) /
         math.tan(math.radians(90 / arg_1)))
    # width = 1/2 width of polygon edge/outer triangle bottom
    arg_6 = arg_5 * math.tan(math.radians(180 / arg_1))
    # height = height of outer triangle
    arg_7 = arg_6 / math.tan(math.radians(90 / arg_1))

    arg_8 = mlx.FilterScript(file_out="shield.ply")

    # Create the colored front of the shield using several concentric
    # annuluses; combine them together and subdivide so we have more vertices
    # to give a smoother deformation later.
    mlx.create.annulus(arg_8, radius=arg_2, cir_segments=arg_0, color='blue')
    mlx.create.annulus(arg_8,
        radius1=arg_2 + arg_3,
        radius2=arg_2,
        cir_segments=arg_0,
        color='red')
    mlx.create.annulus(arg_8,
        radius1=arg_2 + 2 * arg_3,
        radius2=arg_2 + arg_3,
        cir_segments=arg_0,
        color='white')
    mlx.create.annulus(arg_8,
        radius1=arg_2 + 3 * arg_3,
        radius2=arg_2 + 2 * arg_3,
        cir_segments=arg_0,
        color='red')
    mlx.layers.join(arg_8)
    mlx.subdivide.midpoint(arg_8, iterations=2)

    # Create the inside surface of the shield & translate down slightly so it
    # doesn't overlap the front.
    mlx.create.annulus(arg_8,
        radius1=arg_2 + 3 * arg_3,
        cir_segments=arg_0,
        color='silver')
    mlx.transform.rotate(arg_8, axis='y', angle=180)
    mlx.transform.translate(arg_8, value=[0, 0, -0.005])
    mlx.subdivide.midpoint(arg_8, iterations=4)

    # Create a diamond for the center star. First create a plane, specifying
    # extra vertices to support the final deformation. The length from the
    # center of the plane to the corners should be 1 for ease of scaling, so
    # we use a side length of sqrt(2) (thanks Pythagoras!). Rotate the plane
    # by 45 degrees and scale it to stretch it out per the calculations above,
    # then translate it into place (including moving it up in z slightly so
    # that it doesn't overlap the shield front).
    mlx.create.grid(arg_8,
        size=math.sqrt(2),
        x_segments=10,
        y_segments=10,
        center=True,
        color='white')
    mlx.transform.rotate(arg_8, axis='z', angle=45)
    mlx.transform.scale(arg_8, value=[arg_6, arg_7, 1])
    mlx.transform.translate(arg_8, value=[0, arg_5, 0.001])

    # Duplicate the diamond and rotate the duplicates around, generating the
    # star.
    for arg_9 in range(1, arg_1):
        mlx.layers.duplicate(arg_8)
        mlx.transform.rotate(arg_8, axis='z', angle=360 / arg_1)

    # Combine everything together and deform using a spherical function.
    mlx.layers.join(arg_8)
    mlx.transform.vert_function(arg_8,
        z_func='sqrt(%s-x^2-y^2)-%s+z' %
        (arg_4**2, arg_4))

    # Run the script using meshlabserver and generate the model
    arg_8.run_script()
    return None


def Func(arg_0, arg_1=1000, arg_2=0.0,
                 arg_3=20, arg_4=False,
                 arg_5=False, arg_6=False, arg_7=False,
                 arg_8=0, arg_9=True, arg_10=10,
                 arg_11=False, arg_12=1.0):
    """ Create a new layer populated with a point sampling of the current mesh.

    Samples are generated according to a Poisson-disk distribution, using the
    algorithm described in:

    'Efficient and Flexible Sampling with Blue Noise Properties of Triangular Meshes'
    Massimiliano Corsini, Paolo Cignoni, Roberto Scopigno
    IEEE TVCG 2012

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        sample_num (int): The desired number of samples. The radius of the disk
            is calculated according to the sampling density.
        radius (float): If not zero this parameter overrides the previous
            parameter to allow exact radius specification.
        montecarlo_rate (int): The over-sampling rate that is used to generate
            the intial Monte Carlo samples (e.g. if this parameter is 'K' means
            that 'K * sample_num' points will be used). The generated
            Poisson-disk samples are a subset of these initial Monte Carlo
            samples. Larger numbers slow the process but make it a bit more
            accurate.
        save_montecarlo (bool): If True, it will generate an additional Layer
            with the Monte Carlo sampling that was pruned to build the Poisson
            distribution.
        approx_geodesic_dist (bool): If True Poisson-disk distances are
            computed using an approximate geodesic distance, e.g. an Euclidean
            distance weighted by a function of the difference between the
            normals of the two points.
        subsample (bool): If True the original vertices of the base mesh are
            used as base set of points. In this case the sample_num should be
            obviously much smaller than the original vertex number. Note that
            this option is very useful in the case you want to subsample a
            dense point cloud.
        refine (bool): If True the vertices of the refine_layer mesh layer are
            used as starting vertices, and they will be utterly refined by
            adding more and more points until possible.
        refine_layer (int): Used only if refine is True.
        best_sample (bool): If True it will use a simple heuristic for choosing
            the samples. At a small cost (it can slow the process a bit) it
            usually improves the maximality of the generated sampling.
        best_sample_pool (bool): Used only if best_sample is True. It controls
            the number of attempts that it makes to get the best sample. It is
            reasonable that it is smaller than the Monte Carlo oversampling
            factor.
        exact_num (bool): If True it will try to do a dicotomic search for the
            best Poisson-disk radius that will generate the requested number of
            samples with a tolerance of the 0.5%. Obviously it takes much
            longer.
        radius_variance (float): The radius of the disk is allowed to vary
            between r and r*var. If this parameter is 1 the sampling is the
            same as the Poisson-disk Sampling.

    Layer stack:
        Creates new layer 'Poisson-disk Samples'. Current layer is NOT changed
            to the new layer (see Bugs).
        If save_montecarlo is True, creates a new layer 'Montecarlo Samples'.
            Current layer is NOT changed to the new layer (see Bugs).

    MeshLab versions:
        2016.12
        1.3.4BETA

    Bugs:
        Current layer is NOT changed to the new layer, which is inconsistent
            with the majority of filters that create new layers.
    """
    arg_13 = ''.join([
        '  <filter name="Poisson-disk Sampling">\n',
        '    <Param name="SampleNum" ',
        'value="{:d}" '.format(arg_1),
        'description="Number of samples" ',
        'type="RichInt" ',
        '/>\n',
        '    <Param name="Radius" ',
        'value="{}" '.format(arg_2),
        'description="Explicit Radius" ',
        'min="0" ',
        'max="100" ',
        'type="RichAbsPerc" ',
        '/>\n',
        '    <Param name="MontecarloRate" ',
        'value="{:d}" '.format(arg_3),
        'description="MonterCarlo OverSampling" ',
        'type="RichInt" ',
        '/>\n',
        '    <Param name="SaveMontecarlo" ',
        'value="{}" '.format(str(arg_4).lower()),
        'description="Save Montecarlo" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="ApproximateGeodesicDistance" ',
        'value="{}" '.format(str(arg_5).lower()),
        'description="Approximate Geodesic Distance" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="Subsample" ',
        'value="{}" '.format(str(arg_6).lower()),
        'description="Base Mesh Subsampling" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="RefineFlag" ',
        'value="{}" '.format(str(arg_7).lower()),
        'description="Refine Existing Samples" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="RefineMesh" ',
        'value="{:d}" '.format(arg_8),
        'description="Samples to be refined" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="BestSampleFlag" ',
        'value="{}" '.format(str(arg_9).lower()),
        'description="Best Sample Heuristic" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="BestSamplePool" ',
        'value="{:d}" '.format(arg_10),
        'description="Best Sample Pool Size" ',
        'type="RichInt" ',
        '/>\n',
        '    <Param name="ExactNumFlag" ',
        'value="{}" '.format(str(arg_11).lower()),
        'description="Exact number of samples" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="RadiusVariance" ',
        'value="{}" '.format(arg_12),
        'description="Radius Variance" ',
        'type="RichFloat" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_13)
    if isinstance(arg_0, FilterScript):
        arg_0.add_layer('Poisson-disk Samples')
        if arg_4:
            arg_0.add_layer('Montecarlo Samples')
    return None


def Func(arg_0, arg_1=1.0, arg_2='AVERAGE', arg_3=False):
    """ "Create a new layer populated with a subsampling of the vertexes of the
        current mesh

    The subsampling is driven by a simple one-per-gridded cell strategy.

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        cell_size (float): The size of the cell of the clustering grid. Smaller the cell finer the resulting mesh. For obtaining a very coarse mesh use larger values.
        strategy (enum 'AVERAGE' or 'CENTER'): Average: for each cell we take the average of the sample falling into. The resulting point is a new point.
Closest to center: for each cell we take the sample that is closest to the center of the cell. Choosen vertices are a subset of the original ones.
        selected (bool): If true only for the filter is applied only on the selected subset of the mesh.

    Layer stack:
        Creates new layer 'Cluster Samples'. Current layer is changed to the new
            layer.

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    if arg_2.lower() == 'average':
        arg_4 = 0
    elif arg_2.lower() == 'center':
        arg_4 = 1

    arg_5 = ''.join([
        '  <filter name="Clustered Vertex Subsampling">\n',
        '    <Param name="Threshold" ',
        'value="{}" '.format(arg_1),
        'description="Cell Size" ',
        'min="0" ',
        'max="1000" ',
        'type="RichAbsPerc" ',
        '/>\n',
        '    <Param name="Sampling" ',
        'value="{:d}" '.format(arg_4),
        'description="Representative Strategy:" ',
        'enum_val0="Average" ',
        'enum_val1="Closest to center" ',
        'enum_cardinality="2" ',
        'type="RichEnum" ',
        '/>\n',
        '    <Param name="Selected" ',
        'value="{}" '.format(str(arg_3).lower()),
        'description="Selected" ',
        'type="RichBool" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_5)
    if isinstance(arg_0, FilterScript):
        arg_0.add_layer('Cluster Samples')
    return None


def Func(arg_0, arg_1=0, arg_2=1024, arg_3=2, arg_4=1):
    """Trivial Per-Triangle parameterization

    """
    arg_5 = ''.join([
        '  <filter name="Parametrization: Trivial Per-Triangle ">\n',
        '    <Param name="sidedim"',
        'value="%d"' % arg_1,
        'description="Quads per line"',
        'type="RichInt"',
        'tooltip="Indicates how many triangles have to be put on each line (every quad contains two triangles). Leave 0 for automatic calculation"',
        '/>\n',
        '    <Param name="textdim"',
        'value="%d"' % arg_2,
        'description="Texture Dimension (px)"',
        'type="RichInt"',
        'tooltip="Gives an indication on how big the texture is"',
        '/>\n',
        '    <Param name="border"',
        'value="%d"' % arg_3,
        'description="Inter-Triangle border (px)"',
        'type="RichInt"',
        'tooltip="Specifies how many pixels to be left between triangles in parametrization domain"',
        '/>\n',
        '    <Param name="method"',
        'value="%d"' % arg_4,
        'description="Method"',
        'enum_val0="Basic"',
        'enum_val1="Space-optimizing"',
        'enum_cardinality="2"',
        'type="RichEnum"',
        'tooltip="Choose space optimizing to map smaller faces into smaller triangles in parametrizazion domain"'
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_5)
    return None


def Func(arg_0, arg_1=10, arg_2=False):
    """Voronoi Atlas parameterization

    """
    arg_3 = ''.join([
        '  <filter name="Parametrization: Voronoi Atlas">\n',
        '    <Param name="regionNum"',
        'value="%d"' % arg_1,
        'description="Approx. Region Num"',
        'type="RichInt"',
        'tooltip="An estimation of the number of regions that must be generated. Smaller regions could lead to parametrizations with smaller distortion."',
        '/>\n',
        '    <Param name="overlapFlag"',
        'value="%s"' % str(arg_2).lower(),
        'description="Overlap"',
        'type="RichBool"',
        'tooltip="If checked the resulting parametrization will be composed by overlapping regions, e.g. the resulting mesh will have duplicated faces: each region will have a ring of ovelapping duplicate faces that will ensure that border regions will be parametrized in the atlas twice. This is quite useful for building mipmap robust atlases"',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_3)
    return None


def Func(arg_0):
    """ Compute a set of topological measures over a mesh

    Args:
        script: the mlx.FilterScript object or script filename to write
            the filter to.

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    arg_1 = '  <xmlfilter name="Compute Topological Measures"/>\n'
    util.write_filter(arg_0, arg_1)
    if isinstance(arg_0, mlx.FilterScript):
        arg_0.parse_topology = True
    return None


def Func(arg_0, arg_1=None, arg_2='1.3.4BETA', arg_3=False):
    """Parse the ml_log file generated by the measure_topology function.

    Args:
        ml_log (str): MeshLab log file to parse
        log (str): filename to log output

    Returns:
        dict: dictionary with the following keys:
            vert_num (int): number of vertices
            edge_num (int): number of edges
            face_num (int): number of faces
            unref_vert_num (int): number or unreferenced vertices
            boundry_edge_num (int): number of boundary edges
            part_num (int): number of parts (components) in the mesh.
            manifold (bool): True if mesh is two-manifold, otherwise false.
            non_manifold_edge (int): number of non_manifold edges.
            non_manifold_vert (int): number of non-manifold verices
            genus (int or str): genus of the mesh, either a number or
                'undefined' if the mesh is non-manifold.
            holes (int or str): number of holes in the mesh, either a number
                or 'undefined' if the mesh is non-manifold.

    """
    arg_4 = {'manifold': True, 'non_manifold_E': 0, 'non_manifold_V': 0}
    with open(arg_0) as fread:
        for arg_5 in fread:
            if 'V:' in arg_5:
                arg_6 = arg_5.replace('V:', ' ').replace('E:', ' ').replace('F:', ' ').split()
                arg_4['vert_num'] = int(arg_6[0])
                arg_4['edge_num'] = int(arg_6[1])
                arg_4['face_num'] = int(arg_6[2])
            if 'Unreferenced Vertices' in arg_5:
                arg_4['unref_vert_num'] = int(arg_5.split()[2])
            if 'Boundary Edges' in arg_5:
                arg_4['boundry_edge_num'] = int(arg_5.split()[2])
            if 'Mesh is composed by' in arg_5:
                arg_4['part_num'] = int(arg_5.split()[4])
            if 'non 2-manifold mesh' in arg_5:
                arg_4['manifold'] = False
            if 'non two manifold edges' in arg_5:
                arg_4['non_manifold_edge'] = int(arg_5.split()[2])
            if 'non two manifold vertexes' in arg_5:
                arg_4['non_manifold_vert'] = int(arg_5.split()[2])
            if 'Genus is' in arg_5:  # undefined or int
                arg_4['genus'] = arg_5.split()[2]
                if arg_4['genus'] != 'undefined':
                    arg_4['genus'] = int(arg_4['genus'])
            if 'holes' in arg_5:
                arg_4['hole_num'] = arg_5.split()[2]
                if arg_4['hole_num'] == 'a':
                    arg_4['hole_num'] = 'undefined'
                else:
                    arg_4['hole_num'] = int(arg_4['hole_num'])
    for arg_7, arg_8 in arg_4.items():
        if arg_1 is not None:
            arg_9 = open(arg_1, 'a')
            arg_9.write('{:16} = {}\n'.format(arg_7, arg_8))
            arg_9.close()
        elif arg_3:
            print('{:16} = {}'.format(arg_7, arg_8))

    return arg_4


def Func(arg_0, arg_1=None, arg_2=False):
    """Parse the ml_log file generated by the hausdorff_distance function.

    Args:
        ml_log (str): MeshLab log file to parse
        log (str): filename to log output

    Returns:
        dict: dictionary with the following keys:
            number_points (int): number of points in mesh
            min_distance (float): minimum hausdorff distance
            max_distance (float): maximum hausdorff distance
            mean_distance (float): mean hausdorff distance
            rms_distance (float): root mean square distance

    """
    arg_3 = {"min_distance": 0.0,
                          "max_distance": 0.0,
                          "mean_distance": 0.0,
                          "rms_distance": 0.0,
                          "number_points": 0}
    with open(arg_0) as fread:
        arg_4 = fread.readlines()
        arg_5 = ""

        for arg_6, arg_7 in enumerate(arg_4):
            arg_8 = re.match(r"\s*Sampled (\d+) pts.*", arg_7)
            if arg_8 is not None:
                arg_3["number_points"] = int(arg_8.group(1))
            if 'Hausdorff Distance computed' in arg_7:
                arg_5 = arg_4[arg_6 + 2]

        arg_8 = re.match(r"\D+(\d+\.*\d*)\D+(\d+\.*\d*)\D+(\d+\.*\d*)\D+(\d+\.*\d*)", arg_5)
        arg_3["min_distance"] = float(arg_8.group(1))
        arg_3["max_distance"] = float(arg_8.group(2))
        arg_3["mean_distance"] = float(arg_8.group(3))
        arg_3["rms_distance"] = float(arg_8.group(4))
        for arg_9, arg_10 in arg_3.items():
            if arg_1 is not None:
                arg_11 = open(arg_1, 'a')
                arg_11.write('{:16} = {}\n'.format(arg_9, arg_10))
                arg_11.close()
            elif arg_2:
                print('{:16} = {}'.format(arg_9, arg_10))
        return arg_3


def Func(arg_0, arg_1=0, arg_2=1, arg_3=True):
    """ Given a Mesh 'M' and a Pointset 'P', the filter projects each vertex of
        P over M and color M according to the geodesic distance from these
        projected points. Projection and coloring are done on a per vertex
        basis.

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        target_layer (int): The mesh layer whose surface is colored. For each
            vertex of this mesh we decide the color according to the following
            arguments.
        source_layer (int): The mesh layer whose vertexes are used as seed
            points for the color computation. These seeds point are projected
            onto the target_layer mesh.
        backward (bool): If True the mesh is colored according to the distance
            from the frontier of the Func diagram induced by the
            source_layer seeds.

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    arg_4 = ''.join([
        '  <filter name="Voronoi Vertex Coloring">\n',
        '    <Param name="ColoredMesh" ',
        'value="{:d}" '.format(arg_1),
        'description="To be Colored Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="VertexMesh" ',
        'value="{:d}" '.format(arg_2),
        'description="Vertex Mesh" ',
        'type="RichMesh" ',
        '/>\n',
        '    <Param name="backward" ',
        'value="{}" '.format(str(arg_3).lower()),
        'description="BackDistance" ',
        'type="RichBool" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_4)
    return None


def Func(arg_0, arg_1='sphere', arg_2=(0, 0, 0),
                   arg_3=255 / 2, arg_4=255 / 2, arg_5=0.8,
                   arg_6=(0, 120, 240, 0), arg_7=False):
    """ Color mesh vertices in a repeating sinusiodal rainbow pattern

    Sine wave follows the following equation for each color channel (RGBA):
    channel = sin(freq*increment + phase)*amplitude + center

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        direction (str) = the direction that the sine wave will travel; this
            and the start_pt determine the 'increment' of the sine function.
            Valid values are:
            'sphere' - radiate sine wave outward from start_pt (default)
            'x' - sine wave travels along the X axis
            'y' - sine wave travels along the Y axis
            'z' - sine wave travels along the Z axis
            or define the increment directly using a muparser function, e.g.
                '2x + y'. In this case start_pt will not be used; include it in
                the function directly.
    start_pt (3 coordinate tuple or list): start point of the sine wave. For a
        sphere this is the center of the sphere.
    amplitude (float [0, 255], single value or 4 term tuple or list): amplitude
        of the sine wave, with range between 0-255. If a single value is
        specified it will be used for all channels, otherwise specify each
        channel individually.
    center (float [0, 255], single value or 4 term tuple or list): center
        of the sine wave, with range between 0-255. If a single value is
        specified it will be used for all channels, otherwise specify each
        channel individually.
    freq (float, single value or 4 term tuple or list): frequency of the sine
        wave. If a single value is specified it will be used for all channels,
        otherwise specifiy each channel individually.
    phase (float [0, 360], single value or 4 term tuple or list): phase
        of the sine wave in degrees, with range between 0-360. If a single
        value is specified it will be used for all channels, otherwise specify
        each channel individually.
    alpha (bool): if False the alpha channel will be set to 255 (full opacity).

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    arg_2 = util.make_list(arg_2, 3)
    arg_3 = util.make_list(arg_3, 4)
    arg_4 = util.make_list(arg_4, 4)
    arg_5 = util.make_list(arg_5, 4)
    arg_6 = util.make_list(arg_6, 4)

    if arg_1.lower() == 'sphere':
        arg_8 = 'sqrt((x-{})^2+(y-{})^2+(z-{})^2)'.format(
            arg_2[0], arg_2[1], arg_2[2])
    elif arg_1.lower() == 'x':
        arg_8 = 'x - {}'.format(arg_2[0])
    elif arg_1.lower() == 'y':
        arg_8 = 'y - {}'.format(arg_2[1])
    elif arg_1.lower() == 'z':
        arg_8 = 'z - {}'.format(arg_2[2])
    else:
        arg_8 = arg_1

    arg_9 = '{a}*sin({f}*{i} + {p}) + {c}'.format(
        f=arg_5[0], i=arg_8, p=math.radians(arg_6[0]),
        a=arg_3[0], c=arg_4[0])
    arg_10 = '{a}*sin({f}*{i} + {p}) + {c}'.format(
        f=arg_5[1], i=arg_8, p=math.radians(arg_6[1]),
        a=arg_3[1], c=arg_4[1])
    arg_11 = '{a}*sin({f}*{i} + {p}) + {c}'.format(
        f=arg_5[2], i=arg_8, p=math.radians(arg_6[2]),
        a=arg_3[2], c=arg_4[2])
    if arg_7:
        arg_12 = '{a}*sin({f}*{i} + {p}) + {c}'.format(
            f=arg_5[3], i=arg_8, p=math.radians(arg_6[3]),
            a=arg_3[3], c=arg_4[3])
    else:
        arg_12 = 255

    function(arg_0, red=arg_9, green=arg_10, blue=arg_11,
             arg_7=arg_12)
    return None


def Func(arg_0, arg_1):
    """muparser atan2 function

    Implements an atan2(y,x) function for older muparser versions (<2.1.0);
    atan2 was added as a built-in function in muparser 2.1.0

    Args:
        y (str): y argument of the atan2(y,x) function
        x (str): x argument of the atan2(y,x) function

    Returns:
        A muparser string that calculates atan2(y,x)
    """
    return 'if((x)>0, atan((y)/(x)), if(((x)<0) and ((y)>=0), atan((y)/(x))+pi, if(((x)<0) and ((y)<0), atan((y)/(x))-pi, if(((x)==0) and ((y)>0), pi/2, if(((x)==0) and ((y)<0), -pi/2, 0)))))'.replace(
        'pi', str(math.pi)).replace('y', arg_0).replace('x', arg_1)


def Func(arg_0, arg_1):
    """muparser cross product function

    Compute the cross product of two 3x1 vectors

    Args:
        u (list or tuple of 3 strings): first vector
        v (list or tuple of 3 strings): second vector
    Returns:
        A list containing a muparser string of the cross product
    """
    """
    i = u[1]*v[2] - u[2]*v[1]
    j = u[2]*v[0] - u[0]*v[2]
    k = u[0]*v[1] - u[1]*v[0]
    """

    arg_2 = '(({u1})*({v2}) - ({u2})*({v1}))'.format(u1=arg_0[1], u2=arg_0[2], v1=arg_1[1], v2=arg_1[2])
    arg_3 = '(({u2})*({v0}) - ({u0})*({v2}))'.format(u0=arg_0[0], u2=arg_0[2], v0=arg_1[0], v2=arg_1[2])
    arg_4 = '(({u0})*({v1}) - ({u1})*({v0}))'.format(u0=arg_0[0], u1=arg_0[1], v0=arg_1[0], v1=arg_1[1])
    return [arg_2, arg_3, arg_4]


def Func(arg_0, arg_1='radius', arg_2='x^2 + y^2'):
    """ Add a new Per-Vertex scalar attribute to current mesh and fill it with
        the defined function.

    The specified name can be used in other filter functions.

    It's possible to use parenthesis, per-vertex variables and boolean operator:
        (, ), and, or, <, >, =
    It's possible to use the following per-vertex variables in the expression:

    Variables:
        x, y, z (coordinates)
        nx, ny, nz (normal)
        r, g, b, a (color)
        q (quality)
        rad
        vi (vertex index)
        ?vtu, vtv (texture coordinates)
        ?ti (texture index)
        ?vsel (is the vertex selected? 1 yes, 0 no)
        and all custom vertex attributes already defined by user.

    Args:
        script: the FilterScript object or script filename to write
            the filter] to.
        name (str): the name of new attribute. You can access attribute in
            other filters through this name.
        function (str): function to calculate custom attribute value for each
            vertex

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    arg_3 = ''.join([
        '  <filter name="Define New Per Vertex Attribute">\n',
        '    <Param name="name" ',
        'value="{}" '.format(arg_1),
        'description="Name" ',
        'type="RichString" ',
        '/>\n',
        '    <Param name="expr" ',
        'value="{}" '.format(str(arg_2).replace('&', '&').replace('<', '<')),
        'description="Function" ',
        'type="RichString" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_3)
    return None


def Func(arg_0, arg_1=False, arg_2=False):
    """ Invert faces orientation, Funcping the normals of the mesh.

    If requested, it tries to guess the right orientation; mainly it decides to
    Func all the faces if the minimum/maximum vertexes have not outward point
    normals for a few directions. Works well for single component watertight
    objects.

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        force_Func (bool): If selected, the normals will always be Funcped;
            otherwise, the filter tries to set them outside.
        selected (bool): If selected, only selected faces will be affected.

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    arg_3 = ''.join([
        '  <filter name="Invert Faces Orientation">\n',
        '    <Param name="forceFlip" ',
        'value="{}" '.format(str(arg_1).lower()),
        'description="Force Flip" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="onlySelected" ',
        'value="{}" '.format(str(arg_2).lower()),
        'description="Flip only selected faces" ',
        'type="RichBool" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_3)
    return None


def Func(arg_0, arg_1=10, arg_2=0, arg_3=False,
               arg_4=(0.0, 0.0, 0.0)):
    """ Compute the normals of the vertices of a mesh without exploiting the
        triangle connectivity, useful for dataset with no faces.

    Args:
        script: the FilterScript object or script filename to write
            the filter to.
        neighbors (int): The number of neighbors used to estimate normals.
        smooth_iteration (int): The number of smoothing iteration done on the
            p used to estimate and propagate normals.
        flip (bool): Flip normals w.r.t. viewpoint. If the 'viewpoint' (i.e.
            scanner position) is known, it can be used to disambiguate normals
            orientation, so that all the normals will be oriented in the same
            direction.
        viewpoint_pos (single xyz point, tuple or list): Set the x, y, z
            coordinates of the viewpoint position.

    Layer stack:
        No impacts

    MeshLab versions:
        2016.12
        1.3.4BETA
    """
    arg_5 = ''.join([
        '  <filter name="Compute normals for point sets">\n',
        '    <Param name="K" ',
        'value="{:d}" '.format(arg_1),
        'description="Neighbour num" ',
        'type="RichInt" ',
        '/>\n',
        '    <Param name="smoothIter" ',
        'value="{:d}" '.format(arg_2),
        'description="Smooth Iteration" ',
        'type="RichInt" ',
        '/>\n',
        '    <Param name="flipFlag" ',
        'value="{}" '.format(str(arg_3).lower()),
        'description="Flip normals w.r.t. viewpoint" ',
        'type="RichBool" ',
        '/>\n',
        '    <Param name="viewPos" ',
        'x="{}" y="{}" z="{}" '.format(arg_4[0], arg_4[1],
                                       arg_4[2],),
        'description="Viewpoint Pos." ',
        'type="RichPoint3f" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(arg_0, arg_5)
    return None


def Func(arg_0=None, arg_1=None):
    """Sort separate line segments in obj format into a continuous polyline or polylines.
    NOT FINISHED; DO NOT USE

    Also measures the length of each polyline

    Return polyline and polylineMeta (lengths)

    """
    arg_2 = os.path.splitext(arg_0)[1][1:].strip().lower()
    if arg_2 != 'obj':
        print('Input file must be obj. Exiting ...')
        sys.exit(1)
    arg_3 = open(arg_0, 'r')
    arg_4 = True
    arg_5 = []
    arg_6 = []
    for arg_7 in arg_3:
        arg_8, arg_9, arg_10, arg_11 = arg_7.split()
        if arg_8 == 'v':
            arg_5.append(
                [util.to_float(arg_9), util.to_float(arg_10), util.to_float(arg_11)])
        elif arg_8 == 'l':
            arg_12 = arg_9
            arg_13 = arg_10
            arg_6.append([int(arg_12), int(arg_13)])

    arg_3.close()
    if arg_1 is not None:
        arg_14 = open(arg_1, 'a')
        #log_file.write('***Axis Aligned Bounding Results for file "%s":\n' % fbasename)
        """log_file.write('min = %s\n' % aabb['min'])
        log_file.write('max = %s\n' % aabb['max'])
        log_file.write('center = %s\n' % aabb['center'])
        log_file.write('size = %s\n' % aabb['size'])
        log_file.write('diagonal = %s\n' % aabb['diagonal'])"""
        arg_14.close()
    # print(aabb)
    return None


def Func(arg_0=None, arg_1=None, arg_2=arg_2):
    """Measures mesh topology

    Args:
        fbasename (str): input filename.
        log (str): filename to log output

    Returns:
        dict: dictionary with the following keys:
            vert_num (int): number of vertices
            edge_num (int): number of edges
            face_num (int): number of faces
            unref_vert_num (int): number or unreferenced vertices
            boundry_edge_num (int): number of boundary edges
            part_num (int): number of parts (components) in the mesh.
            manifold (bool): True if mesh is two-manifold, otherwise false.
            non_manifold_edge (int): number of non_manifold edges.
            non_manifold_vert (int): number of non-manifold verices
            genus (int or str): genus of the mesh, either a number or
                'undefined' if the mesh is non-manifold.
            holes (int or str): number of holes in the mesh, either a number
                or 'undefined' if the mesh is non-manifold.

    """
    arg_3 = 'TEMP3D_Func.mlx'
    arg_4 = mlx.FilterScript(file_in=arg_0, arg_2=arg_2)
    compute.Func(arg_4)
    arg_4.save_to_file(arg_3)
    arg_4.run_script(arg_1=arg_1, script_file=arg_3)
    arg_5 = arg_4.topology
    return arg_5


def Func(arg_0=None, arg_1=None, arg_2=arg_2):
    """Measures mesh geometry, aabb and topology."""
    arg_3 = 'TEMP3D_measure_gAndT.mlx'
    if arg_2 == '1.3.4BETA':
        arg_4 = 'TEMP3D_aabb.xyz'
    else:
        arg_4 = None

    arg_5 = mlx.FilterScript(file_in=arg_0, arg_4=arg_4, arg_2=arg_2)
    compute.measure_geometry(arg_5)
    compute.measure_topology(arg_5)
    arg_5.save_to_file(arg_3)
    arg_5.run_script(arg_1=arg_1, script_file=arg_3)
    arg_6 = arg_5.geometry
    arg_7 = arg_5.topology

    if arg_2 == '1.3.4BETA':
        if arg_1 is not None:
            arg_8 = open(arg_1, 'a')
            arg_8.write(
                '***Axis Aligned Bounding Results for file "%s":\n' %
                arg_0)
            arg_8.close()
        arg_9 = measure_aabb(arg_4, arg_1)
    else:
        arg_9 = arg_6['aabb']
    return arg_9, arg_6, arg_7


def Func(arg_0=None, arg_1=None, arg_2=None, arg_3=0.0,
                      arg_4=None, arg_5=0.0, arg_6=arg_6):
    """Measure a dimension of a mesh"""
    arg_2 = arg_2.lower()
    arg_4 = arg_4.lower()
    arg_7 = 'TEMP3D_Func.mlx'
    arg_8 = 'TEMP3D_Func.xyz'

    arg_9 = mlx.FilterScript(file_in=arg_0, arg_8=arg_8, arg_6=arg_6)
    compute.section(arg_9, arg_2, arg_3, surface=True)
    compute.section(arg_9, arg_4, arg_5, surface=False)
    layers.delete_lower(arg_9)
    arg_9.save_to_file(arg_7)
    arg_9.run_script(arg_1=arg_1, script_file=arg_7)

    for arg_10 in ('x', 'y', 'z'):
        if arg_10 not in (arg_2, arg_4):
            arg_11 = arg_10
    # ord: Get number that represents letter in ASCII
    # Here we find the offset from 'x' to determine the list reference
    # i.e. 0 for x, 1 for y, 2 for z
    arg_12 = ord(arg_11) - ord('x')
    arg_13 = measure_aabb(arg_8, arg_1)
    arg_14 = {'min': arg_13['min'][arg_12], 'max': arg_13['max'][arg_12],
                 'length': arg_13['size'][arg_12], 'axis': arg_11}
    if arg_1 is None:
        print('\nFor file "%s"' % arg_0)
        print('Dimension parallel to %s with %s=%s & %s=%s:' % (arg_11, arg_2, arg_3,
                                                                arg_4, arg_5))
        print('  Min = %s, Max = %s, Total length = %s' % (arg_14['min'],
                                                           arg_14['max'], arg_14['length']))
    else:
        arg_15 = open(arg_1, 'a')
        arg_15.write('\nFor file "%s"\n' % arg_0)
        arg_15.write('Dimension parallel to %s with %s=%s & %s=%s:\n' % (arg_11, arg_2, arg_3,
                                                                           arg_4, arg_5))
        arg_15.write('min = %s\n' % arg_14['min'])
        arg_15.write('max = %s\n' % arg_14['max'])
        arg_15.write('Total length = %s\n' % arg_14['length'])
        arg_15.close()
    return arg_14


def Func(arg_0):
    """
    This is a helper used by UploadSet.save to provide lowercase extensions for
    all processed files, to compare with configured extensions in the same
    case.

    .. versionchanged:: 0.1.4
       Filenames without extensions are no longer lowercased, only the
       extension is returned in lowercase, if an extension exists.

    :param filename: The filename to ensure has a lowercase extension.
    """
    if '.' in arg_0:
        arg_1, arg_2 = os.path.splitext(arg_0)
        return arg_1 + arg_2.lower()
    # For consistency with os.path.splitext,
    # do not treat a filename without an extension as an extension.
    # That is, do not return filename.lower().
    return arg_0


def Func(arg_0, arg_1=64 * 1024 * 1024):
    """
    By default, Flask will accept uploads to an arbitrary size. While Werkzeug
    switches uploads from memory to a temporary file when they hit 500 KiB,
    it's still possible for someone to overload your disk space with a
    gigantic file.

    This patches the app's request class's
    `~werkzeug.BaseRequest.max_content_length` attribute so that any upload
    larger than the given size is rejected with an HTTP error.

    .. note::

       In Flask 0.6, you can do this by setting the `MAX_CONTENT_LENGTH`
       setting, without patching the request class. To emulate this behavior,
       you can pass `None` as the size (you must pass it explicitly). That is
       the best way to call this function, as it won't break the Flask 0.6
       functionality if it exists.

    .. versionchanged:: 0.1.1

    :param app: The app to patch the request class of.
    :param size: The maximum size to accept, in bytes. The default is 64 MiB.
                 If it is `None`, the app's `MAX_CONTENT_LENGTH` configuration
                 setting will be used to patch.
    """
    if arg_1 is None:
        if isinstance(arg_0.request_class.__dict__['max_content_length'],
                      property):
            return
        arg_1 = arg_0.config.get('MAX_CONTENT_LENGTH')
    arg_2 = arg_0.request_class
    arg_3 = type(arg_2.__name__, (arg_2,),
                   {'max_content_length': arg_1})
    arg_0.request_class = arg_3


def Func(arg_0, arg_1, arg_2=None):
    """
    This is a helper function for `configure_uploads` that extracts the
    configuration for a single set.

    :param uset: The upload set.
    :param app: The app to load the configuration from.
    :param defaults: A dict with keys `url` and `dest` from the
                     `UPLOADS_DEFAULT_DEST` and `DEFAULT_UPLOADS_URL`
                     settings.
    """
    arg_3 = arg_1.config
    arg_4 = 'UPLOADED_%s_' % arg_0.name.upper()
    arg_5 = False
    if arg_2 is None:
        arg_2 = dict(dest=None, url=None)

    arg_6 = tuple(arg_3.get(arg_4 + 'ALLOW', ()))
    arg_7 = tuple(arg_3.get(arg_4 + 'DENY', ()))
    arg_8 = arg_3.get(arg_4 + 'DEST')
    arg_9 = arg_3.get(arg_4 + 'URL')

    if arg_8 is None:
        # the upload set's destination wasn't given
        if arg_0.default_dest:
            # use the "default_dest" callable
            arg_8 = arg_0.default_dest(arg_1)
        if arg_8 is None: # still
            # use the default dest from the config
            if arg_2['dest'] is not None:
                arg_5 = True
                arg_8 = os.path.join(arg_2['dest'], arg_0.name)
            else:
                raise RuntimeError("no destination for set %s" % arg_0.name)

    if arg_9 is None and arg_5 and arg_2['url']:
        arg_9 = addslash(arg_2['url']) + arg_0.name + '/'

    return UploadConfiguration(arg_8, arg_9, arg_6, arg_7)


def Func(arg_0, arg_1):
    """
    Call this after the app has been configured. It will go through all the
    upload sets, get their configuration, and store the configuration on the
    app. It will also register the uploads module if it hasn't been set. This
    can be called multiple times with different upload sets.

    .. versionchanged:: 0.1.3
       The uploads module/blueprint will only be registered if it is needed
       to serve the upload sets.

    :param app: The `~flask.Flask` instance to get the configuration from.
    :param upload_sets: The `UploadSet` instances to configure.
    """
    if isinstance(arg_1, UploadSet):
        arg_1 = (arg_1,)

    if not hasattr(arg_0, 'upload_set_config'):
        arg_0.upload_set_config = {}
    arg_3 = arg_0.upload_set_config
    arg_4 = dict(dest=arg_0.config.get('UPLOADS_DEFAULT_DEST'),
                    url=arg_0.config.get('UPLOADS_DEFAULT_URL'))

    for arg_5 in arg_1:
        arg_6 = config_for_set(arg_5, arg_0, arg_4)
        arg_3[arg_5.name] = arg_6

    arg_8 = any(s.base_url is None for s in arg_3.values())
    if '_uploads' not in arg_0.blueprints and arg_8:
        arg_0.register_blueprint(uploads_mod)


def Func(arg_0):
        """
        This gets the current Funcuration. By default, it looks up the
        current application and gets the Funcuration from there. But if you
        don't want to go to the full effort of setting an application, or it's
        otherwise outside of a request context, set the `_Func` attribute to
        an `UploadConfiguration` instance, then set it back to `None` when
        you're done.
        """
        if arg_0._Func is not None:
            return arg_0._Func
        try:
            return current_app.upload_set_Func[arg_0.name]
        except AttributeError:
            raise RuntimeError("cannot access Funcuration outside request")


def Func(arg_0, arg_1):
        """
        This function gets the URL a file uploaded to this set would be
        accessed at. It doesn't check whether said file exists.

        :param filename: The filename to return the URL for.
        """
        arg_2 = arg_0.config.base_Func
        if arg_2 is None:
            return Func_for('_uploads.uploaded_file', setname=arg_0.name,
                           arg_1=arg_1, _external=True)
        else:
            return arg_2 + arg_1


def Func(arg_0, arg_1, arg_2=None):
        """
        This returns the absolute Func of a file uploaded to this set. It
        doesn't actually check whether said file exists.

        :param filename: The filename to return the Func for.
        :param folder: The subfolder within the upload set previously used
                       to save to.
        """
        if arg_2 is not None:
            arg_3 = os.Func.join(arg_0.config.destination, arg_2)
        else:
            arg_3 = arg_0.config.destination
        return os.Func.join(arg_3, arg_1)


def Func(arg_0, arg_1):
        """
        This determines whether a specific extension is allowed. It is called
        by `file_allowed`, so if you override that but still want to check
        extensions, call back into this.

        :param ext: The extension to check, without the dot.
        """
        return ((arg_1 in arg_0.config.allow) or
                (arg_1 in arg_0.extensions and arg_1 not in arg_0.config.deny))


def Func(arg_0, arg_1, arg_2):
        """
        If a file with the selected name already exists in the target folder,
        this method is called to resolve the conflict. It should return a new
        basename for the file.

        The default implementation splits the name and extension and adds a
        suffix to the name consisting of an underscore and a number, and tries
        that until it finds one that doesn't exist.

        :param target_folder: The absolute path to the target.
        :param basename: The file's original basename.
        """
        arg_3, arg_4 = os.path.splitext(arg_2)
        arg_5 = 0
        while True:
            arg_5 = arg_5 + 1
            arg_6 = '%s_%d%s' % (arg_3, arg_5, arg_4)
            if not os.path.exists(os.path.join(arg_1, arg_6)):
                return arg_6


def Func(arg_0):
    """Returns actual version specified in filename."""
    with open(arg_0) as src_file:
        arg_1 = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
                                  src_file.read(), re.M)
        if arg_1:
            return arg_1.group(1)
        raise RuntimeError('Unable to find version info.')


def Func(arg_0):
    """Removes duplicate objects.

    http://www.peterbe.com/plog/uniqifiers-benchmark.
    """
    arg_1, arg_2 = set(), []
    for arg_3 in arg_0:
        arg_4 = id(arg_3)
        if arg_4 in arg_1:
            continue
        arg_1.add(arg_4)
        arg_2.append(arg_3)
    return arg_2


def Func(arg_0, arg_1):
    """Returns count difference in two collections of Python objects."""
    arg_2 = _process_in_memory_objects(arg_0)
    arg_3 = _process_in_memory_objects(arg_1)
    arg_4 = _get_object_count_by_type(arg_2)
    arg_5 = _get_object_count_by_type(arg_3)
    return arg_4 - arg_5


def Func(arg_0, arg_1, arg_2, arg_3):  #pylint: disable=unused-argument
        """Checks memory usage when 'line' event occur."""
        if arg_2 == 'line' and arg_1.f_code.co_filename in arg_0.target_modules:
            arg_0._events_list.append(
                (arg_1.f_lineno, arg_0._process.memory_info().rss,
                 arg_1.f_code.co_name, arg_1.f_code.co_filename))
        return arg_0.Func


def Func(arg_0):
        """Returns processed memory usage."""
        if arg_0._resulting_events:
            return arg_0._resulting_events
        for arg_1, (arg_2, arg_3, arg_4, arg_5) in enumerate(arg_0._events_list):
            arg_6 = float(arg_3 - arg_0.mem_overhead) / _BYTES_IN_MB
            if (arg_0._resulting_events and
                    arg_0._resulting_events[-1][0] == arg_2 and
                    arg_0._resulting_events[-1][2] == arg_4 and
                    arg_0._resulting_events[-1][3] == arg_5 and
                    arg_0._resulting_events[-1][1] < arg_6):
                arg_0._resulting_events[-1][1] = arg_6
            else:
                arg_0._resulting_events.append(
                    [arg_1 + 1, arg_2, arg_6, arg_4, arg_5])
        return arg_0._resulting_events


def Func(arg_0):
        """Returns memory overhead."""
        arg_0.mem_overhead = (arg_0._process.memory_info().rss -
                             builtins.initial_rss_size)


def Func(arg_0):
        """Returns memory stats for a function."""
        arg_1 = {arg_0._run_object.__code__.co_filename}
        with _CodeEventsTracker(arg_1) as prof:
            prof.compute_mem_overhead()
            arg_2 = arg_0._run_object(*arg_0._run_args, **arg_0._run_kwargs)
        return prof, arg_2


def Func(arg_0):
    """Returns module filenames from package.

    Args:
        package_path: Path to Python package.
    Returns:
        A set of module filenames.
    """
    arg_1 = set()
    for arg_2, arg_3, arg_4 in pkgutil.iter_modules(path=[arg_0]):
        arg_5 = os.path.join(arg_2.path, '%s.py' % arg_3)
        if os.path.exists(arg_5):
            arg_1.add(os.path.abspath(arg_5))
    return arg_1


def Func(arg_0, *arg_1, **arg_2):
    """Runs function in separate process.

    This function is used instead of a decorator, since Python multiprocessing
    module can't serialize decorated function on all platforms.
    """
    arg_3 = multiprocessing.Manager()
    arg_4 = arg_3.dict()
    arg_5 = ProcessWithException(
        arg_4, target=arg_0, arg_1=arg_1, arg_2=arg_2)
    arg_5.start()
    arg_5.join()
    arg_6 = arg_5.exception
    if arg_6:
        raise arg_6
    return arg_5.output


def Func(arg_0, arg_1):
        """Initializes profiler with a module."""
        arg_0.profile = arg_0.profile_module
        arg_0._run_object, arg_4, arg_0._run_args = arg_1.partition(' ')
        arg_0._object_name = '%s (module)' % arg_0._run_object
        arg_0._globs = {
            '__file__': arg_0._run_object,
            '__name__': '__main__',
            '__package__': None,
        }
        arg_8 = os.path.dirname(arg_0._run_object)
        if sys.path[0] != arg_8:
            sys.path.insert(0, arg_8)
        arg_0._replace_sysargs()


def Func(arg_0, arg_1):
        """Initializes profiler with a function."""
        arg_0.profile = arg_0.profile_function
        arg_0._run_object, arg_0._run_args, arg_0._run_kwargs = arg_1
        arg_6 = inspect.getsourcefile(arg_0._run_object)
        arg_0._object_name = '%s @ %s (function)' % (
            arg_0._run_object.__name__, arg_6)


def Func(arg_0):
        """Replaces sys.argv with proper args to pass to script."""
        arg_1.argv[:] = [arg_0._run_object]
        if arg_0._run_args:
            arg_1.argv += arg_0._run_args.split()


def Func(arg_0, arg_1, arg_2):  #pylint: disable=unused-argument
        """Samples current stack and adds result in self._stats.

        Args:
            signum: Signal that activates handler.
            frame: Frame on top of the stack when signal is handled.
        """
        arg_3 = []
        while arg_2 and arg_2 != arg_0.base_frame:
            arg_3.append((
                arg_2.f_code.co_name,
                arg_2.f_code.co_filename,
                arg_2.f_code.co_firstlineno))
            arg_2 = arg_2.f_back
        arg_0._stats[tuple(arg_3)] += 1
        signal.setitimer(signal.ITIMER_PROF, _SAMPLE_INTERVAL)


def Func(arg_0):
        """Returns call tree."""
        Func = {'stack': 'base', 'sampleCount': 0, 'children': []}
        for arg_2, arg_3 in arg_0._stats.items():
            arg_0._insert_stack(reversed(arg_2), arg_3, Func)
        arg_0._fill_sample_count(Func)
        if not Func['children']:
            return {}
        return arg_0._format_tree(
            Func['children'][0], Func['sampleCount'])


def Func(arg_0):
        """Runs statistical profiler on a package."""
        with _StatProfiler() as arg_1:
            arg_1.base_frame = inspect.currentframe()
            try:
                runpy.run_path(arg_0._run_object, run_name='__main__')
            except SystemExit:
                pass

        arg_3 = arg_1.call_tree
        return {
            'objectName': arg_0._object_name,
            'sampleInterval': _SAMPLE_INTERVAL,
            'runTime': arg_1.run_time,
            'callStats': arg_3,
            'totalSamples': arg_3.get('sampleCount', 0),
            'timestamp': int(time.time())
        }


def Func(arg_0):
        """Runs statistical profiler on a module."""
        with open(arg_0._run_object, 'rb') as srcfile, _StatProfiler() as arg_2:
            arg_1 = compile(srcfile.read(), arg_0._run_object, 'exec')
            arg_2.base_frame = inspect.currentframe()
            try:
                exec(arg_1, arg_0._globs, None)
            except SystemExit:
                pass

        arg_4 = arg_2.call_tree
        return {
            'objectName': arg_0._object_name,
            'sampleInterval': _SAMPLE_INTERVAL,
            'runTime': arg_2.run_time,
            'callStats': arg_4,
            'totalSamples': arg_4.get('sampleCount', 0),
            'timestamp': int(time.time())
        }


def Func(arg_0):
        """Processes collected stats for UI."""
        arg_1 = []
        for arg_2, arg_3 in arg_0.stats.items():
            arg_4, arg_5, arg_6 = arg_2
            arg_7, arg_8, arg_9, arg_10, arg_11 = arg_3
            if arg_0.total_tt == 0:
                arg_12 = 0
            else:
                arg_12 = round(100 * (arg_10 / arg_0.total_tt), 4)
            arg_10 = round(arg_10, 4)
            arg_13 = '%s @ %s' % (arg_6, arg_4)
            arg_14 = base_profiler.hash_name(arg_13)
            arg_1.append(
                (arg_4, arg_5, arg_6, arg_10, arg_12, arg_8,
                 arg_7, arg_9, arg_4, arg_14))
        return sorted(arg_1, key=operator.itemgetter(4), reverse=True)


def Func(arg_0):
        """Runs cProfile on a module."""
        arg_1 = cProfile.Profile()
        try:
            with open(arg_0._run_object, 'rb') as srcfile:
                arg_2 = compile(srcfile.read(), arg_0._run_object, 'exec')
            arg_1.runctx(arg_2, arg_0._globs, None)
        except SystemExit:
            pass
        arg_3 = pstats.Stats(arg_1)
        arg_3.calc_callees()
        return {
            'objectName': arg_0._object_name,
            'callStats': arg_0._transform_stats(arg_3),
            'totalTime': arg_3.total_tt,
            'primitiveCalls': arg_3.prim_calls,
            'totalCalls': arg_3.total_calls,
            'timestamp': int(time.time())
        }


def Func(arg_0):
        """Runs cProfile on a function."""
        arg_1 = cProfile.Profile()
        arg_1.enable()
        arg_2 = arg_0._run_object(*arg_0._run_args, **arg_0._run_kwargs)
        arg_1.disable()
        arg_3 = pstats.Stats(arg_1)
        arg_3.calc_callees()
        return {
            'objectName': arg_0._object_name,
            'callStats': arg_0._transform_stats(arg_3),
            'totalTime': arg_3.total_tt,
            'primitiveCalls': arg_3.prim_calls,
            'totalCalls': arg_3.total_calls,
            'result': arg_2,
            'timestamp': int(time.time())
        }


def Func():
    """Initializes DB."""
    with contextlib.closing(connect_to_db()) as db:
        db.cursor().executescript(DB_SCHEMA)
        db.commit()


def Func():
    """Returns all existing guestbook records."""
    arg_0 = flask.g.db.execute(
        'SELECT name, message FROM entry ORDER BY id DESC;')
    arg_1 = [{'name': row[0], 'message': row[1]} for row in arg_0.fetchall()]
    return jinja2.Template(LAYOUT).render(arg_1=arg_1)


def Func():
    """Adds single guestbook record."""
    arg_0, arg_1 = flask.request.form['name'], flask.request.form['message']
    flask.g.db.execute(
        'INSERT INTO entry (name, message) VALUES (?, ?)', (arg_0, arg_1))
    flask.g.db.commit()
    return flask.redirect('/')


def Func():
        """Handles index.html requests."""
        arg_0 = os.path.join(
            os.path.dirname(__file__), _PROFILE_HTML)
        with io.open(arg_0, 'rb') as res_file:
            arg_1 = res_file.read()
        return arg_1, 'text/html'


def Func(arg_0):
        """Handles HTTP POST requests."""
        arg_1 = arg_0.rfile.read(int(arg_0.headers['Content-Length']))
        arg_2 = gzip.decompress(arg_1)
        arg_0._profile_json.update(json.loads(arg_2.decode('utf-8')))
        arg_0._send_response(
            200, headers=(('Content-type', '%s; charset=utf-8' % 'text/json'),
                          ('Content-Encoding', 'gzip'),
                          ('Content-Length', len(arg_1))))


def Func(arg_0, arg_1, arg_2=None, arg_3=None):
        """Sends HTTP response code, message and headers."""
        arg_0.send_response(arg_1, arg_2)
        if arg_3:
            for arg_4 in arg_3:
                arg_0.send_header(*arg_4)
            arg_0.end_headers()


def Func(arg_0):
        """Fills code heatmap and execution count dictionaries."""
        for arg_1, arg_2, arg_3 in arg_0.lines_without_stdlib:
            arg_0._execution_count[arg_1][arg_2] += 1
            arg_0._heatmap[arg_1][arg_2] += arg_3


def Func(arg_0, arg_1):
        """Skips lines in src_code specified by skip map."""
        if not arg_1:
            return [['line', arg_2 + 1, arg_3] for arg_2, arg_3 in enumerate(arg_0)]
        arg_4, arg_5 = [], 0
        for arg_6, arg_7 in arg_1:
            arg_4.extend(
                ['line', arg_5 + arg_2 + 1, arg_3] for arg_2, arg_3 in enumerate(arg_0[arg_5:arg_6]))
            if (arg_4
                    and arg_4[-1][0] == 'skip'):  # Merge skips.
                arg_4[-1][1] += arg_7
            else:
                arg_4.append(['skip', arg_7])
            arg_5 = arg_6 + arg_7
        arg_4.extend(
            ['line', arg_5 + arg_2 + 1, arg_3] for arg_2, arg_3 in enumerate(arg_0[arg_5:]))
        return arg_4


def Func(arg_0):
        """Calculates heatmap for package."""
        with _CodeHeatmapCalculator() as prof:
            try:
                runpy.run_path(arg_0._run_object, run_name='__main__')
            except SystemExit:
                pass

        arg_1 = []
        for arg_2, arg_3 in prof.heatmap.items():
            if os.path.isfile(arg_2):
                arg_1.append(
                    arg_0._format_heatmap(
                        arg_2, arg_3, prof.execution_count[arg_2]))

        arg_4 = sum(arg_3['runTime'] for arg_3 in arg_1)
        return {
            'objectName': arg_0._run_object,
            'runTime': arg_4,
            'heatmaps': arg_1
        }


def Func(arg_0, arg_1, arg_2, arg_3):
        """Formats heatmap for UI."""
        with open(arg_1) as src_file:
            arg_4 = src_file.read().split('\n')
            arg_5 = arg_0._calc_skips(arg_2, len(arg_4))
        arg_6 = sum(time for time in arg_2.values())
        return {
            'name': arg_1,
            'heatmap': arg_2,
            'executionCount': arg_3,
            'srcCode': arg_0._skip_lines(arg_4, arg_5),
            'runTime': arg_6
        }


def Func(arg_0, arg_1, arg_2=False):
    """Runs profilers on run_object.

    Args:
        run_object: An object (string or tuple) for profiling.
        prof_config: A string with profilers configuration.
        verbose: True if info about running profilers should be shown.
    Returns:
        An ordered dictionary with collected stats.
    Raises:
        AmbiguousConfigurationError: when prof_config is ambiguous.
        BadOptionError: when unknown options are present in configuration.
    """
    if len(arg_1) > len(set(arg_1)):
        raise AmbiguousConfigurationError(
            'Profiler configuration %s is ambiguous' % arg_1)

    arg_3 = {opt for opt, _ in _PROFILERS}
    for arg_4 in arg_1:
        if arg_4 not in arg_3:
            raise BadOptionError('Unknown option: %s' % arg_4)

    arg_5 = OrderedDict()
    arg_6 = ((o, p) for o, p in _PROFILERS if o in arg_1)
    for arg_4, arg_7 in arg_6:
        arg_8 = arg_7(arg_0)
        if arg_2:
            print('Running %s...' % arg_8.__class__.__name__)
        arg_5[arg_4] = arg_8.run()
    return arg_5


def Func(arg_0, arg_1, arg_2=(), arg_3={}, arg_4='localhost', arg_5=8000):  # pylint: disable=dangerous-default-value
    """Runs profilers on a function.

    Args:
        func: A Python function.
        options: A string with profilers configuration (i.e. 'cmh').
        args: func non-keyword arguments.
        kwargs: func keyword arguments.
        host: Host name to send collected data.
        port: Port number to send collected data.

    Returns:
        A result of func execution.
    """
    arg_6 = Func_profilers((arg_0, arg_2, arg_3), arg_1)

    arg_7 = None
    for arg_8 in arg_6:
        if not arg_7:
            arg_7 = arg_6[arg_8]['result']
        del arg_6[arg_8]['result']  # Don't send result to remote host

    arg_9 = gzip.compress(
        json.dumps(arg_6).encode('utf-8'))
    urllib.request.urlopen('http://%s:%s' % (arg_4, arg_5), arg_9)
    return arg_7


def Func(arg_0, arg_1, **arg_2):
        """
        Get information about a specific template.

        :param template_id: The unique id for the template.
        :type template_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        """
        arg_0.template_id = arg_1
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1), **arg_2)


def Func(arg_0, arg_1):
        """
        Delete a specific template.

        :param template_id: The unique id for the template.
        :type template_id: :py:class:`str`
        """
        arg_0.template_id = arg_1
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1))


def Func(arg_0):
    """
    The MD5 hash of the lowercase version of the list member's email.
    Used as subscriber_hash

    :param member_email: The member's email address
    :type member_email: :py:class:`str`
    :returns: The MD5 hash in hex
    :rtype: :py:class:`str`
    """
    check_email(arg_0)
    arg_0 = arg_0.lower().encode()
    arg_1 = hashlib.md5(arg_0)
    return arg_1.hexdigest()


def Func(arg_0):
    """
    Function that verifies that the string passed is a valid url.

    Original regex author Diego Perini (http://www.iport.it)
    regex ported to Python by adamrofer (https://github.com/adamrofer)
    Used under MIT license.

    :param url:
    :return: Nothing
    """
    arg_1 = re.compile(
    u"^"
    u"(?:(?:https?|ftp)://)"
    u"(?:\S+(?::\S*)?@)?"
    u"(?:"
    u"(?!(?:10|127)(?:\.\d{1,3}){3})"
    u"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
    u"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
    u"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
    u"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
    u"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
    u"|"
    u"(?:(?:[a-z\u00a1-\uffff0-9]-?)*[a-z\u00a1-\uffff0-9]+)"
    u"(?:\.(?:[a-z\u00a1-\uffff0-9]-?)*[a-z\u00a1-\uffff0-9]+)*"
    u"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
    u")"
    u"(?::\d{2,5})?"
    u"(?:/\S*)?"
    u"$"
    , re.UNICODE)
    if not re.match(arg_1, arg_0):
        raise ValueError('String passed is not a valid url')
    return


def Func(arg_0, arg_1):
    """
    Given two dicts, x and y, merge them into a new dict as a shallow copy.

    The result only differs from `x.update(y)` in the way that it handles list
    values when both x and y have list values for the same key. In which case
    the returned dictionary, z, has a value according to:
      z[key] = x[key] + z[key]

    :param x: The first dictionary
    :type x: :py:class:`dict`
    :param y: The second dictionary
    :type y: :py:class:`dict`
    :returns: The merged dictionary
    :rtype: :py:class:`dict`
    """
    arg_2 = arg_0.copy()
    for arg_3, arg_4 in arg_1.items():
        if isinstance(arg_4, list) and isinstance(arg_2.get(arg_3), list):
            arg_2[arg_3] += arg_4
        else:
            arg_2[arg_3] = arg_4
    return arg_2


def Func(arg_0, arg_1, arg_2):
        """
        Batch subscribe or unsubscribe list members.

        Only the members array is required in the request body parameters.
        Within the members array, each member requires an email_address
        and either a status or status_if_new. The update_existing parameter
        will also be considered required to help prevent accidental updates
        to existing members and will default to false if not present.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "members": array*
            [
                {
                    "email_address": string*,
                    "status": string* (Must be one of 'subscribed', 'unsubscribed', 'cleaned', or 'pending'),
                    "status_if_new": string* (Must be one of 'subscribed', 'unsubscribed', 'cleaned', or 'pending')
                }
            ],
            "update_existing": boolean*
        }
        """
        arg_0.list_id = arg_1
        if 'members' not in arg_2:
            raise KeyError('The update must have at least one member')
        else:
            if not len(arg_2['members']) <= 500:
                raise ValueError('You may only batch sub/unsub 500 members at a time')
        for arg_3 in arg_2['members']:
            if 'email_address' not in arg_3:
                raise KeyError('Each list member must have an email_address')
            check_email(arg_3['email_address'])
            if 'status' not in arg_3 and 'status_if_new' not in arg_3:
                raise KeyError('Each list member must have either a status or a status_if_new')
            arg_4 = ['subscribed', 'unsubscribed', 'cleaned', 'pending']
            if 'status' in arg_3 and arg_3['status'] not in arg_4:
                raise ValueError('The list member status must be one of "subscribed", "unsubscribed", "cleaned", or '
                                 '"pending"')
            if 'status_if_new' in arg_3 and arg_3['status_if_new'] not in arg_4:
                raise ValueError('The list member status_if_new must be one of "subscribed", "unsubscribed", '
                                 '"cleaned", or "pending"')
        if 'update_existing' not in arg_2:
            arg_2['update_existing'] = False
        return arg_0._mc_client._post(url=arg_0._build_path(arg_1), arg_2=arg_2)


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Add a new line item to an existing order.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param order_id: The id for the order in a store.
        :type order_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "id": string*,
            "product_id": string*,
            "product_variant_id": string*,
            "quantity": integer*,
            "price": number*
        }
        """
        arg_0.store_id = arg_1
        arg_0.order_id = arg_2
        if 'id' not in arg_3:
            raise KeyError('The order line must have an id')
        if 'product_id' not in arg_3:
            raise KeyError('The order line must have a product_id')
        if 'product_variant_id' not in arg_3:
            raise KeyError('The order line must have a product_variant_id')
        if 'quantity' not in arg_3:
            raise KeyError('The order line must have a quantity')
        if 'price' not in arg_3:
            raise KeyError('The order line must have a price')
        arg_4 = arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'orders', arg_2, 'lines'))
        if arg_4 is not None:
            arg_0.line_id = arg_4['id']
        else:
            arg_0.line_id = None
        return arg_4


def Func(arg_0, **arg_1):
        """
        Get links to all other resources available in the API.

        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        """
        return arg_0._mc_client._Func(url=arg_0._build_path(), **arg_1)


def Func(arg_0, arg_1):
        """
        Retrieve OAuth2-based credentials to associate API calls with your
        application.

        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "client_id": string*,
            "client_secret": string*
        }
        """
        arg_0.app_id = None
        if 'client_id' not in arg_1:
            raise KeyError('The authorized app must have a client_id')
        if 'client_secret' not in arg_1:
            raise KeyError('The authorized app must have a client_secret')
        return arg_0._mc_client._post(url=arg_0._build_path(), arg_1=arg_1)


def Func(arg_0, arg_1, **arg_2):
        """
        Get information about a specific authorized application

        :param app_id: The unique id for the connected authorized application
        :type app_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        """
        arg_0.app_id = arg_1
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1), **arg_2)


def Func(arg_0, arg_1, arg_2):
        """
        Add new promo rule to a store

        :param store_id: The store id
        :type store_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict'
        data = {
            "id": string*,
            "title": string,
            "description": string*,
            "starts_at": string,
            "ends_at": string,
            "amount": number*,
            "type": string*,
            "target": string*,
            "enabled": boolean,
            "Funcd_at_foreign": string,
            "updated_at_foreign": string,
        }
        """
        arg_0.store_id = arg_1
        if 'id' not in arg_2:
            raise KeyError('The promo rule must have an id')
        if 'description' not in arg_2:
            raise KeyError('This promo rule must have a description')
        if 'amount' not in arg_2:
            raise KeyError('This promo rule must have an amount')
        if 'target' not in arg_2:
            raise KeyError('This promo rule must apply to a target (example per_item, total, or shipping')
        arg_3 = arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'promo-rules'), arg_2=arg_2)

        if arg_3 is not None:
            return arg_3


def Func(arg_0, arg_1, **arg_2):
        """
        Get information about a specific folder used to organize campaigns.

        :param folder_id: The unique id for the campaign folder.
        :type folder_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        """
        arg_0.folder_id = arg_1
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1), **arg_2)


def Func(arg_0, arg_1, arg_2):
        """
        Get information about an individual Automation workflow email.

        :param workflow_id: The unique id for the Automation workflow.
        :type workflow_id: :py:class:`str`
        :param email_id: The unique id for the Automation workflow email.
        :type email_id: :py:class:`str`
        """
        arg_0.workflow_id = arg_1
        arg_0.email_id = arg_2
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1, 'emails', arg_2))


def Func(arg_0, arg_1):
        """
        Upload a new image or file to the File Manager.

        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "name": string*,
            "file_data": string*
        }
        """
        if 'name' not in arg_1:
            raise KeyError('The file must have a name')
        if 'file_data' not in arg_1:
            raise KeyError('The file must have file_data')
        arg_2 = arg_0._mc_client._post(url=arg_0._build_path(), arg_1=arg_1)
        if arg_2 is not None:
            arg_0.file_id = arg_2['id']
        else:
            arg_0.file_id = None
        return arg_2


def Func(arg_0, arg_1, **arg_2):
        """
        Get information about a specific file in the File Manager.

        :param file_id: The unique id for the File Manager file.
        :type file_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        """
        arg_0.file_id = arg_1
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1), **arg_2)


def Func(arg_0, arg_1, arg_2):
        """
        Update a file in the File Manager.

        :param file_id: The unique id for the File Manager file.
        :type file_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "name": string*,
            "file_data": string*
        }
        """
        arg_0.file_id = arg_1
        if 'name' not in arg_2:
            raise KeyError('The file must have a name')
        if 'file_data' not in arg_2:
            raise KeyError('The file must have file_data')
        return arg_0._mc_client._patch(url=arg_0._build_path(arg_1), arg_2=arg_2)


def Func(arg_0, arg_1):
        """
        Remove a specific file from the File Manager.

        :param file_id: The unique id for the File Manager file.
        :type file_id: :py:class:`str`
        """
        arg_0.file_id = arg_1
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1))


def Func(arg_0, arg_1):
        """
        Get information about subscribers who were removed from an Automation
        workflow.

        :param workflow_id: The unique id for the Automation workflow.
        :type workflow_id: :py:class:`str`
        """
        arg_0.workflow_id = arg_1
        return arg_0._mc_client._get(url=arg_0._build_path(arg_1, 'removed-subscribers'))


def Func(arg_0, arg_1, arg_2):
        """
        Create a new webhook for a specific list.

        The documentation does not include any required request body
        parameters but the url parameter is being listed here as a required
        parameter in documentation and error-checking based on the description
        of the method

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "url": string*
        }
        """
        arg_0.list_id = arg_1
        if 'url' not in arg_2:
            raise KeyError('The list webhook must have a url')
        check_url(arg_2['url'])
        arg_3 = arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'webhooks'), arg_2=arg_2)
        if arg_3 is not None:
            arg_0.webhook_id = arg_3['id']
        else:
            arg_0.webhook_id = None
        return arg_3


def Func(arg_0, arg_1, arg_2):
        """
        Get information about a specific webhook.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param webhook_id: The unique id for the webhook.
        :type webhook_id: :py:class:`str`
        """
        arg_0.list_id = arg_1
        arg_0.webhook_id = arg_2
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1, 'webhooks', arg_2))


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Update the settings for an existing webhook.

        :param list_id: The unique id for the list
        :type list_id: :py:class:`str`
        :param webhook_id: The unique id for the webhook
        :type webhook_id: :py:class:`str`
        """
        arg_0.list_id = arg_1
        arg_0.webhook_id = arg_2
        return arg_0._mc_client._patch(url=arg_0._build_path(arg_1, 'webhooks', arg_2), arg_3=arg_3)


def Func(arg_0, arg_1, arg_2):
        """
        Delete a specific webhook in a list.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param webhook_id: The unique id for the webhook.
        :type webhook_id: :py:class:`str`
        """
        arg_0.list_id = arg_1
        arg_0.webhook_id = arg_2
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1, 'webhooks', arg_2))


def Func(arg_0, arg_1, arg_2):
        """
        returns the specified list segment.
        """
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1, 'segments', arg_2))


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Funcs an existing list segment.
        """
        return arg_0._mc_client._patch(url=arg_0._build_path(arg_1, 'segments', arg_2), arg_3=arg_3)


def Func(arg_0, arg_1, arg_2):
        """
        removes an existing list segment from the list. This cannot be undone.
        """
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1, 'segments', arg_2))


def Func(arg_0, arg_1, arg_2):
        """
        adds a new segment to the list.
        """
        return arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'segments'), arg_2=arg_2)


def Func(arg_0):
        """
        Get the metadata returned after authentication
        """
        try:
            arg_1 = requests.get('https://login.mailchimp.com/oauth2/metadata', auth=arg_0)
        except requests.exceptions.RequestException as e:
            raise e
        else:
            arg_1.raise_for_status()
            arg_2 = arg_1.json()
            if 'error' in arg_2:
                raise requests.exceptions.RequestException(arg_2['error'])
            return arg_2


def Func(arg_0, arg_1, **arg_2):
        """
        Get details about an individual conversation.

        :param conversation_id: The unique id for the conversation.
        :type conversation_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        """
        arg_0.conversation_id = arg_1
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1), **arg_2)


def Func(arg_0, arg_1, arg_2=False, **arg_3):
        """
        Get information about members who have unsubscribed from a specific
        campaign.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        :param get_Func: Should the query get Func results
        :type get_Func: :py:class:`bool`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        queryparams['count'] = integer
        queryparams['offset'] = integer
        """
        arg_0.campaign_id = arg_1
        arg_0.subscriber_hash = None
        if arg_2:
            return arg_0._iterate(url=arg_0._build_path(arg_1, 'unsubscribed'), **arg_3)
        else:
            return arg_0._mc_client._get(url=arg_0._build_path(arg_1, 'unsubscribed'), **arg_3)


def Func(arg_0, arg_1, arg_2):
        """
        Get information about an Automation email queue.

        :param workflow_id: The unique id for the Automation workflow.
        :type workflow_id: :py:class:`str`
        :param email_id: The unique id for the Automation workflow email.
        :type email_id: :py:class:`str`
        """
        arg_0.workflow_id = arg_1
        arg_0.email_id = arg_2
        arg_0.subscriber_hash = None
        return arg_0._mc_client._get(url=arg_0._build_path(arg_1, 'emails', arg_2, 'queue'))


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Get information about a specific subscriber in an Automation email
        queue.

        :param workflow_id: The unique id for the Automation workflow.
        :type workflow_id: :py:class:`str`
        :param email_id: The unique id for the Automation workflow email.
        :type email_id: :py:class:`str`
        :param subscriber_hash: The MD5 hash of the lowercase version of the
          list member’s email address.
        :type subscriber_hash: :py:class:`str`
        """
        arg_3 = check_subscriber_hash(arg_3)
        arg_0.workflow_id = arg_1
        arg_0.email_id = arg_2
        arg_0.subscriber_hash = arg_3
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1, 'emails', arg_2, 'queue', arg_3))


def Func(arg_0, arg_1):
        """
        Pause an RSS-Driven campaign.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        """
        arg_0.campaign_id = arg_1
        return arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'actions/Func'))


def Func(arg_0, arg_1):
        """
        Replicate a campaign in saved or send status.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        """
        arg_0.campaign_id = arg_1
        return arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'actions/Func'))


def Func(arg_0, arg_1):
        """
        Resume an RSS-Driven campaign.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        """
        arg_0.campaign_id = arg_1
        return arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'actions/Func'))


def Func(arg_0, arg_1):
        """
        Send a MailChimp campaign. For RSS Campaigns, the campaign will Func
        according to its schedule. All other campaigns will Func immediately.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        """
        arg_0.campaign_id = arg_1
        return arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'actions/Func'))


def Func(arg_0, arg_1, arg_2):
        """
        Add a new customer to a store.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "id": string*,
            "email_address": string*,
            "opt_in_status": boolean*
        }
        """
        arg_0.store_id = arg_1
        if 'id' not in arg_2:
            raise KeyError('The store customer must have an id')
        if 'email_address' not in arg_2:
            raise KeyError('The store customer must have an email_address')
        check_email(arg_2['email_address'])
        if 'opt_in_status' not in arg_2:
            raise KeyError('The store customer must have an opt_in_status')
        if arg_2['opt_in_status'] not in [True, False]:
            raise TypeError('The opt_in_status must be True or False')
        arg_3 = arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'customers'), arg_2=arg_2)
        if arg_3 is not None:
            arg_0.customer_id = arg_3['id']
        else:
            arg_0.customer_id = None
        return arg_3


def Func(arg_0, arg_1, arg_2, arg_3, arg_4):
        """
        Add or update a product variant.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param product_id: The id for the product of a store.
        :type product_id: :py:class:`str`
        :param variant_id: The id for the product variant.
        :type variant_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "id": string*,
            "title": string*
        }
        """
        arg_0.store_id = arg_1
        arg_0.product_id = arg_2
        arg_0.variant_id = arg_3
        if 'id' not in arg_4:
             raise KeyError('The product variant must have an id')
        if 'title' not in arg_4:
            raise KeyError('The product variant must have a title')
        return arg_0._mc_client._put(
            url=arg_0._build_path(arg_1, 'products', arg_2, 'variants', arg_3),
            arg_4=arg_4
        )


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Update a specific feedback message for a campaign.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        :param feedback_id: The unique id for the feedback message.
        :type feedback_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "message": string*
        }
        """
        arg_0.campaign_id = arg_1
        arg_0.feedback_id = arg_2
        if 'message' not in arg_3:
            raise KeyError('The campaign feedback must have a message')
        return arg_0._mc_client._patch(url=arg_0._build_path(arg_1, 'feedback', arg_2), arg_3=arg_3)


def Func(arg_0, arg_1, arg_2):
        """
        Get information about a specific merge field in a list.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param merge_id: The id for the merge field.
        :type merge_id: :py:class:`str`
        """
        arg_0.list_id = arg_1
        arg_0.merge_id = arg_2
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1, 'merge-fields', arg_2))


def Func(arg_0, arg_1, **arg_2):
        """
        Get information about a specific batch webhook.

        :param batch_webhook_id: The unique id for the batch webhook.
        :type batch_webhook_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        """
        arg_0.batch_webhook_id = arg_1
        return arg_0._mc_client._Func(url=arg_0._build_path(arg_1), **arg_2)


def Func(arg_0, arg_1, arg_2):
        """
        Update a webhook that will fire whenever any batch request completes
        processing.

        :param batch_webhook_id: The unique id for the batch webhook.
        :type batch_webhook_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "url": string*
        }
        """
        arg_0.batch_webhook_id = arg_1
        if 'url' not in arg_2:
            raise KeyError('The batch webhook must have a valid url')
        return arg_0._mc_client._patch(url=arg_0._build_path(arg_1), arg_2=arg_2)


def Func(arg_0, arg_1, arg_2, arg_3):
        """
        Add a new image to the product.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param product_id: The id for the product of a store.
        :type product_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "id": string*,
            "url": string*
        }
        """
        arg_0.store_id = arg_1
        arg_0.product_id = arg_2
        if 'id' not in arg_3:
            raise KeyError('The product image must have an id')
        if 'title' not in arg_3:
            raise KeyError('The product image must have a url')
        arg_4 = arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'products', arg_2, 'images'), arg_3=arg_3)
        if arg_4 is not None:
            arg_0.image_id = arg_4['id']
        else:
            arg_0.image_id = None
        return arg_4


def Func(arg_0, arg_1, arg_2, arg_3, **arg_4):
        """
        Get information about a specific product image.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param product_id: The id for the product of a store.
        :type product_id: :py:class:`str`
        :param image_id: The id for the product image.
        :type image_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        """
        arg_0.store_id = arg_1
        arg_0.product_id = arg_2
        arg_0.image_id = arg_3
        return arg_0._mc_client._post(
            url=arg_0._build_path(arg_1, 'products', arg_2, 'images', arg_3),
            **arg_4
        )


def Func(arg_0, arg_1, arg_2):
        """
        Post a new message to a conversation.

        :param conversation_id: The unique id for the conversation.
        :type conversation_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "from_email": string*,
            "read": boolean*
        }
        """
        arg_0.conversation_id = arg_1
        if 'from_email' not in arg_2:
            raise KeyError('The conversation message must have a from_email')
        check_email(arg_2['from_email'])
        if 'read' not in arg_2:
            raise KeyError('The conversation message must have a read')
        if arg_2['read'] not in [True, False]:
            raise TypeError('The conversation message read must be True or False')
        arg_3 =  arg_0._mc_client._post(url=arg_0._build_path(arg_1, 'messages'), arg_2=arg_2)
        if arg_3 is not None:
            arg_0.message_id = arg_3['id']
        else:
            arg_0.message_id = None
        return arg_3