Ejemplo n.º 1
0
    def create_database(self, filename, progress_func=None, settings=None):
        """
		``create_database`` writes the current database (.bndb) out to the specified file.

		:param str filename: path and filename to write the bndb to, this string `should` have ".bndb" appended to it.
		:param callback progress_func: optional function to be called with the current progress and total count.
		:param SaveSettings settings: optional argument for special save options.
		:return: true on success, false on failure
		:rtype: bool
		:Example:
			>>> settings = SaveSettings()
			>>> bv.file.create_database(f"{bv.file.filename}.bndb", None, settings)
			True
		"""
        if settings is not None:
            settings = settings.handle

        if progress_func is None:
            return core.BNCreateDatabase(self.raw.handle, str(filename),
                                         settings)
        else:
            return core.BNCreateDatabaseWithProgress(
                self.raw.handle, str(filename), None,
                ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_ulonglong,
                                 ctypes.c_ulonglong)
                (lambda ctxt, cur, total: progress_func(cur, total)), settings)
Ejemplo n.º 2
0
 def create_database(self, filename, progress_func=None):
     if progress_func is None:
         return core.BNCreateDatabase(self.raw.handle, str(filename))
     else:
         return core.BNCreateDatabaseWithProgress(
             self.raw.handle, str(filename), None,
             ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_ulonglong,
                              ctypes.c_ulonglong)
             (lambda ctxt, cur, total: progress_func(cur, total)))