예제 #1
0
 def sections(self):
     raw_resources = fetcher.resources()
     sections = []
     for title, raw_section in raw_resources.items():
         section = {'title': title, 'items': []}
         sections.append(section)
         for text, url in raw_section.items():
             item = {'text': text, 'url': url}
             section['items'].append(item)
     return sections
예제 #2
0
def resources() -> List[Dict[str, str]]:
    urls = []
    for category, entries in fetcher.resources().items():
        for name, url in entries.items():
            urls.append({
                'name': f'Resources – {category} – {name}',
                'type': 'Resource',
                'url': url
            })
    return urls
예제 #3
0
def resources_resources(args):
    results = {}
    words = args.split()
    resources = fetcher.resources()
    for title, items in resources.items():
        for text, url in items.items():
            asked_for_this_section_only = len(words) == 1 and roughly_matches(title, words[0])
            asked_for_this_section_and_item = len(words) == 2 and roughly_matches(title, words[0]) and roughly_matches(text, words[1])
            asked_for_this_item_only = len(words) == 1 and roughly_matches(text, words[0])
            if asked_for_this_section_only or asked_for_this_section_and_item or asked_for_this_item_only:
                results[url] = text
    return results
예제 #4
0
def resources_resources(args: str) -> Dict[str, str]:
    results = {}
    words = args.split()
    resources = fetcher.resources()
    for title, items in resources.items():
        for text, url in items.items():
            asked_for_this_section_only = len(words) == 1 and roughly_matches(title, words[0])
            asked_for_this_section_and_item = len(words) == 2 and roughly_matches(title, words[0]) and roughly_matches(text, words[1])
            asked_for_this_item_only = len(words) == 1 and roughly_matches(text, words[0])
            the_whole_thing_sounds_right = roughly_matches(text, ' '.join(words))
            the_url_matches = roughly_matches(url, ' '.join(words))
            if asked_for_this_section_only or asked_for_this_section_and_item or asked_for_this_item_only or the_whole_thing_sounds_right or the_url_matches:
                results[url] = text
    return results
 def sections(self):
     raw_resources = fetcher.resources()
     sections = []
     for title, raw_section in raw_resources.items():
         section = {'title': title, 'items': []}
         sections.append(section)
         for text, url in raw_section.items():
             item = {
                 'text':
                 text,
                 'url':
                 url,
                 'is_external':
                 url.startswith('http')
                 and '://pennydreadfulmagic.com/' not in url
             }
             section['items'].append(item)
     return sections