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): try: with bk.Read(self.from_file) as fin: fin.read_header() for point in fin.get_points(): self.shapes.append(point) self.header = fin.header except PermissionError: raise PermissionError if not self.shapes: raise ValueError
def read(self): try: with bk.Read(self.from_file) as fin: fin.read_header() for line in fin.get_lines(): self.shapes.append(line) if line.is_closed(): self.nb_closed += 1 else: self.nb_open += 1 self.header = fin.header except PermissionError: raise PermissionError if not self.shapes: raise ValueError