Commit Graph

61 Commits

Author SHA1 Message Date
XhmikosR
177e9755a3
Use assertIn instead of assertTrue 2022-03-07 09:08:23 +02:00
Naelson Douglas
bce4b79920 removed a manual indexer iterator pitfall from the code 2021-10-24 14:06:53 -03:00
funilrys
4f6ddfaab8
Blacking. 2021-07-13 20:14:25 +02:00
Steven Black
023eb7faa7
Issue #1628: fix — parse out @ characters from lists. 2021-04-26 17:55:39 -04:00
Steven Black
2b167dcce8
Better name for is_valid_user_provided_domain_format. 2021-04-26 17:08:38 -04:00
funilrys
4b1a939668
Apply black+isort 2021-03-31 14:57:56 +02:00
funilrys
7971a0cbc9
Introduction of the support of RAW lines.
This patch fixes https://github.com/StevenBlack/hosts/issues/1563#issuecomment-810688754

Indeed, before this patch, the updater was not supporting a RAW (not
hosts) list of domains as input.

Changes:

    matches_exclusions():
        (new) Support for rule formatted as 'example.com' along with
              the pre-existing '0.0.0.0 example.com'.

    normalize_rule():
        (edit) Apply DRY.

        (new) Support the normalization of the rule formatted as
              'example.com' along with the pre-existing '0.0.0.0
              example.com'.

    strip_rule():
        (new) Complete rewrite in order to strip all possible lines.
2021-03-31 14:53:22 +02:00
Tim Gates
f6d8977748
docs: fix simple typo, seprator -> separator
There is a small typo in testUpdateHostsFile.py.

Should read `separator` rather than `seprator`.
2020-12-22 08:16:04 +11:00
Alexander Cecile
b350c68540 Improved tests for get_file_by_url 2020-09-02 20:25:01 -04:00
Alexander Cecile
d85c96576a Remove unused test code 2020-08-28 03:18:41 -04:00
Alexander Cecile
ad35681244 Improve tests for get_file_by_url 2020-08-28 03:17:06 -04:00
Alexander Cecile
26b2ab9e5a Add basic tests for get_file_by_url 2020-08-25 20:40:30 -04:00
Alexander Cecile
aa9da1ee0d Remove unused import in tests 2020-08-21 17:30:47 -04:00
Alexander Cecile
5186071948 Introduce the requests library.
Replace the combination of urllib, beautifulsoup and lxml with the requests library.
2020-08-17 19:52:11 -04:00
gfyoung
24f7482fc6
Remove unnecessary reset_mock calls 2020-08-09 00:42:24 -07:00
Steven Black
a09e408c8a
Merge pull request #1342 from codeswhite/patch-network-retry
Implemented connectivity check (Fixed #1038)
2020-07-13 13:41:19 -04:00
funilrys
abf763e9a0
Change strategy regarding #1332.
Instead of changing the directory separator globally, we change it only
when we generate/update the readme data file.
2020-07-13 15:35:16 +02:00
funilrys
b8b067b6ab
Replace the returned separator under Windows. 2020-07-13 11:29:11 +02:00
funilrys
c756858a1b
Merge branch 'master' into issue-1332 2020-07-13 11:23:45 +02:00
Max G
f26168194b Retry to get file from URL once failed
(Resolves #1038)
2020-07-11 14:09:51 +03:00
Max G
9e3db93d92 Updated test 2020-07-10 23:43:09 +03:00
funilrys
73479bc632
Fix directory separtor under Windows.
This patch fix #1332.
2020-07-10 01:04:44 +02:00
funilrys
a2008b78f9
First, format with black. 2020-05-27 21:59:34 +02:00
Guilherme Heuser Prestes
b40aa38ee6
remove the '-' from mock 2020-04-24 21:13:41 +02:00
XhmikosR
f5358fd0b4 Join a few short lines and fixes a few typos 2020-04-23 09:02:38 +03:00
funilrys
665dc98191
Unification of the sorting of the sources.
Before this patch, there was no proper sorting and the sources.

As @XhmikosR mentioned in StevenBlack/hosts#1166, without this patch,
the output is totally different in Windows. But let's be honest, if it
is like that under Windows, chances are that the same behavior happens
across different OSes or machines around the globe.

Another reason behind this patch is that - desperate the fact that we
certainly trust @StevenBlack - the integrity of the generated files
could not be guarenteed because of the sorting which may be completely
different from an OS to another and a machine to another.

For those reasons, this patch introduces a unification of the sorting of
all sources.

The idea behind this patch is to have @StevenBlack's ad-hoc hosts
file always on top (1st) and the rest of the sources sorted
alphabetically based on the name of the folder inside the `data`
or `extensions` directory.

This will ensure that we get the same result everywhere.

Concretely speaking, I just added the function (`sort_sources`) which
sorts a given list of sources files. And later on, call the new function
everywhere it was necessary. Tests of the newly introduced function
are also included.

Contributors:
  * @ScriptTiger
  * @XhmikosR

Notes:
  * This patch fix (completely ?) ScriptTiger/hosts#1
  * This patch fix https://github.com/StevenBlack/hosts/issues/1166#issuecomment-590511086
2020-04-21 22:54:25 +02:00
Anthony Molinaro
7dd582dac3 2 blank lines? 2020-04-07 23:07:40 -07:00
Anthony Molinaro
9c1b8b2579 use more succinct name for arg 2020-04-07 22:40:30 -07:00
Anthony Molinaro
aec3738838 fix unit test 2020-04-07 22:18:35 -07:00
XhmikosR
d2566110ff Fix GitHub capitalization 2020-02-22 16:21:26 +02:00
funilrys
05dad7e657
Introduction of Black: The uncompromising Python code formatter.
Please find more about it there:
* https://github.com/python/black
* https://black.readthedocs.io/en/stable/
2019-07-13 13:40:13 +02:00
funilrys
c0d661f388
Review of the notion of keepdomaincomments
This patch fix StevenBlack/hosts#777

This patch:
  * Change the default state of keepdomaincomments.
    * Indeed, comments are now displayed by default.
    * But if you don't need comments, feel free to use the argument.
  * Delete the requirement input when calling the `-k` argument.
  * Update tests case regarding the new state of keepdomaincomments.
2018-09-14 00:15:56 +02:00
gfyoung
92442955bc
Minor house-cleaning
* No parentheses single-line string
* Remove builtins function, which was
really for Python 2.x compatibility
2018-09-06 21:12:48 -07:00
gfyoung
d8df5f1dc4
Use example files to allow proper git-ignoring
The following files:

* myhosts
* blacklist
* whitelist

can be all be modified by the user for personal usage.
However, git is tracking these files since they exist
in the repository, which makes it difficult to do so
without accidentally pushing one's own customizations.

This commit converts those examples to ".example" files,
which serve as the defaults if one of the files listed
above does not exist.

Closes gh-144.
2018-09-06 12:20:37 -07:00
funilrys
7c2da6044e
Deletion of unneeded comment 2018-09-05 23:53:57 -04:00
funilrys
782a178596
This patch fix https://github.com/StevenBlack/hosts/pull/730#discussion_r205657347 2018-09-05 23:53:57 -04:00
funilrys
e246960c43
Fixing flake8 issues 2018-09-05 23:53:57 -04:00
funilrys
58db5143ed
Deletion of future dependencies
Also:
  * deletion of raw_input
2018-09-05 23:53:35 -04:00
funilrys
edb4f57da4
Fix flake8 issue.
This patch is related to https://github.com/StevenBlack/hosts/issues/729
2018-09-05 23:53:11 -04:00
funilrys
eb37488a16
Sorting and update of imports && deletion of Python2 related logic
This patch is related to https://github.com/StevenBlack/hosts/issues/729
2018-09-05 23:53:11 -04:00
funilrys
11d8c064ac
Deletion of unneeded comment 2018-09-05 23:51:29 -04:00
funilrys
52e25bf7b9
This patch fix https://github.com/StevenBlack/hosts/pull/730#discussion_r205657347 2018-09-05 23:51:29 -04:00
funilrys
6a28f41fdc
Fixing flake8 issues 2018-09-05 23:51:29 -04:00
funilrys
928bb5201c
Deletion of future dependencies
Also:
  * deletion of raw_input
2018-09-05 23:51:28 -04:00
funilrys
8ebad236c6
Fix flake8 issue.
This patch is related to https://github.com/StevenBlack/hosts/issues/729
2018-09-05 23:51:27 -04:00
funilrys
05c2c6c825
Sorting and update of imports && deletion of Python2 related logic
This patch is related to https://github.com/StevenBlack/hosts/issues/729
2018-09-05 23:51:27 -04:00
gfyoung
e66c2cb37e
Doc / Check for Centos restart
Closes gh-622.
2018-05-22 21:53:56 -04:00
Steven Black
03c247bfab Test to accompany accepting IP followed by host IP address. 2018-03-14 00:10:07 -04:00
funilrys
318389b08f
Introduction of more tests cases
Please note that this patch introduce more tests cases
in order to avoid future issue when calling `domains_to_idna()`
2018-03-04 11:18:50 +01:00
funilrys
4798710029
Introduction of domain_to_idna() tests. 2018-03-02 22:23:21 +01:00