Populate the user's labels from a JSON encoded list.
169602
def _sync_labels(self, labels_json):
        """""""
        for label_json in labels_json:
            label_id = label_json['id']
            self.labels[label_id] = Label(label_json, self)
261042
def _from_json_list(cls, response_raw, wrapper=None):
        

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        array = obj[cls._FIELD_RESPONSE]
        array_deserialized = []

        for item in array:
            item_unwrapped = item if wrapper is None else item[wrapper]
            item_deserialized = converter.deserialize(cls, item_unwrapped)
            array_deserialized.append(item_deserialized)

        pagination = converter.deserialize(client.Pagination,
                                           obj[cls._FIELD_PAGINATION])

        return client.BunqResponse(array_deserialized, response_raw.headers,
                                   pagination)
801907
def populate(cls, graph):
        
        [graph.bind(k, v) for k, v in cls._dict.items()]
501193
def label(self, name, color, update=True):
        
        url = '%s/labels' % self
        data = dict(name=name, color=color)
        response = self.http.post(
            url, json=data, auth=self.auth, headers=self.headers
        )
        if response.status_code == 201:
            return True
        elif response.status_code == 422 and update:
            url = '%s/%s' % (url, name)
            response = self.http.patch(
                url, json=data, auth=self.auth, headers=self.headers
            )
        response.raise_for_status()
        return False
740895
def user_parse(data):
        """"""
        yield 'id', data.get('uuid')
        yield 'username', data.get('username')
        yield 'last_name', data.get('display_name')
        links = data.get('links', {})
        yield 'picture', links.get('avatar', {}).get('href')
        yield 'link', links.get('html', {}).get('href')
436181
def a_list(label=None, kwargs=None, attributes=None):
    
    result = ['label=%s' % quote(label)] if label is not None else []
    if kwargs:
        items = ['%s=%s' % (quote(k), quote(v))
            for k, v in tools.mapping_items(kwargs) if v is not None]
        result.extend(items)
    if attributes:
        if hasattr(attributes, 'items'):
            attributes = tools.mapping_items(attributes)
        items = ['%s=%s' % (quote(k), quote(v))
            for k, v in attributes if v is not None]
        result.extend(items)
    return ' '.join(result)
1301832
def mapLabelRefs(dataDict):
  
  labelRefs = [label for label in set(
    itertools.chain.from_iterable([x[1] for x in dataDict.values()]))]

  for recordNumber, data in dataDict.iteritems():
    dataDict[recordNumber] = (data[0], numpy.array(
      [labelRefs.index(label) for label in data[1]]), data[2])

  return labelRefs, dataDict
458996
def update_from_json(self, data):
        
        self.subscription = data.get("subscription", "none")
        self.approved = bool(data.get("approved", False))
        self.ask = data.get("ask", None)
        self.name = data.get("name", None)
        self.groups = set(data.get("groups", []))
588106
def populate(self, **values):
        """"""
        values = values.copy()
        fields = list(self.iterate_with_name())
        for _, structure_name, field in fields:
            if structure_name in values:
                field.__set__(self, values.pop(structure_name))
        for name, _, field in fields:
            if name in values:
                field.__set__(self, values.pop(name))
289887
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'feedback_type' in _dict:
            args['feedback_type'] = _dict.get('feedback_type')
        if 'document' in _dict:
            args['document'] = ShortDoc._from_dict(_dict.get('document'))
        if 'model_id' in _dict:
            args['model_id'] = _dict.get('model_id')
        if 'model_version' in _dict:
            args['model_version'] = _dict.get('model_version')
        if 'location' in _dict:
            args['location'] = Location._from_dict(_dict.get('location'))
        if 'text' in _dict:
            args['text'] = _dict.get('text')
        if 'original_labels' in _dict:
            args['original_labels'] = OriginalLabelsOut._from_dict(
                _dict.get('original_labels'))
        if 'updated_labels' in _dict:
            args['updated_labels'] = UpdatedLabelsOut._from_dict(
                _dict.get('updated_labels'))
        if 'pagination' in _dict:
            args['pagination'] = Pagination._from_dict(_dict.get('pagination'))
        return cls(**args)
1065604
def load(json_src, save=False):
    """"""
    if isinstance(json_src, six.string_types):
        json_src = json_lib.loads(json_src)

    if isinstance(json_src, list):
        return [getattr(objects, obj['class']).load(obj, save)
                for obj in json_src]

    return getattr(objects, json_src['class']).load(json_src, save)
1305847
def get_labels(labels):
    """"""
    label_u = unique_labels(labels)
    label_u_line = [i + "_line" for i in label_u]
    return label_u, label_u_line
1115692
function (options) {
                var dataModel = this._dataModel;
                // normalize labels to lowerCase
                var sz = options.length, item;
                for (var i = 0; sz > i; i++) {
                    item = options[i];
                    item[this.LABEL_META] = item.label.toLowerCase();
                }
                jsonUtils.setValue(dataModel, 'listContent', options);
                this._setDisplayIdx(0);
            }
313738
def list_from_json(source_list_json):
    
    result = []
    if source_list_json == [] or source_list_json == None:
        return result
    for list_item in source_list_json:
        item = json.loads(list_item)
        try:
            if item['class_name'] == 'Departure':
                temp = Departure()
            elif item['class_name'] == 'Disruption':
                temp = Disruption()
            elif item['class_name'] == 'Station':
                temp = Station()
            elif item['class_name'] == 'Trip':
                temp = Trip()
            elif item['class_name'] == 'TripRemark':
                temp = TripRemark()
            elif item['class_name'] == 'TripStop':
                temp = TripStop()
            elif item['class_name'] == 'TripSubpart':
                temp = TripSubpart()
            else:
                print('Unrecognised Class ' + item['class_name'] + ', skipping')
                continue
            temp.from_json(list_item)
            result.append(temp)
        except KeyError:
            print('Unrecognised item with no class_name, skipping')
            continue
    return result
1087938
function populateLabelsForPR(pr) {
  print(['Get labels for PR ', clc.yellow.bold(`${pr.head.user.login}/${pr.head.repo.name}#${pr.number}`)], debug);
  return new Promise((resolve) => {
    github.issues.getIssueLabels({
      user: pr.base.user.login,
      repo: pr.base.repo.name,
      number: pr.number
    }, function (err, labels) {
      if (err && debug) {
        print(['Error fetching labels for PR ', clc.red.bold`${pr.base.user.login}/${pr.base.repo.name}#${pr.number}`], debug);
      }
      if (labels && labels.length > 0) {
        pr.labels = labels.map((label) => {
          return {
            name: label.name,
            color: label.color
          };
        });
      }
      return resolve(pr);
    });
  });
}
715992
def labels(self):
        
        if self._labels is None:
            self._labels = map(self.labelFormat().format, self.values())
        return self._labels
939631
def from_json(cls, data):
        
        user = cls()

        user.user_id = data['userId']
        user.username = data['username']
        user.auth_system = data['authSystem']
        user.roles = data['roles']

        return user