The best way to deal with the issue (and this it not just the case of using FragIt, but any kind of library) which I learned from the very excellent "The Clean Coder" by Robert C. Martin is to write a wrapper for the FragIt API to suit your specific needs because this you can unit test and know instantly when the API has changed.
In header of this wrapper, you can provide code that looks like
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
# always assume that we have openbabel | |
has_openbabel = True | |
try: | |
import openbabel | |
except ImportError: | |
has_openbabel = False | |
def FragIt_GetFragmentationPoints(input): | |
""" Obtains the fragmentation points using the FragIt API | |
based on the inpu | |
""" | |
# If the user has no Open Babel installed, inform the user | |
if not has_openbabel: | |
def FragIt_GetFragmentationPoints(input): | |
print "WARNING: FragIt API not available because" | |
print " Open Babel is missing / misconfigured." | |
return None |
There are many ways to deal with it, this is one.
By the way: happy 1 year anniversary for the last blog post!