Generate entities for source path
        :param SyncCopy self: this
        :param blobxfer.models.azure.StorageEntity src_ase: source ase
        :rtype: blobxfer.models.azure.StorageEntity
        :return: destination storage entity
762285
def _generate_destination_for_source(self, src_ase):
        # type: (SyncCopy, blobxfer.models.azure.StorageEntity) ->
        #        blobxfer.models.azure.StorageEntity)
        
        # create a storage entity for each destination
        for sa, cont, name, dpath in self._get_destination_paths():
            if self._spec.options.rename:
                name = str(pathlib.Path(name))
                if name == '.':
                    raise RuntimeError(
                        'attempting rename multiple files to a directory')
            else:
                name = str(pathlib.Path(name) / src_ase.name)
            # translate source mode to dest mode
            dst_mode = self._translate_src_mode_to_dst_mode(src_ase.mode)
            dst_ase = self._check_for_existing_remote(sa, cont, name, dst_mode)
            if dst_ase is None:
                dst_ase = blobxfer.models.azure.StorageEntity(cont, ed=None)
                dst_ase.populate_from_local(
                    sa, cont, name, dst_mode, src_ase.cache_control)
                dst_ase.size = src_ase.size
            # overwrite tier with specified storage tier
            if (dst_mode == blobxfer.models.azure.StorageModes.Block and
                    self._spec.options.access_tier is not None):
                dst_ase.access_tier = self._spec.options.access_tier
            # check condition for dst
            action = self._check_copy_conditions(src_ase, dst_ase)
            if action == SynccopyAction.Copy:
                yield dst_ase
            elif action == SynccopyAction.Skip:
                # add to exclusion set if skipping
                if self._spec.options.delete_extraneous_destination:
                    uid = (
                        blobxfer.operations.synccopy.SyncCopy.
                        create_deletion_id(
                            dst_ase._client, dst_ase.container, dst_ase.name)
                    )
                    self._delete_exclude.add(uid)
                if self._general_options.dry_run:
                    logger.info('[DRY RUN] skipping: {} -> {}'.format(
                        src_ase.path, dst_ase.path))
477271
def add_path_with_storage_account(self, remote_path, storage_account):
        # type: (SourcePath, str, str) -> None
        
        if len(self._path_map) >= 1:
            raise RuntimeError(
                'cannot add multiple remote paths to SourcePath objects')
        rpath = blobxfer.util.normalize_azure_path(remote_path)
        self.add_path(rpath)
        self._path_map[rpath] = storage_account
1266503
def sync_code(self):
        """"""
        from ambry.orm.file import File
        from ambry.bundle.files import BuildSourceFile

        self.dstate = self.STATES.BUILDING

        synced = 0

        for fc in [File.BSFILE.BUILD, File.BSFILE.META, File.BSFILE.LIB, File.BSFILE.TEST, File.BSFILE.DOC]:
            bsf = self.build_source_files.file(fc)
            if bsf.fs_is_newer:
                self.log('Syncing {}'.format(bsf.file_name))
                bsf.sync(BuildSourceFile.SYNC_DIR.FILE_TO_RECORD)
                synced += 1

        # Only the metadata needs to be driven to the objects, since the other files are used as code,
        # directly from the file record.
        self.build_source_files.file(File.BSFILE.META).record_to_objects()

        return synced
699762
public static Entity getEntity(EntityWidget widget, StorageService storageService) {
		Entity entity = widget.getEntity();				
		if (entity == null) {	
            String entityId = widget.getInternalSettings().get(EntityWidget.ENTITY_ID);
            try {
                entity = storageService.getEntityById(entityId);
            } catch (NotFoundException e) {                
                e.printStackTrace();
            }      
            widget.setEntity(entity);
        }
		return entity;
	}
1013080
def get(self, storagemodel) -> StorageTableModel:
        

        modeldefinition = self.getmodeldefinition(storagemodel, True)

        try:

            pk = storagemodel.getPartitionKey()
            rk = storagemodel.getRowKey()

            entity = modeldefinition['tableservice'].get_entity(modeldefinition['tablename'], pk, rk)
            storagemodel._exists = True
        
            """ sync with entity values """
            for key, default in vars(storagemodel).items():
                if not key.startswith('_') and key not in ['','PartitionKey','RowKey']:
                    value = getattr(entity, key, None)
                    if not value is None:
                        setattr(storagemodel, key, value)
             
        except AzureMissingResourceHttpError as e:
            log.debug('can not get table entity:  Table {}, PartitionKey {}, RowKey {} because {!s}'.format(modeldefinition['tablename'], pk, rk, e))
            storagemodel._exists = False

        except Exception as e:
            msg = 'can not get table entity:  Table {}, PartitionKey {}, RowKey {} because {!s}'.format(modeldefinition['tablename'], pk, rk, e)
            raise AzureStorageWrapException(msg=msg)

        finally:
            return storagemodel
848610
def _add_to_download_queue(self, lpath, rfile):
        # type: (Downloader, pathlib.Path,
        #        blobxfer.models.azure.StorageEntity) -> None
        
        # prepare remote file for download
        dd = blobxfer.models.download.Descriptor(
            lpath, rfile, self._spec.options, self._general_options,
            self._resume)
        with self._transfer_lock:
            self._transfer_cc[dd.entity.path] = 0
            if dd.entity.is_encrypted:
                self._dd_map[str(dd.final_path)] = dd
        # add download descriptor to queue
        self._transfer_queue.put(dd)
        if self._download_start_time is None:
            with self._transfer_lock:
                if self._download_start_time is None:
                    self._download_start_time = blobxfer.util.datetime_now()
769883
function compileEntity() {
          var entity = extend({
            buildId: bff.key(payload),
            extension: file.extension,
            filename: file.filename,
            fingerprint: print,
            url: file.url
          }, payload);

          return entity;
        }
447887
def _copy_sources_to_generated_destination(self):
        

        files = []
        for key in FILES_EXTENSIONS.keys():
            if type(self.project['export'][key]) is dict:
                for k,v in self.project['export'][key].items():
                    files.extend(v)
            elif type(self.project['export'][key]) is list:
                files.extend(self.project['export'][key])
            else:
                files.append(self.project['export'][key])

        destination = os.path.join(self.settings.root, self.project['export']['output_dir']['path'])
        if os.path.exists(destination):
            shutil.rmtree(destination)
        for item in files:
            s = os.path.join(self.settings.root, item)
            d = os.path.join(destination, item)
            if os.path.isdir(s):
                shutil.copytree(s,d)
            else:
                if not os.path.exists(os.path.dirname(d)):
                    os.makedirs(os.path.join(self.settings.root, os.path.dirname(d)))
                shutil.copy2(s,d)
867793
def _finalize_upload(self, sd):
        # type: (SyncCopy, blobxfer.models.synccopy.Descriptor) -> None
        
        metadata = sd.src_entity.raw_metadata
        if blobxfer.util.is_not_empty(sd.src_entity.md5):
            digest = sd.src_entity.md5
        else:
            digest = None
        if sd.requires_put_block_list:
            # put block list for non one-shot block blobs
            self._finalize_block_blob(sd, metadata, digest)
        elif sd.remote_is_page_blob or sd.remote_is_append_blob:
            # append and page blob finalization
            self._finalize_nonblock_blob(sd, metadata, digest)
        elif sd.remote_is_file:
            # azure file finalization
            self._finalize_azure_file(sd, metadata, digest)
        # set access tier
        if sd.requires_access_tier_set:
            blobxfer.operations.azure.blob.block.set_blob_access_tier(
                sd.dst_entity)
1060030
def _process_synccopy_descriptor(self, sd):
        # type: (SyncCopy, blobxfer.models.synccopy.Descriptor) -> None
        
        # update progress bar
        self._update_progress_bar()
        # get download offsets
        offsets, resume_bytes = sd.next_offsets()
        # add resume bytes to counter
        if resume_bytes is not None:
            with self._transfer_lock:
                self._synccopy_bytes_sofar += resume_bytes
                logger.debug('adding {} sofar {} from {}'.format(
                    resume_bytes, self._synccopy_bytes_sofar,
                    sd.dst_entity.name))
            del resume_bytes
        # check if all operations completed
        if offsets is None and sd.all_operations_completed:
            # finalize upload for non-one shots
            if not sd.is_one_shot_block_blob:
                self._finalize_upload(sd)
            else:
                # set access tier for one shots
                if sd.requires_access_tier_set:
                    blobxfer.operations.azure.blob.block.set_blob_access_tier(
                        sd.dst_entity)
            # accounting
            with self._transfer_lock:
                self._transfer_set.remove(
                    blobxfer.operations.synccopy.SyncCopy.
                    create_unique_transfer_operation_id(
                        sd.src_entity, sd.dst_entity))
                self._synccopy_sofar += 1
            return
        # re-enqueue for finalization if no offsets
        if offsets is None:
            self._transfer_queue.put(sd)
            return
        # prepare upload
        if offsets.chunk_num == 0:
            self._prepare_upload(sd.dst_entity)
        # prepare replica targets
        if blobxfer.util.is_not_empty(sd.dst_entity.replica_targets):
            for ase in sd.dst_entity.replica_targets:
                if offsets.chunk_num == 0:
                    self._prepare_upload(ase)
        # re-enqueue for other threads to download next offset if not append
        if sd.src_entity.mode != blobxfer.models.azure.StorageModes.Append:
            self._transfer_queue.put(sd)
        # issue get range
        if sd.src_entity.mode == blobxfer.models.azure.StorageModes.File:
            data = blobxfer.operations.azure.file.get_file_range(
                sd.src_entity, offsets)
        else:
            data = blobxfer.operations.azure.blob.get_blob_range(
                sd.src_entity, offsets)
        # process data for upload
        self._process_data(sd, sd.dst_entity, offsets, data)
        # iterate replicas
        if blobxfer.util.is_not_empty(sd.dst_entity.replica_targets):
            for ase in sd.dst_entity.replica_targets:
                self._process_data(sd, ase, offsets, data)
        # re-enqueue for append blobs
        if sd.src_entity.mode == blobxfer.models.azure.StorageModes.Append:
            self._transfer_queue.put(sd)
299135
def _create_clients(self, timeout, proxy):
        # type: (StorageAccount, blobxfer.models.options.Timeout,
        #        blobxfer.models.options.HttpProxy) -> None
        
        self._append_blob_client = \
            blobxfer.operations.azure.blob.append.create_client(
                self, timeout, proxy)
        self._block_blob_client = \
            blobxfer.operations.azure.blob.block.create_client(
                self, timeout, proxy)
        self._file_client = blobxfer.operations.azure.file.create_client(
            self, timeout, proxy)
        self._page_blob_client = \
            blobxfer.operations.azure.blob.page.create_client(
                self, timeout, proxy)
479894
def create_entity(uid='', path='', desc='', kind='1'):
        '''
        
        '''

        if path:
            pass
        else:
            return False

        if uid:
            pass
        else:
            uid = get_uuid()
        try:
            TabEntity.create(
                uid=uid,
                path=path,
                desc=desc,
                time_create=time.time(),
                kind=kind
            )
            return True
        except:
            return False
949612
def save(self, sync_only=False):
        

        entity = datastore.Entity(key=self._key)
        entity["last_accessed"] = self.last_accessed

        # todo: restore sync only
        entity["data"] = self._data
        if self.expires:
            entity["expires"] = self.expires

        self._client.put(entity)
405305
private void updateEntity(String type, String id, XContentBuilder source) throws StorageException {
        try {
            String doc = source.string();
            /* JestResult response = */esClient.execute(new Index.Builder(doc)
                    .setParameter(Parameters.OP_TYPE, "index").index(getIndexName()).type(type).id(id).build()); //$NON-NLS-1$
        } catch (Exception e) {
            throw new StorageException(e);
        }
    }
1014404
def save_content_type_object(repo, schema, uuid, data):
    
    storage_manager = StorageManager(repo)
    model_class = deserialize(schema,
                              module_name=schema['namespace'])
    model = model_class(data)
    commit = storage_manager.store(model, 'Updated via PUT request.')
    return commit, model
848681
function afterEntityStored( returnResult, serverResponse ) {
		var self = this;

		// Writing an entity to the backend will usually invoke an update event to be
		// broadcast over websockets, where we would also retrieve the updated record.
		// We still put the updated record we receive here into the cache to ensure early consistency, if that is requested.
		if( !returnResult && !self.forceEarlyCacheUpdate ) {
			return;
		}

		if( serverResponse.data[ configuration.entityName ] ) {
			var rawEntity = serverResponse.data[ configuration.entityName ];
			// If early cache updates are forced, put the return entity into the cache.
			if( self.forceEarlyCacheUpdate ) {
				var newEntity = self.deserializer( rawEntity );
				self.__updateCacheWithEntity( newEntity );

				if( returnResult ) {
					return newEntity;
				}
			}
			if( returnResult ) {
				return rawEntity;
			}
		}
	}
1231516
def create_share(ase, containers_created, timeout=None):
    # type: (blobxfer.models.azure.StorageEntity, dict, int) -> None
    
    # check if auth allows create container
    if not ase.can_create_containers:
        return
    key = ase.client.account_name + ':file=' + ase.container
    if key in containers_created:
        return
    if ase.client.create_share(
            share_name=ase.container,
            fail_on_exist=False,
            timeout=timeout):
        logger.info('created file share {} on storage account {}'.format(
            ase.container, ase.client.account_name))
    # always add to set (as it could be pre-existing)
    containers_created.add(key)