Write one data block with additional integrity check.

        If prior to calling this method the tag was not authenticated,
        a :exc:`RuntimeError` exception is raised.

        Command execution errors raise :exc:`~nfc.tag.TagCommandError`.
433008
def write_with_mac(self, data, block):
        
        # Write a single data block protected with a mac. The card
        # will only accept the write if it computed the same mac.
        log.debug("write 1 block with mac")
        if len(data) != 16:
            raise ValueError("data must be 16 octets")
        if type(block) is not int:
            raise ValueError("block number must be int")
        if self._sk is None or self._iv is None:
            raise RuntimeError("tag must be authenticated first")

        # The write count is the first three byte of the wcnt block.
        wcnt = str(self.read_without_mac(0x90)[0:3])
        log.debug("write count is 0x{0}".format(wcnt[::-1].encode("hex")))

        # We must generate the mac_a block to write the data. The data
        # to encrypt to the mac is composed of write count and block
        # numbers (8 byte) and the data we want to write. The mac for
        # write must be generated with the key flipped (sk2 || sk1).
        def flip(sk):
            return sk[8:16] + sk[0:8]

        data = wcnt + "\x00" + chr(block) + "\x00\x91\x00" + data
        maca = self.generate_mac(data, flip(self._sk), self._iv) + wcnt+5*"\0"

        # Now we can write the data block with our computed mac to the
        # desired block and the maca block. Write without encryption
        # means that the data is not encrypted with a service key.
        sc_list = [tt3.ServiceCode(0, 0b001001)]
        bc_list = [tt3.BlockCode(block), tt3.BlockCode(0x91)]
        self.write_without_encryption(sc_list, bc_list, data[8:24] + maca)
376483
def _writeSentenceInBlock(sentence, blockID, sentenceID):
    ''''''
    with open("sentenceIDs.txt", "a") as fp:
        fp.write("sentenceID: "+str(blockID)+"_"+str(sentenceID)+"\n")
        fp.write("sentence string: "+sentence+"\n")
        fp.write("\n")
371289
private void writeTagPayload(Tag<?> tag) throws IOException {
        switch (tag.getType()) {
            case TAG_END:
                writeEndTagPayload((EndTag) tag);
                break;

            case TAG_BYTE:
                writeByteTagPayload((ByteTag) tag);
                break;

            case TAG_SHORT:
                writeShortTagPayload((ShortTag) tag);
                break;

            case TAG_INT:
                writeIntTagPayload((IntTag) tag);
                break;

            case TAG_LONG:
                writeLongTagPayload((LongTag) tag);
                break;

            case TAG_FLOAT:
                writeFloatTagPayload((FloatTag) tag);
                break;

            case TAG_DOUBLE:
                writeDoubleTagPayload((DoubleTag) tag);
                break;

            case TAG_BYTE_ARRAY:
                writeByteArrayTagPayload((ByteArrayTag) tag);
                break;

            case TAG_STRING:
                writeStringTagPayload((StringTag) tag);
                break;

            case TAG_LIST:
                writeListTagPayload((ListTag<?>) tag);
                break;

            case TAG_COMPOUND:
                writeCompoundTagPayload((CompoundTag) tag);
                break;

            case TAG_INT_ARRAY:
                writeIntArrayTagPayload((IntArrayTag) tag);
                break;

            case TAG_SHORT_ARRAY:
                writeShortArrayTagPayload((ShortArrayTag) tag);
                break;

            default:
                throw new IOException("Invalid tag type: " + tag.getType() + ".");
        }
    }
1076773
def __parse_tag(self, tag, count):
        """"""

        fileobj = cBytesIO(tag)

        for i in xrange(count):
            tag_data = fileobj.read(8)
            # someone writes wrong item counts
            if not tag_data:
                break
            if len(tag_data) != 8:
                raise error
            size = cdata.uint32_le(tag_data[:4])
            flags = cdata.uint32_le(tag_data[4:8])

            # Bits 1 and 2 bits are flags, 0-3
            # Bit 0 is read/write flag, ignored
            kind = (flags & 6) >> 1
            if kind == 3:
                raise APEBadItemError("value type must be 0, 1, or 2")

            key = value = fileobj.read(1)
            if not key:
                raise APEBadItemError
            while key[-1:] != b'\x00' and value:
                value = fileobj.read(1)
                if not value:
                    raise APEBadItemError
                key += value
            if key[-1:] == b"\x00":
                key = key[:-1]

            if PY3:
                try:
                    key = key.decode("ascii")
                except UnicodeError as err:
                    reraise(APEBadItemError, err, sys.exc_info()[2])
            value = fileobj.read(size)
            if len(value) != size:
                raise APEBadItemError

            value = _get_value_type(kind)._new(value)

            self[key] = value
1256359
async function verifyTagName(tagName, execaOpts) {
  try {
    return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOpts)).code === 0;
  } catch (error) {
    debug(error);
  }
}
370717
def tag(self, tag: str, overwrite: bool = False) -> None:
        
        LOGGER.info('tagging repo: %s', tag)
        try:
            self.repo.create_tag(tag)
        except GitCommandError as exc:
            if 'already exists' in exc.stderr and overwrite:
                LOGGER.info('overwriting existing tag')
                self.remove_tag(tag)
                self.repo.create_tag(tag)
            else:
                LOGGER.exception('error while tagging repo')
                raise
871061
def tagReportCallback(llrpMsg):
    """"""
    global tagReport
    tags = llrpMsg.msgdict['RO_ACCESS_REPORT']['TagReportData']
    if len(tags):
        logger.info('saw tag(s): %s', pprint.pformat(tags))
    else:
        logger.info('no tags seen')
        return
    for tag in tags:
        tagReport += tag['TagSeenCount'][0]
        if "OpSpecResult" in tag:
            # copy the binary data to the standard output stream
            data = tag["OpSpecResult"].get("ReadData")
            if data:
                if sys.version_info.major < 3:
                    sys.stdout.write(data)
                else:
                    sys.stdout.buffer.write(data)                     # bytes
                logger.debug("hex data: %s", binascii.hexlify(data))
1103162
private static void validateTags(String[] tagList, ArrayList<String> validList, ArrayList<String> invalidList) {
        for (String tag : tagList) {
            tag = tag.trim();
            if (tag.contains("\\") || tag.contains(" ") || tag.contains("\n") || tag.contains("-") || tag.equals("")) {
                invalidList.add(tag);
            } else {
                validList.add(tag);
            }
        }
    }
88763
public void writeTag(Tag<?> tag) throws IOException {
        String name = tag.getName();
        byte[] nameBytes = name.getBytes(NBTConstants.CHARSET.name());

        os.writeByte(tag.getType().getId());
        os.writeShort(nameBytes.length);
        os.write(nameBytes);

        if (tag.getType() == TagType.TAG_END) {
            throw new IOException("Named TAG_End not permitted.");
        }

        writeTagPayload(tag);
    }
994545
static byte[] serializeBinary(TagContext tags) throws TagContextSerializationException {
    // Use a ByteArrayDataOutput to avoid needing to handle IOExceptions.
    final ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput();
    byteArrayDataOutput.write(VERSION_ID);
    int totalChars = 0; // Here chars are equivalent to bytes, since we're using ascii chars.
    for (Iterator<Tag> i = InternalUtils.getTags(tags); i.hasNext(); ) {
      Tag tag = i.next();
      if (TagTtl.NO_PROPAGATION.equals(tag.getTagMetadata().getTagTtl())) {
        continue;
      }
      totalChars += tag.getKey().getName().length();
      totalChars += tag.getValue().asString().length();
      encodeTag(tag, byteArrayDataOutput);
    }
    if (totalChars > TAGCONTEXT_SERIALIZED_SIZE_LIMIT) {
      throw new TagContextSerializationException(
          "Size of TagContext exceeds the maximum serialized size "
              + TAGCONTEXT_SERIALIZED_SIZE_LIMIT);
    }
    return byteArrayDataOutput.toByteArray();
  }
296949
def write(self, byte):
        
        if self.is_closed_flag:
            raise Exception("Unable to write - already closed!")
        self.written += len(byte)
        self.file.write(byte)
218081
void writeTagNoClear(long bucketIndex, int posInBucket, long tag) {
		long tagStartIdx = getTagOffset(bucketIndex, posInBucket);
		// BIT BANGIN YEAAAARRHHHGGGHHH
		for (int i = 0; i < bitsPerTag; i++) {
			// second arg just does bit test in tag
			if ((tag & (1L << i)) != 0) {
				memBlock.set(tagStartIdx + i);
			}
		}
	}
633661
void write(CallInfo callInfo, DataSetAssertion assertion) {
    Element rootNode = root(callInfo); 
    DataSource ds = assertion.getSource();
    write(rootNode, ds);
    Element saNode = createNode(rootNode, ASSERTION_TAG);
    List<MetaData.ColumnInfo> mdCols = ds.getMetaData().columns();
    write(saNode, 
        EXPECTED_TAG, 
        mdCols,
        assertion.data(DataSetAssertion.IteratorType.EXPECTED_DATA));
    if (! assertion.passed()) {
      Element errorsNode = createNode(saNode, ERRORS_TAG);
      write(errorsNode, 
          EXPECTED_TAG, 
          mdCols,
          assertion.data(DataSetAssertion.IteratorType.ERRORS_EXPECTED));
      write(errorsNode, 
          ACTUAL_TAG, 
          mdCols,
          assertion.data(DataSetAssertion.IteratorType.ERRORS_ACTUAL));
    }
    flush(rootNode);
  }
477330
def try(*args, &block)
      case
      when args.empty? && block_given?
        yield self
      when respond_to?(args.first)
        __send__(*args, &block)
      else
        @tag.try(*args, &block)
      end
    end
746734
def ack(self, delivery_tag, multiple=False):
        '''
        
        '''
        args = Writer()
        args.write_longlong(delivery_tag).\
            write_bit(multiple)

        self.send_frame(MethodFrame(self.channel_id, 60, 80, args))
446267
def set_tag(self, key, value):
        
        with self.update_lock:
            if key == ext_tags.SAMPLING_PRIORITY and not self._set_sampling_priority(value):
                return self
            if self.is_sampled():
                tag = thrift.make_tag(
                    key=key,
                    value=value,
                    max_length=self.tracer.max_tag_value_length, )
                self.tags.append(tag)
        return self
279572
@Benchmark
  @BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public byte[] serializeTagContext(Data data) throws Exception {
    return data.serializer.toByteArray(data.tagContext);
  }