From 37f72c89aa4778599402f79d6e7d026b79a689b3 Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Tue, 12 Feb 2019 19:34:22 +0700 Subject: [PATCH 01/22] convert to py3 using 2to3 script --- command_helper/completions.py | 2 +- command_helper/get_documentation.py | 4 +- command_helper/get_keyword.py | 8 +-- command_helper/jump_to_file.py | 2 +- command_helper/noralize_cell.py | 2 +- command_helper/workspace_objects.py | 2 +- commands/scan.py | 1 + dataparser/data_parser/data_parser.py | 8 +-- dataparser/index/index.py | 4 +- dataparser/queue/scanner.py | 6 +- dataparser/run_index.py | 4 +- dataparser/run_scanner.py | 2 +- test/resource/library/MyLibrary.py | 2 +- test/resource/library/OtherMyLibrary.py | 2 +- .../real_suite/libs/com/company/library.py | 6 +- .../test_data/suite_tree/LibNoClass.py | 4 +- ...nTheFileNameAndIsNotGoodRealLifeExample.py | 2 +- .../LibraryWithReallyTooLongName.py | 8 +-- test/run_test.py | 18 +++--- test/unit/test_completions.py | 2 +- test/unit/test_get_documentation.py | 2 +- test/unit/test_get_keyword_from_library.py | 2 +- test/unit/test_get_keyword_from_resource.py | 2 +- test/unit/test_indexkw.py | 62 +++++++++---------- test/unit/test_jump_to_file.py | 2 +- test/unit/test_runner_for_index.py | 2 +- test/unit/test_scanner.py | 4 +- 27 files changed, 83 insertions(+), 82 deletions(-) diff --git a/command_helper/completions.py b/command_helper/completions.py index 7cd1b21..9a6eb0f 100644 --- a/command_helper/completions.py +++ b/command_helper/completions.py @@ -3,7 +3,7 @@ from json import load as json_load try: from db_json_settings import DBJsonSetting - from utils.get_text import get_prefix + from .utils.get_text import get_prefix except: from ..setting.db_json_settings import DBJsonSetting from ..command_helper.utils.get_text import get_prefix diff --git a/command_helper/get_documentation.py b/command_helper/get_documentation.py index 4ea2e05..8cceb7b 100644 --- a/command_helper/get_documentation.py +++ b/command_helper/get_documentation.py @@ -3,9 +3,9 @@ try: from parser_utils.file_formatter import rf_table_name from parser_utils.util import get_index_name, normalise_path - from noralize_cell import get_data_from_json + from .noralize_cell import get_data_from_json from db_json_settings import DBJsonSetting - from utils.util import kw_equals_kw_candite + from .utils.util import kw_equals_kw_candite except: from ..dataparser.parser_utils.file_formatter import rf_table_name from ..dataparser.parser_utils.util import get_index_name, normalise_path diff --git a/command_helper/get_keyword.py b/command_helper/get_keyword.py index 443340b..c21c37d 100644 --- a/command_helper/get_keyword.py +++ b/command_helper/get_keyword.py @@ -2,10 +2,10 @@ from os import path from sys import version_info try: - from get_documentation import GetKeywordDocumentation + from .get_documentation import GetKeywordDocumentation from db_json_settings import DBJsonSetting - from noralize_cell import get_data_from_json - from utils.util import kw_equals_kw_candite + from .noralize_cell import get_data_from_json + from .utils.util import kw_equals_kw_candite except: from .get_documentation import GetKeywordDocumentation from ..setting.db_json_settings import DBJsonSetting @@ -164,5 +164,5 @@ def is_string(self, str_): if version_info.major > 2: status = isinstance(str_, str) else: - status = isinstance(str_, basestring) + status = isinstance(str_, str) return status diff --git a/command_helper/jump_to_file.py b/command_helper/jump_to_file.py index f0e3566..146f0be 100644 --- a/command_helper/jump_to_file.py +++ b/command_helper/jump_to_file.py @@ -3,7 +3,7 @@ try: from parser_utils.file_formatter import lib_table_name - from noralize_cell import get_data_from_json + from .noralize_cell import get_data_from_json except ImportError: from ..dataparser.parser_utils.file_formatter import lib_table_name from .noralize_cell import get_data_from_json diff --git a/command_helper/noralize_cell.py b/command_helper/noralize_cell.py index c5a6fa1..3af3c91 100644 --- a/command_helper/noralize_cell.py +++ b/command_helper/noralize_cell.py @@ -1,7 +1,7 @@ import re import collections try: - from utils.util import get_data_from_json, kw_equals_kw_candite + from .utils.util import get_data_from_json, kw_equals_kw_candite from db_json_settings import DBJsonSetting except: from .utils.util import get_data_from_json, kw_equals_kw_candite diff --git a/command_helper/workspace_objects.py b/command_helper/workspace_objects.py index 1fd32e5..6422aab 100644 --- a/command_helper/workspace_objects.py +++ b/command_helper/workspace_objects.py @@ -1,6 +1,6 @@ from os import listdir, path try: - from noralize_cell import get_data_from_json + from .noralize_cell import get_data_from_json from db_json_settings import DBJsonSetting except: from ..command_helper.noralize_cell import get_data_from_json diff --git a/commands/scan.py b/commands/scan.py index 4d389f4..516c076 100644 --- a/commands/scan.py +++ b/commands/scan.py @@ -48,6 +48,7 @@ def run_scan(self, log_file): p_args = scan_popen_arg_parser('all') p_args.append('--workspace') p_args.append(get_setting(SettingObject.workspace)) + print((" ".join(p_args))) p = subprocess.Popen( p_args, stderr=subprocess.STDOUT, diff --git a/dataparser/data_parser/data_parser.py b/dataparser/data_parser/data_parser.py index 60fbbd2..e8455c5 100644 --- a/dataparser/data_parser/data_parser.py +++ b/dataparser/data_parser/data_parser.py @@ -192,7 +192,7 @@ def _get_library_kw_source(self, libcode, keyword): def get_class_that_defined_method(self, meth): try: - class_mro = inspect.getmro(meth.im_class) + class_mro = inspect.getmro(meth.__self__.__class__) except AttributeError: return None for cls in class_mro: @@ -236,7 +236,7 @@ def _argument_path_formatter(self, library, args): def _parse_xml_doc(self, library): root = ET.parse(library).getroot() - if ('type', DBJsonSetting.library) in root.items(): + if ('type', DBJsonSetting.library) in list(root.items()): return root.attrib['name'], self._parse_xml_lib(root) else: raise ValueError('XML file is not library: {0}'.format( @@ -323,8 +323,8 @@ def _format_resource(self, setting, file_path): c_dir = path.dirname(self.file_path) resource_path = normalise_path(path.join(c_dir, setting.name)) if not path.isfile(resource_path): - print ('Import failure on file: {0},'.format(file_path), - 'could not locate: {0}'.format(setting.name)) + print(('Import failure on file: {0},'.format(file_path), + 'could not locate: {0}'.format(setting.name))) return resource_path def _format_variable_file(self, setting): diff --git a/dataparser/index/index.py b/dataparser/index/index.py index b90cc4f..26b8cf8 100644 --- a/dataparser/index/index.py +++ b/dataparser/index/index.py @@ -175,7 +175,7 @@ def get_imports(self, data): result += self.get_library_imports(data) if DBJsonSetting.variable_files in data: for var in data[DBJsonSetting.variable_files]: - result.append(rf_table_name(var.keys()[0])) + result.append(rf_table_name(list(var.keys())[0])) if DBJsonSetting.resources in data: for resource in data[DBJsonSetting.resources]: result.append(rf_table_name(resource)) @@ -221,7 +221,7 @@ def get_keywords(self, data): arg_list = [] if DBJsonSetting.keywords in data: kws = data[DBJsonSetting.keywords] - for kw in kws.iterkeys(): + for kw in kws.keys(): kw_list.append(kws[kw][DBJsonSetting.keyword_name]) kw_args = self.get_kw_arguments( kws[kw][DBJsonSetting.keyword_arguments]) diff --git a/dataparser/queue/scanner.py b/dataparser/queue/scanner.py index 382bc3a..4b816b2 100644 --- a/dataparser/queue/scanner.py +++ b/dataparser/queue/scanner.py @@ -4,9 +4,9 @@ import os import xml.etree.ElementTree as ET from robot.errors import DataError -from finder import finder +from .finder import finder from data_parser.data_parser import DataParser -from queue import ParsingQueue +from .queue import ParsingQueue from parser_utils.file_formatter import rf_table_name, lib_table_name from parser_utils.util import normalise_path from db_json_settings import DBJsonSetting @@ -146,7 +146,7 @@ def add_libraries_queue(self, libs): def add_var_files_queue(self, var_files): for var_file in var_files: - file_name = var_file.keys()[0] + file_name = list(var_file.keys())[0] self.queue.add( file_name, 'variable_file', diff --git a/dataparser/run_index.py b/dataparser/run_index.py index a87b9fe..1b4fb0c 100644 --- a/dataparser/run_index.py +++ b/dataparser/run_index.py @@ -8,8 +8,8 @@ SETTING_DIR = path.join(ROOT_DIR, '..', 'setting') sys.path.append(SETTING_DIR) -from index.index import index_a_table -from index.index import Index +from .index.index import index_a_table +from .index.index import Index def index_all(db_path, index_path, module_search_path, libs_in_xml): diff --git a/dataparser/run_scanner.py b/dataparser/run_scanner.py index dd9b70a..8f08d12 100644 --- a/dataparser/run_scanner.py +++ b/dataparser/run_scanner.py @@ -6,7 +6,7 @@ SETTING_DIR = path.join(ROOT_DIR, '..', 'setting') sys.path.append(SETTING_DIR) -from queue.scanner import Scanner +from .queue.scanner import Scanner def scan_all(workspace, extension, db_path, diff --git a/test/resource/library/MyLibrary.py b/test/resource/library/MyLibrary.py index 2b032dc..5df478c 100644 --- a/test/resource/library/MyLibrary.py +++ b/test/resource/library/MyLibrary.py @@ -4,7 +4,7 @@ def keyword_1(self, arg1): """kw 1 doc Tags: tag1, tag2 """ - print arg1 + print(arg1) def keyword_2(self, arg2, arg3): """kw 2 doc""" diff --git a/test/resource/library/OtherMyLibrary.py b/test/resource/library/OtherMyLibrary.py index d8055f3..12de778 100644 --- a/test/resource/library/OtherMyLibrary.py +++ b/test/resource/library/OtherMyLibrary.py @@ -8,7 +8,7 @@ def keyword_1(self, arg1): """kw 1 doc Tags: tag1, tag2 """ - print arg1 + print(arg1) def keyword_2(self, arg2, arg3): """kw 2 doc""" diff --git a/test/resource/test_data/real_suite/libs/com/company/library.py b/test/resource/test_data/real_suite/libs/com/company/library.py index e20b007..f511727 100644 --- a/test/resource/test_data/real_suite/libs/com/company/library.py +++ b/test/resource/test_data/real_suite/libs/com/company/library.py @@ -5,8 +5,8 @@ class CompanyLibrary(object): """docstring for ComparyLibrary""" def company_keyword(self, arg): - print arg + print(arg) def company_keyword_2(self, args): - print args - print BuiltIn().get_library_instance('Selenium2Library') + print(args) + print(BuiltIn().get_library_instance('Selenium2Library')) diff --git a/test/resource/test_data/suite_tree/LibNoClass.py b/test/resource/test_data/suite_tree/LibNoClass.py index 8b6015d..e328e99 100644 --- a/test/resource/test_data/suite_tree/LibNoClass.py +++ b/test/resource/test_data/suite_tree/LibNoClass.py @@ -1,8 +1,8 @@ def library_keyword_1(arg1): """library keyword 1 doc""" - print arg1 + print(arg1) def library_keyword_2(arg1, arg2): """library keyword 2 doc""" - print arg1, arg2 + print(arg1, arg2) diff --git a/test/resource/test_data/suite_tree/LibraryNameWhichIsLongerThan100CharactersButItSeemsThatItRequiresQuiteAlotLettersInTheFileNameAndIsNotGoodRealLifeExample.py b/test/resource/test_data/suite_tree/LibraryNameWhichIsLongerThan100CharactersButItSeemsThatItRequiresQuiteAlotLettersInTheFileNameAndIsNotGoodRealLifeExample.py index 65da5b9..37a9596 100644 --- a/test/resource/test_data/suite_tree/LibraryNameWhichIsLongerThan100CharactersButItSeemsThatItRequiresQuiteAlotLettersInTheFileNameAndIsNotGoodRealLifeExample.py +++ b/test/resource/test_data/suite_tree/LibraryNameWhichIsLongerThan100CharactersButItSeemsThatItRequiresQuiteAlotLettersInTheFileNameAndIsNotGoodRealLifeExample.py @@ -8,4 +8,4 @@ class LibraryNameWhichIsLongerThan100CharactersButItSeemsThatItRequiresQuiteAlot @keyword(name='Keyword Which Also Has Really Long Name But Not As Long The Class Name By ${argument} In Keyword') def function(self, argument): """Documentation is here""" - print argument + print(argument) diff --git a/test/resource/test_data/suite_tree/LibraryWithReallyTooLongName.py b/test/resource/test_data/suite_tree/LibraryWithReallyTooLongName.py index d3ba102..6f555e7 100644 --- a/test/resource/test_data/suite_tree/LibraryWithReallyTooLongName.py +++ b/test/resource/test_data/suite_tree/LibraryWithReallyTooLongName.py @@ -5,18 +5,18 @@ class LibraryWithReallyTooLongName(object): def long_name_keyword(self, *args): """Documentation goes here""" - print args + print(args) def other_long_name_keyword(self, *args, **kwargs): """Other documentation goes here""" - print args, kwargs + print(args, kwargs) @keyword(name='Other Name Here') def not_name(self, arg): """def not_name kw name Other Name Here""" - print arg + print(arg) @keyword(name='Other ${arg1} and ${arg2} Too') def keyword_deco(self, arg1, arg2): """lib keyword with emmedded args""" - print arg1, arg2 + print(arg1, arg2) diff --git a/test/run_test.py b/test/run_test.py index a53e820..53a05f0 100644 --- a/test/run_test.py +++ b/test/run_test.py @@ -13,7 +13,7 @@ def acceptance_test(options): if '-s' in options or '--suite' in options: return _acceptance_include(options[1:]) else: - print 'Only "-s" or "--suite" supported' + print('Only "-s" or "--suite" supported') _exit(255) @@ -35,14 +35,14 @@ def _acceptance_include(options): def clean_results(): - print 'Clean: {0}'.format(env.RESULTS_DIR) + print('Clean: {0}'.format(env.RESULTS_DIR)) if os.path.exists(env.RESULTS_DIR): shutil.rmtree(env.RESULTS_DIR) os.mkdir(env.RESULTS_DIR) def unit_test(): - print 'Running unit test' + print('Running unit test') sys.path.insert(0, env.COMMAND_HELPER_DIR) sys.path.insert(0, env.SETTING_DIR) sys.path.insert(0, env.SRC_DIR) @@ -56,7 +56,7 @@ def unit_test(): def _help(): - print 'Usage: python run_test.py [-s suite_name]' + print('Usage: python run_test.py [-s suite_name]') return 255 @@ -71,13 +71,13 @@ def _exit(rc): u_result = unit_test() a_result = acceptance_test(sys.argv[1:]) if u_result.errors or u_result.failures: - print 'Unit tests failed' - print 'errors: ', u_result.errors - print 'failures: ', u_result.failures + print('Unit tests failed') + print('errors: ', u_result.errors) + print('failures: ', u_result.failures) _exit(u_result.errors) elif a_result != 0: - print 'Acceptance tests failed' + print('Acceptance tests failed') _exit(a_result) else: - print 'All passed' + print('All passed') _exit(0) diff --git a/test/unit/test_completions.py b/test/unit/test_completions.py index 5c8b551..97498cc 100644 --- a/test/unit/test_completions.py +++ b/test/unit/test_completions.py @@ -141,7 +141,7 @@ def test_get_kw_completion_list_structure_with_object(self): kw_tuple = get_kw_completion_list(self.test_a_index, prefix, RF_CELL, object_name, False) for completion in kw_tuple: - self.assertRegexpMatches(completion[0], object_name) + self.assertRegex(completion[0], object_name) def test_kw_create_completion_item(self): # kw with args diff --git a/test/unit/test_get_documentation.py b/test/unit/test_get_documentation.py index 16ea729..5fa4cad 100644 --- a/test/unit/test_get_documentation.py +++ b/test/unit/test_get_documentation.py @@ -2,7 +2,7 @@ import env import shutil from os import path, makedirs -from index_runner import index_all +from .index_runner import index_all from queue.scanner import Scanner from parser_utils.file_formatter import rf_table_name, lib_table_name from get_documentation import GetKeywordDocumentation diff --git a/test/unit/test_get_keyword_from_library.py b/test/unit/test_get_keyword_from_library.py index 0970d23..bfaf82f 100644 --- a/test/unit/test_get_keyword_from_library.py +++ b/test/unit/test_get_keyword_from_library.py @@ -3,7 +3,7 @@ import shutil import platform from os import path, mkdir -from index_runner import index_all +from .index_runner import index_all from queue.scanner import Scanner from get_keyword import GetKeyword diff --git a/test/unit/test_get_keyword_from_resource.py b/test/unit/test_get_keyword_from_resource.py index f072490..0f88dd6 100644 --- a/test/unit/test_get_keyword_from_resource.py +++ b/test/unit/test_get_keyword_from_resource.py @@ -2,7 +2,7 @@ import env import shutil from os import path, mkdir -from index_runner import index_all +from .index_runner import index_all from queue.scanner import Scanner from parser_utils.file_formatter import rf_table_name from get_keyword import GetKeyword diff --git a/test/unit/test_indexkw.py b/test/unit/test_indexkw.py index 995f5d7..fc1abea 100644 --- a/test/unit/test_indexkw.py +++ b/test/unit/test_indexkw.py @@ -57,7 +57,7 @@ def test_parse_table_data(self): data, status = self.index.read_table( os.path.join(env.RESOURCES_DIR, t_name)) var, kw_index = self.index.parse_table_data(data, t_name) - self.assertTrue(u'${/}' in var) + self.assertTrue('${/}' in var) self.assertTrue('${OUTPUT_FILE}' in var) self.assertTrue('@{TEST_TAGS}' in var) @@ -169,10 +169,10 @@ def test_index_creation_test_a(self): kw_list.extend(self.get_LibNoClass_kw_index(KeywordRecord)[0]) kw_list.extend(self.get_LongName_kw_index(KeywordRecord)[0]) var_list = [ - u'${TEST_A}', - u'${RESOURCE_A}', - u'${COMMON_VARIABLE_1}', - u'${COMMON_VARIABLE_2}' + '${TEST_A}', + '${RESOURCE_A}', + '${COMMON_VARIABLE_1}', + '${COMMON_VARIABLE_2}' ] t_index = { 'keywords': kw_list, @@ -201,10 +201,10 @@ def test_index_creation_test_b(self): kw_list.extend(self.get_LongName_kw_index(KeywordRecord)[0]) kw_list.extend(self.get_OtherNameLib_kw_index(KeywordRecord)[0]) var_list = [ - u'${TEST_B}', - u'${RESOURCE_B}', - u'${COMMON_VARIABLE_1}', - u'${COMMON_VARIABLE_2}' + '${TEST_B}', + '${RESOURCE_B}', + '${COMMON_VARIABLE_1}', + '${COMMON_VARIABLE_2}' ] t_index = { 'keywords': kw_list, @@ -234,23 +234,23 @@ def test_index_consturctor(self): ) def test_get_kw_arguments(self): - kw_args = [u'item', u'msg=None'] + kw_args = ['item', 'msg=None'] result = self.index.get_kw_arguments(kw_args) - expected = [u'item', u'msg'] + expected = ['item', 'msg'] self.assertEqual(result, expected) - kw_args = [u'name', u'*args'] + kw_args = ['name', '*args'] result = self.index.get_kw_arguments(kw_args) self.assertEqual(result, kw_args) kw_args = [] result = self.index.get_kw_arguments(kw_args) self.assertEqual(result, kw_args) - kw_args = [u'object=None', u'*args', u'**kwargs'] + kw_args = ['object=None', '*args', '**kwargs'] result = self.index.get_kw_arguments(kw_args) - expected = [u'object', u'*args', u'**kwargs'] + expected = ['object', '*args', '**kwargs'] self.assertEqual(result, expected) - kw_args = [u'${kwa1}', '@{list}', '&{kwargs}'] + kw_args = ['${kwa1}', '@{list}', '&{kwargs}'] result = self.index.get_kw_arguments(kw_args) - expected = [u'kwa1', '*list', '**kwargs'] + expected = ['kwa1', '*list', '**kwargs'] self.assertEqual(result, expected) kw_args = ['${arg1}=${True}', '${arg2}=Text_here', '${arg3}=${False}'] result = self.index.get_kw_arguments(kw_args) @@ -627,10 +627,10 @@ def get_OtherNameLib_kw_index(self, keywordrecord): return l, kw_list, arg_list, object_name, table_name def get_test_a_kw_index(self, keywordrecord): - kw_list = [u'Test A Keyword', u'Keyword'] + kw_list = ['Test A Keyword', 'Keyword'] arg_list = [None, None] table_name = self.test_a_table_name - object_name = u'test_a.robot' + object_name = 'test_a.robot' l = [] for kw, arg in zip(kw_list, arg_list): l.append( @@ -647,15 +647,15 @@ def get_test_a_kw_index(self, keywordrecord): def get_test_b_kw_index(self, keywordrecord): kw_list = [] table_name = self.test_b_table_name - object_name = u'test_a.robot' + object_name = 'test_a.robot' l = [] return l, kw_list, [None], object_name, table_name def get_resource_a_kw_index(self, keywordrecord): - kw_list = [u'Resource A Keyword 1', u'resource A Keyword 2'] + kw_list = ['Resource A Keyword 1', 'resource A Keyword 2'] arg_list = ['kwa1', None] table_name = self.resource_a_table_name - object_name = u'resource_a.robot' + object_name = 'resource_a.robot' l = [] for kw, arg in zip(kw_list, arg_list): l.append( @@ -671,13 +671,13 @@ def get_resource_a_kw_index(self, keywordrecord): def get_resource_b_kw_index(self, keywordrecord): kw_list = [ - u'Resource B Keyword 1', - u'resource B Keyword 2', - u'Embedding ${arg} To Keyword Name', - u'Resource B Keyword 3 Many Args'] + 'Resource B Keyword 1', + 'resource B Keyword 2', + 'Embedding ${arg} To Keyword Name', + 'Resource B Keyword 3 Many Args'] arg_list = ['kwb1', None, 'arg', ['arg1', 'arg2', 'arg3']] table_name = self.resource_b_table_name - object_name = u'resource_b.robot' + object_name = 'resource_b.robot' l = [] for kw, arg in zip(kw_list, arg_list): l.append( @@ -693,12 +693,12 @@ def get_resource_b_kw_index(self, keywordrecord): def get_common_kw_index(self, keywordrecord): kw_list = [ - u'Common Keyword 2', - u'common Keyword 1', - u'Really Long Keyword To Test With Jumping To Keyword Does Not Scroll The Visible Area To A Wrong Place Should There Be More Words' + 'Common Keyword 2', + 'common Keyword 1', + 'Really Long Keyword To Test With Jumping To Keyword Does Not Scroll The Visible Area To A Wrong Place Should There Be More Words' ] table_name = self.common_table_name - object_name = u'common.robot' + object_name = 'common.robot' l = [] for kw in kw_list: l.append( @@ -715,7 +715,7 @@ def get_common_kw_index(self, keywordrecord): def get_kw_args(self, data): arg_list = [] kws = data["keywords"] - for i in kws.iterkeys(): + for i in kws.keys(): args = kws[i]['keyword_arguments'] for arg in args: if '=' in arg: diff --git a/test/unit/test_jump_to_file.py b/test/unit/test_jump_to_file.py index 100e735..8ec0d9e 100644 --- a/test/unit/test_jump_to_file.py +++ b/test/unit/test_jump_to_file.py @@ -2,7 +2,7 @@ import shutil import unittest -from index_runner import index_all +from .index_runner import index_all from jump_to_file import JumpToFile from queue.scanner import Scanner import env diff --git a/test/unit/test_runner_for_index.py b/test/unit/test_runner_for_index.py index 4fc6e0f..7ce1f09 100644 --- a/test/unit/test_runner_for_index.py +++ b/test/unit/test_runner_for_index.py @@ -5,7 +5,7 @@ import re from time import sleep from queue.scanner import Scanner -from test_runner_for_scanner import run_process +from .test_runner_for_scanner import run_process class TestRunner(unittest.TestCase): diff --git a/test/unit/test_scanner.py b/test/unit/test_scanner.py index 1da7aaa..1537979 100644 --- a/test/unit/test_scanner.py +++ b/test/unit/test_scanner.py @@ -90,11 +90,11 @@ def test_queue_populated(self): ) def test_add_libraries_queue(self): - libs = [{'library_name': u'OperatingSystem', + libs = [{'library_name': 'OperatingSystem', 'library_alias': None, 'library_arguments': None, 'library_path': None}, - {'library_name': u'Process', + {'library_name': 'Process', 'library_alias': None, 'library_arguments': None, 'library_path': None}] From ddba4bce8a63b0c559b0de736125bfb84bfe0e01 Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Tue, 12 Feb 2019 19:35:52 +0700 Subject: [PATCH 02/22] rename queue to data_queue to avoid import issue in multiprocessor package --- dataparser/{queue => data_queue}/__init__.py | 0 dataparser/{queue => data_queue}/finder.py | 0 dataparser/{queue => data_queue}/queue.py | 0 dataparser/{queue => data_queue}/scanner.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename dataparser/{queue => data_queue}/__init__.py (100%) rename dataparser/{queue => data_queue}/finder.py (100%) rename dataparser/{queue => data_queue}/queue.py (100%) rename dataparser/{queue => data_queue}/scanner.py (100%) diff --git a/dataparser/queue/__init__.py b/dataparser/data_queue/__init__.py similarity index 100% rename from dataparser/queue/__init__.py rename to dataparser/data_queue/__init__.py diff --git a/dataparser/queue/finder.py b/dataparser/data_queue/finder.py similarity index 100% rename from dataparser/queue/finder.py rename to dataparser/data_queue/finder.py diff --git a/dataparser/queue/queue.py b/dataparser/data_queue/queue.py similarity index 100% rename from dataparser/queue/queue.py rename to dataparser/data_queue/queue.py diff --git a/dataparser/queue/scanner.py b/dataparser/data_queue/scanner.py similarity index 100% rename from dataparser/queue/scanner.py rename to dataparser/data_queue/scanner.py From 69401f2ab5e5876a707af30d34496f62cb10d430 Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Tue, 12 Feb 2019 19:38:51 +0700 Subject: [PATCH 03/22] fix import issue and md5 for py3 --- dataparser/index/index.py | 4 ++-- dataparser/parser_utils/file_formatter.py | 4 ++-- dataparser/run_index.py | 4 ++-- dataparser/run_scanner.py | 2 +- test/unit/test_get_documentation.py | 2 +- test/unit/test_get_keyword_from_library.py | 2 +- test/unit/test_get_keyword_from_resource.py | 2 +- test/unit/test_indexkw.py | 4 ++-- test/unit/test_jump_to_file.py | 2 +- test/unit/test_queue.py | 2 +- test/unit/test_runner_for_index.py | 2 +- test/unit/test_scanner.py | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dataparser/index/index.py b/dataparser/index/index.py index 26b8cf8..5e8018e 100644 --- a/dataparser/index/index.py +++ b/dataparser/index/index.py @@ -8,10 +8,10 @@ from collections import namedtuple from parser_utils.file_formatter import rf_table_name, lib_table_name from parser_utils.util import get_index_name -from queue.queue import ParsingQueue +from data_queue.queue import ParsingQueue from data_parser.data_parser import DataParser from db_json_settings import DBJsonSetting -from queue.finder import finder +from data_queue.finder import finder logging.basicConfig( format='%(levelname)s:%(asctime)s: %(message)s', diff --git a/dataparser/parser_utils/file_formatter.py b/dataparser/parser_utils/file_formatter.py index 0a4c745..5fef7b9 100644 --- a/dataparser/parser_utils/file_formatter.py +++ b/dataparser/parser_utils/file_formatter.py @@ -12,6 +12,6 @@ def rf_table_name(f_path): def lib_table_name(library): return '{realname}-{md5}.json'.format( - realname=library[-100:].decode('ascii'), - md5=md5(library).hexdigest() + realname=library[-100:], + md5=md5(library.encode()).hexdigest() ) diff --git a/dataparser/run_index.py b/dataparser/run_index.py index 1b4fb0c..a87b9fe 100644 --- a/dataparser/run_index.py +++ b/dataparser/run_index.py @@ -8,8 +8,8 @@ SETTING_DIR = path.join(ROOT_DIR, '..', 'setting') sys.path.append(SETTING_DIR) -from .index.index import index_a_table -from .index.index import Index +from index.index import index_a_table +from index.index import Index def index_all(db_path, index_path, module_search_path, libs_in_xml): diff --git a/dataparser/run_scanner.py b/dataparser/run_scanner.py index 8f08d12..f027513 100644 --- a/dataparser/run_scanner.py +++ b/dataparser/run_scanner.py @@ -6,7 +6,7 @@ SETTING_DIR = path.join(ROOT_DIR, '..', 'setting') sys.path.append(SETTING_DIR) -from .queue.scanner import Scanner +from data_queue.scanner import Scanner def scan_all(workspace, extension, db_path, diff --git a/test/unit/test_get_documentation.py b/test/unit/test_get_documentation.py index 5fa4cad..645d3a1 100644 --- a/test/unit/test_get_documentation.py +++ b/test/unit/test_get_documentation.py @@ -3,7 +3,7 @@ import shutil from os import path, makedirs from .index_runner import index_all -from queue.scanner import Scanner +from data_queue.scanner import Scanner from parser_utils.file_formatter import rf_table_name, lib_table_name from get_documentation import GetKeywordDocumentation diff --git a/test/unit/test_get_keyword_from_library.py b/test/unit/test_get_keyword_from_library.py index bfaf82f..d609e41 100644 --- a/test/unit/test_get_keyword_from_library.py +++ b/test/unit/test_get_keyword_from_library.py @@ -4,7 +4,7 @@ import platform from os import path, mkdir from .index_runner import index_all -from queue.scanner import Scanner +from data_queue.scanner import Scanner from get_keyword import GetKeyword diff --git a/test/unit/test_get_keyword_from_resource.py b/test/unit/test_get_keyword_from_resource.py index 0f88dd6..f8fd6e0 100644 --- a/test/unit/test_get_keyword_from_resource.py +++ b/test/unit/test_get_keyword_from_resource.py @@ -3,7 +3,7 @@ import shutil from os import path, mkdir from .index_runner import index_all -from queue.scanner import Scanner +from data_queue.scanner import Scanner from parser_utils.file_formatter import rf_table_name from get_keyword import GetKeyword diff --git a/test/unit/test_indexkw.py b/test/unit/test_indexkw.py index fc1abea..d8710d9 100644 --- a/test/unit/test_indexkw.py +++ b/test/unit/test_indexkw.py @@ -5,8 +5,8 @@ import json from time import sleep from collections import namedtuple -from queue.scanner import Scanner -from queue.scanner import rf_table_name, lib_table_name +from data_queue.scanner import Scanner +from data_queue.scanner import rf_table_name, lib_table_name from index.index import Index diff --git a/test/unit/test_jump_to_file.py b/test/unit/test_jump_to_file.py index 8ec0d9e..e63a6ba 100644 --- a/test/unit/test_jump_to_file.py +++ b/test/unit/test_jump_to_file.py @@ -4,7 +4,7 @@ from .index_runner import index_all from jump_to_file import JumpToFile -from queue.scanner import Scanner +from data_queue.scanner import Scanner import env diff --git a/test/unit/test_queue.py b/test/unit/test_queue.py index 6f98264..d07b3bb 100644 --- a/test/unit/test_queue.py +++ b/test/unit/test_queue.py @@ -1,6 +1,6 @@ import unittest from collections import OrderedDict -from queue.queue import ParsingQueue +from data_queue.queue import ParsingQueue class TestLibraryParsingQueue(unittest.TestCase): diff --git a/test/unit/test_runner_for_index.py b/test/unit/test_runner_for_index.py index 7ce1f09..bde7710 100644 --- a/test/unit/test_runner_for_index.py +++ b/test/unit/test_runner_for_index.py @@ -4,7 +4,7 @@ import shutil import re from time import sleep -from queue.scanner import Scanner +from data_queue.scanner import Scanner from .test_runner_for_scanner import run_process diff --git a/test/unit/test_scanner.py b/test/unit/test_scanner.py index 1537979..63bfa14 100644 --- a/test/unit/test_scanner.py +++ b/test/unit/test_scanner.py @@ -5,7 +5,7 @@ import hashlib from time import sleep import json -from queue.scanner import Scanner +from data_queue.scanner import Scanner class TestScanner(unittest.TestCase): From c27a39e3e9ec9009ff67f4df80438ef4a448170b Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Tue, 12 Feb 2019 19:52:57 +0700 Subject: [PATCH 04/22] fix typo for resource2 --- .../real_suite/resource/resource1/real_suite_resource.robot | 2 +- .../resource/{reosurce2 => resource2}/real_suite_resource.robot | 0 test/resource/test_data/real_suite/test/real_suite.robot | 2 +- test/unit/test_scanner.py | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename test/resource/test_data/real_suite/resource/{reosurce2 => resource2}/real_suite_resource.robot (100%) diff --git a/test/resource/test_data/real_suite/resource/resource1/real_suite_resource.robot b/test/resource/test_data/real_suite/resource/resource1/real_suite_resource.robot index dca47bb..2816dfe 100644 --- a/test/resource/test_data/real_suite/resource/resource1/real_suite_resource.robot +++ b/test/resource/test_data/real_suite/resource/resource1/real_suite_resource.robot @@ -1,7 +1,7 @@ *** Settings *** Library ../../libs/SuiteLib.py 2 Library Process -Resource ../../reosurce2/real_suite_resource.robot +Resource ../../resource2/real_suite_resource.robot Variables ../var_file/variables.py some_arg *** Variables *** diff --git a/test/resource/test_data/real_suite/resource/reosurce2/real_suite_resource.robot b/test/resource/test_data/real_suite/resource/resource2/real_suite_resource.robot similarity index 100% rename from test/resource/test_data/real_suite/resource/reosurce2/real_suite_resource.robot rename to test/resource/test_data/real_suite/resource/resource2/real_suite_resource.robot diff --git a/test/resource/test_data/real_suite/test/real_suite.robot b/test/resource/test_data/real_suite/test/real_suite.robot index 4dbd97d..24873fd 100644 --- a/test/resource/test_data/real_suite/test/real_suite.robot +++ b/test/resource/test_data/real_suite/test/real_suite.robot @@ -1,6 +1,6 @@ *** Settings *** Resource ../resource/resource1/real_suite_resource.robot -Resource ../resource/reosurce2/real_suite_resource.robot +Resource ../resource/resource2/real_suite_resource.robot Test Setup Real Suite User Keyword 3 *** Test Cases *** diff --git a/test/unit/test_scanner.py b/test/unit/test_scanner.py index 63bfa14..5e86c8b 100644 --- a/test/unit/test_scanner.py +++ b/test/unit/test_scanner.py @@ -80,7 +80,7 @@ def test_queue_populated(self): key = os.path.join( self.real_suite, 'resource', - 'reosurce2', + 'resource2', 'real_suite_resource.robot' ) key = os.path.normcase(key) From e6052303dc1a28c853c444ac6d93785b5367d637 Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Tue, 12 Feb 2019 19:53:43 +0700 Subject: [PATCH 05/22] ignore *.json --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 653bb9d..8c9d0a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.pyc test/results/* -*.log \ No newline at end of file +*.log +*.json From 324ca41de5e9e8d727748b53430f24ecf89534f1 Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Tue, 12 Feb 2019 20:11:53 +0700 Subject: [PATCH 06/22] fix md5 has for py3 --- test/unit/test_scanner.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/unit/test_scanner.py b/test/unit/test_scanner.py index 5e86c8b..cca3594 100644 --- a/test/unit/test_scanner.py +++ b/test/unit/test_scanner.py @@ -220,13 +220,13 @@ def test_parse_suite_structure(self): files = os.listdir(self.db_dir) builtin = '{0}-{1}.json'.format( 'BuiltIn', - hashlib.md5('BuiltIn').hexdigest()) + hashlib.md5('BuiltIn'.encode()).hexdigest()) self.assertTrue(builtin in files) init = '{0}-{1}.json'.format( '__init__.robot', hashlib.md5( os.path.normcase( - os.path.join(workspace, '__init__.robot'))).hexdigest() + os.path.join(workspace, '__init__.robot')).encode()).hexdigest() ) self.assertTrue(init in files) suite = '{0}-{1}.json'.format( @@ -234,16 +234,16 @@ def test_parse_suite_structure(self): hashlib.md5( os.path.normcase( os.path.join( - workspace, 'test_with_libs.robot'))).hexdigest() + workspace, 'test_with_libs.robot')).encode()).hexdigest() ) self.assertTrue(suite in files) operatingsystem = '{0}-{1}.json'.format( 'OperatingSystem', - hashlib.md5('OperatingSystem').hexdigest()) + hashlib.md5('OperatingSystem'.encode()).hexdigest()) self.assertTrue(operatingsystem in files) operatingsystem = '{0}-{1}.json'.format( 'Process', - hashlib.md5('Process').hexdigest()) + hashlib.md5('Process'.encode()).hexdigest()) self.assertTrue(operatingsystem in files) self.assertEqual(len(files), 6) @@ -258,11 +258,11 @@ def test_parse_real_suite(self): files = os.listdir(self.db_dir) builtin = '{0}-{1}.json'.format( 'BuiltIn', - hashlib.md5('BuiltIn').hexdigest()) + hashlib.md5('BuiltIn'.encode()).hexdigest()) self.assertTrue(builtin in files) operatingsystem = '{0}-{1}.json'.format( 'OperatingSystem', - hashlib.md5('OperatingSystem').hexdigest()) + hashlib.md5('OperatingSystem'.encode()).hexdigest()) self.assertTrue(operatingsystem in files) self.assertEqual(len(files), 14) @@ -336,6 +336,6 @@ def add_test_data(self): def f_name(self, data, db_dir): file_name = '{realname}-{md5}.json'.format( realname=os.path.basename(data['file_path']), - md5=hashlib.md5(data['file_path']).hexdigest() + md5=hashlib.md5(data['file_path'].encode()).hexdigest() ) return os.path.join(db_dir, file_name) From 711fd7b5660e9aabf25d920b26c722002fefe1ca Mon Sep 17 00:00:00 2001 From: tanakiat Date: Tue, 12 Feb 2019 23:08:19 +0700 Subject: [PATCH 07/22] use SeleniumLibrary instead of Selenium2Library --- .travis.yml | 2 +- test/acceptance/library_parser.robot | 4 ++-- test/acceptance/variable_files/library_vars.py | 2 +- test/acceptance/variable_files/suite_parser_vars.py | 4 ++-- .../test_data/real_suite/libs/com/company/library.py | 2 +- .../resource/resource2/real_suite_resource.robot | 2 +- test/resource/test_data/simple_resource.robot | 2 +- test/resource/test_data/simple_test.robot | 2 +- test/resource/test_data/suite_tree/common.robot | 2 +- test/unit/test_completions.py | 4 ++-- test/unit/test_get_keyword_from_library.py | 6 +++--- test/unit/test_get_text.py | 8 ++++---- test/unit/test_indexkw.py | 6 +++--- test/unit/test_jump_to_file.py | 6 +++--- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 459410d..6290051 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,6 @@ python: - "2.7" install: - pip install robotframework - - pip install robotframework-selenium2library==1.8.0 + - pip install robotframework-seleniumlibrary==3.3.1 script: - "python test/run_test.py" diff --git a/test/acceptance/library_parser.robot b/test/acceptance/library_parser.robot index 7ecb74f..ab011c4 100644 --- a/test/acceptance/library_parser.robot +++ b/test/acceptance/library_parser.robot @@ -15,11 +15,11 @@ Parser Should Be Able To Parse Internal Library Parser Should Be Able To Parse External Library From Python Path ${result} = Parse Library - ... Selenium2Library + ... SeleniumLibrary ${result_keys} = Get Dictionary Keys ${result} Lists Should Be Equal ... ${result_keys} - ... ${SELENIUM2LIBRARY_KEYS_LIST} + ... ${SELENIUMLIBRARY_KEYS_LIST} ${keywords} = Get From Dictionary ... ${result} ... keywords diff --git a/test/acceptance/variable_files/library_vars.py b/test/acceptance/variable_files/library_vars.py index 3c22e50..8875a85 100644 --- a/test/acceptance/variable_files/library_vars.py +++ b/test/acceptance/variable_files/library_vars.py @@ -13,7 +13,7 @@ def get_variables(): var['MYLIBRARY_KW'] = get_mylibrary(resource_dir) var['OTHERMYLIBRARY_KW'] = get_othermylibrary(resource_dir) var['MYLIBRARY_XML'] = get_mylibrary_xml(var['MYLIBRARY_KW']) - var['SELENIUM2LIBRARY_KEYS_LIST'] = ['arguments', + var['SELENIUMLIBRARY_KEYS_LIST'] = ['arguments', 'keywords', 'library_module'] var['ADDCOOKIE_KEYS_LILST'] = ['keyword_name', diff --git a/test/acceptance/variable_files/suite_parser_vars.py b/test/acceptance/variable_files/suite_parser_vars.py index 0b6820f..52f3249 100644 --- a/test/acceptance/variable_files/suite_parser_vars.py +++ b/test/acceptance/variable_files/suite_parser_vars.py @@ -33,7 +33,7 @@ def create_simple_test(resource_dir): result['file_name'] = 'simple_test.robot' result['file_path'] = path.join(resource_dir, result['file_name']) result['libraries'] = [ - {'library_name': 'Selenium2Library', + {'library_name': 'SeleniumLibrary', 'library_alias': None, 'library_arguments': ['timeout=5.0', 'implicit_wait=0.0'], 'library_path': None} @@ -57,7 +57,7 @@ def create_simple_resource(resource_dir): result['file_path'] = path.join(resource_dir, result['file_name']) lib_path = path.abspath(path.join(resource_dir, '..', 'FooBar.py')) result['libraries'] = [ - {'library_name': 'Selenium2Library', + {'library_name': 'SeleniumLibrary', 'library_alias': None, 'library_arguments': ['timeout=5.0'], 'library_path': None}, diff --git a/test/resource/test_data/real_suite/libs/com/company/library.py b/test/resource/test_data/real_suite/libs/com/company/library.py index f511727..58bcd98 100644 --- a/test/resource/test_data/real_suite/libs/com/company/library.py +++ b/test/resource/test_data/real_suite/libs/com/company/library.py @@ -9,4 +9,4 @@ def company_keyword(self, arg): def company_keyword_2(self, args): print(args) - print(BuiltIn().get_library_instance('Selenium2Library')) + print(BuiltIn().get_library_instance('SeleniumLibrary')) diff --git a/test/resource/test_data/real_suite/resource/resource2/real_suite_resource.robot b/test/resource/test_data/real_suite/resource/resource2/real_suite_resource.robot index 55bdc9b..cfde927 100644 --- a/test/resource/test_data/real_suite/resource/resource2/real_suite_resource.robot +++ b/test/resource/test_data/real_suite/resource/resource2/real_suite_resource.robot @@ -1,7 +1,7 @@ *** Settings *** Library com.company.library.CompanyLibrary Library ../../libs/SuiteLib.py 1 -Library Selenium2Library timeout=15.0 run_on_failure=Real Suite User Keyword 4 +Library SeleniumLibrary timeout=15.0 run_on_failure=Real Suite User Keyword 4 *** Variables *** # Comment diff --git a/test/resource/test_data/simple_resource.robot b/test/resource/test_data/simple_resource.robot index 7ea6d6c..f9bc994 100644 --- a/test/resource/test_data/simple_resource.robot +++ b/test/resource/test_data/simple_resource.robot @@ -1,5 +1,5 @@ *** Settings *** -Library Selenium2Library timeout=5.0 +Library SeleniumLibrary timeout=5.0 Documentation foobar Resource simple_resrouce2.robot Variables simple_variable_file.py arg11 arg22 diff --git a/test/resource/test_data/simple_test.robot b/test/resource/test_data/simple_test.robot index 27f1ac2..0053bf4 100644 --- a/test/resource/test_data/simple_test.robot +++ b/test/resource/test_data/simple_test.robot @@ -1,5 +1,5 @@ *** Settings *** -Library Selenium2Library timeout=5.0 implicit_wait=0.0 +Library SeleniumLibrary timeout=5.0 implicit_wait=0.0 Documentation foobar Resource simple_resrouce2.robot Variables simple_variable_file.py arg11 arg22 diff --git a/test/resource/test_data/suite_tree/common.robot b/test/resource/test_data/suite_tree/common.robot index 6073c9b..55709f0 100644 --- a/test/resource/test_data/suite_tree/common.robot +++ b/test/resource/test_data/suite_tree/common.robot @@ -1,5 +1,5 @@ *** Settings *** -Library Selenium2Library timeout=5.0 run_on_failure=Common Keyword 1 +Library SeleniumLibrary timeout=5.0 run_on_failure=Common Keyword 1 Library LibraryWithReallyTooLongName.py WITH NAME LongName Variables common_variables.py one two diff --git a/test/unit/test_completions.py b/test/unit/test_completions.py index 97498cc..45a4645 100644 --- a/test/unit/test_completions.py +++ b/test/unit/test_completions.py @@ -156,7 +156,7 @@ def test_kw_create_completion_item(self): self.assertEqual(completion, expected) # kw not args kw = 'Unselect Frame' - lib = 'Selenium2Library' + lib = 'SeleniumLibrary' completion = create_kw_completion_item(kw, [], RF_CELL, lib, False) trigger = '{0}\t{1}'.format(kw, lib) expected = (trigger, kw) @@ -175,7 +175,7 @@ def test_kw_create_completion_item_sinlge_line(self): self.assertEqual(completion, expected) # kw not args kw = 'Unselect Frame' - lib = 'Selenium2Library' + lib = 'SeleniumLibrary' completion = create_kw_completion_item(kw, [], RF_CELL, lib, True) trigger = '{0}\t{1}'.format(kw, lib) expected = (trigger, kw) diff --git a/test/unit/test_get_keyword_from_library.py b/test/unit/test_get_keyword_from_library.py index d609e41..ce4ceb0 100644 --- a/test/unit/test_get_keyword_from_library.py +++ b/test/unit/test_get_keyword_from_library.py @@ -78,7 +78,7 @@ def test_get_lib_keyword_file(self): self.assertIn(self.s2l_press_key, kw_file) kw_file = self.get_kw.get_lib_keyword_file( self.s2l_table_file, - 'Selenium2Library', + 'SeleniumLibrary', 'PressKey' ) self.assertIn(self.s2l_press_key, kw_file) @@ -168,7 +168,7 @@ def s2l(self): if platform.system() == 'Windows': return 'selenium2library' else: - return 'Selenium2Library' + return 'SeleniumLibrary' @property def s2l_simulate(self): @@ -186,7 +186,7 @@ def s2l_textarea_value_should_be(self): def s2l_table_file(self): return path.join( self.db_dir, - 'Selenium2Library-ac72a5ed5dae4edc06e58114b7c0ce92.json' + 'SeleniumLibrary-ac72a5ed5dae4edc06e58114b7c0ce92.json' ) @property diff --git a/test/unit/test_get_text.py b/test/unit/test_get_text.py index ce4bc4f..031abdc 100644 --- a/test/unit/test_get_text.py +++ b/test/unit/test_get_text.py @@ -20,16 +20,16 @@ def test_object(self): def test_two_object_cursor_at_end(self): line = '{0}Run Keyword And Expect Error{1}no'.format( - ' BuiltIn.', ' Selenium2Library.') + ' BuiltIn.', ' SeleniumLibrary.') prefix = 'no' column = len(line) expected = get_object_from_line(line, prefix, column) - self.assertEqual(expected, 'Selenium2Library') + self.assertEqual(expected, 'SeleniumLibrary') def test_two_object_cursor_at_first(self): line = '{1}no{0}Run Keyword And Expect Error'.format( - ' BuiltIn.', ' Selenium2Library.') + ' BuiltIn.', ' SeleniumLibrary.') prefix = 'no' column = 23 expected = get_object_from_line(line, prefix, column) - self.assertEqual(expected, 'Selenium2Library') + self.assertEqual(expected, 'SeleniumLibrary') diff --git a/test/unit/test_indexkw.py b/test/unit/test_indexkw.py index d8710d9..de77e19 100644 --- a/test/unit/test_indexkw.py +++ b/test/unit/test_indexkw.py @@ -300,7 +300,7 @@ def test_get_object_name(self): object_name = self.index.get_object_name(self.get_os()) self.assertEqual(object_name, 'OperatingSystem') object_name = self.index.get_object_name(self.get_s2l()) - self.assertEqual(object_name, 'Selenium2Library') + self.assertEqual(object_name, 'SeleniumLibrary') def test_library_with_alias(self): data = self.index.create_index_for_table(self.db_dir, @@ -369,7 +369,7 @@ def resource_a_table_name(self): @property def s2l_table_name(self): - return lib_table_name('Selenium2Library') + return lib_table_name('SeleniumLibrary') @property def os_table_name(self): @@ -493,7 +493,7 @@ def get_s2l_kw_index(self, keywordrecord): s2l_data = self.get_s2l() kw_list = self.index.get_keywords(s2l_data)[0] arg_list = self.get_kw_args(s2l_data) - object_name = 'Selenium2Library' + object_name = 'SeleniumLibrary' table_name = self.s2l_table_name l = [] for kw, arg in zip(kw_list, arg_list): diff --git a/test/unit/test_jump_to_file.py b/test/unit/test_jump_to_file.py index e63a6ba..759d026 100644 --- a/test/unit/test_jump_to_file.py +++ b/test/unit/test_jump_to_file.py @@ -57,15 +57,15 @@ def test_is_resource(self): self.assertTrue(status) def test_is_library(self): - line = 'Library Selenium2Library' + line = 'Library SeleniumLibrary' status = self.jump.is_import(line) self.assertTrue(status) - line = '| Library | Selenium2Library |' + line = '| Library | SeleniumLibrary |' status = self.jump.is_import(line) self.assertTrue(status) - line = '| Library | Selenium2Library |' + line = '| Library | SeleniumLibrary |' status = self.jump.is_import(line) self.assertTrue(status) From 89a043c1e06facc0fe81579a65f7dcbde6772ecf Mon Sep 17 00:00:00 2001 From: tanakiat Date: Tue, 12 Feb 2019 23:47:22 +0700 Subject: [PATCH 08/22] Fix the failed unittest in case of using SeleniumLibrary instead of Selenium2Library --- test/unit/test_get_text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/test_get_text.py b/test/unit/test_get_text.py index 031abdc..eaacaa1 100644 --- a/test/unit/test_get_text.py +++ b/test/unit/test_get_text.py @@ -30,6 +30,6 @@ def test_two_object_cursor_at_first(self): line = '{1}no{0}Run Keyword And Expect Error'.format( ' BuiltIn.', ' SeleniumLibrary.') prefix = 'no' - column = 23 + column = 22 expected = get_object_from_line(line, prefix, column) self.assertEqual(expected, 'SeleniumLibrary') From f7910ae35cdd76fc4a2aa54a8779dc758bc979f1 Mon Sep 17 00:00:00 2001 From: tanakiat Date: Tue, 12 Feb 2019 23:47:47 +0700 Subject: [PATCH 09/22] write unittest errors&failures to file for easier investigation --- test/run_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/run_test.py b/test/run_test.py index 53a05f0..d3cb9f6 100644 --- a/test/run_test.py +++ b/test/run_test.py @@ -72,8 +72,10 @@ def _exit(rc): a_result = acceptance_test(sys.argv[1:]) if u_result.errors or u_result.failures: print('Unit tests failed') - print('errors: ', u_result.errors) - print('failures: ', u_result.failures) + print('errors: {}'.format(u_result.errors), + file=open(os.path.join(env.RESULTS_DIR,"unittest_erros.log"), "a")) + print('failures: {}'.format(u_result.failures), + file=open(os.path.join(env.RESULTS_DIR,"unittest_failures.log"), "a")) _exit(u_result.errors) elif a_result != 0: print('Acceptance tests failed') From 15701c862e167daaba4a099a2d1646b28d219543 Mon Sep 17 00:00:00 2001 From: tanakiat Date: Wed, 13 Feb 2019 00:20:41 +0700 Subject: [PATCH 10/22] fix import --- command_helper/completions.py | 2 +- command_helper/get_documentation.py | 4 ++-- command_helper/get_keyword.py | 6 +++--- command_helper/jump_to_file.py | 2 +- command_helper/noralize_cell.py | 2 +- test/unit/test_get_documentation.py | 2 +- test/unit/test_get_keyword_from_library.py | 2 +- test/unit/test_get_keyword_from_resource.py | 2 +- test/unit/test_jump_to_file.py | 2 +- test/unit/test_runner_for_index.py | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/command_helper/completions.py b/command_helper/completions.py index 9a6eb0f..7cd1b21 100644 --- a/command_helper/completions.py +++ b/command_helper/completions.py @@ -3,7 +3,7 @@ from json import load as json_load try: from db_json_settings import DBJsonSetting - from .utils.get_text import get_prefix + from utils.get_text import get_prefix except: from ..setting.db_json_settings import DBJsonSetting from ..command_helper.utils.get_text import get_prefix diff --git a/command_helper/get_documentation.py b/command_helper/get_documentation.py index 8cceb7b..4ea2e05 100644 --- a/command_helper/get_documentation.py +++ b/command_helper/get_documentation.py @@ -3,9 +3,9 @@ try: from parser_utils.file_formatter import rf_table_name from parser_utils.util import get_index_name, normalise_path - from .noralize_cell import get_data_from_json + from noralize_cell import get_data_from_json from db_json_settings import DBJsonSetting - from .utils.util import kw_equals_kw_candite + from utils.util import kw_equals_kw_candite except: from ..dataparser.parser_utils.file_formatter import rf_table_name from ..dataparser.parser_utils.util import get_index_name, normalise_path diff --git a/command_helper/get_keyword.py b/command_helper/get_keyword.py index c21c37d..bf9cf20 100644 --- a/command_helper/get_keyword.py +++ b/command_helper/get_keyword.py @@ -2,10 +2,10 @@ from os import path from sys import version_info try: - from .get_documentation import GetKeywordDocumentation + from get_documentation import GetKeywordDocumentation from db_json_settings import DBJsonSetting - from .noralize_cell import get_data_from_json - from .utils.util import kw_equals_kw_candite + from noralize_cell import get_data_from_json + from utils.util import kw_equals_kw_candite except: from .get_documentation import GetKeywordDocumentation from ..setting.db_json_settings import DBJsonSetting diff --git a/command_helper/jump_to_file.py b/command_helper/jump_to_file.py index 146f0be..f0e3566 100644 --- a/command_helper/jump_to_file.py +++ b/command_helper/jump_to_file.py @@ -3,7 +3,7 @@ try: from parser_utils.file_formatter import lib_table_name - from .noralize_cell import get_data_from_json + from noralize_cell import get_data_from_json except ImportError: from ..dataparser.parser_utils.file_formatter import lib_table_name from .noralize_cell import get_data_from_json diff --git a/command_helper/noralize_cell.py b/command_helper/noralize_cell.py index 3af3c91..c5a6fa1 100644 --- a/command_helper/noralize_cell.py +++ b/command_helper/noralize_cell.py @@ -1,7 +1,7 @@ import re import collections try: - from .utils.util import get_data_from_json, kw_equals_kw_candite + from utils.util import get_data_from_json, kw_equals_kw_candite from db_json_settings import DBJsonSetting except: from .utils.util import get_data_from_json, kw_equals_kw_candite diff --git a/test/unit/test_get_documentation.py b/test/unit/test_get_documentation.py index 645d3a1..eb4ba55 100644 --- a/test/unit/test_get_documentation.py +++ b/test/unit/test_get_documentation.py @@ -2,7 +2,7 @@ import env import shutil from os import path, makedirs -from .index_runner import index_all +from index_runner import index_all from data_queue.scanner import Scanner from parser_utils.file_formatter import rf_table_name, lib_table_name from get_documentation import GetKeywordDocumentation diff --git a/test/unit/test_get_keyword_from_library.py b/test/unit/test_get_keyword_from_library.py index ce4ceb0..ce30be7 100644 --- a/test/unit/test_get_keyword_from_library.py +++ b/test/unit/test_get_keyword_from_library.py @@ -3,7 +3,7 @@ import shutil import platform from os import path, mkdir -from .index_runner import index_all +from index_runner import index_all from data_queue.scanner import Scanner from get_keyword import GetKeyword diff --git a/test/unit/test_get_keyword_from_resource.py b/test/unit/test_get_keyword_from_resource.py index f8fd6e0..7225e84 100644 --- a/test/unit/test_get_keyword_from_resource.py +++ b/test/unit/test_get_keyword_from_resource.py @@ -2,7 +2,7 @@ import env import shutil from os import path, mkdir -from .index_runner import index_all +from index_runner import index_all from data_queue.scanner import Scanner from parser_utils.file_formatter import rf_table_name from get_keyword import GetKeyword diff --git a/test/unit/test_jump_to_file.py b/test/unit/test_jump_to_file.py index 759d026..3c5bd1a 100644 --- a/test/unit/test_jump_to_file.py +++ b/test/unit/test_jump_to_file.py @@ -2,7 +2,7 @@ import shutil import unittest -from .index_runner import index_all +from index_runner import index_all from jump_to_file import JumpToFile from data_queue.scanner import Scanner import env diff --git a/test/unit/test_runner_for_index.py b/test/unit/test_runner_for_index.py index bde7710..711e9ae 100644 --- a/test/unit/test_runner_for_index.py +++ b/test/unit/test_runner_for_index.py @@ -5,7 +5,7 @@ import re from time import sleep from data_queue.scanner import Scanner -from .test_runner_for_scanner import run_process +from test_runner_for_scanner import run_process class TestRunner(unittest.TestCase): From 205d3ce4777e7ff9d5798bdffe61f781c445c60f Mon Sep 17 00:00:00 2001 From: tanakiat Date: Thu, 14 Feb 2019 01:09:06 +0700 Subject: [PATCH 11/22] fix py2 behavior in py3 and update to use SeleniumLibrary instead --- command_helper/jump_to_file.py | 3 +-- command_helper/utils/util.py | 2 +- dataparser/parser_utils/file_formatter.py | 3 ++- test/unit/test_get_keyword_from_library.py | 12 +++++------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/command_helper/jump_to_file.py b/command_helper/jump_to_file.py index f0e3566..abec6f1 100644 --- a/command_helper/jump_to_file.py +++ b/command_helper/jump_to_file.py @@ -34,8 +34,7 @@ def get_library_path(self, imported_lib, open_tab, db_dir): imported_file=imported_lib, open_tab=open_tab ) else: - imported_lib_utf8 = imported_lib.encode('utf-8') - file_name = lib_table_name(imported_lib_utf8) + file_name = lib_table_name(imported_lib) file_name = str(file_name) file_path = os.path.join(db_dir, file_name) data = get_data_from_json(file_path) diff --git a/command_helper/utils/util.py b/command_helper/utils/util.py index f6d1c7e..c39f506 100644 --- a/command_helper/utils/util.py +++ b/command_helper/utils/util.py @@ -12,7 +12,7 @@ def get_data_from_json(json_file): def _keyword_with_embedded_arg(kw, kw_candite): kw = kw.lower().replace(' ', '').replace('_', '') kw_candite = kw_candite.lower().replace(' ', '').replace('_', '') - kw_re = re.sub(r'(?i)(\$\{[\w ]*\})', r'(?i)(\S+)', kw_candite) + kw_re = re.sub(r'(?i)(\$\{[\w ]*\})', r'(?i)(\\S+)', kw_candite) return re.search(kw_re, kw) diff --git a/dataparser/parser_utils/file_formatter.py b/dataparser/parser_utils/file_formatter.py index 5fef7b9..a9d7c55 100644 --- a/dataparser/parser_utils/file_formatter.py +++ b/dataparser/parser_utils/file_formatter.py @@ -13,5 +13,6 @@ def rf_table_name(f_path): def lib_table_name(library): return '{realname}-{md5}.json'.format( realname=library[-100:], - md5=md5(library.encode()).hexdigest() + md5=md5(library.encode() if isinstance(library, str) + else library).hexdigest() ) diff --git a/test/unit/test_get_keyword_from_library.py b/test/unit/test_get_keyword_from_library.py index ce30be7..3b09a44 100644 --- a/test/unit/test_get_keyword_from_library.py +++ b/test/unit/test_get_keyword_from_library.py @@ -52,16 +52,17 @@ def test_get_lib_kw(self): regex, file_path = self.get_kw.get_lib_keyword( self.s2l_table_file, None, - 'Simulate' + 'Simulate Event' ) self.assertIsNotNone(regex) + import pdb; pdb.set_trace() # breakpoint d4f66d13 // self.assertIsNotNone(file_path) def test_get_lib_keyword_file(self): kw_file = self.get_kw.get_lib_keyword_file( self.s2l_table_file, None, - 'Simulate' + 'Simulate Event' ) self.assertIn(self.s2l_simulate, kw_file) kw_file = self.get_kw.get_lib_keyword_file( @@ -165,10 +166,7 @@ def test_keyword_lib_with_alias(self): @property def s2l(self): - if platform.system() == 'Windows': - return 'selenium2library' - else: - return 'SeleniumLibrary' + return 'SeleniumLibrary' @property def s2l_simulate(self): @@ -186,7 +184,7 @@ def s2l_textarea_value_should_be(self): def s2l_table_file(self): return path.join( self.db_dir, - 'SeleniumLibrary-ac72a5ed5dae4edc06e58114b7c0ce92.json' + 'SeleniumLibrary-ed5a6b78e6f238da896f2d5aad33b8b8.json' ) @property From 7f4d0e89f089281a28b09f314a9188af5cb1826b Mon Sep 17 00:00:00 2001 From: tanakiat Date: Thu, 14 Feb 2019 01:29:00 +0700 Subject: [PATCH 12/22] handle byte check for md5hash --- dataparser/parser_utils/file_formatter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataparser/parser_utils/file_formatter.py b/dataparser/parser_utils/file_formatter.py index a9d7c55..7c24349 100644 --- a/dataparser/parser_utils/file_formatter.py +++ b/dataparser/parser_utils/file_formatter.py @@ -3,7 +3,7 @@ def rf_table_name(f_path): - md5sum = md5(f_path.encode('utf-8')).hexdigest() + md5sum = md5(f_path.encode('utf-8') if isinstance(f_path, str) else f_path).hexdigest() return '{realname}-{md5}.json'.format( realname=path.basename(f_path)[-100:], md5=md5sum From be38fd7c2379aa39a784e812c5d4fbd5c940fd09 Mon Sep 17 00:00:00 2001 From: tanakiat Date: Sun, 17 Feb 2019 00:15:40 +0700 Subject: [PATCH 13/22] PY3 support with changes to support new RBFW and SeleniumLibrary by @aaltat --- .../{simple_resrouce2.robot => simple_resource2.robot} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename test/resource/test_data/{simple_resrouce2.robot => simple_resource2.robot} (94%) diff --git a/test/resource/test_data/simple_resrouce2.robot b/test/resource/test_data/simple_resource2.robot similarity index 94% rename from test/resource/test_data/simple_resrouce2.robot rename to test/resource/test_data/simple_resource2.robot index 88b3818..8990f2c 100644 --- a/test/resource/test_data/simple_resrouce2.robot +++ b/test/resource/test_data/simple_resource2.robot @@ -1,3 +1,3 @@ -*** Keywords *** -Other Rerouce Kw - Log 1 +*** Keywords *** +Other Rerouce Kw + Log 1 From bd86244e955184a0b1e43b54213e5c05b2556f4f Mon Sep 17 00:00:00 2001 From: tanakiat Date: Sun, 17 Feb 2019 00:17:03 +0700 Subject: [PATCH 14/22] add missing files :p --- .travis.yml | 16 +++-- README.md | 12 ++-- Robot.py | 3 +- Robot.sublime-settings | 2 +- commands/query_completions.py | 1 + commands/scan_open_tab.py | 4 +- dataparser/data_parser/data_parser.py | 67 +++++++++++++------ dataparser/data_queue/scanner.py | 10 +-- dataparser/index/index.py | 2 +- dataparser/parser_utils/file_formatter.py | 3 +- dataparser/parser_utils/util.py | 4 +- messages/st3-6.3.2.txt | 2 + setting/db_json_settings.py | 3 + setting/setting.py | 2 +- test/acceptance/library_parser.robot | 17 +++-- .../acceptance/variable_files/library_vars.py | 18 ++--- .../variable_files/suite_parser_vars.py | 15 +++-- test/resource/test_data/simple_resource.robot | 2 +- test/resource/test_data/simple_test.robot | 2 +- test/run_test.py | 11 ++- test/unit/test_get_documentation.py | 8 +-- test/unit/test_get_keyword_from_library.py | 11 ++- test/unit/test_get_keyword_from_resource.py | 10 +-- test/unit/test_indexkw.py | 14 ++-- test/unit/test_scanner.py | 8 +-- 25 files changed, 150 insertions(+), 97 deletions(-) create mode 100644 messages/st3-6.3.2.txt diff --git a/.travis.yml b/.travis.yml index 6290051..65eab02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,16 @@ language: python -python: - - "2.7" +matrix: + include: + - python: "3.6" + env: + - INTERPRETER=python3 + - python: "3.4" + env: + - INTERPRETER=python3 + install: - - pip install robotframework + - pip install robotframework==3.1.1 - pip install robotframework-seleniumlibrary==3.3.1 script: -- "python test/run_test.py" + - "$INTERPRETER --version" + - "$INTERPRETER test/run_test.py" \ No newline at end of file diff --git a/README.md b/README.md index 587c9aa..00bdab8 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ Robot Framework Assistant provides IDE features to edit [Robot Framework](http://robotframework.org/) test data in the [Sublime Text 3](https://www.sublimetext.com/3). +> **FROM v6.3.2 ONWARDS, THIS PLUGIN WILL DROP PY2 SUPPORT DUE TO PY2 END OF LIFE IN THE EARLY OF 2020** + From release 3.0.0 onwards plugin is not anymore compatible with Sublime Text 2. The releases made before the 3.0.0 will serve the Sublime Text 2 users. The documentation for Sublime Text 2 user @@ -37,7 +39,7 @@ The default settings can be found from the **Preferences | Package settings** The only mandatory settings which user needs to define are the [robot_framework_workspace](https://github.com/andriyko/sublime-robot-framework-assistant#robot_framework_workspace) and the -[path_to_python](https://github.com/andriyko/sublime-robot-framework-assistant#path_to_python). +[path_to_python3](https://github.com/andriyko/sublime-robot-framework-assistant#path_to_python3). The rest of the parameters can be safely left in their default values, when trying out the plugin. @@ -71,13 +73,13 @@ definition in this plugin is not affected by this option. If there library or variable file imports in the Robot Framework data, those imports are automatically parser and included in the scanning. -## path_to_python +## path_to_python3 In order the creating the database of keywords and variables to -work, path to Python binary must be defined. It must be the same +work, path to Python3.x binary must be defined. It must be the same Python binary where the Robot Framework is installed. -In Linux like environments this could be like: /usr/bin/python -and in Windows this could be like: C:\\Python27\\python.exe +In Linux like environments this could be like: /usr/bin/python3 +and in Windows this could be like: C:\\Python3\\python3.exe ## robot_framework_module_search_path Module search path defines a list of paths where the Robot Framework diff --git a/Robot.py b/Robot.py index 9cdfb0a..bc54c8a 100644 --- a/Robot.py +++ b/Robot.py @@ -1,5 +1,6 @@ """ -Robot Framework from sublime is a autocompletion plugin for Sublime Text 3 +Robot Framework Assistant offers IDE features for editing Robot Framework test +data in Sublime Text 3. """ import sys import os diff --git a/Robot.sublime-settings b/Robot.sublime-settings index afd6d94..3c3a72a 100644 --- a/Robot.sublime-settings +++ b/Robot.sublime-settings @@ -74,7 +74,7 @@ and in Windows this could be like: C:\\Python27\\python.exe */ - "path_to_python": "/usr/bin/python", + "path_to_python3": "/usr/bin/python", /* Module search path defines a list of paths where the diff --git a/commands/query_completions.py b/commands/query_completions.py index eb3d364..2edbc9a 100644 --- a/commands/query_completions.py +++ b/commands/query_completions.py @@ -46,6 +46,7 @@ def return_completions(self, view, prefix, locations): # workspace = get_setting(SettingObject.workspace) open_tab = view.file_name() index_file = get_index_file(open_tab) + print(view, prefix, index_file) if index_file: return self.get_completions(view, prefix, index_file) else: diff --git a/commands/scan_open_tab.py b/commands/scan_open_tab.py index 98c4015..6ed5866 100644 --- a/commands/scan_open_tab.py +++ b/commands/scan_open_tab.py @@ -57,8 +57,8 @@ def run_single_scan(self, open_tab, log_file): def file_in_workspace(self, open_tab): workspace = get_setting(SettingObject.workspace) - workspace = path.normcase(workspace) - open_tab = path.normcase(open_tab) + workspace = path.normpath(workspace) + open_tab = path.normpath(open_tab) extension = get_setting(SettingObject.extension) if open_tab.endswith(extension): return open_tab.startswith(workspace) diff --git a/dataparser/data_parser/data_parser.py b/dataparser/data_parser/data_parser.py index e8455c5..9659678 100644 --- a/dataparser/data_parser/data_parser.py +++ b/dataparser/data_parser/data_parser.py @@ -46,7 +46,9 @@ def parse_resource(self, file_path): model = parsing.TestDataDirectory(source=folder).populate() else: model = parsing.ResourceFile(file_path).populate() - return self._parse_robot_data(file_path, model) + data = self._parse_robot_data(file_path, model) + data[DBJsonSetting.table_type] = DBJsonSetting.resource_file + return data else: logging.error('File %s could not be found', file_path) raise ValueError( @@ -56,7 +58,9 @@ def parse_suite(self, file_path): self.file_path = file_path if path.exists(file_path): model = parsing.TestCaseFile(source=file_path).populate() - return self._parse_robot_data(file_path, model) + data = self._parse_robot_data(file_path, model) + data[DBJsonSetting.table_type] = DBJsonSetting.suite + return data else: logging.error('File %s could not be found', file_path) raise ValueError( @@ -78,6 +82,7 @@ def parse_variable_file(self, file_path, args=None): for variable in variables: var_list.append(variable[0]) data[DBJsonSetting.variables] = sorted(var_list) + data[DBJsonSetting.table_type] = DBJsonSetting.variable_file return data def parse_library(self, library, args=None): @@ -116,6 +121,7 @@ def parse_library(self, library, args=None): if data[DBJsonSetting.keywords] is None: raise ValueError('Library did not contain keywords') else: + data[DBJsonSetting.table_type] = DBJsonSetting.library return data def register_console_logger(self): @@ -140,8 +146,10 @@ def _parse_python_lib(self, library, args): else: import_name = library importer = Importer('test library') + lib_args = self._argument_strip(lib, args) libcode = importer.import_class_or_module( - import_name, return_source=False) + import_name, instantiate_with_args=lib_args, + return_source=False) kw_with_deco = self._get_keywords_with_robot_name(libcode) for keyword in lib.keywords: kw = {} @@ -155,25 +163,41 @@ def _parse_python_lib(self, library, args): function_name = keyword.name kw[DBJsonSetting.keyword_file] = self._get_library_kw_source( libcode, function_name) + # if 'selenium' in str(libcode).lower(): + # import pdb; pdb.set_trace() # breakpoint 402cb44b // kws[strip_and_lower(keyword.name)] = kw return kws - def _get_keywords_with_robot_name(self, libcode): + def _argument_strip(self, lib, given_args): + formated_args = [] + if not given_args: + return formated_args + try: + default_args = lib.inits[0].args + except IndexError: + default_args = [] + for default_arg in default_args: + if '=' in default_arg: + default_parts = default_arg.split('=', 1) + formated_args.append(default_parts[1]) + else: + formated_args.append(default_arg) + return formated_args + + def _get_keywords_with_robot_name(self, lib_instance): """Returns keywords which uses Robot keyword decorator with robot_name - The keyword name can be chaned with Robot Framework keyword decorator - and by using the robot_name attribute. Return dictinionary which key is - the value of the robot_name attribute and the orinal function name. + The keyword name can be changed with Robot Framework keyword decorator + and by using the robot_name attribute. Return dictionary which key is + the value of the robot_name attribute and the original function name. """ kw_deco = {} - for key in libcode.__dict__: - if callable(libcode.__dict__[key]): - try: - if 'robot_name' in libcode.__dict__[key].__dict__: - kw = libcode.__dict__[key].__dict__['robot_name'] - kw_deco[kw] = key - except AttributeError: - pass + lib_class = type(lib_instance) + for name in dir(lib_instance): + owner = lib_class if hasattr(lib_class, name) else lib_instance + method_attrib = getattr(owner, name) + if hasattr(method_attrib, 'robot_name') and method_attrib.robot_name: + kw_deco[method_attrib.robot_name] = name return kw_deco def _get_library_kw_source(self, libcode, keyword): @@ -182,12 +206,15 @@ def _get_library_kw_source(self, libcode, keyword): func_file = None if hasattr(libcode, kw_func): func = getattr(libcode, kw_func) + else: + func_file, func = None, None if func: - kw_class = self.get_class_that_defined_method(func) - if kw_class: - func_file = self.get_function_file(kw_class) - else: - func_file = self.get_function_file(func) + # kw_class = self.get_class_that_defined_method(func) + # if kw_class: + # func_file = self.get_function_file(kw_class) + # else: + # func_file = self.get_function_file(func) + return func.__code__.co_filename return func_file def get_class_that_defined_method(self, meth): diff --git a/dataparser/data_queue/scanner.py b/dataparser/data_queue/scanner.py index 4b816b2..8e119c3 100644 --- a/dataparser/data_queue/scanner.py +++ b/dataparser/data_queue/scanner.py @@ -40,11 +40,9 @@ def scan(self, workspace, ext, db_path): if not os.path.dirname(workspace): raise EnvironmentError( 'Workspace must be folder: {0}'.format(str(workspace))) - if not os.path.exists(db_path): - os.makedirs(db_path) - else: + if os.path.exists(db_path): shutil.rmtree(db_path) - os.makedirs(db_path) + os.makedirs(db_path) self.add_builtin() if self.xml_libraries: self.add_xml_libraries(self.xml_libraries) @@ -113,6 +111,8 @@ def parse_all(self, item): if data_type in self.rf_data_type: return self.scan_rf_data(item[0]) elif data_type == DBJsonSetting.library: + # if 'selenium' in item[0].lower(): + # import pdb; pdb.set_trace() # breakpoint a2b04478 // return self.parser.parse_library(item[0], item[1]['args']) elif data_type == DBJsonSetting.variable_file: return self.parser.parse_variable_file(item[0], item[1]['args']) @@ -146,7 +146,7 @@ def add_libraries_queue(self, libs): def add_var_files_queue(self, var_files): for var_file in var_files: - file_name = list(var_file.keys())[0] + file_name = list(var_file)[0] self.queue.add( file_name, 'variable_file', diff --git a/dataparser/index/index.py b/dataparser/index/index.py index 5e8018e..7e05d54 100644 --- a/dataparser/index/index.py +++ b/dataparser/index/index.py @@ -175,7 +175,7 @@ def get_imports(self, data): result += self.get_library_imports(data) if DBJsonSetting.variable_files in data: for var in data[DBJsonSetting.variable_files]: - result.append(rf_table_name(list(var.keys())[0])) + result.append(rf_table_name(list(var)[0])) if DBJsonSetting.resources in data: for resource in data[DBJsonSetting.resources]: result.append(rf_table_name(resource)) diff --git a/dataparser/parser_utils/file_formatter.py b/dataparser/parser_utils/file_formatter.py index 7c24349..6270197 100644 --- a/dataparser/parser_utils/file_formatter.py +++ b/dataparser/parser_utils/file_formatter.py @@ -3,7 +3,8 @@ def rf_table_name(f_path): - md5sum = md5(f_path.encode('utf-8') if isinstance(f_path, str) else f_path).hexdigest() + md5sum = md5(f_path.encode() if isinstance(f_path, str) + else f_path).hexdigest() return '{realname}-{md5}.json'.format( realname=path.basename(f_path)[-100:], md5=md5sum diff --git a/dataparser/parser_utils/util.py b/dataparser/parser_utils/util.py index b951103..8d0919b 100644 --- a/dataparser/parser_utils/util.py +++ b/dataparser/parser_utils/util.py @@ -1,10 +1,10 @@ from os import path - +import glob def normalise_path(f_path): dirname = path.abspath(path.dirname(f_path)) basename = path.basename(f_path) - dirname = path.normpath(path.normcase(dirname)) + dirname = path.normpath(dirname) return path.join(dirname, basename) diff --git a/messages/st3-6.3.2.txt b/messages/st3-6.3.2.txt new file mode 100644 index 0000000..b20db36 --- /dev/null +++ b/messages/st3-6.3.2.txt @@ -0,0 +1,2 @@ +Drop PY2 support +Support new RBFW and SeleniumLibrary diff --git a/setting/db_json_settings.py b/setting/db_json_settings.py index 3d5f1d5..0e5af8d 100644 --- a/setting/db_json_settings.py +++ b/setting/db_json_settings.py @@ -21,6 +21,7 @@ class DBJsonSetting(object): library_path = 'library_path' resources = 'resources' tags = 'tags' + table_type = 'table_type' variable = 'variable' variable_files = 'variable_files' variables = 'variables' @@ -31,3 +32,5 @@ class DBJsonSetting(object): # Import setting types variable_file = 'variable_file' resource_file = 'resource_file' + + suite = 'suite' diff --git a/setting/setting.py b/setting/setting.py index cb53397..78cface 100644 --- a/setting/setting.py +++ b/setting/setting.py @@ -51,7 +51,7 @@ class SettingObject(object): scanner_runner = 'scanner_runner' index_runner = 'index_runner' log_file = 'log_file' - python_binary = 'path_to_python' + python_binary = 'path_to_python3' workspace = 'robot_framework_workspace' extension = 'robot_framework_extension' builtin_variables = 'robot_framework_builtin_variables' diff --git a/test/acceptance/library_parser.robot b/test/acceptance/library_parser.robot index ab011c4..2dee89b 100644 --- a/test/acceptance/library_parser.robot +++ b/test/acceptance/library_parser.robot @@ -34,14 +34,16 @@ Parser Should Be Able To Parse External Library From Python Path ... ${ADDCOOKIE_KEYS_LILST} Parser Should Be Able To Parse External Library From Module - ${result} = Parse Library + ${lib_path} = OperatingSystem.Normalize Path ... ${CURDIR}${/}..${/}resource${/}test_data${/}suite_tree${/}LibNoClass.py + ${result} = Parse Library ${lib_path} Dictionaries Should Be Equal ... ${result} ... ${LIB_FROM_MODULE} Parser Should Be Able To Parse Library With Robot API Keyword Decorator - ${lib_path} = OperatingSystem.Normalize Path ${CURDIR}${/}..${/}resource${/}test_data${/}suite_tree${/}LibraryWithReallyTooLongName.py + ${lib_path} = OperatingSystem.Normalize Path + ... ${CURDIR}${/}..${/}resource${/}test_data${/}suite_tree${/}LibraryWithReallyTooLongName.py ${result} = Parse Library ${lib_path} ${kws} = Set Variable &{result}[keywords] ${kw_with_deco} = Set Variable &{kws}[other_name_here] @@ -52,16 +54,19 @@ Parser Should Be Able To Parse Library With Robot API Keyword Decorator ... ${lib_path} Parser Should Be Able To Parse External Library From Custom Location - ${result} = Parse Library + ${lib_path} = OperatingSystem.Normalize Path ... ${CURDIR}${/}..${/}resource${/}library${/}MyLibrary.py + ${result} = Parse Library ${lib_path} Dictionaries Should Be Equal ... ${result} ... ${MYLIBRARY_KW} Parser Should Be Able To Parse External Library With Arguments From Custom Location @{args} = Create List arg111 arg222 - ${result} = Parse Library + ${lib_path} = OperatingSystem.Normalize Path ... ${CURDIR}${/}..${/}resource${/}library${/}OtherMyLibrary.py + ${result} = Parse Library + ... ${lib_path} ... ${args} Dictionaries Should Be Equal ... ${result} @@ -75,10 +80,12 @@ Parser Should Be Able To Parse External Library From XML File ... ${MYLIBRARY_XML} Parser Should Be Not Able To Parse Resource File From XML File + ${lib_path} = OperatingSystem.Normalize Path + ... ${CURDIR}${/}..${/}resource${/}library${/}simple_resource.xml Run Keyword And Expect Error ... ValueError: XML file is not library: simple_resource ... Parse Library - ... ${CURDIR}${/}..${/}resource${/}library${/}simple_resource.xml + ... ${lib_path} *** Keywords *** Simple Library Results Verifier diff --git a/test/acceptance/variable_files/library_vars.py b/test/acceptance/variable_files/library_vars.py index 8875a85..7a2fd4b 100644 --- a/test/acceptance/variable_files/library_vars.py +++ b/test/acceptance/variable_files/library_vars.py @@ -3,7 +3,7 @@ import copy import inspect import robot.libraries.Screenshot - +import glob def get_variables(): root_dir = path.dirname(path.abspath(__file__)) @@ -15,7 +15,8 @@ def get_variables(): var['MYLIBRARY_XML'] = get_mylibrary_xml(var['MYLIBRARY_KW']) var['SELENIUMLIBRARY_KEYS_LIST'] = ['arguments', 'keywords', - 'library_module'] + 'library_module', + 'table_type'] var['ADDCOOKIE_KEYS_LILST'] = ['keyword_name', 'keyword_arguments', 'documentation', @@ -29,15 +30,14 @@ def get_lib_from_module(resource_dir): data = {} module = 'LibNoClass' data['arguments'] = [] + data['table_type'] = 'library' data['library_module'] = module - f_path = path.normcase( - path.normpath( + f_path = path.normpath( path.join( resource_dir, 'suite_tree' ) ) - ) data['file_path'] = path.join(f_path, '{0}{1}'.format(module, '.py')) data['file_name'] = '{0}{1}'.format(module, '.py') kws = {} @@ -64,8 +64,8 @@ def get_mylibrary(resource_dir): data = {} data['arguments'] = [] data['library_module'] = module - f_path = path.normcase( - path.normpath(path.join(resource_dir, '..', 'library'))) + data['table_type'] = 'library' + f_path = path.normpath(path.join(resource_dir, '..', 'library')) data['file_path'] = path.join(f_path, '{0}{1}'.format(module, '.py')) data['file_name'] = '{0}{1}'.format(module, '.py') kws = {} @@ -91,8 +91,7 @@ def get_othermylibrary(resource_dir): module = 'OtherMyLibrary' data = get_mylibrary(resource_dir) data['library_module'] = module - f_path = path.normcase( - path.normpath(path.join(resource_dir, '..', 'library'))) + f_path = path.normpath(path.join(resource_dir, '..', 'library')) data['file_path'] = path.join(f_path, '{0}{1}'.format(module, '.py')) data['file_name'] = '{0}{1}'.format(module, '.py') data['arguments'] = ['arg111', 'arg222'] @@ -123,6 +122,7 @@ def get_mylibrary_xml(data): def get_screenshot(): source_file = inspect.getsourcefile(robot.libraries.Screenshot) data = {} + data['table_type'] = 'library' data['library_module'] = 'Screenshot' data['keywords'] = screenshot_keywords(source_file) data['arguments'] = [] diff --git a/test/acceptance/variable_files/suite_parser_vars.py b/test/acceptance/variable_files/suite_parser_vars.py index 52f3249..d613290 100644 --- a/test/acceptance/variable_files/suite_parser_vars.py +++ b/test/acceptance/variable_files/suite_parser_vars.py @@ -1,5 +1,5 @@ from os import path - +import glob def get_variables(): root_dir = path.dirname(path.abspath(__file__)) @@ -14,6 +14,7 @@ def get_variables(): def create_simple_var(resource_dir): result = {} + result['table_type'] = 'variable_file' result['file_name'] = 'simple_variable_file.py' result['file_path'] = path.join(resource_dir, result['file_name']) result['variables'] = ['${VARIABLE_FILE_1}', '${VARIABLE_FILE_2}'] @@ -22,6 +23,7 @@ def create_simple_var(resource_dir): def create_other_simple_var(resource_dir): result = {} + result['table_type'] = 'variable_file' result['file_name'] = 'other_simple_variable_file.py' result['file_path'] = path.join(resource_dir, result['file_name']) result['variables'] = ['${VARIABLE_FILE_1}', '${VARIABLE_FILE_2}'] @@ -30,7 +32,9 @@ def create_other_simple_var(resource_dir): def create_simple_test(resource_dir): result = {} + result['table_type'] = 'variable_file' result['file_name'] = 'simple_test.robot' + result['table_type'] = 'suite' result['file_path'] = path.join(resource_dir, result['file_name']) result['libraries'] = [ {'library_name': 'SeleniumLibrary', @@ -38,7 +42,7 @@ def create_simple_test(resource_dir): 'library_arguments': ['timeout=5.0', 'implicit_wait=0.0'], 'library_path': None} ] - result['resources'] = [path.join(resource_dir, 'simple_resrouce2.robot')] + result['resources'] = [path.join(resource_dir, 'simple_resource2.robot')] result['variable_files'] = [ {path.join(resource_dir, 'simple_variable_file.py'): {'variable_file_arguments': ['arg11', 'arg22']}} @@ -54,6 +58,7 @@ def create_simple_test(resource_dir): def create_simple_resource(resource_dir): result = {} result['file_name'] = 'simple_resource.robot' + result['table_type'] = 'resource_file' result['file_path'] = path.join(resource_dir, result['file_name']) lib_path = path.abspath(path.join(resource_dir, '..', 'FooBar.py')) result['libraries'] = [ @@ -70,7 +75,7 @@ def create_simple_resource(resource_dir): {path.join(resource_dir, 'simple_variable_file.py'): {'variable_file_arguments': ['arg11', 'arg22']}} ] - result['resources'] = [path.join(resource_dir, 'simple_resrouce2.robot')] + result['resources'] = [path.join(resource_dir, 'simple_resource2.robot')] kws = {} kws['my_kw_1'] = my_kw_1() kws['my_kw_2'] = my_kw_2() @@ -80,8 +85,7 @@ def create_simple_resource(resource_dir): def get_resource_path(root_dir): - return path.normcase( - path.normpath( + return path.normpath( path.join( root_dir, '..', @@ -89,7 +93,6 @@ def get_resource_path(root_dir): 'resource', 'test_data' ) - ) ) diff --git a/test/resource/test_data/simple_resource.robot b/test/resource/test_data/simple_resource.robot index f9bc994..9f758ef 100644 --- a/test/resource/test_data/simple_resource.robot +++ b/test/resource/test_data/simple_resource.robot @@ -1,7 +1,7 @@ *** Settings *** Library SeleniumLibrary timeout=5.0 Documentation foobar -Resource simple_resrouce2.robot +Resource simple_resource2.robot Variables simple_variable_file.py arg11 arg22 Library ../FooBar.py diff --git a/test/resource/test_data/simple_test.robot b/test/resource/test_data/simple_test.robot index 0053bf4..9c73754 100644 --- a/test/resource/test_data/simple_test.robot +++ b/test/resource/test_data/simple_test.robot @@ -1,7 +1,7 @@ *** Settings *** Library SeleniumLibrary timeout=5.0 implicit_wait=0.0 Documentation foobar -Resource simple_resrouce2.robot +Resource simple_resource2.robot Variables simple_variable_file.py arg11 arg22 *** Variable *** diff --git a/test/run_test.py b/test/run_test.py index d3cb9f6..ee538ed 100644 --- a/test/run_test.py +++ b/test/run_test.py @@ -4,6 +4,7 @@ import unittest import shutil from robot import run as robot_run +import os def acceptance_test(options): @@ -37,7 +38,7 @@ def _acceptance_include(options): def clean_results(): print('Clean: {0}'.format(env.RESULTS_DIR)) if os.path.exists(env.RESULTS_DIR): - shutil.rmtree(env.RESULTS_DIR) + shutil.rmtree(env.RESULTS_DIR) os.mkdir(env.RESULTS_DIR) @@ -48,7 +49,7 @@ def unit_test(): sys.path.insert(0, env.SRC_DIR) sys.path.append(env.UNIT_TEST_DIR) # suite = unittest.TestLoader().loadTestsFromName( - # 'test_current_view.TestIndexing.test_create_view') + # 'test_scanner.TestScanner.test_queue_populated') suite = unittest.TestLoader().discover( start_dir=env.UNIT_TEST_DIR, pattern='test*.py') @@ -72,10 +73,8 @@ def _exit(rc): a_result = acceptance_test(sys.argv[1:]) if u_result.errors or u_result.failures: print('Unit tests failed') - print('errors: {}'.format(u_result.errors), - file=open(os.path.join(env.RESULTS_DIR,"unittest_erros.log"), "a")) - print('failures: {}'.format(u_result.failures), - file=open(os.path.join(env.RESULTS_DIR,"unittest_failures.log"), "a")) + print('errors: {}'.format(u_result.errors)) + print('failures: {}'.format(u_result.failures)) _exit(u_result.errors) elif a_result != 0: print('Acceptance tests failed') diff --git a/test/unit/test_get_documentation.py b/test/unit/test_get_documentation.py index eb4ba55..6ce00f6 100644 --- a/test/unit/test_get_documentation.py +++ b/test/unit/test_get_documentation.py @@ -209,19 +209,19 @@ def test_get_table_name_from_index_with_embedding_arg_kw(self): @property def test_a_file(self): - return path.normcase(path.join(self.suite_dir, 'test_a.robot')) + return path.normpath(path.join(self.suite_dir, 'test_a.robot')) @property def test_b_file(self): - return path.normcase(path.join(self.suite_dir, 'test_b.robot')) + return path.normpath(path.join(self.suite_dir, 'test_b.robot')) @property def resource_a_table_file(self): - return path.normcase(path.join(self.suite_dir, 'resource_a.robot')) + return path.normpath(path.join(self.suite_dir, 'resource_a.robot')) @property def resource_b_table_file(self): - return path.normcase(path.join(self.suite_dir, 'resource_b.robot')) + return path.normpath(path.join(self.suite_dir, 'resource_b.robot')) @property def test_a_table_name(self): diff --git a/test/unit/test_get_keyword_from_library.py b/test/unit/test_get_keyword_from_library.py index 3b09a44..e6c2118 100644 --- a/test/unit/test_get_keyword_from_library.py +++ b/test/unit/test_get_keyword_from_library.py @@ -55,7 +55,6 @@ def test_get_lib_kw(self): 'Simulate Event' ) self.assertIsNotNone(regex) - import pdb; pdb.set_trace() # breakpoint d4f66d13 // self.assertIsNotNone(file_path) def test_get_lib_keyword_file(self): @@ -170,15 +169,15 @@ def s2l(self): @property def s2l_simulate(self): - return path.join(self.s2l, 'keywords', '_element.py') + return path.join(self.s2l, 'keywords', 'element.py') @property def s2l_press_key(self): - return path.join(self.s2l, 'keywords', '_element.py') + return path.join(self.s2l, 'keywords', 'element.py') @property def s2l_textarea_value_should_be(self): - return path.join(self.s2l, 'keywords', '_formelement.py') + return path.join(self.s2l, 'keywords', 'formelement.py') @property def s2l_table_file(self): @@ -198,7 +197,7 @@ def get_common_robot_path(self): @property def long_name_file(self): return path.join( - path.normcase(self.suite_dir), 'LibraryWithReallyTooLongName.py' + path.normpath(self.suite_dir), 'LibraryWithReallyTooLongName.py' ) @property @@ -208,7 +207,7 @@ def get_resource_b_robot_path(self): @property def get_resource_lib_longer_than_100_chars(self): return path.join( - path.normcase(self.suite_dir), + path.normpath(self.suite_dir), ( 'LibraryNameWhichIsLongerThan100CharactersButItSeemsThatIt' 'RequiresQuiteAlotLettersInTheFileNameAndIsNotGoodReal' diff --git a/test/unit/test_get_keyword_from_resource.py b/test/unit/test_get_keyword_from_resource.py index 7225e84..84de3b0 100644 --- a/test/unit/test_get_keyword_from_resource.py +++ b/test/unit/test_get_keyword_from_resource.py @@ -51,7 +51,7 @@ def setUp(self): def test_return_file_and_patter(self): kw = 'Common Keyword 2' object_name = None - expected_path = path.normcase(self.get_common_robot_path) + expected_path = path.normpath(self.get_common_robot_path) regex, file_path = self._get_kw.return_file_and_patter(object_name, kw) self.assertEqual(regex, self.get_common_keyword_2_regex) self.assertEqual(file_path, expected_path) @@ -166,19 +166,19 @@ def get_common_variables_path(self): @property def test_a_file(self): - return path.normcase(path.join(self.suite_dir, 'test_a.robot')) + return path.normpath(path.join(self.suite_dir, 'test_a.robot')) @property def resource_a_table_file(self): - return path.normcase(path.join(self.suite_dir, 'resource_a.robot')) + return path.normpath(path.join(self.suite_dir, 'resource_a.robot')) @property def test_b_file(self): - return path.normcase(path.join(self.suite_dir, 'test_b.robot')) + return path.normpath(path.join(self.suite_dir, 'test_b.robot')) @property def resource_b_table_file(self): - return path.normcase(path.join(self.suite_dir, 'resource_b.robot')) + return path.normpath(path.join(self.suite_dir, 'resource_b.robot')) @property def test_a_table_name(self): diff --git a/test/unit/test_indexkw.py b/test/unit/test_indexkw.py index de77e19..7a2b5c6 100644 --- a/test/unit/test_indexkw.py +++ b/test/unit/test_indexkw.py @@ -328,7 +328,7 @@ def test_a_table_name_index(self): @property def real_suite_table_name(self): return rf_table_name( - os.path.normcase( + os.path.normpath( os.path.join( self.real_suite_dir, 'test', @@ -340,30 +340,30 @@ def real_suite_table_name(self): @property def resource_b_table_name(self): return rf_table_name( - os.path.normcase(os.path.join(self.suite_dir, 'resource_b.robot')) + os.path.normpath(os.path.join(self.suite_dir, 'resource_b.robot')) ) @property def common_table_name(self): return rf_table_name( - os.path.normcase(os.path.join(self.suite_dir, 'common.robot')) + os.path.normpath(os.path.join(self.suite_dir, 'common.robot')) ) @property def test_a_table_name(self): return rf_table_name( - os.path.normcase(os.path.join(self.suite_dir, 'test_a.robot')) + os.path.normpath(os.path.join(self.suite_dir, 'test_a.robot')) ) @property def test_b_table_name(self): return rf_table_name( - os.path.normcase(os.path.join(self.suite_dir, 'test_b.robot')) + os.path.normpath(os.path.join(self.suite_dir, 'test_b.robot')) ) @property def resource_a_table_name(self): - return rf_table_name(os.path.normcase( + return rf_table_name(os.path.normpath( os.path.join(self.suite_dir, 'resource_a.robot')) ) @@ -715,7 +715,7 @@ def get_common_kw_index(self, keywordrecord): def get_kw_args(self, data): arg_list = [] kws = data["keywords"] - for i in kws.keys(): + for i in kws: args = kws[i]['keyword_arguments'] for arg in args: if '=' in arg: diff --git a/test/unit/test_scanner.py b/test/unit/test_scanner.py index cca3594..ab1354c 100644 --- a/test/unit/test_scanner.py +++ b/test/unit/test_scanner.py @@ -83,7 +83,7 @@ def test_queue_populated(self): 'resource2', 'real_suite_resource.robot' ) - key = os.path.normcase(key) + key = os.path.normpath(key) self.assertEqual( self.scanner.queue.queue[key], {'scanned': True, 'type': None, 'args': None} @@ -225,14 +225,14 @@ def test_parse_suite_structure(self): init = '{0}-{1}.json'.format( '__init__.robot', hashlib.md5( - os.path.normcase( + os.path.normpath( os.path.join(workspace, '__init__.robot')).encode()).hexdigest() ) self.assertTrue(init in files) suite = '{0}-{1}.json'.format( 'test_with_libs.robot', hashlib.md5( - os.path.normcase( + os.path.normpath( os.path.join( workspace, 'test_with_libs.robot')).encode()).hexdigest() ) @@ -324,7 +324,7 @@ def create_resource_item2(self): resource = os.path.join( env.RESOURCES_DIR, 'test_data', - 'simple_resrouce2.robot' + 'simple_resource2.robot' ) return (resource, {'scanned': False, 'type': 'resource', 'args': None}) From 30bbd89edab0c86d2e80b70493324ed254472b94 Mon Sep 17 00:00:00 2001 From: tanakiat Date: Sun, 17 Feb 2019 00:28:04 +0700 Subject: [PATCH 15/22] Bring the existing readme backed. --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 00bdab8..587c9aa 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ Robot Framework Assistant provides IDE features to edit [Robot Framework](http://robotframework.org/) test data in the [Sublime Text 3](https://www.sublimetext.com/3). -> **FROM v6.3.2 ONWARDS, THIS PLUGIN WILL DROP PY2 SUPPORT DUE TO PY2 END OF LIFE IN THE EARLY OF 2020** - From release 3.0.0 onwards plugin is not anymore compatible with Sublime Text 2. The releases made before the 3.0.0 will serve the Sublime Text 2 users. The documentation for Sublime Text 2 user @@ -39,7 +37,7 @@ The default settings can be found from the **Preferences | Package settings** The only mandatory settings which user needs to define are the [robot_framework_workspace](https://github.com/andriyko/sublime-robot-framework-assistant#robot_framework_workspace) and the -[path_to_python3](https://github.com/andriyko/sublime-robot-framework-assistant#path_to_python3). +[path_to_python](https://github.com/andriyko/sublime-robot-framework-assistant#path_to_python). The rest of the parameters can be safely left in their default values, when trying out the plugin. @@ -73,13 +71,13 @@ definition in this plugin is not affected by this option. If there library or variable file imports in the Robot Framework data, those imports are automatically parser and included in the scanning. -## path_to_python3 +## path_to_python In order the creating the database of keywords and variables to -work, path to Python3.x binary must be defined. It must be the same +work, path to Python binary must be defined. It must be the same Python binary where the Robot Framework is installed. -In Linux like environments this could be like: /usr/bin/python3 -and in Windows this could be like: C:\\Python3\\python3.exe +In Linux like environments this could be like: /usr/bin/python +and in Windows this could be like: C:\\Python27\\python.exe ## robot_framework_module_search_path Module search path defines a list of paths where the Robot Framework From 56ee229d8253995ecdb4367baf2a8edff23066fe Mon Sep 17 00:00:00 2001 From: tanakiat Date: Sun, 17 Feb 2019 10:10:37 +0700 Subject: [PATCH 16/22] Incoporate reviewer comments --- dataparser/data_parser/data_parser.py | 7 ------- dataparser/data_queue/scanner.py | 2 -- test/run_test.py | 1 - 3 files changed, 10 deletions(-) diff --git a/dataparser/data_parser/data_parser.py b/dataparser/data_parser/data_parser.py index 9659678..6bbd8c8 100644 --- a/dataparser/data_parser/data_parser.py +++ b/dataparser/data_parser/data_parser.py @@ -163,8 +163,6 @@ def _parse_python_lib(self, library, args): function_name = keyword.name kw[DBJsonSetting.keyword_file] = self._get_library_kw_source( libcode, function_name) - # if 'selenium' in str(libcode).lower(): - # import pdb; pdb.set_trace() # breakpoint 402cb44b // kws[strip_and_lower(keyword.name)] = kw return kws @@ -209,11 +207,6 @@ def _get_library_kw_source(self, libcode, keyword): else: func_file, func = None, None if func: - # kw_class = self.get_class_that_defined_method(func) - # if kw_class: - # func_file = self.get_function_file(kw_class) - # else: - # func_file = self.get_function_file(func) return func.__code__.co_filename return func_file diff --git a/dataparser/data_queue/scanner.py b/dataparser/data_queue/scanner.py index 8e119c3..5172cb8 100644 --- a/dataparser/data_queue/scanner.py +++ b/dataparser/data_queue/scanner.py @@ -111,8 +111,6 @@ def parse_all(self, item): if data_type in self.rf_data_type: return self.scan_rf_data(item[0]) elif data_type == DBJsonSetting.library: - # if 'selenium' in item[0].lower(): - # import pdb; pdb.set_trace() # breakpoint a2b04478 // return self.parser.parse_library(item[0], item[1]['args']) elif data_type == DBJsonSetting.variable_file: return self.parser.parse_variable_file(item[0], item[1]['args']) diff --git a/test/run_test.py b/test/run_test.py index ee538ed..01f0cef 100644 --- a/test/run_test.py +++ b/test/run_test.py @@ -4,7 +4,6 @@ import unittest import shutil from robot import run as robot_run -import os def acceptance_test(options): From 35a06cd4bcf1047fd918b62164556bc303819a05 Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Mon, 18 Feb 2019 12:24:04 +0700 Subject: [PATCH 17/22] rename noralize_cell to normalize_cell get rid of unnecessary print --- command_helper/get_documentation.py | 4 ++-- command_helper/get_keyword.py | 4 ++-- command_helper/jump_to_file.py | 4 ++-- command_helper/{noralize_cell.py => normalize_cell.py} | 0 command_helper/workspace_objects.py | 4 ++-- commands/jump_to_keyword.py | 2 +- commands/query_completions.py | 1 - commands/show_documentation.py | 2 +- dataparser/parser_utils/util.py | 1 - test/acceptance/variable_files/library_vars.py | 1 - test/acceptance/variable_files/suite_parser_vars.py | 1 - test/unit/test_noralize_cell.py | 2 +- 12 files changed, 11 insertions(+), 15 deletions(-) rename command_helper/{noralize_cell.py => normalize_cell.py} (100%) diff --git a/command_helper/get_documentation.py b/command_helper/get_documentation.py index 4ea2e05..c926c4b 100644 --- a/command_helper/get_documentation.py +++ b/command_helper/get_documentation.py @@ -3,13 +3,13 @@ try: from parser_utils.file_formatter import rf_table_name from parser_utils.util import get_index_name, normalise_path - from noralize_cell import get_data_from_json + from normalize_cell import get_data_from_json from db_json_settings import DBJsonSetting from utils.util import kw_equals_kw_candite except: from ..dataparser.parser_utils.file_formatter import rf_table_name from ..dataparser.parser_utils.util import get_index_name, normalise_path - from ..command_helper.noralize_cell import get_data_from_json + from ..command_helper.normalize_cell import get_data_from_json from ..setting.db_json_settings import DBJsonSetting from ..command_helper.utils.util import kw_equals_kw_candite diff --git a/command_helper/get_keyword.py b/command_helper/get_keyword.py index bf9cf20..b70cbfc 100644 --- a/command_helper/get_keyword.py +++ b/command_helper/get_keyword.py @@ -4,12 +4,12 @@ try: from get_documentation import GetKeywordDocumentation from db_json_settings import DBJsonSetting - from noralize_cell import get_data_from_json + from normalize_cell import get_data_from_json from utils.util import kw_equals_kw_candite except: from .get_documentation import GetKeywordDocumentation from ..setting.db_json_settings import DBJsonSetting - from ..command_helper.noralize_cell import get_data_from_json + from ..command_helper.normalize_cell import get_data_from_json from ..command_helper.utils.util import kw_equals_kw_candite diff --git a/command_helper/jump_to_file.py b/command_helper/jump_to_file.py index abec6f1..05a4fd6 100644 --- a/command_helper/jump_to_file.py +++ b/command_helper/jump_to_file.py @@ -3,10 +3,10 @@ try: from parser_utils.file_formatter import lib_table_name - from noralize_cell import get_data_from_json + from normalize_cell import get_data_from_json except ImportError: from ..dataparser.parser_utils.file_formatter import lib_table_name - from .noralize_cell import get_data_from_json + from .normalize_cell import get_data_from_json class JumpToFile(object): diff --git a/command_helper/noralize_cell.py b/command_helper/normalize_cell.py similarity index 100% rename from command_helper/noralize_cell.py rename to command_helper/normalize_cell.py diff --git a/command_helper/workspace_objects.py b/command_helper/workspace_objects.py index 6422aab..e3da521 100644 --- a/command_helper/workspace_objects.py +++ b/command_helper/workspace_objects.py @@ -1,9 +1,9 @@ from os import listdir, path try: - from .noralize_cell import get_data_from_json + from .normalize_cell import get_data_from_json from db_json_settings import DBJsonSetting except: - from ..command_helper.noralize_cell import get_data_from_json + from ..command_helper.normalize_cell import get_data_from_json from ..setting.db_json_settings import DBJsonSetting diff --git a/commands/jump_to_keyword.py b/commands/jump_to_keyword.py index c1c9c59..7bdad30 100644 --- a/commands/jump_to_keyword.py +++ b/commands/jump_to_keyword.py @@ -6,7 +6,7 @@ from ..command_helper.get_keyword import GetKeyword from ..command_helper.get_metadata import get_rf_table_separator from ..command_helper.jump_to_file import JumpToFile -from ..command_helper.noralize_cell import ReturnKeywordAndObject +from ..command_helper.normalize_cell import ReturnKeywordAndObject from ..command_helper.utils.get_text import get_line from ..setting.setting import get_setting from ..setting.setting import SettingObject diff --git a/commands/query_completions.py b/commands/query_completions.py index 2edbc9a..eb3d364 100644 --- a/commands/query_completions.py +++ b/commands/query_completions.py @@ -46,7 +46,6 @@ def return_completions(self, view, prefix, locations): # workspace = get_setting(SettingObject.workspace) open_tab = view.file_name() index_file = get_index_file(open_tab) - print(view, prefix, index_file) if index_file: return self.get_completions(view, prefix, index_file) else: diff --git a/commands/show_documentation.py b/commands/show_documentation.py index cb2c1c5..a95431b 100644 --- a/commands/show_documentation.py +++ b/commands/show_documentation.py @@ -4,7 +4,7 @@ from ..setting.setting import SettingObject from .query_completions import get_index_file from ..command_helper.utils.get_text import get_line -from ..command_helper.noralize_cell import ReturnKeywordAndObject +from ..command_helper.normalize_cell import ReturnKeywordAndObject from ..command_helper.get_metadata import get_rf_table_separator from ..command_helper.get_documentation import GetKeywordDocumentation diff --git a/dataparser/parser_utils/util.py b/dataparser/parser_utils/util.py index 8d0919b..ae0df1e 100644 --- a/dataparser/parser_utils/util.py +++ b/dataparser/parser_utils/util.py @@ -1,5 +1,4 @@ from os import path -import glob def normalise_path(f_path): dirname = path.abspath(path.dirname(f_path)) diff --git a/test/acceptance/variable_files/library_vars.py b/test/acceptance/variable_files/library_vars.py index 7a2fd4b..047c9f4 100644 --- a/test/acceptance/variable_files/library_vars.py +++ b/test/acceptance/variable_files/library_vars.py @@ -3,7 +3,6 @@ import copy import inspect import robot.libraries.Screenshot -import glob def get_variables(): root_dir = path.dirname(path.abspath(__file__)) diff --git a/test/acceptance/variable_files/suite_parser_vars.py b/test/acceptance/variable_files/suite_parser_vars.py index d613290..5c978ae 100644 --- a/test/acceptance/variable_files/suite_parser_vars.py +++ b/test/acceptance/variable_files/suite_parser_vars.py @@ -1,5 +1,4 @@ from os import path -import glob def get_variables(): root_dir = path.dirname(path.abspath(__file__)) diff --git a/test/unit/test_noralize_cell.py b/test/unit/test_noralize_cell.py index 506bc6c..90f2d35 100644 --- a/test/unit/test_noralize_cell.py +++ b/test/unit/test_noralize_cell.py @@ -2,7 +2,7 @@ import env import json from os import path -from noralize_cell import ReturnKeywordAndObject +from normalize_cell import ReturnKeywordAndObject class TestCompletions(unittest.TestCase): From 7d5f6e71721b5daeb7a02be2a1fe67c58597414c Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Mon, 18 Feb 2019 12:33:35 +0700 Subject: [PATCH 18/22] Make the changes for is_string fx to raise an exception if it's not py3 --- command_helper/get_keyword.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command_helper/get_keyword.py b/command_helper/get_keyword.py index b70cbfc..330eecb 100644 --- a/command_helper/get_keyword.py +++ b/command_helper/get_keyword.py @@ -164,5 +164,5 @@ def is_string(self, str_): if version_info.major > 2: status = isinstance(str_, str) else: - status = isinstance(str_, str) + raise RuntimeError('Plugin only works with python 3') return status From d671b0a9021d474b655ea3c66b50bcc8abfe6c5a Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Mon, 18 Feb 2019 19:24:58 +0700 Subject: [PATCH 19/22] Raise an error message dialog if python with RBFW package is not python 3 --- Robot.sublime-settings | 2 +- command_helper/get_keyword.py | 7 ++----- commands/__init__.py | 10 ++++++++++ commands/scan.py | 2 ++ commands/scan_and_index.py | 2 ++ commands/scan_open_tab.py | 2 ++ setting/setting.py | 2 +- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Robot.sublime-settings b/Robot.sublime-settings index 3c3a72a..afd6d94 100644 --- a/Robot.sublime-settings +++ b/Robot.sublime-settings @@ -74,7 +74,7 @@ and in Windows this could be like: C:\\Python27\\python.exe */ - "path_to_python3": "/usr/bin/python", + "path_to_python": "/usr/bin/python", /* Module search path defines a list of paths where the diff --git a/command_helper/get_keyword.py b/command_helper/get_keyword.py index 330eecb..c18bb15 100644 --- a/command_helper/get_keyword.py +++ b/command_helper/get_keyword.py @@ -161,8 +161,5 @@ def rf_data(self, file_path): return None def is_string(self, str_): - if version_info.major > 2: - status = isinstance(str_, str) - else: - raise RuntimeError('Plugin only works with python 3') - return status + return isinstance(str_, str) + diff --git a/commands/__init__.py b/commands/__init__.py index bfe5bd9..18bbf43 100644 --- a/commands/__init__.py +++ b/commands/__init__.py @@ -1,3 +1,4 @@ +import subprocess from .command_logging import LogCommands from .index_open_tab import IndexOpenTabCommand from .jump_to_keyword import JumpToKeyword @@ -11,6 +12,7 @@ from .setting_import_helper import InsertImport from .setting_import_helper import SettingImporter from .show_documentation import ShowKeywordDocumentation +from sublime import error_message __all__ = [ 'IndexOpenTabCommand', @@ -27,3 +29,11 @@ 'SettingImporter', 'ShowKeywordDocumentation' ] + +def check_binary_version(python_binary): + result = subprocess.check_output([python_binary,"-c", "import sys;print(sys.version_info.major)"]) + version = int(result.decode('utf-8').strip()) + if version < 3: + error_message('RobotFrameworkAssistant\n' + + '***********************************\n' + + 'Plugin fully support on python 3\n') \ No newline at end of file diff --git a/commands/scan.py b/commands/scan.py index 516c076..407af93 100644 --- a/commands/scan.py +++ b/commands/scan.py @@ -3,6 +3,7 @@ import subprocess from platform import system from os import path, makedirs +from . import check_binary_version from ..setting.setting import get_setting from ..setting.setting import SettingObject @@ -34,6 +35,7 @@ def run(self, edit): Also all imports, from found files, will be iterated and table is created also from imports. """ + check_binary_version(get_setting(SettingObject.python_binary)) log_file = get_setting(SettingObject.log_file) makedirs(path.dirname(log_file), exist_ok=True) file_ = open(log_file, 'a') diff --git a/commands/scan_and_index.py b/commands/scan_and_index.py index a8200cf..d78c256 100644 --- a/commands/scan_and_index.py +++ b/commands/scan_and_index.py @@ -5,6 +5,7 @@ from os import path, makedirs from hashlib import md5 import json +from . import check_binary_version from ..setting.setting import get_setting from ..setting.setting import SettingObject from ..setting.db_json_settings import DBJsonSetting @@ -45,6 +46,7 @@ def add_builtin_vars(db_path): class ScanIndexCommand(sublime_plugin.TextCommand): def run(self, edit): + check_binary_version(get_setting(SettingObject.python_binary)) log_file = get_setting(SettingObject.log_file) db_dir = get_setting(SettingObject.table_dir) makedirs(path.dirname(log_file), exist_ok=True) diff --git a/commands/scan_open_tab.py b/commands/scan_open_tab.py index 6ed5866..8bde1f1 100644 --- a/commands/scan_open_tab.py +++ b/commands/scan_open_tab.py @@ -3,6 +3,7 @@ import subprocess from platform import system from os import path, makedirs +from . import check_binary_version from ..setting.setting import get_setting from ..setting.setting import SettingObject from .scan import scan_popen_arg_parser @@ -16,6 +17,7 @@ def run(self, edit): Purpose of the command is scan and create the db table from the currently open tab. """ + check_binary_version(get_setting(SettingObject.python_binary)) log_file = get_setting(SettingObject.log_file) makedirs(path.dirname(log_file), exist_ok=True) open_tab = self.view.file_name() diff --git a/setting/setting.py b/setting/setting.py index 78cface..cb53397 100644 --- a/setting/setting.py +++ b/setting/setting.py @@ -51,7 +51,7 @@ class SettingObject(object): scanner_runner = 'scanner_runner' index_runner = 'index_runner' log_file = 'log_file' - python_binary = 'path_to_python3' + python_binary = 'path_to_python' workspace = 'robot_framework_workspace' extension = 'robot_framework_extension' builtin_variables = 'robot_framework_builtin_variables' From cafa0bcdecd0b1b3e8af18825c689ae241a4bfb3 Mon Sep 17 00:00:00 2001 From: Tanakiat Srisaranyakul Date: Fri, 22 Feb 2019 15:20:52 +0700 Subject: [PATCH 20/22] Update __init__.py add missing new line at the end of the file --- commands/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/__init__.py b/commands/__init__.py index 18bbf43..b814638 100644 --- a/commands/__init__.py +++ b/commands/__init__.py @@ -36,4 +36,4 @@ def check_binary_version(python_binary): if version < 3: error_message('RobotFrameworkAssistant\n' + '***********************************\n' + - 'Plugin fully support on python 3\n') \ No newline at end of file + 'Plugin fully support on python 3\n') From 4def9f98ce81b1914e36f50fe1d2a5487ca57e15 Mon Sep 17 00:00:00 2001 From: tanakiat Date: Sun, 24 Feb 2019 22:54:27 +0700 Subject: [PATCH 21/22] move check python version into setting.py instead --- commands/__init__.py | 10 ---------- commands/scan.py | 2 -- commands/scan_and_index.py | 2 -- commands/scan_open_tab.py | 2 -- setting/setting.py | 16 ++++++++++++++++ 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/commands/__init__.py b/commands/__init__.py index b814638..bfe5bd9 100644 --- a/commands/__init__.py +++ b/commands/__init__.py @@ -1,4 +1,3 @@ -import subprocess from .command_logging import LogCommands from .index_open_tab import IndexOpenTabCommand from .jump_to_keyword import JumpToKeyword @@ -12,7 +11,6 @@ from .setting_import_helper import InsertImport from .setting_import_helper import SettingImporter from .show_documentation import ShowKeywordDocumentation -from sublime import error_message __all__ = [ 'IndexOpenTabCommand', @@ -29,11 +27,3 @@ 'SettingImporter', 'ShowKeywordDocumentation' ] - -def check_binary_version(python_binary): - result = subprocess.check_output([python_binary,"-c", "import sys;print(sys.version_info.major)"]) - version = int(result.decode('utf-8').strip()) - if version < 3: - error_message('RobotFrameworkAssistant\n' + - '***********************************\n' + - 'Plugin fully support on python 3\n') diff --git a/commands/scan.py b/commands/scan.py index 407af93..516c076 100644 --- a/commands/scan.py +++ b/commands/scan.py @@ -3,7 +3,6 @@ import subprocess from platform import system from os import path, makedirs -from . import check_binary_version from ..setting.setting import get_setting from ..setting.setting import SettingObject @@ -35,7 +34,6 @@ def run(self, edit): Also all imports, from found files, will be iterated and table is created also from imports. """ - check_binary_version(get_setting(SettingObject.python_binary)) log_file = get_setting(SettingObject.log_file) makedirs(path.dirname(log_file), exist_ok=True) file_ = open(log_file, 'a') diff --git a/commands/scan_and_index.py b/commands/scan_and_index.py index d78c256..a8200cf 100644 --- a/commands/scan_and_index.py +++ b/commands/scan_and_index.py @@ -5,7 +5,6 @@ from os import path, makedirs from hashlib import md5 import json -from . import check_binary_version from ..setting.setting import get_setting from ..setting.setting import SettingObject from ..setting.db_json_settings import DBJsonSetting @@ -46,7 +45,6 @@ def add_builtin_vars(db_path): class ScanIndexCommand(sublime_plugin.TextCommand): def run(self, edit): - check_binary_version(get_setting(SettingObject.python_binary)) log_file = get_setting(SettingObject.log_file) db_dir = get_setting(SettingObject.table_dir) makedirs(path.dirname(log_file), exist_ok=True) diff --git a/commands/scan_open_tab.py b/commands/scan_open_tab.py index 8bde1f1..6ed5866 100644 --- a/commands/scan_open_tab.py +++ b/commands/scan_open_tab.py @@ -3,7 +3,6 @@ import subprocess from platform import system from os import path, makedirs -from . import check_binary_version from ..setting.setting import get_setting from ..setting.setting import SettingObject from .scan import scan_popen_arg_parser @@ -17,7 +16,6 @@ def run(self, edit): Purpose of the command is scan and create the db table from the currently open tab. """ - check_binary_version(get_setting(SettingObject.python_binary)) log_file = get_setting(SettingObject.log_file) makedirs(path.dirname(log_file), exist_ok=True) open_tab = self.view.file_name() diff --git a/setting/setting.py b/setting/setting.py index cb53397..1077051 100644 --- a/setting/setting.py +++ b/setting/setting.py @@ -1,5 +1,7 @@ +import subprocess from os import path import sublime +from sublime import error_message class PathResolver(object): @@ -99,6 +101,18 @@ def get_view_path(): return path.join(project_setting, PathResolver().view_folder) +def get_python_binary(): + python_binary = get_sublime_setting(SettingObject.python_binary) + result = subprocess.check_output( + [python_binary, "-c", "import sys;print(sys.version_info.major)"]) + version = int(result.decode('utf-8').strip()) + if version < 3: + error_message('RobotFrameworkAssistant\n' + + '***********************************\n' + + 'Plugin fully support on python 3\n') + return python_binary + + def get_setting(setting): if setting.lower() == SettingObject.table_dir: return get_scanner_dir() @@ -110,6 +124,8 @@ def get_setting(setting): return PathResolver().index_runner elif setting.lower() == SettingObject.log_file: return get_log_file() + elif setting.lower() == SettingObject.python_binary: + return get_python_binary() else: return get_sublime_setting(setting) From fba063ee6bf1a82564b4849911e34d8576a2c47c Mon Sep 17 00:00:00 2001 From: tanakiat Date: Tue, 26 Feb 2019 00:16:33 +0700 Subject: [PATCH 22/22] Make SettingObject a singleton so we call python_binary once to check the version and correct the typo --- dataparser/data_queue/scanner.py | 2 +- setting/setting.py | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/dataparser/data_queue/scanner.py b/dataparser/data_queue/scanner.py index 5172cb8..121cb96 100644 --- a/dataparser/data_queue/scanner.py +++ b/dataparser/data_queue/scanner.py @@ -119,7 +119,7 @@ def parse_all(self, item): item)) def scan_rf_data(self, f): - """Scans test suite or resoruce file""" + """Scans test suite or resource file""" self.parser.unregister_console_logger() try: return self.parser.parse_resource(f) diff --git a/setting/setting.py b/setting/setting.py index 1077051..802a2ba 100644 --- a/setting/setting.py +++ b/setting/setting.py @@ -47,6 +47,7 @@ def log_file(self): class SettingObject(object): + __instance = None table_dir = 'table_dir' index_dir = 'index_dir' @@ -67,6 +68,13 @@ class SettingObject(object): automatic_index_creation = 'robot_framework_automatic_indexing' automatic_database_update = 'robot_framework_automatic_database_update' kw_prefixes = 'robot_framework_keyword_prefixes' + PY3 = None + + def __new__(cls, val): + if SettingObject.__instance is None: + SettingObject.__instance = object.__new__(cls) + SettingObject.__instance.val = val + return SettingObject.__instance def get_scanner_dir(): @@ -102,14 +110,21 @@ def get_view_path(): def get_python_binary(): + error_msg = 'RobotFrameworkAssistant\n' + \ + '***********************************\n' + \ + 'The plugin is fully supported on python 3\n' python_binary = get_sublime_setting(SettingObject.python_binary) - result = subprocess.check_output( - [python_binary, "-c", "import sys;print(sys.version_info.major)"]) - version = int(result.decode('utf-8').strip()) - if version < 3: - error_message('RobotFrameworkAssistant\n' + - '***********************************\n' + - 'Plugin fully support on python 3\n') + if SettingObject.PY3 is None: + result = subprocess.check_output( + [python_binary, "-c", "import sys;print(sys.version_info.major)"]) + version = int(result.decode('utf-8').strip()) + if version < 3: + error_message(error_msg) + SettingObject.PY3 = False + else: + SettingObject.PY3 = True + elif not SettingObject.PY3: + error_message(error_msg) return python_binary