Save the shapefile data to three files or
        three file-like objects. SHP and DBF files can also
        be written exclusively using saveShp, saveShx, and saveDbf respectively.
502018
def save(self, target=None, shp=None, shx=None, dbf=None):
        """"""
        # TODO: Create a unique filename for target if None.
        if shp:
            self.saveShp(shp)
        if shx:
            self.saveShx(shx)
        if dbf:
            self.saveDbf(dbf)
        elif target:
            self.saveShp(target)
            self.shp.close()
            self.saveShx(target)
            self.shx.close()
            self.saveDbf(target)
            self.dbf.close()
646186
def save(self, modelfile, layer=None):
        
        if layer:
            obj = {layer: self.model[layer]}
        else:
            obj = self.model
        with open(modelfile, 'w') as fp:
            json.dump(obj, fp, indent=2, sort_keys=True)
1041419
def save_figure_tofile(fig, fmt, fname):
    """"""
    root, ext = osp.splitext(fname)
    if ext == '.png' and fmt == 'image/svg+xml':
        qimg = svg_to_image(fig)
        qimg.save(fname)
    else:
        if fmt == 'image/svg+xml' and is_unicode(fig):
            fig = fig.encode('utf-8')

        with open(fname, 'wb') as f:
            f.write(fig)
508513
def __dbfHeader(self):
        """"""
        if not self.dbf:
            raise ShapefileException("Shapefile Reader requires a shapefile or file-like object. (no dbf file found)")
        dbf = self.dbf
        headerLength = self.__dbfHeaderLength()
        numFields = (headerLength - 33) // 32
        for field in range(numFields):
            fieldDesc = list(unpack("<11sc4xBB14x", dbf.read(32)))
            name = 0
            idx = 0
            if b("\x00") in fieldDesc[name]:
                idx = fieldDesc[name].index(b("\x00"))
            else:
                idx = len(fieldDesc[name]) - 1
            fieldDesc[name] = fieldDesc[name][:idx]
            fieldDesc[name] = u(fieldDesc[name])
            fieldDesc[name] = fieldDesc[name].lstrip()
            fieldDesc[1] = u(fieldDesc[1])
            self.fields.append(fieldDesc)
        terminator = dbf.read(1)
        assert terminator == b("\r")
        self.fields.insert(0, ('DeletionFlag', 'C', 1, 0))
22840
def write(filename, mesh):
    
    if mesh.points.shape[1] == 2:
        logging.warning(
            "PERMAS requires 3D points, but 2D points given. "
            "Appending 0 third component."
        )
        mesh.points = numpy.column_stack(
            [mesh.points[:, 0], mesh.points[:, 1], numpy.zeros(mesh.points.shape[0])]
        )

    opener = gzip.open if filename.endswith(".gz") else open

    with opener(filename, "wb") as fh:
        fh.write(
            "\n".join(
                [
                    "!",
                    "! File written by meshio version {}".format(__version__),
                    "! Further information available at {}".format(__website__),
                    "!",
                    "$ENTER COMPONENT NAME = DFLT_COMP DOFTYPE = DISP MATH",
                    "    $SITUATION NAME = REAL_MODES",
                    "        DFLT_COMP SYSTEM = NSV CONSTRAINTS = SPCVAR_1 ! LOADING = LOADVAR_1",
                    "    $END SITUATION" "!",
                    "!",
                    "    $STRUCTURE",
                    "!" "\n",
                ]
            ).encode("utf-8")
        )

        # Write nodes
        fh.write("        $COOR NSET = ALL_NODES\n".encode("utf-8"))
        for k, x in enumerate(mesh.points):
            fh.write(
                "        {:8d} {:+.15f} {:+.15f} {:+.15f}\n".format(
                    k + 1, x[0], x[1], x[2]
                ).encode("utf-8")
            )

        meshio_to_permas_type = {
            "vertex": (1, "PLOT1"),
            "line": (2, "PLOTL2"),
            "triangle": (3, "TRIA3"),
            "quad": (4, "QUAD4"),
            "tetra": (4, "TET4"),
            "hexahedron": (8, "HEXE8"),
            "wedge": (6, "PENTA6"),
            "pyramid": (5, "PYRA5"),
        }
        #
        # Avoid non-unique element numbers in case of multiple element types by
        # num_ele !!!
        #
        num_ele = 0

        for meshio_type, cell in mesh.cells.items():
            numcells, num_local_nodes = cell.shape
            permas_type = meshio_to_permas_type[meshio_type]
            fh.write("!\n".encode("utf-8"))
            fh.write(
                "        $ELEMENT TYPE = {} ESET = {}\n".format(
                    permas_type[1], permas_type[1]
                ).encode("utf-8")
            )
            for k, c in enumerate(cell):
                form = "        {:8d} " + " ".join(num_local_nodes * ["{:8d}"]) + "\n"
                fh.write(form.format(k + num_ele + 1, *(c + 1)).encode("utf-8"))
            num_ele += numcells

        fh.write("!\n".encode("utf-8"))
        fh.write("    $END STRUCTURE\n".encode("utf-8"))
        fh.write("!\n".encode("utf-8"))
        elem_3D = ["HEXE8", "TET4", "PENTA6", "PYRA5"]
        elem_2D = ["TRIA3", "QUAD4"]
        elem_1D = ["PLOT1", "PLOTL2"]
        fh.write("    $SYSTEM NAME = NSV\n".encode("utf-8"))
        fh.write("!\n".encode("utf-8"))
        fh.write("        $ELPROP\n".encode("utf-8"))
        for meshio_type, cell in mesh.cells.items():
            permas_type = meshio_to_permas_type[meshio_type]
            if permas_type[1] in elem_3D:
                fh.write(
                    "            {} MATERIAL = DUMMY_MATERIAL\n".format(
                        permas_type[1]
                    ).encode("utf-8")
                )
            elif permas_type[1] in elem_2D:
                fh.write(
                    (
                        12 * " "
                        + "{} GEODAT = GD_{} MATERIAL = DUMMY_MATERIAL\n".format(
                            permas_type[1], permas_type[1]
                        )
                    ).encode("utf-8")
                )
            else:
                assert permas_type[1] in elem_1D
        fh.write("!\n".encode("utf-8"))
        fh.write("        $GEODAT SHELL  CONT = THICK  NODES = ALL\n".encode("utf-8"))
        for meshio_type, cell in mesh.cells.items():
            permas_type = meshio_to_permas_type[meshio_type]
            if permas_type[1] in elem_2D:
                fh.write(
                    (12 * " " + "GD_{} 1.0\n".format(permas_type[1])).encode("utf-8")
                )
        fh.write(
            """!
!
    $END SYSTEM
!
    $CONSTRAINTS NAME = SPCVAR_1
    $END CONSTRAINTS
!
    $LOADING NAME = LOADVAR_1
    $END LOADING
!
$EXIT COMPONENT
!
$ENTER MATERIAL
!
    $MATERIAL NAME = DUMMY_MATERIAL TYPE = ISO
!
        $ELASTIC  GENERAL  INPUT = DATA
            2.0E+05 0.3
!
        $DENSITY  GENERAL  INPUT = DATA
            7.8E-09
!
        $THERMEXP  GENERAL  INPUT = DATA
            1.2E-05
!
    $END MATERIAL
!
$EXIT MATERIAL
!
$FIN
""".encode(
                "utf-8"
            )
        )
    return
1263763
def shapefiles(fname, f_tooltip=None, color=None, linewidth=3, shape_type='full'):
    
    from geoplotlib.layers import ShapefileLayer
    _global_config.layers.append(ShapefileLayer(fname, f_tooltip, color, linewidth, shape_type))
976977
def save_all(self, path, table_format='txt', sep='\t',
                 table_ext=None, float_format='%.12g'):
        

        if type(path) is str:
            path = path.rstrip('\\')
            path = Path(path)

        path.mkdir(parents=True, exist_ok=True)

        self.save(path=path,
                  table_format=table_format,
                  sep=sep,
                  table_ext=table_ext,
                  float_format=float_format)

        for ext, ext_name in zip(self.get_extensions(data=True),
                                 self.get_extensions()):
            ext_path = path / ext_name

            ext.save(path=ext_path,
                     table_format=table_format,
                     sep=sep,
                     table_ext=table_ext,
                     float_format=float_format)
        return self
1136212
def load_shp(self, shapefile_name):
        
        shp_ext = 'shp'
        try:
            self.shp = open("%s.%s" % (shapefile_name, shp_ext), "rb")
        except IOError:
            try:
                self.shp = open("%s.%s" % (shapefile_name, shp_ext.upper()), "rb")
            except IOError:
                pass
392067
def __save_output(self):
        
        out = zipfile.ZipFile(self.outputfilename, 'w')

        for info_zip in self.infile.infolist():

            if info_zip.filename in self.templated_files:
                # Template file - we have edited these.

                # get a temp file
                streamout = open(get_secure_filename(), "w+b")
                fname, output_stream = self.output_streams[
                    self.templated_files.index(info_zip.filename)
                ]

                transformer = get_list_transformer(self.namespaces)
                remapped_stream = output_stream | transformer

                # write the whole stream to it
                for chunk in remapped_stream.serialize():
                    streamout.write(chunk.encode('utf-8'))
                    yield True

                # close the temp file to flush all data and make sure we get
                # it back when writing to the zip archive.
                streamout.close()

                # write the full file to archive
                out.write(streamout.name, fname)

                # remove temp file
                os.unlink(streamout.name)

            else:
                # Copy other files straight from the source archive.
                out.writestr(info_zip, self.infile.read(info_zip.filename))

        # Save images in the "Pictures" sub-directory of the archive.
        for identifier, data in self.images.items():
            out.writestr(PY3O_IMAGE_PREFIX + identifier, data)

        # close the zipfile before leaving
        out.close()
        yield True
698312
def __shpHeader(self):
        """"""
        if not self.shp:
            raise ShapefileException("Shapefile Reader requires a shapefile or file-like object. (no shp file found")
        shp = self.shp
        # File length (16-bit word * 2 = bytes)
        shp.seek(24)
        self.shpLength = unpack(">i", shp.read(4))[0] * 2
        # Shape type
        shp.seek(32)
        self.shapeType= unpack("<i", shp.read(4))[0]
        # The shapefile's bounding box (lower left, upper right)
        self.bbox = _Array('d', unpack("<4d", shp.read(32)))
        # Elevation
        self.elevation = _Array('d', unpack("<2d", shp.read(16)))
        # Measure
        self.measure = _Array('d', unpack("<2d", shp.read(16)))
537588
def save(self, path=None, complevel=1, complib='zlib'):
        
        if path is None:
            path = self.hexuid + '.hdf5'
        elif os.path.isdir(path):
            path += os.sep + self.hexuid + '.hdf5'
        elif not (path.endswith('.hdf5') or path.endswith('.hdf')):
            raise ValueError('File path must have a ".hdf5" or ".hdf" extension.')
        with pd.HDFStore(path, 'w', complevel=complevel, complib=complib) as store:
            store['kwargs'] = pd.Series()
            store.get_storer('kwargs').attrs.metadata = self._rel()
            fc = 0    # Field counter (see special handling of fields below)
            for name, data in self._data().items():
                if hasattr(data, '_revert_categories'):
                    data._revert_categories()
                name = name[1:] if name.startswith('_') else name
                if isinstance(data, Field):    # Fields are handled separately
                    fname = 'FIELD{}_'.format(fc) + name + '/'
                    store[fname + 'data'] = pd.DataFrame(data)
                    for i, field in enumerate(data.field_values):
                        ffname = fname + 'values' + str(i)
                        if isinstance(field, pd.Series):
                            store[ffname] = pd.Series(field)
                        else:
                            store[ffname] = pd.DataFrame(field)
                    fc += 1
                elif isinstance(data, Series):
                    s = pd.Series(data)
                    if isinstance(data.dtype, pd.types.dtypes.CategoricalDtype):
                        s = s.astype('O')
                    store[name] = s
                elif isinstance(data, DataFrame):
                    store[name] = pd.DataFrame(data)
                elif isinstance(data, SparseSeries):
                    s = pd.SparseSeries(data)
                    if isinstance(data.dtype, pd.types.dtypes.CategoricalDtype):
                        s = s.astype('O')
                    store[name] = s
                elif isinstance(data, SparseDataFrame):
                    store[name] = pd.SparseDataFrame(data)
                else:
                    if hasattr(data, 'dtype') and isinstance(data.dtype, pd.types.dtypes.CategoricalDtype):
                        data = data.astype('O')
                    else:
                        for col in data:
                            if isinstance(data[col].dtype, pd.types.dtypes.CategoricalDtype):
                                data[col] = data[col].astype('O')
                    store[name] = data
                if hasattr(data, '_set_categories'):
                    data._set_categories()
286873
def _save(file, data, mode='w+'):
    
    with open(file, mode) as fh:
        fh.write(data)
746730
def save(self, savefile):
        
        with open(str(savefile), 'wb') as f:
            self.write_to_fp(f)
            log.debug("Saved to %s", savefile)
409244
def hdf5write(h5file, obj, root=''):
    
    dic = node_to_dict(obj_to_node(obj))
    h5file.save(dic, root)
670797
def saveFormatFileTo(self, buf, encoding, format):
        
        if buf is None: buf__o = None
        else: buf__o = buf._o
        ret = libxml2mod.xmlSaveFormatFileTo(buf__o, self._o, encoding, format)
        return ret
1189423
def __shape(self):
        """"""
        f = self.__getFileObj(self.shp)
        record = _Shape()
        nParts = nPoints = zmin = zmax = mmin = mmax = None
        (recNum, recLength) = unpack(">2i", f.read(8))
        shapeType = unpack("<i", f.read(4))[0]
        record.shapeType = shapeType
        # For Null shapes create an empty points list for consistency
        if shapeType == 0:
            record.points = []
        # All shape types capable of having a bounding box
        elif shapeType in (3,5,8,13,15,18,23,25,28,31):
            record.bbox = _Array('d', unpack("<4d", f.read(32)))
        # Shape types with parts
        if shapeType in (3,5,13,15,23,25,31):
            nParts = unpack("<i", f.read(4))[0]
        # Shape types with points
        if shapeType in (3,5,8,13,15,23,25,31):
            nPoints = unpack("<i", f.read(4))[0]
        # Read parts
        if nParts:
            record.parts = _Array('i', unpack("<%si" % nParts, f.read(nParts * 4)))
        # Read part types for Multipatch - 31
        if shapeType == 31:
            record.partTypes = _Array('i', unpack("<%si" % nParts, f.read(nParts * 4)))
        # Read points - produces a list of [x,y] values
        if nPoints:
            record.points = [_Array('d', unpack("<2d", f.read(16))) for p in range(nPoints)]
        # Read z extremes and values
        if shapeType in (13,15,18,31):
            (zmin, zmax) = unpack("<2d", f.read(16))
            record.z = _Array('d', unpack("<%sd" % nPoints, f.read(nPoints * 8)))
        # Read m extremes and values
        if shapeType in (13,15,18,23,25,28,31):
            (mmin, mmax) = unpack("<2d", f.read(16))
            # Measure values less than -10e38 are nodata values according to the spec
            record.m = []
            for m in _Array('d', unpack("%sd" % nPoints, f.read(nPoints * 8))):
                if m > -10e38:
                    record.m.append(m)
                else:
                    record.m.append(None)
        # Read a single point
        if shapeType in (1,11,21):
            record.points = [_Array('d', unpack("<2d", f.read(16)))]
        # Read a single Z value
        if shapeType == 11:
            record.z = unpack("<d", f.read(8))
        # Read a single M value
        if shapeType in (11,21):
            record.m = unpack("<d", f.read(8))
        return record
91235
def save_to_file(cn_topo, filename):
    '''
    
    '''
    jstr = cn_topo.serialize()
    with open(filename, 'w') as outfile:
        outfile.write(jstr)