save item in destination data source
550083
function() {
        var editDataSource = this.getProperty( 'editDataSource' );
        var destinationDataSource = this.getProperty( 'destinationDataSource' );
        var destinationProperty = this.getProperty( 'destinationProperty' );

        if( this._isObjectDataSource( editDataSource ) ) {
            var editedItem = editDataSource.getSelectedItem();
            var originItem = destinationDataSource.getProperty( destinationProperty );

            if( this._isRootElementPath( destinationProperty ) ) {
                this._overrideOriginItem( originItem, editedItem );
                destinationDataSource._includeItemToModifiedSet( originItem );
                destinationDataSource.saveItem( originItem, function() {
                    destinationDataSource.updateItems();
                } );
            } else {
                destinationDataSource.setProperty( destinationProperty, editedItem );
            }

        } else {
            destinationDataSource.updateItems();
        }
    }
329564
def download(self, source, destination):
        """"""
        self._handler.download(posix_path(source), destination)
706700
def _insert_item(self, key, new_item, instance, is_after):
        """"""
        index = self._get_index_for_insert(key, instance)
        index = index + 1 if is_after else index
        self.__items = self.__items[:index] + new_item + self.__items[index:]
        # Make sure indexing works with new items
        for new_key, new_value in new_item:
            if new_key in self:
                value_list = [val for k, val in self.__items if k == new_key]
                dict_setitem(self, new_key, value_list)
            else:
                dict_setitem(self, new_key, [new_value])
30129
def copy(self, path, dest, raise_if_exists=False):
        
        if raise_if_exists and dest in self.get_all_data():
            raise RuntimeError('Destination exists: %s' % path)
        contents = self.get_all_data()[path]
        self.get_all_data()[dest] = contents
1237896
def itemData(self, f=None, savePath=None):
        

        params = {
        }
        if f is not None and \
           f.lower() in ['zip', 'json']:
            params['f'] = f
        url = "%s/data" % self.root
        if self.type in ["Shapefile", "CityEngine Web Scene", "Web Scene", "KML",
                         "Code Sample",
                         "Code Attachment", "Operations Dashboard Add In",
                         "CSV", "CSV Collection", "CAD Drawing", "Service Definition",
                         "Microsoft Word", "Microsoft Powerpoint",
                         "Microsoft Excel", "PDF", "Image",
                         "Visio Document", "iWork Keynote", "iWork Pages",
                         "iWork Numbers", "Map Document", "Map Package",
                         "Basemap Package", "Tile Package", "Project Package",
                         "Task File", "ArcPad Package", "Explorer Map",
                         "Globe Document", "Scene Document", "Published Map",
                         "Map Template", "Windows Mobile Package", "Pro Map",
                         "Layout", "Layer", "Layer Package", "File Geodatabase",
                         "Explorer Layer", "Geoprocessing Package", "Geoprocessing Sample",
                         "Locator Package", "Rule Package", "Workflow Manager Package",
                         "Desktop Application", "Desktop Application Template",
                         "Code Sample", "Desktop Add In", "Explorer Add In",
                         "ArcGIS Desktop Add-In", "ArcGIS Explorer Add-In",
                         "ArcGIS Explorer application configuration", "ArcGIS Explorer document",
                         ]:
            if savePath is None:
                raise AttributeError('savePath must be provided for a item of type: %s' % self.type)
            if os.path.isdir(savePath) == False:
                os.makedirs(savePath)
            result = self._get(url=url,
                               param_dict=params,
                               securityHandler=self._securityHandler,
                               proxy_url=self._proxy_url,
                               proxy_port=self._proxy_port,
                               out_folder=savePath,
                               file_name=self.name)
            return result
        else:
            results =  self._get(url, params,
                                 proxy_port=self._proxy_port,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url)
            return results
209830
def smart_save(dbpath, archive, calc_id):
    
    tmpdir = tempfile.mkdtemp()
    newdb = os.path.join(tmpdir, os.path.basename(dbpath))
    shutil.copy(dbpath, newdb)
    try:
        with sqlite3.connect(newdb) as conn:
            conn.execute('DELETE FROM job WHERE status != "complete"')
            if calc_id:
                conn.execute('DELETE FROM job WHERE id != %d' % calc_id)
    except:
        safeprint('Please check the copy of the db in %s' % newdb)
        raise
    zipfiles([newdb], archive, 'a', safeprint)
    shutil.rmtree(tmpdir)
267096
def SaveDataToFD(self, raw_data, fd):
    """"""
    fd.write(yaml.Dump(raw_data).encode("utf-8"))
22222
def save_location(self, filename: str, location: PostLocation, mtime: datetime) -> None:
        """"""
        filename += '_location.txt'
        location_string = (location.name + "\n" +
                           "https://maps.google.com/maps?q={0},{1}&ll={0},{1}\n".format(location.lat,
                                                                                        location.lng))
        with open(filename, 'wb') as text_file:
            shutil.copyfileobj(BytesIO(location_string.encode()), text_file)
        os.utime(filename, (datetime.now().timestamp(), mtime.timestamp()))
        self.context.log('geo', end=' ', flush=True)
396092
def moveListItem(L, fromidx, toidx):
    ""
    r = L.pop(fromidx)
    L.insert(toidx, r)
    return toidx
702912
def _save_file(self, data):
        

        if platform.system() == 'Windows':
            with open(self.file, "w") as outfile:
                json.dump(data, outfile)
        else:
            newpath = self.file + '.new'

            with open(newpath, "w") as outfile:
                json.dump(data, outfile)

            os.rename(
                os.path.realpath(newpath),
                os.path.realpath(self.file)
            )
262202
def save_as(self):
        """"""
        filename = splitext(self.filename)[0]
        filename, _ = QFileDialog.getSaveFileName(self, 'Export events',
                                                  filename)
        if filename == '':
            return

        self.filename = filename
        short_filename = short_strings(basename(self.filename))
        self.idx_filename.setText(short_filename)
17332
def save_data(self, session, exp_id, content):
    ''''''

    subid = session.get('subid')

    # We only attempt save if there is a subject id, set at start
    data_file = None
    if subid is not None:

        data_base = "%s/%s" %(self.data_base, subid)

        # If not running in headless, ensure path exists
        if not self.headless and not os.path.exists(data_base):
            mkdir_p(data_base)

        # Conditions for saving:
        do_save = False

        # If headless with token pre-generated OR not headless
        if self.headless and os.path.exists(data_base) or not self.headless:
            do_save = True
        if data_base.endswith(('revoked','finished')):
            do_save = False  

        # If headless with token pre-generated OR not headless
        if do_save is True:
            data_file = "%s/%s-results.json" %(data_base, exp_id)
            if os.path.exists(data_file):
                self.logger.warning('%s exists, and is being overwritten.' %data_file)
            write_json(content, data_file)

    return data_file
272542
def save(self):
        """"""
        if ( self._new or
            (self._validID() and self._changed) or
            (self._updated and self._changed > self._updated) ):
            # Don't save if we have not loaded existing data!
            self._saveDB()
            return True
        return False
443014
def _save(self) -> RunSummary:
        
        assert self.summary["run"] is not None, "Must have called process before"

        trace_frames = self.bulk_saver.get_items_to_add(TraceFrame)
        log.info(
            "Saving %d issues, %d trace frames, %d trace annotations",
            len(self.bulk_saver.get_items_to_add(Issue)),
            len(self.bulk_saver.get_items_to_add(TraceFrame)),
            len(self.bulk_saver.get_items_to_add(TraceFrameAnnotation)),
        )

        num_pre = 0
        num_post = 0
        for frame in trace_frames:
            if frame.kind == TraceKind.PRECONDITION:
                num_pre += 1
            elif frame.kind == TraceKind.POSTCONDITION:
                num_post += 1
        log.info(
            "Within trace frames: %d preconditions, %d postconditions",
            num_pre,
            num_post,
        )

        with self.database.make_session() as session:
            pk_gen = self.primary_key_generator.reserve(
                session, [Run], use_lock=self.use_lock
            )
            self.summary["run"].id.resolve(id=pk_gen.get(Run), is_new=True)
            session.add(self.summary["run"])
            session.commit()

            run_id = self.summary["run"].id.resolved()
            self.summary["run"] = None  # Invalidate it

        self.bulk_saver.save_all(self.database, self.use_lock)

        # Now that the run is finished, fetch it from the DB again and set its
        # status to FINISHED.
        with self.database.make_session() as session:
            run = session.query(self.RUN_MODEL).filter_by(id=run_id).one()
            run.status = RunStatus.FINISHED
            session.add(run)
            session.commit()
            run_summary = run.get_summary()

        run_summary.num_invisible_issues = 0
        run_summary.num_missing_preconditions = len(
            self.summary["missing_preconditions"]
        )
        run_summary.num_missing_postconditions = len(
            self.summary["missing_postconditions"]
        )

        return run_summary
954404
def _copy_database_data_serverside(self, source, destination, tables):
        """"""
        for table in tqdm(tables, total=len(tables), desc='Copying table data (optimized)'):
            self.execute('INSERT INTO {0}.{1} SELECT * FROM {2}.{1}'.format(destination, wrap(table), source))
726661
def save_item(self, item):
        
        try:
            self.dynamodb_client.update_item(**item)
        except botocore.exceptions.ClientError as error:
            handle_constraint_violation(error)
255397
def save(unique_keys, data, table_name='swdata'):
    

    _set_table(table_name)

    connection = _State.connection()

    if isinstance(data, Mapping):
        # Is a single datum
        data = [data]
    elif not isinstance(data, Iterable):
        raise TypeError("Data must be a single mapping or an iterable "
                        "of mappings")

    insert = _State.table.insert(prefixes=['OR REPLACE'])
    for row in data:
        if not isinstance(row, Mapping):
            raise TypeError("Elements of data must be mappings, got {}".format(
                            type(row)))
        fit_row(connection, row, unique_keys)
        connection.execute(insert.values(row))
    _State.check_last_committed()