def clear(self, bitno): '''clear bit number bitno - set it to false''' byteno, bit_within_byteno = divmod(bitno, 8) mask = 1 << bit_within_byteno os.lseek(self.file_, byteno, os.SEEK_SET) char = os.read(self.file_, 1) if isinstance(char, str): byte = ord(char) was_char = True else: byte = int(char) was_char = False byte &= File_seek_backend.effs - mask os.lseek(self.file_, byteno, os.SEEK_SET) if was_char: os.write(chr(byte)) else: char = python2x3.intlist_to_binary([byte]) os.write(char)
def clear(self, bitno): """clear bit number bitno - set it to false""" byteno, bit_within_byteno = divmod(bitno, 8) mask = 1 << bit_within_byteno os.lseek(self.file_, byteno, os.SEEK_SET) char = os.read(self.file_, 1) if isinstance(char, str): byte = ord(char) was_char = True else: byte = int(char) was_char = False byte &= File_seek_backend.effs - mask os.lseek(self.file_, byteno, os.SEEK_SET) if was_char: os.write(chr(byte)) else: char = python2x3.intlist_to_binary([byte]) os.write(char)
def set(self, bitno): '''set bit number bitno to true''' byteno, bit_within_byteno = divmod(bitno, 8) mask = 1 << bit_within_byteno os.lseek(self.file_, byteno, os.SEEK_SET) char = os.read(self.file_, 1) if isinstance(char, str): byte = ord(char) was_char = True else: byte = char[0] was_char = False byte |= mask os.lseek(self.file_, byteno, os.SEEK_SET) if was_char: os.write(self.file_, chr(byte)) else: char = python2x3.intlist_to_binary([byte]) os.write(self.file_, char)
def set(self, bitno): """set bit number bitno to true""" byteno, bit_within_byteno = divmod(bitno, 8) mask = 1 << bit_within_byteno os.lseek(self.file_, byteno, os.SEEK_SET) char = os.read(self.file_, 1) if isinstance(char, str): byte = ord(char) was_char = True else: byte = char[0] was_char = False byte |= mask os.lseek(self.file_, byteno, os.SEEK_SET) if was_char: os.write(self.file_, chr(byte)) else: char = python2x3.intlist_to_binary([byte]) os.write(self.file_, char)