Пример #1
0
 def __init__(self, path_to_file_to_insert: str, path_to_main_file: str):
     self.inserted_file = Stuff.read_the_file(path_to_file_to_insert)
     self.main_file = Stuff.read_the_file(path_to_main_file)
     if not self._check_the_opportunity_to_enter():
         raise Exception("The file you want to write is too large")
     self.index_of_start_of_data = \
         Stuff.find_index_of_the_start_of_data(self.main_file)
     self.bits_per_sample = self._get_bits_per_sample(self.main_file)
     self.inserted_name = self._define_filename(path_to_file_to_insert)
     self.inserted_hash = Stuff.get_hash(self.inserted_file)
 def _create_pickle(self):
     dict_of_files = {}
     for element in self.inserted_files:
         data = Stuff.read_the_file(element)
         dict_of_files[element] = data
     result = bytearray(pickle.dumps(dict_of_files))
     if not self._need_compression:
         return result
     else:
         rle = RLEEncoder(result)
         return rle.encode()
 def __init__(self,
              path_to_the_file,
              index_of_start_of_data=None,
              need_decompression=False):
     self._need_decompression = need_decompression
     self.main_file = Stuff.read_the_file(path_to_the_file)
     if index_of_start_of_data is None:
         self.index_of_start_of_data = \
             Stuff.find_index_of_the_start_of_data(self.main_file)
     else:
         self.index_of_start_of_data = index_of_start_of_data
     self.bits_per_sample = self._get_bits_per_sample()
 def __init__(self,
              path_to_file_to_insert: list,
              path_to_main_file: str,
              need_compression=False,
              index_of_start_of_data=None):
     self._need_compression = need_compression
     self.inserted_files = path_to_file_to_insert
     self.pickled_files = self._create_pickle()
     self.main_file = Stuff.read_the_file(path_to_main_file)
     self.bits_per_sample = self._get_bits_per_sample(self.main_file)
     if index_of_start_of_data is None:
         self.index_of_start_of_data = \
             Stuff.find_index_of_the_start_of_data(self.main_file)
     else:
         self.index_of_start_of_data = index_of_start_of_data
     if not self._check_the_opportunity_to_enter():
         raise Exception("The file you want to write is too large")
     self.final_filename = re.search(r'\\?([ _0-9а-яА-Я\w]+[^\\]\w+)?$',
                                     path_to_main_file).group(1)
Пример #5
0
 def __init__(self, path_to_the_file):
     self.main_file = Stuff.read_the_file(path_to_the_file)
     self.index_of_start_of_data = \
         Stuff.find_index_of_the_start_of_data(self.main_file)
     self.bits_per_sample = self._get_bits_per_sample()
 def test_read_the_file(self):
     with open('filename.txt', 'w') as file:
         file.write('blablabla')
     result = LSBStuff.read_the_file('filename.txt')
     os.remove('filename.txt')
     self.assertIsInstance(result, bytearray)