Remove tags from a file.

    Args:
        filething (filething)
    Raises:
        mutagen.MutagenError
1326
def delete(filething):
    

    dsf_file = DSFFile(filething.fileobj)

    if dsf_file.dsd_chunk.offset_metdata_chunk != 0:
        id3_location = dsf_file.dsd_chunk.offset_metdata_chunk
        dsf_file.dsd_chunk.offset_metdata_chunk = 0
        dsf_file.dsd_chunk.write()

        filething.fileobj.seek(id3_location)
        filething.fileobj.truncate()
324489
async def delTag(self, tag, init=False):
        '''
        
        '''
        path = s_chop.tagpath(tag)

        name = '.'.join(path)

        if self.isrunt:
            raise s_exc.IsRuntForm(mesg='Cannot delete tags from runt nodes.',
                                   form=self.form.full, tag=tag)

        curv = self.tags.pop(name, s_common.novalu)
        if curv is s_common.novalu:
            return False

        pref = name + '.'

        subtags = [(len(t), t) for t in self.tags.keys() if t.startswith(pref)]
        subtags.sort(reverse=True)

        removed = []

        for sublen, subtag in subtags:
            valu = self.tags.pop(subtag, None)
            removed.append((subtag, valu))

        removed.append((name, curv))

        info = {'univ': True}
        sops = [('prop:del', (self.buid, self.form.name, '#' + t, info)) for (t, v) in removed]

        # fire all the splices
        splices = [self.snap.splice('tag:del', ndef=self.ndef, tag=t, valu=v) for (t, v) in removed]
        await self.snap.stor(sops, splices)

        # fire all the handlers / triggers
        [await self.snap.core.runTagDel(self, t, v) for (t, v) in removed]
655640
def remove_tag(self, tag):
        

        tags = self.get_tags()
        tags.remove(tag)

        post_data = TAGS_TEMPLATE.format(connectware_id=self.get_connectware_id(),
                                         tags=escape(",".join(tags)))
        self._conn.put('/ws/DeviceCore', post_data)

        # Invalidate cache
        self._device_json = None
1080659
def remove_tag(self, tag):
        # type: (str) -> bool
        
        return self._remove_hdxobject(self.data.get('tags'), tag, matchon='name')
1095528
def save(self, filething=None, v1=1, v2_version=4, v23_sep='/',
             padding=None):
        

        if v2_version == 3:
            # EasyID3 only works with v2.4 frames, so update_to_v23() would
            # break things. We have to save a shallow copy of all tags
            # and restore it after saving. Due to CHAP/CTOC copying has
            # to be done recursively implemented in ID3Tags.
            backup = self.__id3._copy()
            try:
                self.__id3.update_to_v23()
                self.__id3.save(
                    filething, v1=v1, v2_version=v2_version, v23_sep=v23_sep,
                    padding=padding)
            finally:
                self.__id3._restore(backup)
        else:
            self.__id3.save(filething, v1=v1, v2_version=v2_version,
                            v23_sep=v23_sep, padding=padding)
80069
def load(self, filething, **kwargs):
        """"""

        fileobj = filething.fileobj

        try:
            self.tags = _IFFID3(fileobj, **kwargs)
        except ID3NoHeaderError:
            self.tags = None
        except ID3Error as e:
            raise error(e)
        else:
            self.tags.filename = self.filename

        fileobj.seek(0, 0)
        self.info = AIFFInfo(fileobj)
151428
def _removeTags(tags, objects):
    
    for t in tags:
        for o in objects:
            o.tags.remove(t)

    return True
1327054
def __delete_file(self, file):
        

        for file_node in self.__script_editor.model.get_file_nodes(file, self.__script_editor.model.root_node):
            self.__script_editor.unregister_node_path(file_node)
            self.__delete_path(file)
            if self.__script_editor.model.is_authoring_node(file_node):
                self.__script_editor.get_editor(file).set_modified(True)
            else:
                self.__script_editor.model.unregister_file(file_node)
1228446
def removeXmlElement(name, directory, file_pattern, logger=None):
    
    for path, dirs, files in os.walk(os.path.abspath(directory)):
        for filename in fnmatch.filter(files, file_pattern):
            filepath = os.path.join(path, filename)
            remove_xml_element_file(name, filepath)
226391
def del_tags(self, tags):
        
        # SQLA Adding a SymbolTag object, feels awkward/uneccessary.
        # Should I be implementing this functionality a different way?

        if isinstance(tags, (str, unicode)):
            tags = [tags]

        objs = object_session(self)

        docommit = False
        for symboltag in self.tags:
            if symboltag.tag in tags:
                objs.delete(symboltag)
                docommit = True

        
        if docommit:
            objs.commit()
1331136
def _remove_tag_helper(self, p_key, p_value):
        
        tags = self.fields['tags']

        try:
            tags[p_key] = [t for t in tags[p_key] if p_value != "" and t != p_value]
            if len(tags[p_key]) == 0:
                del tags[p_key]
        except KeyError:
            pass
678206
def __strip_tags(self, node: yaml.Node) -> None:
        
        if isinstance(node, yaml.SequenceNode):
            for subnode in node.value:
                self.__strip_tags(subnode)
        elif isinstance(node, yaml.MappingNode):
            node.tag = 'tag:yaml.org,2002:map'
            for key_node, value_node in node.value:
                self.__strip_tags(key_node)
                self.__strip_tags(value_node)
722173
def save(self, filething=None):
        

        fileobj = filething.fileobj

        data = _APEv2Data(fileobj)

        if data.is_at_start:
            delete_bytes(fileobj, data.end - data.start, data.start)
        elif data.start is not None:
            fileobj.seek(data.start)
            # Delete an ID3v1 tag if present, too.
            fileobj.truncate()
        fileobj.seek(0, 2)

        tags = []
        for key, value in self.items():
            # Packed format for an item:
            # 4B: Value length
            # 4B: Value type
            # Key name
            # 1B: Null
            # Key value
            value_data = value._write()
            if not isinstance(key, bytes):
                key = key.encode("utf-8")
            tag_data = bytearray()
            tag_data += struct.pack("<2I", len(value_data), value.kind << 1)
            tag_data += key + b"\0" + value_data
            tags.append(bytes(tag_data))

        # "APE tags items should be sorted ascending by size... This is
        # not a MUST, but STRONGLY recommended. Actually the items should
        # be sorted by importance/byte, but this is not feasible."
        tags.sort(key=lambda tag: (len(tag), tag))
        num_tags = len(tags)
        tags = b"".join(tags)

        header = bytearray(b"APETAGEX")
        # version, tag size, item count, flags
        header += struct.pack("<4I", 2000, len(tags) + 32, num_tags,
                              HAS_HEADER | IS_HEADER)
        header += b"\0" * 8
        fileobj.write(header)

        fileobj.write(tags)

        footer = bytearray(b"APETAGEX")
        footer += struct.pack("<4I", 2000, len(tags) + 32, num_tags,
                              HAS_HEADER)
        footer += b"\0" * 8

        fileobj.write(footer)
887387
def delete_all_tags(self):
        
        j, r = self.datacenter.request('DELETE', self.path + '/tags')
        r.raise_for_status()
1290734
def files(context, yes, tag, bundle, before, notondisk):
    """"""
    file_objs = []

    if not tag and not bundle:
        click.echo("I'm afraid I can't let you do that.")
        context.abort()

    if bundle:
        bundle_obj = context.obj['store'].bundle(bundle)
        if bundle_obj is None:
            click.echo(click.style('bundle not found', fg='red'))
            context.abort()

    query = context.obj['store'].files_before(bundle = bundle, tags = tag, before = before)

    if notondisk:
        file_objs = set(query) - context.obj['store'].files_ondisk(query)
    else:
        file_objs = query.all()

    if len(file_objs) > 0 and len(yes) < 2:
        if not click.confirm(f"Are you sure you want to delete {len(file_objs)} files?"):
            context.abort()

    for file_obj in file_objs:
        if yes or click.confirm(f"remove file from disk and database: {file_obj.full_path}"):
            file_obj_path = Path(file_obj.full_path)
            if file_obj.is_included and (file_obj_path.exists() or file_obj_path.is_symlink()):
                file_obj_path.unlink()
            file_obj.delete()
            context.obj['store'].commit()
            click.echo(f'{file_obj.full_path} deleted')
1087430
def delete(filething):
    

    t = OggSpeex(filething)
    filething.fileobj.seek(0)
    t.delete(filething)
251407
def del_tag(
            self,
            tag):
        

        if tag.replace("@", "") not in self.tags:
            return

        self.refresh
        oldContent = self.to_string(indentLevel=1)
        newTags = []
        newTags[:] = [n for n in newTags if tag not in n]
        self.tags = newTags
        newContent = self.to_string(indentLevel=1)

        # ADD DIRECTLY TO CONTENT IF THE PROJECT IS BEING ADDED SPECIFICALLY TO
        # THIS OBJECT
        self.parent._update_document_tree(
            oldContent=oldContent,
            newContent=newContent
        )

        self.refresh
        return None