Permalink
Browse files

Merge branch 'staging' of github.com:sunlightlabs/billy into staging

  • Loading branch information...
2 parents 63e9b3c + bd5d0ef commit a127e1c08b34c52f6a650268d3f587ac1f01b2e0 @twneale twneale committed May 17, 2012
Showing with 21 additions and 11 deletions.
  1. +16 −9 billy/fulltext.py
  2. +3 −1 billy/schemas/bill.json
  3. +2 −1 billy/web/admin/templates/billy/legislator.html
View
25 billy/fulltext.py
@@ -15,14 +15,19 @@ def pdfdata_to_text(data):
def worddata_to_text(data):
- _, txtfile = tempfile.mkstemp(prefix='tmp-worddata-', suffix='.txt')
- with tempfile.NamedTemporaryFile(delete=True) as tmpf:
- tmpf.write(data)
- subprocess.check_call('abiword --to=%s %s' % (txtfile, tmpf.name),
- shell=True)
- tmpf.flush()
- text = open(txtfile).read()
- os.remove(txtfile)
+ desc, txtfile = tempfile.mkstemp(prefix='tmp-worddata-', suffix='.txt')
+ try:
+ with tempfile.NamedTemporaryFile(delete=True) as tmpf:
+ tmpf.write(data)
+ tmpf.flush()
+ subprocess.check_call(['abiword', '--to=%s' %txtfile, tmpf.name])
+ f = open(txtfile)
+ text = f.read()
+ tmpf.close()
+ f.close()
+ finally:
+ os.remove(txtfile)
+ os.close(desc)
return text.decode('utf8')
def text_after_line_numbers(lines):
@@ -55,5 +60,7 @@ def _clean_text(text):
def oyster_text(function):
@wraps(function)
def wrapper(oyster_doc, data):
- return _clean_text(function(oyster_doc, data))
+ data = function(oyster_doc, data)
+ if data:
+ return _clean_text(data)
return wrapper
View
4 billy/schemas/bill.json
@@ -15,11 +15,13 @@
"versions": {"type": "array", "items": {"type": "object", "properties": {
"name": {"type": "string"},
"url": {"type": "string", "blank": true},
+ "mimetype": {"type": "string", "required": false},
"title": {"type": "string", "required": false}
}}},
"documents": {"type": "array", "items": {"type": "object", "properties": {
"name": {"type": "string"},
- "url": {"type": "string"}
+ "url": {"type": "string"},
+ "mimetype": {"type": "string", "required": false}
}}},
"sponsors": {"type": "array", "items": {"type": "object", "properties": {
"type": {"type": "string"},
View
3 billy/web/admin/templates/billy/legislator.html
@@ -38,7 +38,8 @@
{% endif %}
{% if role.type == 'committee member' %}
- member of the {{ role.committee }} Committee
+ member of the {{ role.committee }} Committee
+ {% if role.subcommittee %}, {{role.subcommittee}} Subcommittee {% endif %}
{% endif %}
</li>
{% endfor %}

0 comments on commit a127e1c

Please sign in to comment.