(self)
| 57 | super(CSV_API, self).__init__(code, k_type, begin_date, end_date, autype) |
| 58 | |
| 59 | def get_kl_data(self): |
| 60 | cur_path = os.path.dirname(os.path.realpath(__file__)) |
| 61 | k_type = self.k_type.name[2:].lower() |
| 62 | file_path = f"{cur_path}/../{self.code}_{k_type}.csv" |
| 63 | if not os.path.exists(file_path): |
| 64 | raise CChanException(f"file not exist: {file_path}", ErrCode.SRC_DATA_NOT_FOUND) |
| 65 | |
| 66 | for line_number, line in enumerate(open(file_path, 'r')): |
| 67 | if self.headers_exist and line_number == 0: |
| 68 | continue |
| 69 | data = line.strip("\n").split(",") |
| 70 | if len(data) != len(self.columns): |
| 71 | raise CChanException(f"file format error: {file_path}", ErrCode.SRC_DATA_FORMAT_ERROR) |
| 72 | if self.begin_date is not None and data[self.time_column_idx] < self.begin_date: |
| 73 | continue |
| 74 | if self.end_date is not None and data[self.time_column_idx] > self.end_date: |
| 75 | continue |
| 76 | yield CKLine_Unit(create_item_dict(data, self.columns)) |
| 77 | |
| 78 | def SetBasciInfo(self): |
| 79 | pass |
nothing calls this directly
no test coverage detected