@path_required<EOL><INDENT>def save(self, description=None, raiseError=True, ntrials=<NUM_LIT:3>):<DEDENT>
assert isinstance(raiseError, bool), "<STR_LIT>"<EOL>assert isinstance(ntrials, int), "<STR_LIT>"<EOL>assert ntrials><NUM_LIT:0>, "<STR_LIT>"<EOL>if description is not None:<EOL><INDENT>assert isinstance(description, basestring), "<STR_LIT>"<EOL><DEDENT>dirInfoPath = os.path.join(self.__path, self.__dirInfo)<EOL>if description is None and not os.path.isfile(dirInfoPath):<EOL><INDENT>description = '<STR_LIT>'<EOL><DEDENT>LR =  Locker(filePath=None, lockPass=str(uuid.uuid1()), lockPath=os.path.join(self.__path, self.__repoLock))<EOL>acquired, code = LR.acquire_lock()<EOL>m = "<STR_LIT>"%(code,)<EOL>if not acquired:<EOL><INDENT>assert not raiseError, Exception(m)<EOL>return False, m<EOL><DEDENT>for _trial in range(ntrials):<EOL><INDENT>try:<EOL><INDENT>repoInfoPath = os.path.join(self.__path, self.__repoFile)<EOL>error = None<EOL>self.__save_dirinfo(description=description, dirInfoPath=dirInfoPath)<EOL>if os.path.isfile(repoInfoPath):<EOL><INDENT>with open(repoInfoPath, '<STR_LIT:rb>') as fd:<EOL><INDENT>repo = self.__load_repository_pickle_file(os.path.join(self.__path, self.__repoFile))<EOL>self.__repo['<STR_LIT>'] = repo['<STR_LIT>']<EOL><DEDENT><DEDENT>with open(repoInfoPath, '<STR_LIT:wb>') as fd:<EOL><INDENT>self.__repo["<STR_LIT>"] = time.time()<EOL>pickle.dump( self.__repo,fd, protocol=self._DEFAULT_PICKLE_PROTOCOL )<EOL>fd.flush()<EOL>os.fsync(fd.fileno())<EOL><DEDENT><DEDENT>except Exception as err:<EOL><INDENT>error = "<STR_LIT>"%err<EOL>if self.DEBUG_PRINT_FAILED_TRIALS: print("<STR_LIT>"%(_trial, inspect.stack()[<NUM_LIT:1>][<NUM_LIT:3>], str(error)))<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>LR.release_lock()<EOL>assert error is None or not raiseError, error<EOL>return error is None, error<EOL>
Save repository '.pyreprepo' to disk and create (if missing) or
update (if description is not None) '.pyrepdirinfo'.

:Parameters:
    #. description (None, str): Repository main directory information.
       If given will be replaced.
    #. raiseError (boolean): Whether to raise encountered error instead
       of returning failure.
    #. ntrials (int): After aquiring all locks, ntrials is the maximum
       number of trials allowed before failing.
       In rare cases, when multiple processes
       are accessing the same repository components, different processes
       can alter repository components between successive lock releases
       of some other process. Bigger number of trials lowers the
       likelyhood of failure due to multiple processes same time
       alteration.

:Returns:
    #. success (bool): Whether saving was successful.
    #. error (None, string): Fail to save repository message in case
       saving is not successful. If success is True, error will be None.