def run(self): if self.state == Node.SUCCESS: return try: with open(self.filename) as f: 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 struct.error: self.fail('Inconsistent bytes.') 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 read(self): self.fields = shp.get_all_fields(self.from_file) for index, name in shp.get_numeric_attribute_names(self.from_file): self.numeric_fields.append((index, name)) if self.shape_type in (3, 5): self.read_line() elif self.shape_type in (13, 15): self.read_linez() else: self.read_linem()
def read(self): self.fields = shp.get_all_fields(self.from_file) if self.shape_type == 8: self.read_point() elif self.shape_type == 18: try: self.read_pointz() except RuntimeError: raise RuntimeError else: self.read_pointm() if not self.shapes: raise ValueError
def read(self): self.fields = shp.get_all_fields(self.from_file) self.numeric_fields = shp.get_numeric_attribute_names(self.from_file) if self.shape_type == 1: self.read_point() elif self.shape_type == 11: try: self.read_pointz() except RuntimeError: raise RuntimeError else: self.read_pointm() if not self.shapes: raise ValueError
def run(self): if self.state == Node.SUCCESS: return try: with open(self.filename) as f: 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 struct.error: self.fail('Inconsistent bytes.') 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 ''))