获取雪球调仓历史
        :param instance:
        :param owner:
        :return:
761976
def _get_xq_history(self):
        
        data = {
            "cube_symbol": str(self.account_config["portfolio_code"]),
            "count": 20,
            "page": 1,
        }
        resp = self.s.get(self.config["history_url"], params=data)
        res = json.loads(resp.text)
        return res["list"]
322469
def default_instance(cls):
        
        if cls._instance is None:
            with cls._instance_lock:
                if cls._instance is None:
                    cls._instance = MessageDispatcher()

        return cls._instance
1108016
def as_of(self, date):
        
        if not self.instance:
            return self._as_of_set(date)
        queryset = self.get_queryset().filter(history_date__lte=date)
        try:
            history_obj = queryset[0]
        except IndexError:
            raise self.instance.DoesNotExist(
                "%s had not yet been created." % self.instance._meta.object_name
            )
        if history_obj.history_type == "-":
            raise self.instance.DoesNotExist(
                "%s had already been deleted." % self.instance._meta.object_name
            )
        return history_obj.instance
1221319
def instance(cls):
        

        if not hasattr(cls, "_instance") or cls._instance is None:
            cls._instance = cls()
        return cls._instance
589723
def most_recent(self):
        
        if not self.instance:
            raise TypeError(
                "Can't use most_recent() without a {} instance.".format(
                    self.model._meta.object_name
                )
            )
        tmp = []
        excluded_fields = getattr(self.model, "_history_excluded_fields", [])

        for field in self.instance._meta.fields:
            if field.name in excluded_fields:
                continue
            if isinstance(field, models.ForeignKey):
                tmp.append(field.name + "_id")
            else:
                tmp.append(field.name)
        fields = tuple(tmp)
        try:
            values = self.get_queryset().values_list(*fields)[0]
        except IndexError:
            raise self.instance.DoesNotExist(
                "%s has no historical record." % self.instance._meta.object_name
            )
        return self.instance.__class__(*values)
621015
def ownership(self, ownership):
        
        error_msg = 'ownership must be a list of dictionaries'
        if ownership:
            if not isinstance(ownership, list):
                raise TypeError(error_msg)
            if not all([isinstance(item, dict) for item in ownership]):
                raise TypeError(error_msg)
            if not all([item.get('party_id') for item in ownership]):
                raise ValueError('Ownership missing one or more party_ids')
            if not all([item.get('split') for item in ownership]):
                raise ValueError('Ownership missing one or more splits')
            if sum([item.get('split') for item in ownership]) != Decimal('1'):
                raise ValueError('Ownership must sum up to 100%')
        self._ownership = ownership
63385
public void setOwner(ListenerOwner owner)
    {
        if (owner == null)
        {
            if (m_messageListener != null)
            {
                m_messageListener.free();
                m_messageListener = null;
            }
        }
        super.setOwner(owner);
        if (owner != null)
        {
            Record record = this.getOwner().getRecord();
            MessageManager messageManager = ((Application)record.getTask().getApplication()).getMessageManager();
            if (messageManager != null)
            {
                BaseMessageFilter messageFilter = new BaseMessageFilter(MessageConstants.TRX_RETURN_QUEUE, MessageConstants.INTERNET_QUEUE, this, null);
                messageManager.addMessageFilter(messageFilter);
                m_messageListener = new  WaitForFieldChangeMessageListener(messageFilter, this);
                record.setupRecordListener(m_messageListener, false, false);   // I need to listen for record changes
            }
        }            
    }
348137
def history(self):
        
        history = self.history_class
        if history:
            return self.session.query(history).filter(history.id == self.id)
        else:
            return None
184002
def get_instance(model, instance_id):
    
    try:
        model = get_model(model)
    except ImportError:
        return None

    return model.query.get(instance_id)
181078
def change_owner(ctx, owner, uuid):
    """"""

    objects = ctx.obj['objects']
    database = ctx.obj['db']

    if uuid is True:
        owner_filter = {'uuid': owner}
    else:
        owner_filter = {'name': owner}

    owner = database.objectmodels['user'].find_one(owner_filter)
    if owner is None:
        log('User unknown.', lvl=error)
        return

    for item in objects:
        item.owner = owner.uuid
        item.save()

    log('Done')
943047
def owner(self, owner):
        
        if owner is None:
            raise ValueError("Invalid value for `owner`, must not be `None`")
        if owner is not None and len(owner) > 31:
            raise ValueError("Invalid value for `owner`, length must be less than or equal to `31`")
        if owner is not None and len(owner) < 3:
            raise ValueError("Invalid value for `owner`, length must be greater than or equal to `3`")
        if owner is not None and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', owner):
            raise ValueError("Invalid value for `owner`, must be a follow pattern or equal to `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`")

        self._owner = owner
1139692
def bulk_history_create(self, objs, batch_size=None):
        """"""

        historical_instances = [
            self.model(
                history_date=getattr(instance, "_history_date", now()),
                history_user=getattr(instance, "_history_user", None),
                history_change_reason=getattr(instance, "changeReason", ""),
                history_type="+",
                **{
                    field.attname: getattr(instance, field.attname)
                    for field in instance._meta.fields
                    if field.name not in self.model._history_excluded_fields
                }
            )
            for instance in objs
        ]

        return self.model.objects.bulk_create(
            historical_instances, batch_size=batch_size
        )
635385
public void setOwner(ListenerOwner owner)
    {
        super.setOwner(owner);
        if (owner != null) if (m_recordToSync != null)
            m_recordToSync.addListener(new FileRemoveBOnCloseHandler(this));
    }
1359770
def owner(self):
        
        from .author import Author

        a = self.soup.find('h2', class_='zm-list-content-title').a
        name = a.text
        url = Zhihu_URL + a['href']
        motto = self.soup.find(
            'div', id='zh-single-answer-author-info').div.text
        photo_url = PROTOCOL + self.soup.find(
            'img', class_='zm-list-avatar-medium')['src'].replace('_m', '_r')
        return Author(url, name, motto, photo_url=photo_url,
                      session=self._session)
144017
def set_owner
      return unless owner || group
      chown = command? 'chown'

      return unless chown

      cmd = [chown, '-R', "#{owner}:#{group}", destination_path]
      logger.debug { "Running command: #{cmd.join ' '}" }
      system(*cmd)
    end
1359149
def show_instance(name, call=None):
    '''
    
    '''
    node = get_node(name)
    ret = query(command='my/machines/{0}'.format(node['id']),
                location=node['location'], method='GET')

    return ret
806570
def owner(self):
        
        obj = javabridge.call(self.jobject, "getOwner", "()Lweka/core/CapabilitiesHandler;")
        if obj is None:
            return None
        else:
            return JavaObject(jobject=obj)