示例#1
0
 def _create_and_add_directory_to_model(self, model, original, preview, rel_path=None):
     if rel_path is None:
         path = self._tmp_dir
     else:
         path = self._tmp_dir.resolve_relative_path(rel_path)
     filepath = path.resolve_relative_path(original)
     row = self._add_to_model(model, original, preview, filepath)
     success = False
     while not success:
         try:
             retval = row[c.FILES_MODEL_COLUMN_GFILE].make_directory_with_parents(None)
         except:
             pass
         else:
             success = True
     self.assertTrue(retval)
示例#2
0
 def _create_and_add_file_to_model(self, model, original, preview, rel_path=None):
     if rel_path is None:
         path = self._tmp_dir
     else:
         path = self._tmp_dir.resolve_relative_path(rel_path)
     filepath = path.resolve_relative_path(original)
     row = self._add_to_model(model, original, preview, filepath)
     
     success = False
     while not success:
         try:
             ss = row[c.FILES_MODEL_COLUMN_GFILE].create(Gio.FileCreateFlags.REPLACE_DESTINATION, None)
         except:
             pass
         else:
             success = True
     
     ss.write(row[c.FILES_MODEL_COLUMN_GFILE].get_uri().encode("utf-8"), None)
     ss.close(None)