def testHiddenFilesRecognition(self): # Hidden files and directories (leading dot) are recognized. importer = TranslationImporter() hidden_files = [ ".hidden.pot", ".hidden/foo.pot", "po/.hidden/foo.pot", "po/.hidden.pot", "bla/.hidden/foo/bar.pot", ] visible_files = [ "not.hidden.pot", "not.hidden/foo.pot", "po/not.hidden/foo.pot", "po/not.hidden.pot", "bla/not.hidden/foo/bar.pot", ] for path in hidden_files: self.assertTrue( importer.isHidden(path), 'Failed to recognized "%s" as a hidden file.' % path) for path in visible_files: self.assertFalse( importer.isHidden(path), 'Failed to recognized "%s" as a visible file.' % path)
def testHiddenFilesRecognition(self): # Hidden files and directories (leading dot) are recognized. importer = TranslationImporter() hidden_files = [ ".hidden.pot", ".hidden/foo.pot", "po/.hidden/foo.pot", "po/.hidden.pot", "bla/.hidden/foo/bar.pot", ] visible_files = [ "not.hidden.pot", "not.hidden/foo.pot", "po/not.hidden/foo.pot", "po/not.hidden.pot", "bla/not.hidden/foo/bar.pot", ] for path in hidden_files: self.assertTrue( importer.isHidden(path), 'Failed to recognized "%s" as a hidden file.' % path) for path in visible_files: self.assertFalse( importer.isHidden(path), 'Failed to recognized "%s" as a visible file.' % path)
def _init_translation_file_lists(self): """Initialize the member variables that hold the information about the relevant files. The information is collected from the branch tree and stored in the following member variables: * file_names is a dictionary of two lists ('pot', 'po') of file names that are POT or PO files respectively. This includes all files, changed or unchanged. * changed_files is a dictionary of two lists ('pot', 'po') of tuples of (file_name, file_content) of all changed files that are POT or PO files respectively. """ bzrbranch = self.branch.getBzrBranch() from_tree = bzrbranch.repository.revision_tree( self.from_revision_id) to_tree = bzrbranch.repository.revision_tree( self.branch.last_scanned_id) importer = TranslationImporter() to_tree.lock_read() try: for dir, files in to_tree.walkdirs(): for afile in files: file_path, file_name, file_type = afile[:3] if file_type != 'file': continue if importer.isHidden(file_path): continue if importer.isTemplateName(file_name): append_to = self.template_file_names elif importer.isTranslationName(file_name): append_to = self.translation_file_names else: continue append_to.append(file_path) from_tree.lock_read() try: for file_names, changed_files in self._iter_all_lists(): for changed_file in to_tree.iter_changes( from_tree, specific_files=file_names): (from_kind, to_kind) = changed_file[6] if to_kind != 'file': continue file_id, (from_path, to_path) = changed_file[:2] changed_files.append(( to_path, to_tree.get_file_text(file_id))) finally: from_tree.unlock() finally: to_tree.unlock()
def _init_translation_file_lists(self): """Initialize the member variables that hold the information about the relevant files. The information is collected from the branch tree and stored in the following member variables: * file_names is a dictionary of two lists ('pot', 'po') of file names that are POT or PO files respectively. This includes all files, changed or unchanged. * changed_files is a dictionary of two lists ('pot', 'po') of tuples of (file_name, file_content) of all changed files that are POT or PO files respectively. """ bzrbranch = self.branch.getBzrBranch() from_tree = bzrbranch.repository.revision_tree( self.from_revision_id) to_tree = bzrbranch.repository.revision_tree( self.branch.last_scanned_id) importer = TranslationImporter() to_tree.lock_read() try: for dir, files in to_tree.walkdirs(): for afile in files: file_path, file_name, file_type = afile[:3] if file_type != 'file': continue if importer.isHidden(file_path): continue if importer.isTemplateName(file_name): append_to = self.template_file_names elif importer.isTranslationName(file_name): append_to = self.translation_file_names else: continue append_to.append(file_path) from_tree.lock_read() try: for file_names, changed_files in self._iter_all_lists(): for changed_file in to_tree.iter_changes( from_tree, specific_files=file_names): (from_kind, to_kind) = changed_file[6] if to_kind != 'file': continue file_id, (from_path, to_path) = changed_file[:2] changed_files.append(( to_path, to_tree.get_file_text(file_id))) finally: from_tree.unlock() finally: to_tree.unlock()