Skip to content
Open
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
9 changes: 8 additions & 1 deletion regparser/grammar/amdpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,14 @@ def _through_paragraph(prev_lab, next_lab):
"""Expand "through" for labels ending in a paragraph."""
depth = len(prev_lab)
start = p_levels[depth - 4].index(prev_lab[-1]) + 1
end = p_levels[depth - 4].index(next_lab[-1])
try:
end = p_levels[depth - 4].index(next_lab[-1])
except ValueError as e: # Title 21 seems to skip a level
try:
end = p_levels[depth - 3].index(next_lab[-1])
except ValueError as e: # Title 21 seems to skip a level
end = None # This will fail; for debugging purposes only

return [tokens.Paragraph.make(prev_lab[:depth - 1] +
[p_levels[depth - 4][i]])
for i in range(start, end)]
Expand Down
9 changes: 9 additions & 0 deletions regparser/history/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ def json(self):
def from_json(json_str):
json_dict = json.loads(json_str)
effective = json_dict.get('effective')
if 'fr_citation' not in json_dict:
try:
json_dict['fr_citation'] = {
'volume': json_dict['volume'],
'page': json_dict['page']
}
except KeyError as e:
pass

if effective:
effective = datetime.strptime(effective, '%Y-%m-%d').date()
return Version(json_dict['identifier'], effective,
Expand Down
2 changes: 2 additions & 0 deletions regparser/layer/terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def inflected(self, term):
def look_for_defs(self, node, stack=None):
"""Check a node and recursively check its children for terms which are
being defined. Add these definitions to self.scoped_terms."""
if node.tagged_text is None:
node.tagged_text = '\n '
stack = stack or ParentStack()
stack.add(node.depth(), node)
if node.node_type in (struct.Node.REGTEXT, struct.Node.SUBPART,
Expand Down
3 changes: 2 additions & 1 deletion regparser/web/settings/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from regparser import plugins
import os

META = {}

Expand Down Expand Up @@ -110,7 +111,7 @@
# your own key at
# http://regulationsgov.github.io/developers/key/
REGS_GOV_API = 'https://api.data.gov/regulations/v3/'
REGS_GOV_KEY = 'DEMO_KEY'
REGS_GOV_KEY = os.environ['REGSGOVKEY']

# These are the host and port for the regparser Django server running the
# administrative UI.
Expand Down