コード例 #1
0
ファイル: _validation.py プロジェクト: riku7032/OCRmyPDF
def check_requested_output_file(options):
    if options.output_file == '-':
        if sys.stdout.isatty():
            raise BadArgsError(
                "Output was set to stdout '-' but it looks like stdout "
                "is connected to a terminal.  Please redirect stdout to a "
                "file.")
    elif not is_file_writable(options.output_file):
        raise OutputFileAccessError(
            f"Output file location ({options.output_file}) is not a writable file."
        )
コード例 #2
0
ファイル: test_helpers.py プロジェクト: xiaobin620/OCRmyPDF
 def test_permission_error(self, basic_file):
     pathmock = MagicMock(spec_set=basic_file)
     pathmock.is_symlink.return_value = False
     pathmock.exists.return_value = True
     pathmock.is_file.side_effect = PermissionError
     assert not helpers.is_file_writable(pathmock)
コード例 #3
0
ファイル: test_helpers.py プロジェクト: xiaobin620/OCRmyPDF
 def test_chmod(self, basic_file):
     assert helpers.is_file_writable(basic_file)
     basic_file.chmod(0o400)
     assert not helpers.is_file_writable(basic_file)
     basic_file.chmod(0o000)
     assert not helpers.is_file_writable(basic_file)
コード例 #4
0
ファイル: test_helpers.py プロジェクト: xiaobin620/OCRmyPDF
 def test_symlink_loop(self, tmp_path):
     loop = tmp_path / 'loop'
     loop.symlink_to(loop)
     assert not helpers.is_file_writable(loop)
コード例 #5
0
ファイル: test_helpers.py プロジェクト: xiaobin620/OCRmyPDF
 def test_plain(self, non_existent):
     assert helpers.is_file_writable(non_existent)