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
Indeed, before this patch, no `# Title: XYZ` was describing our generated
host file. This patch fixes that.
Indeed, we now do the following:
- If no extension is included we add:
- `# Title: StevenBlack/hosts`
- If exactly one extension is included we add:
- `# Title: StevenBlack/hosts with the extension_name extension`
- If more than one extension is included we add (in one line):
- `# Title: StevenBlack/hosts with the extname1,
extname2 and extname3 extensions`
Please also note that I disable E203 (whitespace before ':') for flake8
at line 773.
Since we use Black for code formatting let me redirect you to
the documentation of Black which explain what I did.
https://black.readthedocs.io/en/stable/the_black_code_style.html#slices :
> Since E203 is not PEP 8 compliant, you should tell
> Flake8 to ignore these warnings.
I've changed as suggested in https://github.com/StevenBlack/hosts/pull/836#issuecomment-440452979 by @funilrys
The reason I choose NOT to convert this into ISO-8601 is, that we read date.time in different ways depending on with side on the pond we live. By using the "%d %B %Y %H:%M:%S (%Z)" Full date/time this issue is eliminated and any confusion on how to read the date is no longer existent. The ISO-8601 is good for active pages, as the date ordering is to be manipulated by interface.
Alternative to this is we should add extra lines/info about the date.time ordering, do to this i found this as the easiest way to give this information
Since some host files might need to be updated more frequently it's more appropriate to show timezone and the exact time for last build, hince changed the order of month and date to %d %B