def to_python(self,value): '''get python value from serialized place''' if isinstance(value,str) or isinstance(value,unicode): try: return RA_coord.fromStr(value) except: raise ValidationError("Invalid input for RA: "+value) elif isinstance(value, RA_coord) or value is None: return value else: raise TypeError("unable to convert {0} of type {1} to RA_coord",value,type(value).__name__)
def to_python(self, value): '''get python value from serialized place''' if isinstance(value, str) or isinstance(value, unicode): try: return RA_coord.fromStr(value) except: raise ValidationError("Invalid input for RA: " + value) elif isinstance(value, RA_coord) or value is None: return value else: raise TypeError("unable to convert {0} of type {1} to RA_coord", value, type(value).__name__)
def parse_first_coords(coord_file): """parse the coordinates of the first object in the coordinate file and return a Coords object""" with open(coord_file) as cf: line = cf.readline() while line and (line.isspace() or line.startswith("#")): # skip over blank lines and comments line = cf.readline() if not line: raise Exception("Unable to parse coordinates") # TODO use better exception type rastr, decstr = line.split()[0:2] # assume seperationg by whitespace and no internal whitespace ra = RA_coord.fromStr(rastr) dec = Dec_coord.fromStr(decstr) return Coords(ra, dec)
def parse_first_coords(coord_file): '''parse the coordinates of the first object in the coordinate file and return a Coords object''' with open(coord_file) as cf: line = cf.readline() while line and (line.isspace() or line.startswith('#')): #skip over blank lines and comments line = cf.readline() if not line: raise Exception( "Unable to parse coordinates") #TODO use better exception type rastr, decstr = line.split()[ 0:2] #assume seperationg by whitespace and no internal whitespace ra = RA_coord.fromStr(rastr) dec = Dec_coord.fromStr(decstr) return Coords(ra, dec)