def delete_removed(self, folder_name, current_block_cell_names, block_filter=None): """ current_block_cell_names is the set of BlockCellNames currently in closure Items not in closure, can be deleted Params: folder_name = SRC_DIR or DEP_DIR current_block_cell_names = [BlockCellName] block_filter = BlockName or None if BlockName only files from that BlockName will be deleted """ bii_ignore = self._user_cache.bii_ignore folder = self._bii_paths.get_src_folder(folder_name) root_block = self._bii_paths.root_block project_folder = self._bii_paths.project_root # Files on biicode control (excluded ignored) thefiles = walk_bii_folder(folder, bii_ignore, self._biiout) if root_block and folder_name == SRC_DIR: afiles = walk_anonymous_block(self._bii_paths, bii_ignore, self._biiout, root_block) thefiles.update(afiles) # Delete removed cells for blockcellname in thefiles: if ((not block_filter or blockcellname.block_name == block_filter) and blockcellname not in current_block_cell_names): if blockcellname.block_name == root_block: filepath = os.path.join(project_folder, blockcellname.cell_name) else: filepath = os.path.join(folder, blockcellname) os.unlink(filepath) self._delete_empty_dirs(folder_name, block_filter)
def delete_removed(self, folder_name, current_block_cell_names, block_filter=None): """ current_block_cell_names is the set of BlockCellNames currently in closure Items not in closure, can be deleted Params: folder_name = SRC_DIR or DEP_DIR current_block_cell_names = [BlockCellName] block_filter = BlockName or None if BlockName only files from that BlockName will be deleted """ bii_ignore = self._user_cache.bii_ignore folder = self._bii_paths.get_src_folder(folder_name) root_block = self._bii_paths.root_block project_folder = self._bii_paths.project_root # Files on biicode control (excluded ignored) thefiles = walk_bii_folder(folder, bii_ignore, self._biiout) if root_block and folder_name == SRC_DIR: afiles = walk_anonymous_block(self._bii_paths, bii_ignore, self._biiout, root_block) thefiles.update(afiles) # Delete removed cells for blockcellname in thefiles: if ((not block_filter or blockcellname.block_name == block_filter) and blockcellname not in current_block_cell_names): if blockcellname.block_name == root_block: filepath = os.path.join(project_folder, blockcellname.cell_name) else: filepath = os.path.join(folder, blockcellname) os.unlink(filepath) self._delete_empty_dirs(folder_name, block_filter)
def get_src_files(self): """ scans the SRC_DIR to obtain a {BlockCellName: ByteLoad} """ #scan regular block folder bii_ignore = self._user_cache.bii_ignore result = walk_bii_folder(self._bii_paths.blocks, bii_ignore, self._biiout) # check if the project root has to be scanned self.update_root_block() project_block = self._bii_paths.root_block # scan project root if project_block: result_filter = { bcn: content for bcn, content in result.iteritems() if bcn.block_name != project_block } if len(result) != len(result_filter): self._biiout.warn( "Skipping %s block, it already exist in project root" % project_block) result = result_filter anon = walk_anonymous_block(self._bii_paths, bii_ignore, self._biiout, project_block) result.update(anon) return result
def test_anonymous_block(): bii_paths = BiiPathsMock( self.folder, 'root-block: {}\nauto-root-block: True'.format(block_name), self.user_home) return walk_anonymous_block(bii_paths, bii_ignore, self.biiout, BlockName(block_name))
def get_src_files(self): """ scans the SRC_DIR to obtain a {BlockCellName: ByteLoad} """ #scan regular block folder bii_ignore = self._user_cache.bii_ignore result = walk_bii_folder(self._bii_paths.blocks, bii_ignore, self._biiout) # check if the project root has to be scanned self.update_root_block() project_block = self._bii_paths.root_block # scan project root if project_block: result_filter = {bcn: content for bcn, content in result.iteritems() if bcn.block_name != project_block} if len(result) != len(result_filter): self._biiout.warn("Skipping %s block, it already exist in project root" % project_block) result = result_filter anon = walk_anonymous_block(self._bii_paths, bii_ignore, self._biiout, project_block) result.update(anon) return result
def test_anonymous_block(): bii_paths = BiiPathsMock(self.folder, 'root-block: {}\nauto-root-block: True'.format(block_name), self.user_home) return walk_anonymous_block(bii_paths, bii_ignore, self.biiout, BlockName(block_name))