コード例 #1
0
ファイル: geometry.py プロジェクト: fatiando/fatiando
 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)
コード例 #2
0
ファイル: coverme.py プロジェクト: spumer/coverme
 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'])
コード例 #3
0
ファイル: test_rerunner.py プロジェクト: pyarnold/Testify
 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)
コード例 #4
0
ファイル: geometry.py プロジェクト: fatiando/fatiando
 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])
コード例 #5
0
    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)
コード例 #6
0
ファイル: error.py プロジェクト: sfinucane/deviceutils
 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)
コード例 #7
0
 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)
コード例 #8
0
ファイル: admin.py プロジェクト: jaywink/cartridge-reservable
    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)
コード例 #9
0
ファイル: test_suites_test.py プロジェクト: pyarnold/Testify
    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)
コード例 #10
0
    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)
コード例 #11
0
ファイル: test_case.py プロジェクト: pyarnold/Testify
    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
コード例 #12
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)
コード例 #13
0
ファイル: serial.py プロジェクト: sfinucane/deviceutils
 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
コード例 #14
0
ファイル: regularization.py プロジェクト: fatiando/fatiando
 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
コード例 #15
0
    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]
コード例 #16
0
 def tearDown(self):
     if self.plan_obj:
         try:
             self.plan_obj.delete()
         except openpay.error.InvalidRequestError:
             pass
     super(CustomerPlanTest, self).tearDown()
コード例 #17
0
ファイル: client.py プロジェクト: 9seconds/python-future
 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
コード例 #18
0
ファイル: forms.py プロジェクト: DanielLoeb/cartridge
 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
コード例 #19
0
ファイル: export.py プロジェクト: 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)
コード例 #20
0
ファイル: vm.py プロジェクト: 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()
                     )
コード例 #21
0
ファイル: watcher.py プロジェクト: 05bit/docta
 def start(self, *args, **kwargs):
     """
     Schedule all handlers and start watching thread.
     """
     self.build(initial=True)
     self.schedule_all()
     super().start(*args, **kwargs)
コード例 #22
0
ファイル: progressbar.py プロジェクト: rosinality/statisty
    def __init__(self, iterations, printer):
        self.fill_char = '-'
        self.width = 40
        self.printer = printer

        super(TextProgressBar, self).__init__(iterations)
        self.update(0)
コード例 #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))
コード例 #24
0
ファイル: html.py プロジェクト: 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())
コード例 #25
0
    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)
コード例 #26
0
ファイル: admin.py プロジェクト: haganf/cartridge082
 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
コード例 #27
0
ファイル: code_edit.py プロジェクト: GrandHsu/pyqode.core
    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)
コード例 #28
0
    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()
コード例 #29
0
ファイル: util.py プロジェクト: 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)
コード例 #30
0
 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)
コード例 #31
0
ファイル: no_network.py プロジェクト: sumonst21/tahoe-lafs
 def tearDown(self):
     return defer.gatherResults([
         self.s.stopService(),
         defer.maybeDeferred(super(GridTestMixin, self).tearDown),
     ])
コード例 #32
0
ファイル: common_util.py プロジェクト: sajith/tahoe-lafs
 def tearDown(self):
     self.clean_pending(required_to_quiesce=True)
     return super(TestMixin, self).tearDown()
コード例 #33
0
 def close(self):
     super().close() # set "closed" flag
     if self.fp:
         self._close_conn()
コード例 #34
0
 def __init__(self, *args, **kwargs):
     super(Events, self).__init__(*args, **kwargs)
コード例 #35
0
ファイル: sync.py プロジェクト: doitthink/ret-sync
 def __init__(self, sync):
     super().__init__(sync, True)
     gdb.Command.__init__(self, "translate", gdb.COMMAND_OBSCURE,
                          gdb.COMPLETE_NONE)
コード例 #36
0
ファイル: sync.py プロジェクト: doitthink/ret-sync
 def __init__(self, sync):
     super().__init__(sync)
     gdb.Command.__init__(self, "bbt", gdb.COMMAND_OBSCURE,
                          gdb.COMPLETE_NONE)
     self.sync.symtable = {}
コード例 #37
0
 def __init__(self, client, results):
     super(CheckResultsRendererElement, self).__init__()
     self._client = client
     self._results = results
コード例 #38
0
ファイル: common_util.py プロジェクト: sajith/tahoe-lafs
 def setUp(self):
     return super(TestMixin, self).setUp()
コード例 #39
0
ファイル: sync.py プロジェクト: doitthink/ret-sync
 def __init__(self, sync):
     super().__init__(sync)
     gdb.Command.__init__(self, "patch", gdb.COMMAND_OBSCURE,
                          gdb.COMPLETE_NONE)
コード例 #40
0
 def __init__(self, path, file_extension, *args, **kwargs):
     self.path = path
     self.file_extension = file_extension
     super(RenameForm, self).__init__(*args, **kwargs)
コード例 #41
0
 def __init__(self, path, *args, **kwargs):
     self.path = path
     super(MakeDirForm, self).__init__(*args, **kwargs)
コード例 #42
0
 def __init__(self, *args, **kwargs):
     kwargs["null"] = True
     defaults = {"max_length": 50}
     defaults.update(kwargs)
     super(OptionField, self).__init__(*args, **defaults)
コード例 #43
0
 def __init__(self, parent=None, client=None):
     super().__init__(parent, client)
     CitiesData.__init__(self)
コード例 #44
0
ファイル: sync.py プロジェクト: doitthink/ret-sync
 def __init__(self, sync):
     super().__init__(sync)
     gdb.Command.__init__(self, "modlist", gdb.COMMAND_RUNNING,
                          gdb.COMPLETE_NONE)
コード例 #45
0
 def flush(self):
     super().flush()
     if self.fp:
         self.fp.flush()
コード例 #46
0
ファイル: sync.py プロジェクト: doitthink/ret-sync
 def __init__(self, sync):
     super().__init__(sync, True)
     gdb.Command.__init__(self, "syncmodauto", gdb.COMMAND_RUNNING,
                          gdb.COMPLETE_NONE)
コード例 #47
0
 def __init__(self, *args, **kw):
     super().__init__(*args, **kw)
コード例 #48
0
 def __init__(self, ctx):
     super().__init__(
         "Invalid context of type '{}' has been provided."
             .format(type(ctx).__name__))
コード例 #49
0
 def __init__(self, line=None):
     if line is not None:
         super().__init__(line)
     self.line = line
コード例 #50
0
 def __init__(self, *args, **kwargs):
     defaults = {"max_length": 20}
     defaults.update(kwargs)
     super(DiscountCodeField, self).__init__(*args, **defaults)
コード例 #51
0
 def __init__(self, non_printables):
     super().__init__(non_printables)
     self.non_printables = non_printables
コード例 #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)
コード例 #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)
コード例 #54
0
 def formfield(self, *args, **kwargs):
     defaults = {'min_value': 0, 'max_value': 100}
     kwargs.update(**defaults)
     return super(PercentageField, self).formfield(*args, **kwargs)
コード例 #55
0
 def __init__(self, parent=None, client=None):
     super().__init__(parent, client)
     TnOptionOrdersData.__init__(self, self)
コード例 #56
0
ファイル: no_network.py プロジェクト: sumonst21/tahoe-lafs
 def setUp(self):
     self.s = service.MultiService()
     self.s.startService()
     return super(GridTestMixin, self).setUp()
コード例 #57
0
 def __init__(self):
     super(LiteralCheckResultsRendererElement, self).__init__()
コード例 #58
0
ファイル: common_util.py プロジェクト: sajith/tahoe-lafs
 def tearDown(self):
     if self.sigchldHandler:
         signal.signal(signal.SIGCHLD, self.sigchldHandler)
     return super(SignalMixin, self).tearDown()
コード例 #59
0
 def __init__(self, client):
     """
     :param allmydata.interfaces.IStatsProducer client: stats provider.
     """
     super(LiteralCheckResultsRenderer, self).__init__()
     self._client = client
コード例 #60
0
ファイル: models.py プロジェクト: huangdehui2013/cartridge
 def delete(self, *args, **kwargs):
     """
     Clear this sale from products when deleting the sale.
     """
     self._clear()
     super(Sale, self).delete(*args, **kwargs)