def run(self): if self.state == Node.SUCCESS: return try: with open(self.filename): pass except PermissionError: self.fail('Access denied.') return self.data = PolylineData() is_i2s = self.filename[-4:] == '.i2s' if is_i2s: with BlueKenue.Read(self.filename) as f: f.read_header() for poly in f.get_open_polylines(): self.data.add_line(poly) self.data.set_fields(['Value']) else: try: for poly in Shapefile.get_open_polylines(self.filename): self.data.add_line(poly) except ShapefileException as e: self.fail(e) return self.data.set_fields(Shapefile.get_all_fields(self.filename)) if self.data.is_empty(): self.fail('the file does not contain any 2D open polyline.') return self.success('The file contains {} open line{}.'.format( len(self.data), 's' if len(self.data) > 1 else ''))
def run(self): if self.state == Node.SUCCESS: return try: with open(self.filename): pass except PermissionError: self.fail('Access denied.') return self.data = PointData() try: for point, attribute in Shapefile.get_points(self.filename): self.data.add_point(point) self.data.add_attribute(attribute) except ShapefileException as e: self.fail(e) return self.data.set_fields(Shapefile.get_all_fields(self.filename)) if self.data.is_empty(): self.fail('the file does not contain any point.') return self.success('The file contains {} point{}.'.format( len(self.data), 's' if len(self.data) > 1 else ''))