Skip to content
This repository was archived by the owner on Nov 2, 2020. It is now read-only.

Commit bd86244

Browse files
committed
add missing files :p
1 parent be38fd7 commit bd86244

25 files changed

+150
-97
lines changed

.travis.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
language: python
2-
python:
3-
- "2.7"
2+
matrix:
3+
include:
4+
- python: "3.6"
5+
env:
6+
- INTERPRETER=python3
7+
- python: "3.4"
8+
env:
9+
- INTERPRETER=python3
10+
411
install:
5-
- pip install robotframework
12+
- pip install robotframework==3.1.1
613
- pip install robotframework-seleniumlibrary==3.3.1
714
script:
8-
- "python test/run_test.py"
15+
- "$INTERPRETER --version"
16+
- "$INTERPRETER test/run_test.py"

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Robot Framework Assistant provides IDE features to edit
55
[Robot Framework](http://robotframework.org/) test data in the
66
[Sublime Text 3](https://www.sublimetext.com/3).
77

8+
> **FROM v6.3.2 ONWARDS, THIS PLUGIN WILL DROP PY2 SUPPORT DUE TO PY2 END OF LIFE IN THE EARLY OF 2020**
9+
810
From release 3.0.0 onwards plugin is not anymore compatible with
911
Sublime Text 2. The releases made before the 3.0.0 will serve
1012
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**
3739
The only mandatory settings which user needs to define are the
3840
[robot_framework_workspace](https://github.com/andriyko/sublime-robot-framework-assistant#robot_framework_workspace)
3941
and the
40-
[path_to_python](https://github.com/andriyko/sublime-robot-framework-assistant#path_to_python).
42+
[path_to_python3](https://github.com/andriyko/sublime-robot-framework-assistant#path_to_python3).
4143
The rest of the parameters can be safely left in their default values,
4244
when trying out the plugin.
4345

@@ -71,13 +73,13 @@ definition in this plugin is not affected by this option.
7173
If there library or variable file imports in the Robot Framework data,
7274
those imports are automatically parser and included in the scanning.
7375

74-
## path_to_python
76+
## path_to_python3
7577
In order the creating the database of keywords and variables to
76-
work, path to Python binary must be defined. It must be the same
78+
work, path to Python3.x binary must be defined. It must be the same
7779
Python binary where the Robot Framework is installed.
7880

79-
In Linux like environments this could be like: /usr/bin/python
80-
and in Windows this could be like: C:\\Python27\\python.exe
81+
In Linux like environments this could be like: /usr/bin/python3
82+
and in Windows this could be like: C:\\Python3\\python3.exe
8183

8284
## robot_framework_module_search_path
8385
Module search path defines a list of paths where the Robot Framework

Robot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
2-
Robot Framework from sublime is a autocompletion plugin for Sublime Text 3
2+
Robot Framework Assistant offers IDE features for editing Robot Framework test
3+
data in Sublime Text 3.
34
"""
45
import sys
56
import os

Robot.sublime-settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
and in Windows this could be like: C:\\Python27\\python.exe
7575
*/
7676

77-
"path_to_python": "/usr/bin/python",
77+
"path_to_python3": "/usr/bin/python",
7878

7979
/*
8080
Module search path defines a list of paths where the

commands/query_completions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def return_completions(self, view, prefix, locations):
4646
# workspace = get_setting(SettingObject.workspace)
4747
open_tab = view.file_name()
4848
index_file = get_index_file(open_tab)
49+
print(view, prefix, index_file)
4950
if index_file:
5051
return self.get_completions(view, prefix, index_file)
5152
else:

commands/scan_open_tab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def run_single_scan(self, open_tab, log_file):
5757

5858
def file_in_workspace(self, open_tab):
5959
workspace = get_setting(SettingObject.workspace)
60-
workspace = path.normcase(workspace)
61-
open_tab = path.normcase(open_tab)
60+
workspace = path.normpath(workspace)
61+
open_tab = path.normpath(open_tab)
6262
extension = get_setting(SettingObject.extension)
6363
if open_tab.endswith(extension):
6464
return open_tab.startswith(workspace)

dataparser/data_parser/data_parser.py

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def parse_resource(self, file_path):
4646
model = parsing.TestDataDirectory(source=folder).populate()
4747
else:
4848
model = parsing.ResourceFile(file_path).populate()
49-
return self._parse_robot_data(file_path, model)
49+
data = self._parse_robot_data(file_path, model)
50+
data[DBJsonSetting.table_type] = DBJsonSetting.resource_file
51+
return data
5052
else:
5153
logging.error('File %s could not be found', file_path)
5254
raise ValueError(
@@ -56,7 +58,9 @@ def parse_suite(self, file_path):
5658
self.file_path = file_path
5759
if path.exists(file_path):
5860
model = parsing.TestCaseFile(source=file_path).populate()
59-
return self._parse_robot_data(file_path, model)
61+
data = self._parse_robot_data(file_path, model)
62+
data[DBJsonSetting.table_type] = DBJsonSetting.suite
63+
return data
6064
else:
6165
logging.error('File %s could not be found', file_path)
6266
raise ValueError(
@@ -78,6 +82,7 @@ def parse_variable_file(self, file_path, args=None):
7882
for variable in variables:
7983
var_list.append(variable[0])
8084
data[DBJsonSetting.variables] = sorted(var_list)
85+
data[DBJsonSetting.table_type] = DBJsonSetting.variable_file
8186
return data
8287

8388
def parse_library(self, library, args=None):
@@ -116,6 +121,7 @@ def parse_library(self, library, args=None):
116121
if data[DBJsonSetting.keywords] is None:
117122
raise ValueError('Library did not contain keywords')
118123
else:
124+
data[DBJsonSetting.table_type] = DBJsonSetting.library
119125
return data
120126

121127
def register_console_logger(self):
@@ -140,8 +146,10 @@ def _parse_python_lib(self, library, args):
140146
else:
141147
import_name = library
142148
importer = Importer('test library')
149+
lib_args = self._argument_strip(lib, args)
143150
libcode = importer.import_class_or_module(
144-
import_name, return_source=False)
151+
import_name, instantiate_with_args=lib_args,
152+
return_source=False)
145153
kw_with_deco = self._get_keywords_with_robot_name(libcode)
146154
for keyword in lib.keywords:
147155
kw = {}
@@ -155,25 +163,41 @@ def _parse_python_lib(self, library, args):
155163
function_name = keyword.name
156164
kw[DBJsonSetting.keyword_file] = self._get_library_kw_source(
157165
libcode, function_name)
166+
# if 'selenium' in str(libcode).lower():
167+
# import pdb; pdb.set_trace() # breakpoint 402cb44b //
158168
kws[strip_and_lower(keyword.name)] = kw
159169
return kws
160170

161-
def _get_keywords_with_robot_name(self, libcode):
171+
def _argument_strip(self, lib, given_args):
172+
formated_args = []
173+
if not given_args:
174+
return formated_args
175+
try:
176+
default_args = lib.inits[0].args
177+
except IndexError:
178+
default_args = []
179+
for default_arg in default_args:
180+
if '=' in default_arg:
181+
default_parts = default_arg.split('=', 1)
182+
formated_args.append(default_parts[1])
183+
else:
184+
formated_args.append(default_arg)
185+
return formated_args
186+
187+
def _get_keywords_with_robot_name(self, lib_instance):
162188
"""Returns keywords which uses Robot keyword decorator with robot_name
163189
164-
The keyword name can be chaned with Robot Framework keyword decorator
165-
and by using the robot_name attribute. Return dictinionary which key is
166-
the value of the robot_name attribute and the orinal function name.
190+
The keyword name can be changed with Robot Framework keyword decorator
191+
and by using the robot_name attribute. Return dictionary which key is
192+
the value of the robot_name attribute and the original function name.
167193
"""
168194
kw_deco = {}
169-
for key in libcode.__dict__:
170-
if callable(libcode.__dict__[key]):
171-
try:
172-
if 'robot_name' in libcode.__dict__[key].__dict__:
173-
kw = libcode.__dict__[key].__dict__['robot_name']
174-
kw_deco[kw] = key
175-
except AttributeError:
176-
pass
195+
lib_class = type(lib_instance)
196+
for name in dir(lib_instance):
197+
owner = lib_class if hasattr(lib_class, name) else lib_instance
198+
method_attrib = getattr(owner, name)
199+
if hasattr(method_attrib, 'robot_name') and method_attrib.robot_name:
200+
kw_deco[method_attrib.robot_name] = name
177201
return kw_deco
178202

179203
def _get_library_kw_source(self, libcode, keyword):
@@ -182,12 +206,15 @@ def _get_library_kw_source(self, libcode, keyword):
182206
func_file = None
183207
if hasattr(libcode, kw_func):
184208
func = getattr(libcode, kw_func)
209+
else:
210+
func_file, func = None, None
185211
if func:
186-
kw_class = self.get_class_that_defined_method(func)
187-
if kw_class:
188-
func_file = self.get_function_file(kw_class)
189-
else:
190-
func_file = self.get_function_file(func)
212+
# kw_class = self.get_class_that_defined_method(func)
213+
# if kw_class:
214+
# func_file = self.get_function_file(kw_class)
215+
# else:
216+
# func_file = self.get_function_file(func)
217+
return func.__code__.co_filename
191218
return func_file
192219

193220
def get_class_that_defined_method(self, meth):

dataparser/data_queue/scanner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ def scan(self, workspace, ext, db_path):
4040
if not os.path.dirname(workspace):
4141
raise EnvironmentError(
4242
'Workspace must be folder: {0}'.format(str(workspace)))
43-
if not os.path.exists(db_path):
44-
os.makedirs(db_path)
45-
else:
43+
if os.path.exists(db_path):
4644
shutil.rmtree(db_path)
47-
os.makedirs(db_path)
45+
os.makedirs(db_path)
4846
self.add_builtin()
4947
if self.xml_libraries:
5048
self.add_xml_libraries(self.xml_libraries)
@@ -113,6 +111,8 @@ def parse_all(self, item):
113111
if data_type in self.rf_data_type:
114112
return self.scan_rf_data(item[0])
115113
elif data_type == DBJsonSetting.library:
114+
# if 'selenium' in item[0].lower():
115+
# import pdb; pdb.set_trace() # breakpoint a2b04478 //
116116
return self.parser.parse_library(item[0], item[1]['args'])
117117
elif data_type == DBJsonSetting.variable_file:
118118
return self.parser.parse_variable_file(item[0], item[1]['args'])
@@ -146,7 +146,7 @@ def add_libraries_queue(self, libs):
146146

147147
def add_var_files_queue(self, var_files):
148148
for var_file in var_files:
149-
file_name = list(var_file.keys())[0]
149+
file_name = list(var_file)[0]
150150
self.queue.add(
151151
file_name,
152152
'variable_file',

dataparser/index/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def get_imports(self, data):
175175
result += self.get_library_imports(data)
176176
if DBJsonSetting.variable_files in data:
177177
for var in data[DBJsonSetting.variable_files]:
178-
result.append(rf_table_name(list(var.keys())[0]))
178+
result.append(rf_table_name(list(var)[0]))
179179
if DBJsonSetting.resources in data:
180180
for resource in data[DBJsonSetting.resources]:
181181
result.append(rf_table_name(resource))

dataparser/parser_utils/file_formatter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44

55
def rf_table_name(f_path):
6-
md5sum = md5(f_path.encode('utf-8') if isinstance(f_path, str) else f_path).hexdigest()
6+
md5sum = md5(f_path.encode() if isinstance(f_path, str)
7+
else f_path).hexdigest()
78
return '{realname}-{md5}.json'.format(
89
realname=path.basename(f_path)[-100:],
910
md5=md5sum

0 commit comments

Comments
 (0)