diff options
| author | Cody Logan <clpo13@gmail.com> | 2020-01-03 11:07:59 -0800 |
|---|---|---|
| committer | Cody Logan <clpo13@gmail.com> | 2020-01-03 11:07:59 -0800 |
| commit | 80de3d14325a15bf30f1d6863d996a4dd0d87e0f (patch) | |
| tree | b3ef72fce84749a40a86af8e04368eb31ffbfc55 | |
| parent | 3c2d03f02e644b8afc5178f7c1a11d50d6b21118 (diff) | |
| parent | 5f35b45b0b15e0f66608b9c774b76f39e7aa93ee (diff) | |
| download | wikiget-80de3d14325a15bf30f1d6863d996a4dd0d87e0f.tar.gz wikiget-80de3d14325a15bf30f1d6863d996a4dd0d87e0f.zip | |
Merge branch 'master' of github.com:clpo13/wikiget
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | test/test_wikiget.py | 36 | ||||
| -rw-r--r-- | wikiget/wikiget.py | 4 |
3 files changed, 24 insertions, 24 deletions
@@ -15,9 +15,9 @@ Requires Python 3.5+. Install with `pip install --user wikiget` or, if you're us `wikiget [-h] [-V] [-q | -v] [-f] [-a] [--site SITE] [-o OUTPUT] FILE` If `FILE` is in the form `File:Example.jpg` or `Example.jpg`, it will be fetched -from the default site, which is "en.wikipedia.org". If it's the fully-qualified -URL of a file description page, like `https://commons.wikimedia.org/wiki/File:Example.jpg`, -the file is fetched from the specified site, in this case "commons.wikimedia.org". +from the default site, which is "commons.wikimedia.org". If it's the fully-qualified +URL of a file description page, like `https://en.wikipedia.org/wiki/File:Example.jpg`, +the file is fetched from the specified site, in this case "en.wikipedia.org". Full URLs may contain characters your shell interprets differently, so you can either escape those characters with a backslash `\` or surround the entire URL with single `'` or double `"` quotes. @@ -42,7 +42,7 @@ offending filename is printed. ```bash wikiget File:Example.jpg -wikiget --site commons.wikimedia.org File:Example.jpg +wikiget --site en.wikipedia.org File:Example.jpg wikiget https://en.wikipedia.org/wiki/File:Example.jpg -o test.jpg ``` diff --git a/test/test_wikiget.py b/test/test_wikiget.py index 8aaaec8..6bd1c9d 100644 --- a/test/test_wikiget.py +++ b/test/test_wikiget.py @@ -29,8 +29,8 @@ def test_invalid_site_input(): """ Invalid site strings should not return regex match objects. """ - invalid_input = ["example.com", "vim.wikia.com", - "en.wikipedia.com", "en.wikimpedia.org"] + invalid_input = ['example.com', 'vim.wikia.com', + 'en.wikipedia.com', 'en.wikimpedia.org'] for i in invalid_input: site_match = wikiget.valid_site(i) assert site_match is None @@ -40,8 +40,8 @@ def test_valid_site_input(): """ Valid site strings should return regex match objects. """ - valid_input = ["en.wikipedia.org", "commons.wikimedia.org", - "de.wikipedia.org", "meta.wikimedia.org"] + valid_input = ['en.wikipedia.org', 'commons.wikimedia.org', + 'de.wikipedia.org', 'meta.wikimedia.org'] for i in valid_input: site_match = wikiget.valid_site(i) assert site_match is not None @@ -53,20 +53,20 @@ def test_file_regex(): to the file prefix and name. :return: """ - i = "File:Example.jpg" + i = 'File:Example.jpg' file_match = wikiget.valid_file(i) assert file_match is not None - assert file_match.group(0) == "File:Example.jpg" # entire match - assert file_match.group(1) == "File:" # first group - assert file_match.group(2) == "Example.jpg" # second group + assert file_match.group(0) == 'File:Example.jpg' # entire match + assert file_match.group(1) == 'File:' # first group + assert file_match.group(2) == 'Example.jpg' # second group def test_invalid_file_input(): """ Invalid file strings should not return regex match objects. """ - invalid_input = ["file:example", "example.jpg", "Foo Bar.gif", - "Fil:Example.jpg"] + invalid_input = ['file:example', 'example.jpg', 'Foo Bar.gif', + 'Fil:Example.jpg'] for i in invalid_input: file_match = wikiget.valid_file(i) assert file_match is None @@ -76,9 +76,9 @@ def test_valid_file_input(): """ Valid file strings should return regex match objects. """ - valid_input = ["Image:example.jpg", "file:example.jpg", - "File:example.file-01.jpg", "FILE:FOO.BMP", - "File:ß handwritten sample.gif", "File:A (1).jpeg"] + valid_input = ['Image:example.jpg', 'file:example.jpg', + 'File:example.file-01.jpg', 'FILE:FOO.BMP', + 'File:ß handwritten sample.gif', 'File:A (1).jpeg'] for i in valid_input: file_match = wikiget.valid_file(i) assert file_match is not None @@ -89,14 +89,14 @@ def test_verify_hash(): Confirm that verify_hash returns the proper SHA1 hash. """ # TODO: do we need to actually create a file? - file_name = "testfile" - file_contents = "foobar" - file_sha1 = "8843d7f92416211de9ebb963ff4ce28125932878" + file_name = 'testfile' + file_contents = 'foobar' + file_sha1 = '8843d7f92416211de9ebb963ff4ce28125932878' try: - dl = open(file_name, "w") + dl = open(file_name, 'w') except PermissionError: - pytest.skip("need write access to create test file") + pytest.skip('need write access to create test file') else: with dl: dl.write(file_contents) diff --git a/wikiget/wikiget.py b/wikiget/wikiget.py index a825c54..bdd05a3 100644 --- a/wikiget/wikiget.py +++ b/wikiget/wikiget.py @@ -32,7 +32,7 @@ from tqdm import tqdm from wikiget.version import __version__ BLOCKSIZE = 65536 -DEFAULT_SITE = 'en.wikipedia.org' +DEFAULT_SITE = 'commons.wikimedia.org' USER_AGENT = 'wikiget/{} (https://github.com/clpo13/wikiget) ' \ 'mwclient/{}'.format(__version__, mwclient_version) @@ -120,7 +120,7 @@ def download(dl, args): filename = url.path site_name = url.netloc if args.site is not DEFAULT_SITE and not args.quiet: - # this will work even if the user specifies 'en.wikipedia.org' + # this will work even if the user specifies 'commons.wikimedia.org' print('Warning: target is a URL, ignoring site specified with ' '--site') else: |
