This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# This script installs to /usr/local only. To install elsewhere you can just | |
# unzip https://github.com/mxcl/homebrew/zipball/master anywhere you like. | |
module Tty extend self | |
def blue; bold 34; end | |
def white; bold 39; end | |
def red; underline 31; end | |
def reset; escape 0; end | |
def bold n; escape "1;#{n}" end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Strip spaces at start and end | |
* Replace tabs with space | |
* Collapse multiple spaces | |
* Reverse the affiliations file | |
* Load into Google refine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
_RE_MULTIPLE_SPACES = re.compile('\s\s+') | |
_RE_AFFILIATION_PREFIX = re.compile('([A-Z][A-Z]+)\(') | |
_RE_AFFILIATION_SUFFIX = re.compile('\)[,;]? [A-Z][A-Z]+\(') | |
_RE_EMAIL = re.compile(';?\s?<EMAIL>\s?(.*?)\s?</EMAIL>;?') | |
def clean_affiliations_string(affiliations_string): | |
""" | |
Strips the spaces and collapses multiple spaces. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original inspiration found here: | |
http://www.openerp.com/forum/topic21864.html | |
== Install libxml2 == | |
$ wget ftp://xmlsoft.org/libxml2/libxml2-sources-2.7.8.tar.gz | |
$ tar xvf libxml2-sources-2.7.8.tar.gz | |
$ cd libxml2-2.7.8/ | |
$ ./configure --with-python=/usr/bin/python2.6 | |
$ make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from invenio.dbquery import run_sql | |
from invenio.websearchadminlib import add_col | |
def collection_exist(tag): | |
""" | |
Checks if a collection exists. | |
@return: The name of the collection if it exists, None otherwise. | |
""" |