Commit graph

62 commits

Author SHA1 Message Date
Chris Mayo
cd67cb4a78 Replace os.error
os.error is an alias for OSError.
2024-08-27 19:26:46 +01:00
Chris Mayo
7a3be9ba93 Avoid FileNotFoundError if FILENAME does not exist
File ".../linkcheck/fileutil.py", line 110, in is_valid_config_source
    return os.path.isfile(filename) or stat.S_ISFIFO(os.stat(filename).st_mode)
                                                     ^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory
2023-11-13 19:22:12 +00:00
Chris Down
85ce9841eb Allow FIFOs to be used as config files
There are some config options which have no equivalent command line
option. Some may want to set these options dynamically or on a one-off
basis where a static config file is not ideal, and one very easy way to
do that is using process substitution:

    linkchecker --config <(printf '%s\n' '[filtering]' 'ignorewarnings=http-redirected') ...

This, however, does not work in the current code because these are
typically implemented as FIFOs, which don't pass the `os.path.isfile`
check:

    WARNING linkcheck.cmdline 2023-10-31 00:12:09,678 MainThread Unreadable config file: '/dev/fd/63'

Allow reading FIFOs as config input so that this is possible.
`fileutil.is_readable` also now doesn't check if the path leads to a
regular file: this is only used as part of cookie and config file input,
and in both cases that's not really relevant.
2023-10-31 00:31:28 +00:00
Kian-Meng Ang
a70ea9ea14 Fix typos
Found via `codespell ./linkcheck/ ./tests ./doc/man/en -L bu,noone,fo,pres,shttp`
2022-09-02 17:20:02 +08:00
Chris Mayo
8f9f687ed8 Remove isinstance() from fileutil.path_safe()
paths are derived from urls which are strings.
2020-06-18 19:27:06 +01:00
Chris Mayo
a92a684ac4 Run black on linkcheck/ 2020-05-30 17:01:36 +01:00
Chris Mayo
3473656fe1 Replace import of distutils.spawn.find_executable with shutil.which 2020-05-25 19:50:57 +01:00
Chris Mayo
28f4587dfa Remove str_text from fileutil.py, strformat.py and url.py 2020-05-19 19:56:42 +01:00
Chris Mayo
690605c519 Remove unused code from linkcheck/fileutil.py 2020-05-18 19:29:55 +01:00
Chris Mayo
a15a2833ca Remove spaces after names in class method definitions
And also nested functions.

This is a PEP 8 convention, E211.
2020-05-16 20:19:42 +01:00
Chris Mayo
1663e10fe7 Remove spaces after names in function definitions
This is a PEP 8 convention, E211.
2020-05-16 20:19:42 +01:00
Chris Mayo
44e81d27dd Remove inheriting object
All Python 3 classes are new-style.
2020-05-08 10:45:31 +01:00
Chris Mayo
b0ea72e8c1 Remove # -*- coding: lines
Except for tests that include non-unicode characters:

tests/test_po.py
tests/test_strformat.py
tests/test_url.py
tests/checker/test_error.py
tests/checker/test_news.py
2020-05-08 10:45:31 +01:00
Chris Mayo
e7c5f353cd Remove unused function linkcheck.fileutil.write_file()
Doesn't appear to have ever been used.

Causes flake8 error:
linkcheck/fileutil.py:45:9: F821 undefined name 'file'
2020-03-31 19:46:31 +01:00
Chris Mayo
0ee4414a60 Replace memoized with functools.lru_cache 2020-03-31 19:46:31 +01:00
Chris Mayo
a9f147c347 Update fileutil.pathencode() because paths are now strings 2019-10-05 19:38:57 +01:00
Petr Dlouhý
fb39a4116f Python3: fix fileutil 2018-01-05 20:31:21 +01:00
Bastian Kleineidam
4b28e6e860 Move mime stuff into own submodule. 2014-05-10 21:22:10 +02:00
Bastian Kleineidam
ef13a3fce1 Implement sitemap and sitemap index parsing. 2014-03-05 19:26:37 +01:00
Bastian Kleineidam
380f14453b Fix mimetype guessing from content. 2014-03-05 19:23:58 +01:00
Bastian Kleineidam
7b34be590b Introduce check plugins, use Python requests for http/s connections, and some code cleanups and improvements. 2014-03-01 00:12:34 +01:00
Bastian Kleineidam
c806be5c15 Updated copyright 2014-01-08 22:33:04 +01:00
Bastian Kleineidam
64d95e45e0 Remove local HTML and CSS syntax check. 2013-02-08 21:36:02 +01:00
Bastian Kleineidam
45a4bbdaa9 Use locale.format() and os.path.getsize() 2012-12-01 00:05:14 +01:00
Bastian Kleineidam
42a17cbb98 Prepare py3 port and display sys.argv on internal errors. 2012-11-26 18:49:07 +01:00
Bastian Kleineidam
3a51ac7662 Warn about accessible passwords in config files. 2012-10-15 14:36:10 +02:00
Bastian Kleineidam
1db63227f6 Memoize file operations to minimize disk I/O. 2012-09-18 09:37:21 +02:00
Bastian Kleineidam
ac6591a009 Recognize WML files on Windows. 2012-08-24 09:46:26 +02:00
Bastian Kleineidam
db95fce77e Ignore PHP processing instructions in local files. 2012-06-10 14:02:01 +02:00
Bastian Kleineidam
b12c1e40fb Allow specifying the file mode when opening temp files. 2012-06-10 11:03:43 +02:00
Bastian Kleineidam
b83d3b53fc Added missing documentation. 2012-06-02 00:31:02 +02:00
Bastian Kleineidam
e13a479362 Fix error logging. 2012-05-23 06:55:02 +02:00
Bastian Kleineidam
fa92d59448 Catch mimedb init errors. 2012-05-23 06:02:23 +02:00
Bastian Kleineidam
1deeb88e16 Add project support. 2012-01-26 20:23:15 +01:00
Bastian Kleineidam
f1eb51d885 Updated copyright 2012-01-06 09:21:30 +01:00
Bastian Kleineidam
e316f5be68 Remove unneeded comment. 2012-01-04 20:04:36 +01:00
Bastian Kleineidam
3d9958dfbb Parse Safari bookmark files. 2011-12-17 16:38:25 +01:00
Bastian Kleineidam
53f34d6b2e Add is_tty utility function. 2011-05-26 07:28:14 +02:00
Bastian Kleineidam
719441cca5 Make module detection more robust and use it when possible. 2011-04-20 09:08:11 +02:00
Bastian Kleineidam
4ee62863e5 Recognize PHP files as HTML files on Windows. 2011-03-11 13:30:34 +01:00
Bastian Kleineidam
c6d2eab46c Prevent false positives when detecting file type of certain archive files. 2011-03-10 13:13:25 +01:00
Bastian Kleineidam
a06f354837 Add distutils find_executable to fileutils. 2011-03-09 10:47:38 +01:00
Bastian Kleineidam
e638a2fe6d Updated copyright and translations. Added some missing docstrings. 2011-02-17 07:38:02 +01:00
Bastian Kleineidam
0d4377d1ba Support Google Chrome Bookmark files. 2011-02-15 18:26:00 +01:00
Bastian Kleineidam
71b15b70f4 Updated copyright 2011-01-06 09:59:57 +01:00
Bastian Kleineidam
5f70b7210f Add tempfile utility function. 2011-01-06 09:52:11 +01:00
Bastian Kleineidam
3775f18621 Fix Linkchecker URL list detection. 2010-10-03 17:58:56 +02:00
Bastian Kleineidam
133b4f53fd Fix typos and remove unneeded functions. 2010-10-03 12:57:42 +02:00
Bastian Kleineidam
e494d6bbb6 Move MIME type detection into fileutil.py module, and use mimetools for detection. 2010-10-03 08:47:48 +02:00
Bastian Kleineidam
7d076e7129 Add get_size() method for local files. 2010-07-29 19:52:26 +02:00