openest.generate.retrieve module¶
-
openest.generate.retrieve.any_from_url(url)[source]¶ Returns a model retrieved from the argument url
any_from_url is a wrapper around
from_url(). It returns a model chosen bychoose_model(). Therefore, the file reader returned byfrom_url()must have one of the allowed model types as the first four characters in the document.Parameters: url (str) – URL of file to retrieve Returns: Model chosen by choose_model()Return type: object
-
openest.generate.retrieve.choose_model(fp, source=None)[source]¶ Reads a file object and returns a model based on file header
The file is converted into a
BinModel,DDPModel, orSplineModeldepending on the first four characters of the file.To use choose_model, the first four characters of the file reader object must be one of the following:
bin1, in which case aBinModelwill be returned,ddp1orddp2, in which case aDDPModelwill be returned, orspp1, in which case aSplineModelwill be returned.
If the model type is not one of the types listed above, a BaseException will be raised.
Todo
- Change exception type - sublcassing
BaseExceptionis not PEP compliant. - Custom exceptions should inherrit from
Exceptionor other built-in exceptions. This is so thatexcept Exceptionwill catch all exceptions except forKeyboardInterruptandSystemExit, which are not errors, but user-triggered events. See PEP-352.
- Change exception type - sublcassing
Parameters: - fp (file reader object) – file reader object to be converted into a model.
- source (str) – Meta-information about url the file was recovered from
Returns: Model of class
BinModel,DDPModel, orSplineModel.Return type: object
-
openest.generate.retrieve.from_url(url, create_func)[source]¶ Returns a
StringIO.StringIObuffer with the contents of the response from urlTodo
- response from urllib2.urlopen(req) is already a buffer. Is writing to a new buffer necessary?
-
openest.generate.retrieve.spline_from_url(url)[source]¶ Returns a
SplineModelfrom the argument url