Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

YUI 3 modules #34

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions yui3/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Depdendencies:
BeautifulSoup 3
4 changes: 4 additions & 0 deletions yui3/fetch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
mkdir data
wget http://yuilibrary.com/yui/docs/guides/ -O data/official.html
wget http://yuilibrary.com/gallery/show/ -O data/gallery.html
5 changes: 5 additions & 0 deletions yui3/meta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Name: YUI Library
Domain: yuilibrary.com
Type: YUI 3 Module
MediaWiki: 0
Keywords: yui, yui 3, yui3
58 changes: 58 additions & 0 deletions yui3/parse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re
from BeautifulSoup import BeautifulSoup
from collections import defaultdict
# Use defaultdict to append duplicates, but output only the first entry

modules = defaultdict(list)

def normalize(string):
''' -> Remove parantheses part from ending of module names
-> Remove YUI from module name
'''
return re.sub('( ?\(.*\)$|YUI\ ?[2-3]?[ -]?)', '', string)

def get_descr_string(type, descr):
return '''<b>Type:</b> %s<br /><b>Description:</b> %s''' %(type, re.sub('(\n|\r)', '<br />', descr))

# Parse the official modules
official_soup = BeautifulSoup(open('data/official.html'))
for module in official_soup.findAll('li', {'class' : 'component'}):
modules[module.a.text].append(dict(link = 'http://yuilibrary.com' + module.a['href'],
name = module.a.text,
descr = get_descr_string('Official', module.a['data-tooltip'])))

# Parse the community supported gallery modules
gallery_soup = BeautifulSoup(open('data/gallery.html'))
for module in gallery_soup.findAll('a', href = re.compile('/gallery/show/.+')):
if 'patch' in module.text.lower():
continue
h4 = module.findNext('h4')
if h4.span:
descr = get_descr_string('Gallery, available on CDN', h4.span.next.next)
else:
descr = get_descr_string('Gallery', h4.next.next)

modules[normalize(module.text)].append(dict(link = 'http://yuilibrary.com' + module['href'],
descr = descr,
name = module.text))

with open('output.txt', 'w') as f:
for name, value in modules.items():
f.write('\t'.join([
name, # title
'A', # type
'', # redirect
'', # otheruses
'', # categories
'', # references
'', # see_also
'', # further_reading
'', # external_links
'', # disambiguation
'', # images
value[0]['descr'], # abstract
value[0]['link'] # source_url
]) + "\n")
2 changes: 2 additions & 0 deletions yui3/parse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
python parse.py
2 changes: 2 additions & 0 deletions yui3/queries.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yui charts
yui 3 accordion