Skip to content

Commit

Permalink
Require an /about/ entry
Browse files Browse the repository at this point in the history
- add check to translate.py
- add check and Ontobee example to migrate.py
- update README
  • Loading branch information
jamesaoverton committed Nov 16, 2015
1 parent b3bdf0a commit c264b20
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ Any entry can have a `status:` keyword. By default, every entry uses "temporary"
Apache RedirectMatch directives are processed in the [order that they appear](https://httpd.apache.org/docs/2.4/mod/mod_alias.html#order) in the configuration file. Be careful that your `prefix` and `regex` entries do not conflict with your other entries. The YAML-to-Apache translation preserves the order of entries, so you can control the order of processing, but it's best to avoid conflicts.


### `/about/` Terms

Every YAML configuration should have a `prefix: /about/` entry pointing to the project's preferred ontology term browser, e.g. [Ontobee](http://www.ontobee.org), [Bioportal](http://bioportal.bioontology.org/), or [OLS](http://www.ebi.ac.uk/ontology-lookup/). For example:

- prefix: /about/
replacement: http://www.ontobee.org/ontology/OBI?iri=http://purl.obolibrary.org/obo/
tests:
- from: /about/OBI_0000070
to: http://www.ontobee.org/ontology/OBI?iri=http://purl.obolibrary.org/obo/OBI_0000070

If this entry is missing, the tools will raise an error.


## Migrating Configuration

OBO projects currently use OCLC for managing PURLs. This project aims to replace OCLC in a straightforward way.
Expand Down
20 changes: 20 additions & 0 deletions tools/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,29 @@ def main():
entries = exact + sorted(prefix, key=lambda k: len(k['id']), reverse=True)
if len(entries) == 0:
raise ValueError('No entries found')

# Check for an /about/ prefix for all ontologies except the root
has_about = False
if args.base_url == '/obo':
has_about = True

for entry in entries:
args.yaml_file.write(entry_template %
(entry['rule'], entry['id'], entry['url']))
if entry['rule'] == 'prefix' and entry['id'] == '/about/':
has_about = True

# If there is not /about/ entry, add a 'best guess' Ontobee redirect.
# Still throws an error: the user should check the /about/ entry!
if not has_about:
guess_id = args.base_url.replace('/obo/', '').upper()
args.yaml_file.write("""- prefix: /about/
replacement: http://www.ontobee.org/ontology/%s?iri=http://purl.obolibrary.org/obo/
tests:
- from: /about/%s_0000000
to: http://www.ontobee.org/ontology/%s?iri=http://purl.obolibrary.org/obo/%s_0000000"""
% (guess_id, guess_id, guess_id, guess_id))
raise ValueError('No "/about/" prefix found in configuration; example entry added. Check it manually!')


# Define a SAX ContentHandler class to match the XML format,
Expand Down
10 changes: 10 additions & 0 deletions tools/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,21 @@ def main():

args.htaccess_file.write(header_template % args.yaml_file.name)

# Check for an /about/ prefix for all ontologies except the root
has_about = False
if base_url == '/obo':
has_about = True

i = 0
for entry in document['entries']:
i += 1
if 'prefix' in entry and entry['prefix'] == '/about/':
has_about = True
args.htaccess_file.write(process_entry(base_url, i, entry) + '\n')

if not has_about:
raise ValueError('No "/about/" prefix found in configuration')


def clean_source(s):
"""Given a URL string,
Expand Down

0 comments on commit c264b20

Please sign in to comment.