From ac3d797dff2a84c9882c6595002886b06a024f40 Mon Sep 17 00:00:00 2001 From: Vuyisile Ndlovu Date: Fri, 26 Oct 2018 10:56:19 +0200 Subject: [PATCH 1/3] Allows write_results to take a path --- axe_selenium_python/axe.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/axe_selenium_python/axe.py b/axe_selenium_python/axe.py index c8bc6ef..e08cd71 100755 --- a/axe_selenium_python/axe.py +++ b/axe_selenium_python/axe.py @@ -93,17 +93,19 @@ def report(self, violations): string += "\n\n\n" return string - def write_results(self, data, name="results.json"): + def write_results(self, data, name): """ Write JSON to file with the specified name. :param name: Name of file to be written to. :param output: JSON object. """ - filepath = os.path.join(os.getcwd(), name) + filepath = os.path.abspath(name) with open(filepath, "w", encoding="utf8") as f: try: f.write(unicode(json.dumps(data, indent=4))) except NameError: f.write(json.dumps(data, indent=4)) + except FileNotFoundError as fnf_error: + print(fnf_error) \ No newline at end of file From c42aa7dae39bee206616a9b1ecac11cf12ef4b4b Mon Sep 17 00:00:00 2001 From: Vuyisile Ndlovu Date: Fri, 26 Oct 2018 11:02:51 +0200 Subject: [PATCH 2/3] fixed pep8 issues --- axe_selenium_python/axe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/axe_selenium_python/axe.py b/axe_selenium_python/axe.py index e08cd71..07da0fb 100755 --- a/axe_selenium_python/axe.py +++ b/axe_selenium_python/axe.py @@ -108,4 +108,4 @@ def write_results(self, data, name): except NameError: f.write(json.dumps(data, indent=4)) except FileNotFoundError as fnf_error: - print(fnf_error) \ No newline at end of file + print(fnf_error) From df1552f88923265a94662cca2c9c4f5950267e71 Mon Sep 17 00:00:00 2001 From: Vuyisile Ndlovu Date: Wed, 31 Oct 2018 08:43:16 +0200 Subject: [PATCH 3/3] Fixed default arguments and updated path handling logic --- axe_selenium_python/axe.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/axe_selenium_python/axe.py b/axe_selenium_python/axe.py index 07da0fb..0622d68 100755 --- a/axe_selenium_python/axe.py +++ b/axe_selenium_python/axe.py @@ -93,19 +93,22 @@ def report(self, violations): string += "\n\n\n" return string - def write_results(self, data, name): + def write_results(self, data, name=None): """ Write JSON to file with the specified name. - :param name: Name of file to be written to. + :param name: Path to the file to be written to. If no path is passed + a new file will be created. :param output: JSON object. """ - filepath = os.path.abspath(name) + + if name: + filepath = os.path.abspath(name) + else: + filepath = os.path.join(os.path.getcwd(), name) with open(filepath, "w", encoding="utf8") as f: try: f.write(unicode(json.dumps(data, indent=4))) except NameError: f.write(json.dumps(data, indent=4)) - except FileNotFoundError as fnf_error: - print(fnf_error)