Example #1
0
 def __init__(self, vertices, z1, z2, props=None):
     super().__init__(props)
     self.x = np.fromiter((v[0] for v in vertices), dtype=np.float)
     self.y = np.fromiter((v[1] for v in vertices), dtype=np.float)
     self.z1 = float(z1)
     self.z2 = float(z2)
     self.nverts = len(vertices)
Example #2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.url = urlparse(self.settings['url'])
     self.db = self.url.path.strip('/')
     if not self.db:
         raise ValueError("Database is not defined %s" %
             self.settings['url'])
Example #3
0
 def __init__(self, *args, **kwargs):
     filename = kwargs.pop('rerun_test_file')
     if filename == '-':
         self.rerun_test_file = sys.stdin
     else:
         self.rerun_test_file = open(filename)
     super(TestRerunner, self).__init__(*args, **kwargs)
Example #4
0
 def __init__(self, x, y, z, radius, props=None):
     super().__init__(props)
     self.x = float(x)
     self.y = float(y)
     self.z = float(z)
     self.radius = float(radius)
     self.center = np.array([x, y, z])
    def mouseMoveEvent(self, event):
        """
        Overrides mouseMovedEvent to display any decoration tooltip and emits
        the mouse_moved event.

        :param event: QMouseEvent
        """
        cursor = self.cursorForPosition(event.pos())
        self._last_mouse_pos = event.pos()
        block_found = False
        for sel in self.decorations:
            if sel.contains_cursor(cursor) and sel.tooltip:
                if (self._prev_tooltip_block_nbr != cursor.blockNumber() or
                        not QtWidgets.QToolTip.isVisible()):
                    pos = event.pos()
                    # add left margin
                    pos.setX(pos.x() + self.panels.margin_size())
                    # add top margin
                    pos.setY(pos.y() + self.panels.margin_size(0))
                    self._tooltips_runner.request_job(
                        self.show_tooltip,
                        self.mapToGlobal(pos), sel.tooltip[0: 1024], sel)
                    self._prev_tooltip_block_nbr = cursor.blockNumber()
                block_found = True
                break
        if not block_found and self._prev_tooltip_block_nbr != -1:
            QtWidgets.QToolTip.hideText()
            self._prev_tooltip_block_nbr = -1
            self._tooltips_runner.cancel_requests()
        self.mouse_moved.emit(event)
        super(CodeEdit, self).mouseMoveEvent(event)
Example #6
0
 def __init__(self, message='', uuid=None, name=None, make=None, model=None, version=None):
     self._uuid = uuid
     self.name = name
     self.make = make
     self.model = model
     self.version = version
     super().__init__(message)
 def __init__(self, parent=None, client=None):
     super().__init__(parent, client)
     SiteData.__init__(self)
     self._orders = Orders(self, client)
     self._portins = PortIns(self, client)
     self._sip_peers = SipPeers(self, client)
     self._totaltns = SiteTotaltns(self, client)
Example #8
0
    def __init__(self, *args, **kwargs):
        """
        For ``Product`` subclasses that are registered with an Admin class
        that doesn't implement fieldsets, add any extra model fields
        to this instance's fieldsets. This mimics Django's behaviour of
        adding all model fields when no fieldsets are defined on the
        Admin class.
        """

        super(ProductAdmin, self).__init__(*args, **kwargs)

        # Test that the fieldsets don't differ from ProductAdmin's.
        if (self.model is not Product and
                self.fieldsets == ProductAdmin.fieldsets):

            # Make a copy so that we aren't modifying other Admin
            # classes' fieldsets.
            self.fieldsets = deepcopy(self.fieldsets)

            # Insert each field between the publishing fields and nav
            # fields. Do so in reverse order to retain the order of
            # the model's fields.
            for field in reversed(self.model._meta.fields):
                check_fields = [f.name for f in Product._meta.fields]
                check_fields.append("product_ptr")
                try:
                    check_fields.extend(self.exclude)
                except (AttributeError, TypeError):
                    pass
                try:
                    check_fields.extend(self.form.Meta.exclude)
                except (AttributeError, TypeError):
                    pass
                if field.name not in check_fields and field.editable:
                    self.fieldsets[0][1]["fields"].insert(3, field.name)
Example #9
0
    def __init__(self, **kwargs):
        super(ListSuitesMixin, self).__init__(**kwargs)

        # add a dynamic test to guard against
        # https://github.com/Yelp/Testify/issues/85
        test = MethodType(lambda self: True, self, type(self))
        setattr(self, 'test_foo', test)
    def __init__(self, *args, **kwargs):
        self.replay_json = kwargs.pop("replay_json")
        self.replay_json_inline = kwargs.pop("replay_json_inline")

        self.results = self.loadlines()

        super(TestRunnerJSONReplay, self).__init__(*args, **kwargs)
Example #11
0
    def __init__(self, *args, **kwargs):
        super(TestCase, self).__init__()

        self.__test_fixtures = TestFixtures.discover_from(self)

        self.__suites_include = kwargs.get('suites_include', set())
        self.__suites_exclude = kwargs.get('suites_exclude', set())
        self.__suites_require = kwargs.get('suites_require', set())
        self.__name_overrides = kwargs.get('name_overrides', None)

        TestResult.debug = kwargs.get('debugger') # sorry :(

        # callbacks for various stages of execution, used for stuff like logging
        self.__callbacks = defaultdict(list)

        self.__all_test_results = []

        self._stage = self.STAGE_UNSTARTED

        # for now, we still support the use of unittest-style assertions defined on the TestCase instance
        for name in dir(deprecated_assertions):
            if name.startswith(('assert', 'fail')):
                self.name = getattr(deprecated_assertions, name).__get__(self, self.__class__)
        self.failure_limit = kwargs.pop('failure_limit', None)
        self.failure_count = 0
 def mouseDoubleClickEvent(self, event):
     initial_state = event.isAccepted()
     event.ignore()
     self.mouse_double_clicked.emit(event)
     if not event.isAccepted():
         event.setAccepted(initial_state)
         super(CodeEdit, self).mouseDoubleClickEvent(event)
Example #13
0
 def __init__(self, port, timeout=None):
     """
     """
     super().__init__()
     self._serial = serial.Serial(self, port=None)  # port=None prevents auto-open on init.
     self.timeout = timeout
     self.port = port
Example #14
0
 def __init__(self, beta, fdmat):
     if beta <= 0:
         raise ValueError("Invalid beta=%g. Must be > 0" % (beta))
     super().__init__(
         nparams=fdmat.shape[1], islinear=False)
     self.beta = beta
     self.fdmat = fdmat
    def setUp(self):
        super(TransferTest, self).setUp()
        self.customer = openpay.Customer.create(
            name="John", last_name="Doe", description="Test User",
            email="*****@*****.**")
        self.bank_account = self.customer.bank_accounts.create(
            clabe="032180000118359719",
            alias="Cuenta principal",
            holder_name="John Doe")

        self.card = self.customer.cards.create(
            card_number="4111111111111111",
            holder_name="Juan Perez",
            expiration_year="20",
            expiration_month="12",
            cvv2="110",
            address={
                "city": "Querétaro",
                "country_code": "MX",
                "postal_code": "76900",
                "line1": "Av 5 de Febrero",
                "line2": "Roble 207",
                "line3": "col carrillo",
                "state": "Queretaro"
            }
        )

        self.charge = self.customer.charges.create(
            source_id=self.card.id, method="card",
            amount=100, description="Test Charge",
            order_id=generate_order_id())

        self.second_customer = openpay.Customer.all().data[3]
 def tearDown(self):
     if self.plan_obj:
         try:
             self.plan_obj.delete()
         except openpay.error.InvalidRequestError:
             pass
     super(CustomerPlanTest, self).tearDown()
Example #17
0
 def __init__(self, host, port=None, key_file=None, cert_file=None,
              strict=_strict_sentinel, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
              source_address=None, **_3to2kwargs):
     if 'check_hostname' in _3to2kwargs: check_hostname = _3to2kwargs['check_hostname']; del _3to2kwargs['check_hostname']
     else: check_hostname = None
     if 'context' in _3to2kwargs: context = _3to2kwargs['context']; del _3to2kwargs['context']
     else: context = None
     super(HTTPSConnection, self).__init__(host, port, strict, timeout,
                                           source_address)
     self.key_file = key_file
     self.cert_file = cert_file
     if context is None:
         # Some reasonable defaults
         context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
         context.options |= ssl.OP_NO_SSLv2
     will_verify = context.verify_mode != ssl.CERT_NONE
     if check_hostname is None:
         check_hostname = will_verify
     elif check_hostname and not will_verify:
         raise ValueError("check_hostname needs a SSL context with "
                          "either CERT_OPTIONAL or CERT_REQUIRED")
     if key_file or cert_file:
         context.load_cert_chain(cert_file, key_file)
     self._context = context
     self._check_hostname = check_hostname
Example #18
0
 def __init__(self, request, data=None, initial=None):
     """
     Store the request so that it can be used to retrieve the cart
     which is required to validate the discount code when entered.
     """
     super(DiscountForm, self).__init__(data=data, initial=initial)
     self._request = request
Example #19
0
File: export.py Project: nirs/lago
    def update_lago_metadata(self):
        super().update_lago_metadata()

        if self.standalone:
            self.exported_metadata['base'] = 'None'
        else:
            self.exported_metadata['base'] = os.path.basename(self.src)
Example #20
0
File: vm.py Project: nirs/lago
 def start(self):
     super().start()
     if not self.alive():
         # the wait_suspend method is a work around for:
         # https://bugzilla.redhat.com/show_bug.cgi?id=1411025
         # 'LAGO__START_WAIT__SUSPEND' should be set to a float or integer
         # indicating how much time to sleep between the time the domain
         # is created in paused mode, until it is resumed.
         wait_suspend = os.environ.get('LAGO__START__WAIT_SUSPEND')
         dom_xml = self._libvirt_xml()
         LOGGER.debug('libvirt XML: %s\n', dom_xml)
         with LogTask('Starting VM %s' % self.vm.name()):
             if wait_suspend is None:
                 self._createXML(dom_xml)
             else:
                 LOGGER.debug('starting domain in paused mode')
                 try:
                     wait_suspend = float(wait_suspend)
                 except:
                     raise ValueError(
                         'LAGO__START__WAIT_SUSPEND value is not a number'
                     )
                 dom = self._createXML(
                     dom_xml, flags=libvirt.VIR_DOMAIN_START_PAUSED
                 )
                 time.sleep(wait_suspend)
                 dom.resume()
                 if not dom.isActive():
                     raise RuntimeError(
                         'failed to resume %s domain' % dom.name()
                     )
Example #21
0
 def start(self, *args, **kwargs):
     """
     Schedule all handlers and start watching thread.
     """
     self.build(initial=True)
     self.schedule_all()
     super().start(*args, **kwargs)
Example #22
0
    def __init__(self, iterations, printer):
        self.fill_char = '-'
        self.width = 40
        self.printer = printer

        super(TextProgressBar, self).__init__(iterations)
        self.update(0)
Example #23
0
    def test_call_with_args_does_nothing(self):
        if utils.PY2:
            from __builtin__ import super as builtin_super
        else:
            from builtins import super as builtin_super

        class Base(object):
            def calc(self, value):
                return 2 * value

        class Sub1(Base):
            def calc(self, value):
                return 7 + super().calc(value)

        class Sub2(Base):
            def calc(self, value):
                return super().calc(value) - 1

        class Diamond(Sub1, Sub2):
            def calc(self, value):
                return 3 * super().calc(value)

        for cls in (Base, Sub1, Sub2, Diamond):
            obj = cls()
            self.assertSuperEquals(builtin_super(cls), super(cls))
            self.assertSuperEquals(builtin_super(cls, obj), super(cls, obj))
Example #24
0
File: html.py Project: 05bit/docta
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Jinja
        template_loader = jinja2.FileSystemLoader(self.project.templates_dir())
        self.jinja = jinja2.Environment(loader=template_loader)
        self.jinja.globals.update(**self.template_globals())
    def keyPressEvent(self, event):
        """
        Overrides the keyPressEvent to emit the key_pressed signal.

        Also takes care of indenting and handling smarter home key.

        :param event: QKeyEvent
        """
        initial_state = event.isAccepted()
        event.ignore()
        self.key_pressed.emit(event)
        state = event.isAccepted()
        if not event.isAccepted():
            if event.key() == QtCore.Qt.Key_Tab:
                self.indent()
                event.accept()
            elif event.key() == QtCore.Qt.Key_Backtab:
                self.un_indent()
                event.accept()
            elif event.key() == QtCore.Qt.Key_Home:
                self._do_home_key(
                    event, int(event.modifiers()) & QtCore.Qt.ShiftModifier)
            if not event.isAccepted():
                event.setAccepted(initial_state)
                super(CodeEdit, self).keyPressEvent(event)
        new_state = event.isAccepted()
        event.setAccepted(state)
        self.post_key_pressed.emit(event)
        event.setAccepted(new_state)
Example #26
0
 def save_model(self, request, obj, form, change):
     """
     Store the product ID for creating variations in save_formset.
     """
     super(ProductAdmin, self).save_model(request, obj, form, change)
     # We store the product ID so we can retrieve a clean copy of
     # the product in save_formset, see: GH #301.
     self._product_id = obj.id
Example #27
0
    def focusInEvent(self, event):
        """
        Overrides focusInEvent to emits the focused_in signal

        :param event: QFocusEvent
        """
        self.focused_in.emit(event)
        super(CodeEdit, self).focusInEvent(event)
    def resizeEvent(self, e):
        """
        Overrides resize event to resize the editor's panels.

        :param e: resize event
        """
        super(CodeEdit, self).resizeEvent(e)
        self.panels.resize()
Example #29
0
File: util.py Project: kaeufl/obspy
 def __init__(self, value, lower_uncertainty=None, upper_uncertainty=None,
              datum=None):
     """
     """
     self.datum = datum
     super(Longitude, self).__init__(
         value, lower_uncertainty=lower_uncertainty,
         upper_uncertainty=upper_uncertainty)
 def __init__(self, parent=None, client=None):
     super().__init__(parent, client)
     PortInData.__init__(self)
     self._activation_status = ActivationStatus(self)
     self._history = History(self)
     self._loas = Loas(self, client)
     self._notes = Notes(self, client)
     self._totals = Totals(self, client)
Example #31
0
 def tearDown(self):
     return defer.gatherResults([
         self.s.stopService(),
         defer.maybeDeferred(super(GridTestMixin, self).tearDown),
     ])
Example #32
0
 def tearDown(self):
     self.clean_pending(required_to_quiesce=True)
     return super(TestMixin, self).tearDown()
Example #33
0
 def close(self):
     super().close() # set "closed" flag
     if self.fp:
         self._close_conn()
Example #34
0
 def __init__(self, *args, **kwargs):
     super(Events, self).__init__(*args, **kwargs)
Example #35
0
 def __init__(self, sync):
     super().__init__(sync, True)
     gdb.Command.__init__(self, "translate", gdb.COMMAND_OBSCURE,
                          gdb.COMPLETE_NONE)
Example #36
0
 def __init__(self, sync):
     super().__init__(sync)
     gdb.Command.__init__(self, "bbt", gdb.COMMAND_OBSCURE,
                          gdb.COMPLETE_NONE)
     self.sync.symtable = {}
Example #37
0
 def __init__(self, client, results):
     super(CheckResultsRendererElement, self).__init__()
     self._client = client
     self._results = results
Example #38
0
 def setUp(self):
     return super(TestMixin, self).setUp()
Example #39
0
 def __init__(self, sync):
     super().__init__(sync)
     gdb.Command.__init__(self, "patch", gdb.COMMAND_OBSCURE,
                          gdb.COMPLETE_NONE)
Example #40
0
 def __init__(self, path, file_extension, *args, **kwargs):
     self.path = path
     self.file_extension = file_extension
     super(RenameForm, self).__init__(*args, **kwargs)
Example #41
0
 def __init__(self, path, *args, **kwargs):
     self.path = path
     super(MakeDirForm, self).__init__(*args, **kwargs)
Example #42
0
 def __init__(self, *args, **kwargs):
     kwargs["null"] = True
     defaults = {"max_length": 50}
     defaults.update(kwargs)
     super(OptionField, self).__init__(*args, **defaults)
 def __init__(self, parent=None, client=None):
     super().__init__(parent, client)
     CitiesData.__init__(self)
Example #44
0
 def __init__(self, sync):
     super().__init__(sync)
     gdb.Command.__init__(self, "modlist", gdb.COMMAND_RUNNING,
                          gdb.COMPLETE_NONE)
Example #45
0
 def flush(self):
     super().flush()
     if self.fp:
         self.fp.flush()
Example #46
0
 def __init__(self, sync):
     super().__init__(sync, True)
     gdb.Command.__init__(self, "syncmodauto", gdb.COMMAND_RUNNING,
                          gdb.COMPLETE_NONE)
Example #47
0
 def __init__(self, *args, **kw):
     super().__init__(*args, **kw)
Example #48
0
 def __init__(self, ctx):
     super().__init__(
         "Invalid context of type '{}' has been provided."
             .format(type(ctx).__name__))
Example #49
0
 def __init__(self, line=None):
     if line is not None:
         super().__init__(line)
     self.line = line
Example #50
0
 def __init__(self, *args, **kwargs):
     defaults = {"max_length": 20}
     defaults.update(kwargs)
     super(DiscountCodeField, self).__init__(*args, **defaults)
Example #51
0
 def __init__(self, non_printables):
     super().__init__(non_printables)
     self.non_printables = non_printables
Example #52
0
 def __init__(self, *args, **kwargs):
     if not args and "verbose_name" not in kwargs:
         args = (_("SKU"),)
     defaults = {"max_length": 20}
     defaults.update(kwargs)
     super(SKUField, self).__init__(*args, **defaults)
Example #53
0
 def __init__(self, *args, **kwargs):
     set_locale()
     defaults = {"null": True, "blank": True, "max_digits": 10,
                 "decimal_places": localeconv()["frac_digits"]}
     defaults.update(kwargs)
     super(MoneyField, self).__init__(*args, **defaults)
Example #54
0
 def formfield(self, *args, **kwargs):
     defaults = {'min_value': 0, 'max_value': 100}
     kwargs.update(**defaults)
     return super(PercentageField, self).formfield(*args, **kwargs)
Example #55
0
 def __init__(self, parent=None, client=None):
     super().__init__(parent, client)
     TnOptionOrdersData.__init__(self, self)
Example #56
0
 def setUp(self):
     self.s = service.MultiService()
     self.s.startService()
     return super(GridTestMixin, self).setUp()
Example #57
0
 def __init__(self):
     super(LiteralCheckResultsRendererElement, self).__init__()
Example #58
0
 def tearDown(self):
     if self.sigchldHandler:
         signal.signal(signal.SIGCHLD, self.sigchldHandler)
     return super(SignalMixin, self).tearDown()
Example #59
0
 def __init__(self, client):
     """
     :param allmydata.interfaces.IStatsProducer client: stats provider.
     """
     super(LiteralCheckResultsRenderer, self).__init__()
     self._client = client
Example #60
0
 def delete(self, *args, **kwargs):
     """
     Clear this sale from products when deleting the sale.
     """
     self._clear()
     super(Sale, self).delete(*args, **kwargs)