Skip to content

Commit

Permalink
saving some work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
cockroacher committed Oct 29, 2024
1 parent 911dd8c commit 5810fb9
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 4 deletions.
18 changes: 17 additions & 1 deletion default.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ class CommandLineOptions: # pylint: disable=too-many-instance-attributes,missing
def __init__(self):
self.language = False

def show_credits(self, _):
"""
Prints out the webperf_core credits and exits the program.
This function uses the provided language function to print out webperf_core credits.
After printing the help text, it ends the program.
"""
print(self.language('TEXT_CREDITS'))
# Get all websites used by get_http_content
# - get_http_content\(['"\r\n\t ]+[^"']+["']
# Get all contributors of repo
# - https://api.github.com/repos/Webperf-se/webperf_core/contributors
sys.exit()

def show_help(self, _):
"""
Prints out the command usage help text and exits the program.
Expand Down Expand Up @@ -485,6 +499,7 @@ def handle_option(self, opt, arg):
("--it", "--input-take"): self.set_input_take,
("-o", "--output"): self.set_output_filename,
("-r", "--review", "--report"): self.enable_reviews,
("-c", "--credits", "--contributions"): self.show_credits,
("-s", "--setting"): self.set_setting,
("-ss", "--save-setting"): self.save_setting
}
Expand Down Expand Up @@ -521,10 +536,11 @@ def main(argv):
options.load_language(get_config('general.language'))

try:
opts, _ = getopt.getopt(argv, "hu:t:i:o:rA:D:L:s:", [
opts, _ = getopt.getopt(argv, "hu:t:i:o:rA:D:L:s:c", [
"help", "url=", "test=", "input=", "output=",
"review", "report", "addUrl=", "deleteUrl=",
"language=", "input-skip=", "input-take=",
"credits",
"is=", "it=", "setting=", "save-setting="])
except getopt.GetoptError:
print(main.__doc__)
Expand Down
32 changes: 32 additions & 0 deletions defaults/credit-sources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"package.dependencies": {
"lighthouse": "12.2.1",
"pa11y": "8.0.0",
"sitespeed.io": "35.3.0",
"vnu-jar": "23.4.11",
"yellowlabtools": "3.0.1"
},
"websites": [
"https://api.github.com/repos/{0}/{1}",
"https://api.github.com/repos/{0}/{1}/{2}?state=closed&per_page=100",
"https://api.github.com/repos/{0}/{1}/{2}/{3}/labels",
"https://api.websitecarbon.com/site?url={url}",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element#obsolete_and_deprecated_elements",
"https://developer.mozilla.org/en-US/docs/Web/CSS/Reference",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element",
"https://spdx.org/licenses/",
"https://nginx.org/en/security_advisories.html",
"https://www.cvedetails.com/vulnerability-list.php?vendor_id=26&product_id=3427&page=1",
"https://openssl-library.org/news/vulnerabilities/",
"https://openssl-library.org/policies/releasestrat/index.html",
"https://www.php.net/eol.php",
"https://httpd.apache.org/security/vulnerabilities_24.html",
"https://wordpress.org/plugins/{0}/advanced/",
"https://learn.microsoft.com/en-us/lifecycle/products/internet-information-services-iis",
"https://cdn.datatables.net/releases.html",
"https://nuget.optimizely.com/package/?id=EPiServer.Find",
"https://www.php.net/releases/",
"https://svn.apache.org/viewvc/httpd/httpd/tags/",
"https://mta-sts.{hostname}/.well-known/mta-sts.txt"
]
}
19 changes: 19 additions & 0 deletions defaults/credits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"creditors": [
{
"name": "webperf-core",
"license": "MIT",
"usage": "",
"contributors": [
"7h3Rabbit",
"cockroacher",
"marcusosterberg",
"flowertwig-org",
"dependabot[bot]",
"krompaco",
"puggan",
"linulas"
]
}
]
}
Binary file modified locales/en/LC_MESSAGES/webperf-core.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locales/en/LC_MESSAGES/webperf-core.po
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ msgid "TEXT_TEST_VALID_ARGUMENTS_A11Y_STATEMENT"
msgstr "-t 26\t: Accessibility Statement (Alfa)"

msgid "TEXT_COMMAND_USAGE"
msgstr "\n\tWebPerf Core\n\n\tUsage:\ndefault.py -u https://webperf.se\n\n\tOptions and arguments:\n\t-h/--help\t\t\t: Help information on how to use script\n\t-u/--url <site url>\t\t: website url to test against\n\t-t/--test <test number>\t\t: run ONE test (use ? to list available tests)\n\t-r/--review\t\t\t: show reviews in terminal\n\t-i/--input <file path>\t\t: input file path (.json/.sqlite/.sitemap/<category name>.webprf)\n\t-i/--input-skip <number>\t: number of items to skip\n\t-i/--input-take <number>\t: number of items to take\n\t-o/--output <file path>\t\t: output file path (.json/.csv/.sql/.sqlite/.md)\n\t-A/--addUrl <site url>\t\t: website url (required in compination with -i/--input)\n\t-D/--deleteUrl <site url>\t: website url (required in compination with -i/--input)\n\t-L/--language <lang code>\t: language used for output(en = default/sv)\n\t--setting <key>=<value>\t\t: override configuration for current run\n\t\t\t\t\t (use ? to list available settings)\n\t--save-setting <filename>\t: create own configuration from currently used configuration\n\t\t\t\t\t (You should use 'settings.json')"
msgstr "\n\tWebPerf Core\n\n\tUsage:\ndefault.py -u https://webperf.se\n\n\tOptions and arguments:\n\t-h/--help\t\t\t: Help information on how to use script\n\t-u/--url <site url>\t\t: website url to test against\n\t-t/--test <test number>\t\t: run ONE test (use ? to list available tests)\n\t-r/--review\t\t\t: show reviews in terminal\n\t-i/--input <file path>\t\t: input file path (.json/.sqlite/.sitemap/<category name>.webprf)\n\t-i/--input-skip <number>\t: number of items to skip\n\t-i/--input-take <number>\t: number of items to take\n\t-o/--output <file path>\t\t: output file path (.json/.csv/.sql/.sqlite/.md)\n\t-A/--addUrl <site url>\t\t: website url (required in compination with -i/--input)\n\t-D/--deleteUrl <site url>\t: website url (required in compination with -i/--input)\n\t-L/--language <lang code>\t: language used for output(en = default/sv)\n\t--setting <key>=<value>\t\t: override configuration for current run\n\t\t\t\t\t (use ? to list available settings)\n\t--save-setting <filename>\t: create own configuration from currently used configuration\n\t\t\t\t\t (You should use 'settings.json')\n\t-c/--credits\t\t\t: Show projects and people we are thankful for"

msgid "TEXT_TEST_REVIEW_OVERVIEW"
msgstr "\r\n#### Overall:\r\n{0}"
Expand Down
Binary file modified locales/gov/LC_MESSAGES/webperf-core.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locales/gov/LC_MESSAGES/webperf-core.po
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ msgstr "-t 26\t: Accessibility Statement (Alfa)"

#: default.py:137 default.py:141 default.py:146 default.py:213
msgid "TEXT_COMMAND_USAGE"
msgstr "\n\tWebPerf Core\n\n\tUsage:\ndefault.py -u https://webperf.se\n\n\tOptions and arguments:\n\t-h/--help\t\t\t: Help information on how to use script\n\t-u/--url <site url>\t\t: website url to test against\n\t-t/--test <test number>\t\t: run ONE test (use ? to list available tests)\n\t-r/--review\t\t\t: show reviews in terminal\n\t-i/--input <file path>\t\t: input file path (.json/.sqlite/.sitemap/<category name>.webprf)\n\t-i/--input-skip <number>\t: number of items to skip\n\t-i/--input-take <number>\t: number of items to take\n\t-o/--output <file path>\t\t: output file path (.json/.csv/.sql/.sqlite/.md)\n\t-A/--addUrl <site url>\t\t: website url (required in compination with -i/--input)\n\t-D/--deleteUrl <site url>\t: website url (required in compination with -i/--input)\n\t-L/--language <lang code>\t: language used for output(en = default/sv)\n\t--setting <key>=<value>\t\t: override configuration for current run\n\t\t\t\t\t (use ? to list available settings)\n\t--save-setting <filename>\t: create own configuration from currently used configuration\n\t\t\t\t\t (You should use 'settings.json')"
msgstr "\n\tWebPerf Core\n\n\tUsage:\ndefault.py -u https://webperf.se\n\n\tOptions and arguments:\n\t-h/--help\t\t\t: Help information on how to use script\n\t-u/--url <site url>\t\t: website url to test against\n\t-t/--test <test number>\t\t: run ONE test (use ? to list available tests)\n\t-r/--review\t\t\t: show reviews in terminal\n\t-i/--input <file path>\t\t: input file path (.json/.sqlite/.sitemap/<category name>.webprf)\n\t-i/--input-skip <number>\t: number of items to skip\n\t-i/--input-take <number>\t: number of items to take\n\t-o/--output <file path>\t\t: output file path (.json/.csv/.sql/.sqlite/.md)\n\t-A/--addUrl <site url>\t\t: website url (required in compination with -i/--input)\n\t-D/--deleteUrl <site url>\t: website url (required in compination with -i/--input)\n\t-L/--language <lang code>\t: language used for output(en = default/sv)\n\t--setting <key>=<value>\t\t: override configuration for current run\n\t\t\t\t\t (use ? to list available settings)\n\t--save-setting <filename>\t: create own configuration from currently used configuration\n\t\t\t\t\t (You should use 'settings.json')\n\t-c/--credits\t\t\t: Show projects and people we are thankful for"

msgid "TEXT_TEST_REVIEW_OVERVIEW"
msgstr "\r\n#### Overall:\r\n{0}"
Expand Down
Binary file modified locales/sv/LC_MESSAGES/webperf-core.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locales/sv/LC_MESSAGES/webperf-core.po
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ msgid "TEXT_TEST_VALID_ARGUMENTS_A11Y_STATEMENT"
msgstr "-t 26\t: Tillgänglighetsredogörelse (Alfa)"

msgid "TEXT_COMMAND_USAGE"
msgstr "\n\tWebPerf Core\n\n\tAnvänd så här:\ndefault.py -u https://webperf.se\n\n\tVal och argument:\n\t-h/--help\t\t\t: Hjälp och hur du använder skriptet\n\t-u/--url <site url>\t\t: webbplatsens adress att testa\n\t-t/--test <test nummer>\t\t: kör ett specifikt test (ange ? för att lista tillgängliga tester)\n\t-r/--review\t\t\t: visar omdömen direkt i terminalen\n\t-i/--input <file path>\t\t: sökväg för input-fil (.json/.sqlite)\n\t-i/--input-skip <nummer>\t: antal att hoppa över\n\t-i/--input-take <nummer>\t: antal att testa\n\t-o/--output <file path>\t\t: sökväg till output-fil (.json/.csv/.sql/.sqlite/.md)\n\t-A/--addUrl <site url>\t\t: webbplatsens adress/url (ett krav när du använder -i/--input)\n\t-D/--deleteUrl <site url>\t: webbplats adress/url (ett krav när du använder -i/--input)\n\t-L/--language <lang code>\t: språk som används för output(en = default/sv)\n\t--setting <nyckel>=<värde>\t: Använd inställning för nuvarande körning\n\t\t\t\t\t (ange ? för att lista tillgängliga inställningar)\n\t--save-setting <filnamn>\t: Skapa egen inställningsfil från nuvarande använda inställningar\n\t\t\t\t\t (Du bör använda 'settings.json')"
msgstr "\n\tWebPerf Core\n\n\tAnvänd så här:\ndefault.py -u https://webperf.se\n\n\tVal och argument:\n\t-h/--help\t\t\t: Hjälp och hur du använder skriptet\n\t-u/--url <site url>\t\t: webbplatsens adress att testa\n\t-t/--test <test nummer>\t\t: kör ett specifikt test (ange ? för att lista tillgängliga tester)\n\t-r/--review\t\t\t: visar omdömen direkt i terminalen\n\t-i/--input <file path>\t\t: sökväg för input-fil (.json/.sqlite)\n\t-i/--input-skip <nummer>\t: antal att hoppa över\n\t-i/--input-take <nummer>\t: antal att testa\n\t-o/--output <file path>\t\t: sökväg till output-fil (.json/.csv/.sql/.sqlite/.md)\n\t-A/--addUrl <site url>\t\t: webbplatsens adress/url (ett krav när du använder -i/--input)\n\t-D/--deleteUrl <site url>\t: webbplats adress/url (ett krav när du använder -i/--input)\n\t-L/--language <lang code>\t: språk som används för output(en = default/sv)\n\t--setting <nyckel>=<värde>\t: Använd inställning för nuvarande körning\n\t\t\t\t\t (ange ? för att lista tillgängliga inställningar)\n\t--save-setting <filnamn>\t: Skapa egen inställningsfil från nuvarande använda inställningar\n\t\t\t\t\t (Du bör använda 'settings.json')\n\t-c/--credits\t\t\t: Visa projekt och människor vi är tacksamma för"

msgid "TEXT_TEST_REVIEW_OVERVIEW"
msgstr "\r\n#### Övergripande:\r\n{0}"
Expand Down
1 change: 1 addition & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def get_http_content(url, allow_redirects=False, use_text_instead_of_content=Tru
str or bytes: The content of the URL.
"""
try:
print('A\tget_http_content', url)
content = get_cache_file(
url,
use_text_instead_of_content,
Expand Down

0 comments on commit 5810fb9

Please sign in to comment.