JSON endpoint that returns a list of potential tags.

    Used for upload template autocomplete.
351268
def tag_lookup(request):
    
    tag = request.GET['tag']
    tagSlug = slugify(tag.strip())
    tagCandidates = Tag.objects.values('word').filter(slug__startswith=tagSlug)
    tags = json.dumps([candidate['word'] for candidate in tagCandidates])
    return HttpResponse(tags, content_type='application/json')
280002
def digest_json(soup):
    """"""
    abstract_tags = raw_parser.abstract(soup, abstract_type="executive-summary")
    abstract_json = None
    for tag in abstract_tags:
        abstract_json = render_abstract_json(tag)
    return abstract_json
755024
def process_tags(inst_tags):
    """"""
    tag_dict = {}
    for k in range(len(inst_tags)):
        tag_dict[inst_tags[k]['Key']] = inst_tags[k]['Value']
    return tag_dict
299081
def get_tags(ctx, archive_name):
    '''
    
    '''

    _generate_api(ctx)

    var = ctx.obj.api.get_archive(archive_name)

    click.echo(' '.join(var.get_tags()), nl=False)
    print('')
571197
def list_tags(self, pattern=None):
        
        request_url = "{}tags".format(self.create_basic_url())

        params = None
        if pattern:
            params = {'pattern': pattern}

        return_value = self._call_api(request_url, params=params)
        return return_value['tags']
119023
def _json_body_(cls):
        
        json = []
        for series_name, data in six.iteritems(cls._datapoints):
            for point in data:
                json_point = {
                    "measurement": series_name,
                    "fields": {},
                    "tags": {},
                    "time": getattr(point, "time")
                }

                for field in cls._fields:
                    value = getattr(point, field)
                    if value is not None:
                        json_point['fields'][field] = value

                for tag in cls._tags:
                    json_point['tags'][tag] = getattr(point, tag)

                json.append(json_point)
        return json
315904
def __get_tag_ids(self, tags):
        """"""

        db_tags = self.fetchall("select * from tags where name in (%s)"
                                            % ",".join(["?"] * len(tags)), tags) # bit of magic here - using sqlites bind variables

        changes = False

        # check if any of tags needs resurrection
        set_complete = [str(tag["id"]) for tag in db_tags if tag["autocomplete"] == "false"]
        if set_complete:
            changes = True
            self.execute("update tags set autocomplete='true' where id in (%s)" % ", ".join(set_complete))


        found_tags = [tag["name"] for tag in db_tags]

        add = set(tags) - set(found_tags)
        if add:
            statement = "insert into tags(name) values(?)"

            self.execute([statement] * len(add), [(tag,) for tag in add])

            return self.__get_tag_ids(tags)[0], True # all done, recurse
        else:
            return db_tags, changes
689081
def tag_map(self):
        '''  '''
        tm = dd(list)
        for tag in self.__tags:
            tm[tag.tagtype].append(tag)
        return tm
62733
def get_json(request, token):
    """"""
    result = []
    searchtext = request.GET['q']
    if len(searchtext) >= 3:
        pickled = _simple_autocomplete_queryset_cache.get(token, None)
        if pickled is not None:
            app_label, model_name, query = pickle.loads(pickled)
            model = apps.get_model(app_label, model_name)
            queryset = QuerySet(model=model, query=query)
            fieldname = get_search_fieldname(model)
            di = {'%s__istartswith' % fieldname: searchtext}
            app_label_model = '%s.%s' % (app_label, model_name)
            max_items = get_setting(app_label_model, 'max_items', 10)
            items = queryset.filter(**di).order_by(fieldname)[:max_items]

            # Check for duplicate strings
            counts = {}
            for item in items:
                if hasattr(item, "__unicode__"):
                    key = item.__unicode__()
                else:
                    key = str(item)
                #key = unicode(item)
                counts.setdefault(key, 0)
                counts[key] += 1

            # Assemble result set
            for item in items:
                #key = value = unicode(item)
                if hasattr(item, "__unicode__"):
                    key = value = item.__unicode__()
                else:
                    key = value = str(item)
                value = getattr(item, fieldname)
                if counts[key] > 1:
                    func = get_setting(
                        app_label_model,
                        'duplicate_format_function',
                        lambda obj, model, content_type: content_type.name
                    )
                    content_type = ContentType.objects.get_for_model(model)
                    value = '%s (%s)' % (value, func(item, model, content_type))
                result.append((item.id, value))

        else:
            result = 'CACHE_MISS'

    return HttpResponse(json.dumps(result))
4436
function getTemplateTags(start, end) {
            const results = []
            for (const token of microTemplateService.getMicroTemplateTokens()) {
                if (token.range[1] <= start) {
                    continue
                }
                if (end <= token.range[0]) {
                    break
                }
                results.push(token)
            }
            return results
        }
400976
def json(self, args=None):
        
        names = ['identifier', 'abstract', 'keywords']
        out = {key: getattr(self, key) for key in names}
        out.update(self.cf_attrs)
        out = self.format(out, args)

        out['notes'] = self.notes

        out['parameters'] = str({key: {'default': p.default if p.default != p.empty else None, 'desc': ''}
                                 for (key, p) in self._sig.parameters.items()})

        if six.PY2:
            out = walk_map(out, lambda x: x.decode('utf8') if isinstance(x, six.string_types) else x)

        return out
434460
def to_json(self):
        
        endpoints = []
        for endpoint in self.endpoints:
            list_fields = endpoint.fields
            resource_type = endpoint.Meta.resource_type
            table = endpoint.Meta.table

            data = endpoint.to_dict()
            data['fields'] = resource_type.get_type_of_fields(
                list_fields,
                table,
            )
            endpoints.append(data)

        data = {
            'title': self.title,
            'endpoints': sorted(endpoints, key=lambda x: x['name']),
        }

        return json.dumps(data)
405506
def list_upcoming(cls):
        
        return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
            cls.element_from_string(
                cls._get_request(endpoint=cls.ENDPOINT + '/upcoming').text
            )
        )
611734
def find(self, *tags):
        
        tags = list(map(str, tags))
        return self._client.json('corex.find', {'tags': tags})
244408
def options(self, request, tag):
        
        option = tag.patternGenerator('option')
        return tag[[
                OptionView(index, o, option())
                for (index, o)
                in enumerate(self.parameter.choices)]]
1090678
def generated_tag_data(tags):
    
    generated_tags = []
    for key, value in tags.items():
        generated_tags.append({
            'Key': key,
            'Value': value,
        })
    return generated_tags
11226
def tag_autocomplete_js(format_string=None):
    """"""
    if format_string:
        context_list = format_string.split(' ')
        context = {
            'app_label':context_list[0],'model':context_list[1], 'counts':context_list[2]
        }
    else:
        context = {}
    return render_to_string('tagging_ext/tagging_autocomplete_js.html', context)