How to use _set_selectors method in Playwright Python

Best Python code snippet using playwright-python

Run Playwright Python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

__init__.py

Source: __init__.py Github

copy
1# -*- coding: utf-8 -*-
2from operator import attrgetter
3import pyangbind.lib.xpathhelper as xpathhelper
4from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType
5from pyangbind.lib.yangtypes import RestrictedClassType
6from pyangbind.lib.yangtypes import TypedListType
7from pyangbind.lib.yangtypes import YANGBool
8from pyangbind.lib.yangtypes import YANGListType
9from pyangbind.lib.yangtypes import YANGDynClass
10from pyangbind.lib.yangtypes import ReferenceType
11from pyangbind.lib.base import PybindBase
12from collections import OrderedDict
13from decimal import Decimal
14from bitarray import bitarray
15import six
16
17# PY3 support of some PY2 keywords (needs improved)
18if six.PY3:
19  import builtins as __builtin__
20  long = int
21elif six.PY2:
22  import __builtin__
23
24from . import selectors
25class console(PybindBase):
26  """
27  This class was auto-generated by the PythonClass plugin for PYANG
28  from YANG module openconfig-system - based on the path /system/logging/console. Each member element of
29  the container is represented as a class variable - with a specific
30  YANG type.
31
32  YANG Description: Top-level container for data related to console-based
33logging
34  """
35  __slots__ = ('_path_helper', '_extmethods', '__selectors',)
36
37  _yang_name = 'console'
38
39  _pybind_generated_by = 'container'
40
41  def __init__(self, *args, **kwargs):
42
43    helper = kwargs.pop("path_helper", None)
44    if helper is False:
45      self._path_helper = False
46    elif helper is not None and isinstance(helper, xpathhelper.YANGPathHelper):
47      self._path_helper = helper
48    elif hasattr(self, "_parent"):
49      helper = getattr(self._parent, "_path_helper", False)
50      self._path_helper = helper
51    else:
52      self._path_helper = False
53
54    self._extmethods = False
55    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)
56
57    load = kwargs.pop("load", None)
58    if args:
59      if len(args) > 1:
60        raise TypeError("cannot create a YANG container with >1 argument")
61      all_attr = True
62      for e in self._pyangbind_elements:
63        if not hasattr(args[0], e):
64          all_attr = False
65          break
66      if not all_attr:
67        raise ValueError("Supplied object did not have the correct attributes")
68      for e in self._pyangbind_elements:
69        nobj = getattr(args[0], e)
70        if nobj._changed() is False:
71          continue
72        setmethod = getattr(self, "_set_%s" % e)
73        if load is None:
74          setmethod(getattr(args[0], e))
75        else:
76          setmethod(getattr(args[0], e), load=load)
77
78  def _path(self):
79    if hasattr(self, "_parent"):
80      return self._parent._path()+[self._yang_name]
81    else:
82      return ['system', 'logging', 'console']
83
84  def _get_selectors(self):
85    """
86    Getter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)
87
88    YANG Description: Enclosing container 
89    """
90    return self.__selectors
91      
92  def _set_selectors(self, v, load=False):
93    """
94    Setter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)
95    If this variable is read-only (config: false) in the
96    source YANG file, then _set_selectors is considered as a private
97    method. Backends looking to populate this variable should
98    do so via calling thisObj._set_selectors() directly.
99
100    YANG Description: Enclosing container 
101    """
102    if hasattr(v, "_utype"):
103      v = v._utype(v)
104    try:
105      t = YANGDynClass(v,base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)
106    except (TypeError, ValueError):
107      raise ValueError({
108          'error-string': """selectors must be of a type compatible with container""",
109          'defined-type': "container",
110          'generated-type': """YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)""",
111        })
112
113    self.__selectors = t
114    if hasattr(self, '_set'):
115      self._set()
116
117  def _unset_selectors(self):
118    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)
119
120  selectors = __builtin__.property(_get_selectors, _set_selectors)
121
122
123  _pyangbind_elements = OrderedDict([('selectors', selectors), ])
124
125
126from . import selectors
127class console(PybindBase):
128  """
129  This class was auto-generated by the PythonClass plugin for PYANG
130  from YANG module openconfig-system - based on the path /system/logging/console. Each member element of
131  the container is represented as a class variable - with a specific
132  YANG type.
133
134  YANG Description: Top-level container for data related to console-based
135logging
136  """
137  __slots__ = ('_path_helper', '_extmethods', '__selectors',)
138
139  _yang_name = 'console'
140
141  _pybind_generated_by = 'container'
142
143  def __init__(self, *args, **kwargs):
144
145    helper = kwargs.pop("path_helper", None)
146    if helper is False:
147      self._path_helper = False
148    elif helper is not None and isinstance(helper, xpathhelper.YANGPathHelper):
149      self._path_helper = helper
150    elif hasattr(self, "_parent"):
151      helper = getattr(self._parent, "_path_helper", False)
152      self._path_helper = helper
153    else:
154      self._path_helper = False
155
156    self._extmethods = False
157    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)
158
159    load = kwargs.pop("load", None)
160    if args:
161      if len(args) > 1:
162        raise TypeError("cannot create a YANG container with >1 argument")
163      all_attr = True
164      for e in self._pyangbind_elements:
165        if not hasattr(args[0], e):
166          all_attr = False
167          break
168      if not all_attr:
169        raise ValueError("Supplied object did not have the correct attributes")
170      for e in self._pyangbind_elements:
171        nobj = getattr(args[0], e)
172        if nobj._changed() is False:
173          continue
174        setmethod = getattr(self, "_set_%s" % e)
175        if load is None:
176          setmethod(getattr(args[0], e))
177        else:
178          setmethod(getattr(args[0], e), load=load)
179
180  def _path(self):
181    if hasattr(self, "_parent"):
182      return self._parent._path()+[self._yang_name]
183    else:
184      return ['system', 'logging', 'console']
185
186  def _get_selectors(self):
187    """
188    Getter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)
189
190    YANG Description: Enclosing container 
191    """
192    return self.__selectors
193      
194  def _set_selectors(self, v, load=False):
195    """
196    Setter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)
197    If this variable is read-only (config: false) in the
198    source YANG file, then _set_selectors is considered as a private
199    method. Backends looking to populate this variable should
200    do so via calling thisObj._set_selectors() directly.
201
202    YANG Description: Enclosing container 
203    """
204    if hasattr(v, "_utype"):
205      v = v._utype(v)
206    try:
207      t = YANGDynClass(v,base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)
208    except (TypeError, ValueError):
209      raise ValueError({
210          'error-string': """selectors must be of a type compatible with container""",
211          'defined-type': "container",
212          'generated-type': """YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)""",
213        })
214
215    self.__selectors = t
216    if hasattr(self, '_set'):
217      self._set()
218
219  def _unset_selectors(self):
220    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)
221
222  selectors = __builtin__.property(_get_selectors, _set_selectors)
223
224
225  _pyangbind_elements = OrderedDict([('selectors', selectors), ])
226
227
228from . import selectors
229class console(PybindBase):
230  """
231  This class was auto-generated by the PythonClass plugin for PYANG
232  from YANG module openconfig-system - based on the path /system/logging/console. Each member element of
233  the container is represented as a class variable - with a specific
234  YANG type.
235
236  YANG Description: Top-level container for data related to console-based
237logging
238  """
239  __slots__ = ('_path_helper', '_extmethods', '__selectors',)
240
241  _yang_name = 'console'
242
243  _pybind_generated_by = 'container'
244
245  def __init__(self, *args, **kwargs):
246
247    helper = kwargs.pop("path_helper", None)
248    if helper is False:
249      self._path_helper = False
250    elif helper is not None and isinstance(helper, xpathhelper.YANGPathHelper):
251      self._path_helper = helper
252    elif hasattr(self, "_parent"):
253      helper = getattr(self._parent, "_path_helper", False)
254      self._path_helper = helper
255    else:
256      self._path_helper = False
257
258    self._extmethods = False
259    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)
260
261    load = kwargs.pop("load", None)
262    if args:
263      if len(args) > 1:
264        raise TypeError("cannot create a YANG container with >1 argument")
265      all_attr = True
266      for e in self._pyangbind_elements:
267        if not hasattr(args[0], e):
268          all_attr = False
269          break
270      if not all_attr:
271        raise ValueError("Supplied object did not have the correct attributes")
272      for e in self._pyangbind_elements:
273        nobj = getattr(args[0], e)
274        if nobj._changed() is False:
275          continue
276        setmethod = getattr(self, "_set_%s" % e)
277        if load is None:
278          setmethod(getattr(args[0], e))
279        else:
280          setmethod(getattr(args[0], e), load=load)
281
282  def _path(self):
283    if hasattr(self, "_parent"):
284      return self._parent._path()+[self._yang_name]
285    else:
286      return ['system', 'logging', 'console']
287
288  def _get_selectors(self):
289    """
290    Getter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)
291
292    YANG Description: Enclosing container 
293    """
294    return self.__selectors
295      
296  def _set_selectors(self, v, load=False):
297    """
298    Setter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)
299    If this variable is read-only (config: false) in the
300    source YANG file, then _set_selectors is considered as a private
301    method. Backends looking to populate this variable should
302    do so via calling thisObj._set_selectors() directly.
303
304    YANG Description: Enclosing container 
305    """
306    if hasattr(v, "_utype"):
307      v = v._utype(v)
308    try:
309      t = YANGDynClass(v,base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)
310    except (TypeError, ValueError):
311      raise ValueError({
312          'error-string': """selectors must be of a type compatible with container""",
313          'defined-type': "container",
314          'generated-type': """YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)""",
315        })
316
317    self.__selectors = t
318    if hasattr(self, '_set'):
319      self._set()
320
321  def _unset_selectors(self):
322    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)
323
324  selectors = __builtin__.property(_get_selectors, _set_selectors)
325
326
327  _pyangbind_elements = OrderedDict([('selectors', selectors), ])
328
329
330
Full Screen

dialogs.py

Source: dialogs.py Github

copy
1from ...external.qt import QtGui, QtCore
2from astropy.io import fits
3from astropy.io.fits.hdu.table import _TableLikeHDU as FITS_table
4
5
6class FileEditDialog(QtGui.QDialog):
7    def __init__(self, file_path, parent=None):
8        super(FileEditDialog, self).__init__(parent)
9        self.ext = None
10        self.flux = None
11        self.dispersion = None
12        self.flux_unit = None
13        self.dispersion_unit = None
14
15        # TODO: get rid of nasty try/excepts
16        try:
17            self.hdulist = fits.open(str(file_path))
18        except IOError:
19            self.hdulist = fits.open(str(file_path[0]))
20
21        self.vb_layout_main = QtGui.QVBoxLayout()
22        self.setLayout(self.vb_layout_main)
23
24        self._setup_basic()
25
26    def _setup_basic(self):
27        # Form layout layout
28        vb_layout = QtGui.QVBoxLayout()
29
30        # Extension selector
31        self.ext_selector = QtGui.QComboBox()
32        self.ext_selector.addItems(["[{}] {}".format(i, self.hdulist[i].name)
33                                    for i in range(len(self.hdulist))])
34        self.ext_selector.currentIndexChanged.connect(self._set_selectors)
35
36        # Manual input lines
37        self.man_flux_unit = QtGui.QLineEdit()
38        self.man_disp_unit = QtGui.QLineEdit()
39
40        # Column name selectors
41        self.flux_col_selector = QtGui.QComboBox()
42        self.disp_col_selector = QtGui.QComboBox()
43
44        # Label detailing how many extensions were found
45        hdu_count = QtGui.QLabel("Detected {} extensions in this FITS "
46                                 "file.".format(len(self.hdulist)))
47
48        # Form layout
49        self.form_layout = QtGui.QFormLayout()
50        self.form_layout.addRow(self.tr("Extension"), self.ext_selector)
51        self.form_layout.addRow(self.tr("Flux Column"), self.flux_col_selector)
52        self.form_layout.addRow(self.tr("Dispersion Column"),
53                                self.disp_col_selector)
54        self.form_layout.addRow(self.tr("Flux Unit"), self.man_flux_unit)
55        self.form_layout.addRow(self.tr("Dispersion Unit"), self.man_disp_unit)
56
57        # Add widgets to form layout
58        vb_layout.addWidget(hdu_count)
59        vb_layout.addLayout(self.form_layout)
60
61        # Create group box
62        group_box = QtGui.QGroupBox("File Input Factory")
63        group_box.setLayout(vb_layout)
64
65        # Add form layout and accept button to main layout
66        self.vb_layout_main.addWidget(group_box)
67        # self.vb_layout_main.addWidget(btn_accept)
68        button_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok |
69                                            QtGui.QDialogButtonBox.Cancel)
70        button_box.accepted.connect(self._on_accept)
71        button_box.rejected.connect(self._on_reject)
72
73        self.vb_layout_main.addWidget(button_box)
74
75    def _set_selectors(self, index):
76        self.flux_col_selector.clear()
77        self.disp_col_selector.clear()
78
79        data = self.hdulist[index].data
80
81        if data is not None:
82            col_names = data.names
83        else:
84            col_names = ""
85
86        self.flux_col_selector.addItems(col_names)
87        self.disp_col_selector.addItems(col_names)
88
89    def _on_accept(self):
90        self.ext = int(self.ext_selector.currentIndex())
91
92        if isinstance(self.hdulist[self.ext], FITS_table):
93            flux_ind = self.flux_col_selector.currentIndex()
94            disp_ind = self.disp_col_selector.currentIndex()
95            self.flux = self.hdulist[self.ext].data.names[flux_ind]
96            self.dispersion = self.hdulist[self.ext].data.names[disp_ind]
97
98        self.flux_unit = str(self.man_flux_unit.text())
99        self.disp_unit = str(self.man_disp_unit.text())
100
101        super(FileEditDialog, self).accept()
102
103    def _on_reject(self):
104        super(FileEditDialog, self).reject()
105
106
107class PlotUnitsDialog(QtGui.QDialog):
108    def __init__(self, parent=None):
109        super(PlotUnitsDialog, self).__init__(parent)
110
111        self.vb_layout_main = QtGui.QVBoxLayout()
112        self.setLayout(self.vb_layout_main)
113
114        self.wgt_flux_unit = None
115        self.wgt_disp_unit = None
116
117        self._setup_basic()
118
119    def _setup_basic(self):
120        self.wgt_flux_unit = QtGui.QLineEdit()
121        self.wgt_disp_unit = QtGui.QLineEdit()
122
123        form_layout = QtGui.QFormLayout()
124        form_layout.addRow(self.tr("&Flux Unit:"), self.wgt_flux_unit)
125        form_layout.addRow(self.tr("&Dispersion Unit:"), self.wgt_disp_unit)
126
127        button_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok |
128                                            QtGui.QDialogButtonBox.Cancel)
129        button_box.accepted.connect(self._on_accept)
130        button_box.rejected.connect(self._on_reject)
131
132        self.vb_layout_main.addLayout(form_layout)
133        self.vb_layout_main.addWidget(button_box)
134
135    def _on_accept(self):
136        self.flux_unit = str(self.wgt_flux_unit.text())
137        self.disp_unit = str(self.wgt_disp_unit.text())
138
139        super(PlotUnitsDialog, self).accept()
140
141    def _on_reject(self):
142        super(PlotUnitsDialog, self).reject()
143
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run Python Tests on LambdaTest Cloud Grid

Execute automation tests with Playwright Python on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)