save fence points to a file
11510
def save(self, filename):
        ''''''
        f = open(filename, mode='w')
        for p in self.points:
            f.write("%f\t%f\n" % (p.lat, p.lng))
        f.close()
179695
def save_waypoints(self, filename):
        ''''''
        try:
            #need to remove the leading and trailing quotes in filename
            self.wploader.save(filename.strip('"'))
        except Exception as msg:
            print("Failed to save %s - %s" % (filename, msg))
            return
        print("Saved %u waypoints to %s" % (self.wploader.count(), filename))
1200408
def saveAs(self, event=None):
        

        self.debug('Clicked Save as...')
        # On Linux Pers..Dlg causes the cwd to change, so get a copy of current
        curdir = os.getcwd()

        # The user wishes to save to a different name
        writeProtChoice = self._writeProtectOnSaveAs
        if capable.OF_TKFD_IN_EPAR:
            # Prompt using native looking dialog
            fname = asksaveasfilename(parent=self.top,
                    title='Save Parameter File As',
                    defaultextension=self._defSaveAsExt,
                    initialdir=os.path.dirname(self._getSaveAsFilter()))
        else:
            # Prompt. (could use tkinter's FileDialog, but this one is prettier)
            # initWProtState is only used in the 1st call of a session
            from . import filedlg
            fd = filedlg.PersistSaveFileDialog(self.top,
                         "Save Parameter File As", self._getSaveAsFilter(),
                         initWProtState=writeProtChoice)
            if fd.Show() != 1:
                fd.DialogCleanup()
                os.chdir(curdir) # in case file dlg moved us
                return
            fname = fd.GetFileName()
            writeProtChoice = fd.GetWriteProtectChoice()
            fd.DialogCleanup()

        if not fname: return # canceled

        # First check the child parameters, aborting save if
        # invalid entries were encountered
        if self.checkSetSaveChildren():
            os.chdir(curdir) # in case file dlg moved us
            return

        # Run any subclass-specific steps right before the save
        self._saveAsPreSave_Hook(fname)

        # Verify all the entries (without save), keeping track of the invalid
        # entries which have been reset to their original input values
        self.badEntriesList = self.checkSetSaveEntries(doSave=False)

        # If there were invalid entries, prepare the message dialog
        if self.badEntriesList:
            ansOKCANCEL = self.processBadEntries(self.badEntriesList,
                          self.taskName)
            if not ansOKCANCEL:
                os.chdir(curdir) # in case file dlg moved us
                return

        # If there were no invalid entries or the user says OK, finally
        # save to their stated file.  Since we have already processed the
        # bad entries, there should be none returned.
        mstr = "TASKMETA: task="+self.taskName+" package="+self.pkgName
        if self.checkSetSaveEntries(doSave=True, filename=fname, comment=mstr,
                                    set_ro=writeProtChoice,
                                    overwriteRO=True):
            os.chdir(curdir) # in case file dlg moved us
            raise Exception("Unexpected bad entries for: "+self.taskName)

        # Run any subclass-specific steps right after the save
        self._saveAsPostSave_Hook(fname)

        os.chdir(curdir)
430551
function savePoint() {
  if (input.value.trim().length > 0) {
    let clientX = parseInt(input.style.left, 10);
    let clientY = parseInt(input.style.top, 10);
    let content = input.value.trim();
    let svg = findSVGAtPoint(clientX, clientY);
    if (!svg) {
      return;
    }

    let rect = svg.getBoundingClientRect();
    let { documentId, pageNumber } = getMetadata(svg);
    let annotation = Object.assign({
        type: 'point'
      }, scaleDown(svg, {
        x: clientX - rect.left,
        y: clientY - rect.top
      })
    );

    PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)
      .then((annotation) => {
        PDFJSAnnotate.getStoreAdapter().addComment(
          documentId,
          annotation.uuid,
          content
        );

        appendChild(svg, annotation);
      });
  }

  closeInput();
}
65307
def save_surface_files(note, error, registrations, subject,
                       no_surf_export, no_reg_export, surface_format, surface_path,
                       angle_tag, eccen_tag, label_tag, radius_tag, registration_name):
    '''
    
    '''
    if no_surf_export: return {'surface_files': ()}
    surface_format = surface_format.lower()
    # make an exporter for properties:
    if surface_format in ['curv', 'morph', 'auto', 'automatic']:
        def export(flnm, p):
            fsio.write_morph_data(flnm, p)
            return flnm
    elif surface_format in ['mgh', 'mgz']:
        def export(flnm, p):
            flnm = flnm + '.' + surface_format
            dt = np.int32 if np.issubdtype(p.dtype, np.dtype(int).type) else np.float32
            img = fsmgh.MGHImage(np.asarray([[p]], dtype=dt), np.eye(4))
            img.to_filename(flnm)
            return flnm
    elif surface_format in ['nifti', 'nii', 'niigz', 'nii.gz']:
        surface_format = 'nii' if surface_format == 'nii' else 'nii.gz'
        def export(flnm, p):
            flnm = flnm + '.' + surface_format
            dt = np.int32 if np.issubdtype(p.dtype, np.dtype(int).type) else np.float32
            img = nib.Nifti1Image(np.asarray([[p]], dtype=dt), np.eye(4))
            img.to_filename(flnm)
            return flnm
    else:
        error('Could not understand surface file-format %s' % surface_format)
    path = surface_path if surface_path else os.path.join(subject.path, 'surf')
    files = []
    note('Exporting files...')
    for h in six.iterkeys(registrations):
        hemi = subject.hemis[h]
        reg = registrations[h]
        note('Extracting %s predicted mesh...' % h.upper())
        pmesh = reg['predicted_mesh']
        for (pname,tag) in zip(['polar_angle', 'eccentricity', 'visual_area', 'radius'],
                               [angle_tag, eccen_tag, label_tag, radius_tag]):
            flnm = export(os.path.join(path, h + '.' + tag), pmesh.prop(pname))
            files.append(flnm)
        # last do the registration itself
        if registration_name and not no_reg_export:
            flnm = os.path.join(path, h + '.' + registration_name + '.sphere.reg')
            fsio.write_geometry(flnm, pmesh.coordinates.T, pmesh.tess.faces.T)
    return {'surface_files': tuple(files)}
912414
def save_pointings(self):
        """"""

        import tkFileDialog
        f=tkFileDialog.asksaveasfile()
        i=0
        if self.pointing_format.get()=='CFHT PH':
	    f.write("""<?xml version = "1.0"?>
<!DOCTYPE ASTRO SYSTEM "http://vizier.u-strasbg.fr/xml/astrores.dtd">
<ASTRO ID="v0.8" xmlns:ASTRO="http://vizier.u-strasbg.fr/doc/astrores.htx">
<TABLE ID="Table">
<NAME>Fixed Targets</NAME>
<TITLE>Fixed Targets for CFHT QSO</TITLE>
<!-- Definition of each field -->
<FIELD name="NAME" datatype="A" width="20">
   <DESCRIPTION>Name of target</DESCRIPTION>
</FIELD>
<FIELD name="RA" ref="" datatype="A" width="11" unit="&quot;h:m:s&quot;">
   <DESCRIPTION>Right ascension of target</DESCRIPTION>
</FIELD>     
<FIELD name="DEC" ref="" datatype="A" width="11" unit="&quot;d:m:s&quot;">
   <DESCRIPTION>Declination of target</DESCRIPTION>
</FIELD>     
<FIELD name="EPOCH" datatype="F" width="6">
    <DESCRIPTION>Epoch of coordinates</DESCRIPTION>
</FIELD>     
<FIELD name="POINT" datatype="A" width="5">
<DESCRIPTION>Pointing name</DESCRIPTION>
</FIELD>     
<!-- Data table --> 
<DATA><CSV headlines="4" colsep="|"><![CDATA[
NAME                |RA         |DEC        |EPOCH |POINT|
                    |hh:mm:ss.ss|+dd:mm:ss.s|      |     |
12345678901234567890|12345678901|12345678901|123456|12345|
--------------------|-----------|-----------|------|-----|\n""")	
        if self.pointing_format.get()=='Palomar':
	    f.write("index\n")
        for pointing in self.pointings:
            i=i+1
            name=pointing["label"]["text"]
            (sra,sdec)=str(pointing["camera"]).split()
	    ra=sra.split(":")
	    dec=sdec.split(":")
	    dec[0]=str(int(dec[0]))
	    if int(dec[0])>=0:
		    dec[0]='+'+dec[0]
	    if self.pointing_format.get()=='Palomar':
		    f.write( "%5d %16s %2s %2s %4s %3s %2s %4s 2000\n" % (i, name,
									  ra[0].zfill(2),
									  ra[1].zfill(2),
									  ra[2].zfill(2),
									  dec[0].zfill(3),
									  dec[1].zfill(2),
									  dec[2].zfill(2)))
	    elif self.pointing_format.get()=='CFHT PH':
                #f.write("%f %f\n" % (pointing["camera"].ra,pointing["camera"].dec))
                f.write("%-20s|%11s|%11s|%6.1f|%-5d|\n" % (name,sra,sdec,2000.0,1))
            elif self.pointing_format.get()=='KPNO/CTIO':
                str1 = sra.replace(":"," ")
	        str2 = sdec.replace(":"," ")
                f.write("%16s %16s %16s 2000\n" % ( name, str1, str2) )
            elif self.pointing_format.get()=='SSim':
                ra = []
 		dec= []
                for ccd in pointing["camera"].getGeometry():
		    ra.append(ccd[0])
		    ra.append(ccd[2])
		    dec.append(ccd[1])
		    dec.append(ccd[3])
  	        import math
 		dra=math.degrees(math.fabs(max(ra)-min(ra)))
 		ddec=math.degrees(math.fabs(max(dec)-min(dec)))
                f.write("%f %f %16s %16s DATE 1.00 1.00 500 FILE\n" % (dra, ddec, sra, sdec ) ) 
        if self.pointing_format.get()=='CFHT PH':
	    f.write("""]]</CSV></DATA>
</TABLE>
</ASTRO>
""")
	f.close()
435576
function storeFileToDisk(i_oFile, i_sOutput) {
    var l_sDirname = path.dirname(i_oFile.filename),
        l_sFilename;

    console.log("File name: ", i_oFile.filename, " size: ", i_oFile.header.unpackedSize);
    console.log("Saving content of file ");

    l_sDirname = path.join(i_sOutput, path.dirname(i_oFile.filename));
    l_sFilename = path.join(l_sDirname, path.basename(i_oFile.filename));
    return new Promise(function(i_oResolve) {
        mkdirp(l_sDirname, function (err) {
            if (err) console.error(err);
            _writeFile(l_sFilename, i_oFile, i_oResolve);
        });
    });
}
1183561
def save(self, cf, filename, format='dot'):
        
        try:
            dot_graph = Dot(**self.graph_format)

            # add nodes
            nodes = {}
            for cfg_addr in cf._graph.node.keys():
                nodes[cfg_addr] = self._create_node(cfg_addr, cf)

                dot_graph.add_node(nodes[cfg_addr])

            # add edges
            for cfg_src_addr in cf._graph.node.keys():
                for cfg_dst_addr in cf._edges.get(cfg_src_addr, []):
                    edge = self._create_edge(nodes, cfg_src_addr, cfg_dst_addr)

                    dot_graph.add_edge(edge)

            dot_graph.write("{}.{}".format(filename, format), format=format)
        except Exception:
            logger.error("Failed to save call graph: %s (%s)", filename, format, exc_info=True)
743711
def create_imagefile(options, filename, latlon, ground_width, path_objs, mission_obj, fence_obj, width=600, height=600):
    ''''''
    mt = mp_tile.MPTile(service=options.service)

    map_img = mt.area_to_image(latlon[0], latlon[1],
                               width, height, ground_width)
    while mt.tiles_pending() > 0:
        print("Waiting on %u tiles" % mt.tiles_pending())
        time.sleep(1)
    map_img = mt.area_to_image(latlon[0], latlon[1],
                               width, height, ground_width)
    # a function to convert from (lat,lon) to (px,py) on the map
    pixmapper = functools.partial(pixel_coords, ground_width=ground_width, mt=mt, topleft=latlon, width=width)
    for path_obj in path_objs:
        path_obj.draw(map_img, pixmapper, None)
    if mission_obj is not None:
        for m in mission_obj:
            m.draw(map_img, pixmapper, None)
    if fence_obj is not None:
        fence_obj.draw(map_img, pixmapper, None)
    cv.CvtColor(map_img, map_img, cv.CV_BGR2RGB)
    cv.SaveImage(filename, map_img)
1062375
def point2pos(self, point):
        """"""
        row = self._vim.eval('byte2line({})'.format(point))
        col = self._vim.eval('{} - line2byte({})'.format(point, row))
        return (int(row), int(col))
628525
def graph_save(permanent: false, &block)
      if block
        Tempfile.open{|tmp|
          graph(output: tmp)
          tmp.seek(0)
          block.(tmp)
        }
      else
        tmp = Tempfile.open
        graph(output: tmp).tap{|t|t.seek(0)}
      end
    end
868315
def saveFile(self):
        """"""
        filepath, _ = QtWidgets.QFileDialog.getSaveFileName(
            self, "Save File", '', "Androguard Session (*.ag)")

        if filepath:
            # Ensure .ag as file ending
            if not filepath.endswith(".ag"):
                filepath = "{}.ag".format(filepath)

            self.showStatus("Saving %s..." % str(filepath))
            self.saveSession(filepath)
            self.showStatus("Saved Session to %s!" % str(filepath))
594150
def saveShp(self, target):
        """"""
        if not hasattr(target, "write"):
            target = os.path.splitext(target)[0] + '.shp'
        if not self.shapeType:
            self.shapeType = self._shapes[0].shapeType
        self.shp = self.__getFileObj(target)
        self.__shapefileHeader(self.shp, headerType='shp')
        self.__shpRecords()
965325
def save_to_file(self,
                     file_path,
                     labels=None,
                     predict_proba=True,
                     show_predicted_value=True,
                     **kwargs):
        
        file_ = open(file_path, 'w', encoding='utf8')
        file_.write(self.as_html(labels=labels,
                                 predict_proba=predict_proba,
                                 show_predicted_value=show_predicted_value,
                                 **kwargs))
        file_.close()
1053609
def save(filepath=None, **kwargs):
    
    if filepath is None:
        filepath = os.path.join('.env')

    with open(filepath, 'wb') as file_handle:
        file_handle.writelines(
            '{0}={1}\n'.format(key.upper(), val)
            for key, val in kwargs.items()
        )
342489
def fence_draw_callback(self, points):
        ''''''
        self.fenceloader.clear()
        if len(points) < 3:
            return
        self.fenceloader.target_system = self.target_system
        self.fenceloader.target_component = self.target_component
        bounds = mp_util.polygon_bounds(points)
        (lat, lon, width, height) = bounds
        center = (lat+width/2, lon+height/2)
        self.fenceloader.add_latlon(center[0], center[1])
        for p in points:
            self.fenceloader.add_latlon(p[0], p[1])
        # close it
        self.fenceloader.add_latlon(points[0][0], points[0][1])
        self.send_fence()
        self.have_list = True
108264
def _save_file(self, filename, contents):
        """"""
        with open(filename, 'w') as f:
            f.write(contents)