Import an user story and returns a :class:`UserStory` resource.

        :param subject: subject of the :class:`UserStory`
        :param status: status of the :class:`UserStory`
        :param attrs: optional :class:`UserStory` attributes
347696
def import_user_story(self, subject, status, **attrs):
        
        return UserStories(self.requester).import_(
            self.id, subject, status, **attrs
        )
1013474
def get_history_user(self, instance):
        """"""
        try:
            return instance._history_user
        except AttributeError:
            request = None
            try:
                if self.thread.request.user.is_authenticated:
                    request = self.thread.request
            except AttributeError:
                pass

        return self.get_user(instance=instance, request=request)
677741
def top_stories(self, limit=5, first=None, last=None, json=False):
        

        story_ids = requests.get(TOP_STORIES_URL).json()
        story_urls = []
        for story_id in story_ids:
            url = API_BASE + "item/" + str(story_id) + '.json'
            story_urls.append(url)

        if first and last:
            story_urls = story_urls[first:last]
            if limit != 5:
                story_urls[:limit]  # default not given
        else:
            story_urls = story_urls[:limit]

        # try:
        #     response_queue = fetch_parallel(story_urls)
        #     if json:
        #         while not response_queue.empty():
        #             yield response_queue.get()
        #     else:
        #         while not response_queue.empty():
        #             yield story_parser(response_queue.get())
        # except AttributeError:
        #     Exception("Too many requests worker!!")

        # using gevent
        response_list = fetch_event(story_urls)
        if json:
            yield response_list
        else:
            for response in response_list:
                yield story_parser(response)
856517
def create(self, project, subject, **attrs):
        
        attrs.update({'project': project, 'subject': subject})
        return self._new_resource(payload=attrs)
800153
def subject(self) -> Optional[UnstructuredHeader]:
        """"""
        try:
            return cast(UnstructuredHeader, self[b'subject'][0])
        except (KeyError, IndexError):
            return None
1189562
def create_attributes(klass, attributes, previous_object=None):
        

        result = super(Webhook, klass).create_attributes(attributes, previous_object)

        if 'topics' not in result:
            raise Exception("Topics ('topics') must be provided for this operation.")
        return result
779872
def _get_user_data(self):
        

        url = self.session.host + '/sessions/' + str(self.session.id) + '/visualizations/' + str(self.id) + '/settings/'
        r = requests.get(url)
        if r.status_code == 200:
            content = r.json()
        else:
            raise Exception('Error retrieving user data from server')

        return content
392445
def get_news(self):
        
        if self.topic is None or self.topic is 'Top Stories':
            resp = requests.get(top_news_url, params=self.params_dict)
        else:
            topic_code = topicMap[process.extractOne(self.topic, self.topics)[0]]
            resp = requests.get(topic_url.format(topic_code), params=self.params_dict)
        return self.parse_feed(resp.content)
1352630
def reload
      @rdf_subject ||= self.class.nr_uri_from_headers(http_head)
      response = get(nil, true)
      self.content_type = response.env.response_headers['content-type']
      self.content = response.env.body
      self
    end
273020
def entities(self, subject_id):
        
        res = self._cache.get(subject_id)
        if not res:
            raise KeyError("No such subject")
        else:
            return res
1290317
def get_topics(self):
        
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/topics",
            headers={'Accept': Consts.mediaTypeTopicsPreview}
        )
        return data['names']
272093
def add_to_user(self, name, **attrs):
        
        user = self.get_user(name=name)
        attrs_ = user['user']
        attrs_.update(**attrs)
1031859
def get_objects_for_subject(subject=None,
                            object_category=None,
                            relation=None,
                            **kwargs):
    
    searchresult = search_associations(subject=subject,
                                       fetch_objects=True,
                                       rows=0,
                                       object_category=object_category,
                                       relation=relation,
                                       **kwargs
    )
    objs = searchresult['objects']
    return objs
301363
def dispatch_event(event, subject='id'):
    
    def wrapper(method):
        def inner_wrapper(*args, **kwargs):
            resource = method(*args, **kwargs)
            if isinstance(resource, dict):
                subject_ = resource.get(subject)
                data = resource
            else:
                subject_ = getattr(resource, subject)
                data = resource.__dict__
            event(subject_, data).dispatch()
            return resource
        return inner_wrapper
    return wrapper
824597
def status(self, status, headers=None):
        '''
        
        '''
        self.response = _Response(status, headers)
        return self
225820
def consume(topic, conf):
    
    from confluent_kafka.avro import AvroConsumer
    from confluent_kafka.avro.serializer import SerializerError

    print("Consuming user records from topic {} with group {}. ^c to exit.".format(topic, conf["group.id"]))

    c = AvroConsumer(conf, reader_value_schema=record_schema)
    c.subscribe([topic])

    while True:
        try:
            msg = c.poll(1)

            # There were no messages on the queue, continue polling
            if msg is None:
                continue

            if msg.error():
                print("Consumer error: {}".format(msg.error()))
                continue

            record = User(msg.value())
            print("name: {}\n\tfavorite_number: {}\n\tfavorite_color: {}\n".format(
                record.name, record.favorite_number, record.favorite_color))
        except SerializerError as e:
            # Report malformed record, discard results, continue polling
            print("Message deserialization failed {}".format(e))
            continue
        except KeyboardInterrupt:
            break

    print("Shutting down consumer..")
    c.close()
999275
def get_features(subject_id):
    ""
    
    features_path = os.path.join(my_project,'base_features', subject_id, 'features.txt')
    feature_vector = np.loadtxt(features_path)
    
    return feature_vector