|
1
|
|
|
""" |
|
2
|
|
|
Copyright 2016 Brocade Communications Systems, Inc. |
|
3
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
|
4
|
|
|
you may not use this file except in compliance with the License. |
|
5
|
|
|
You may obtain a copy of the License at |
|
6
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
|
7
|
|
|
Unless required by applicable law or agreed to in writing, software |
|
8
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, |
|
9
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
10
|
|
|
See the License for the specific language governing permissions and |
|
11
|
|
|
limitations under the License. |
|
12
|
|
|
""" |
|
13
|
|
|
|
|
14
|
|
|
from lib import excel_action, excel_reader |
|
15
|
|
|
import json |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
class GetExcelVariablesAction(excel_action.ExcelAction): |
|
19
|
|
|
def run(self, sheet, key, variables, strict, excel_file=None, |
|
20
|
|
|
key_column=None, variable_name_row=None): |
|
21
|
|
|
|
|
22
|
|
|
self.replace_defaults(excel_file, key_column, variable_name_row) |
|
23
|
|
|
|
|
24
|
|
|
data = json.loads(variables) |
|
25
|
|
|
excel = excel_reader.ExcelReader(self._excel_file, lock=True) |
|
26
|
|
|
excel.set_sheet(sheet, key_column=self._key_column, |
|
27
|
|
|
var_name_row=self._var_name_row, |
|
28
|
|
|
strict=strict) |
|
29
|
|
|
excel.set_values_for_variables(key, data) |
|
30
|
|
|
excel.save() |
|
31
|
|
|
|
|
32
|
|
|
return (True, 'Success') |
|
33
|
|
|
|