Open a table from disk and read the metadata on it. Creates an user description on the flight to easy the access to the actual data.
(self)
| 1089 | return self._v_objectid |
| 1090 | |
| 1091 | def _g_open(self) -> int: |
| 1092 | """Open a table from disk and read the metadata on it. |
| 1093 | |
| 1094 | Creates an user description on the flight to easy the access to |
| 1095 | the actual data. |
| 1096 | |
| 1097 | """ |
| 1098 | # 1. Open the HDF5 table and get some data from it. |
| 1099 | self._v_objectid, description, chunksize = self._get_info() |
| 1100 | self._v_expectedrows = self.nrows # the actual number of rows |
| 1101 | |
| 1102 | # 2. Create an instance description to host the record fields. |
| 1103 | validate = not self._v_file._isPTFile # only for non-PyTables files |
| 1104 | self.description = Description( |
| 1105 | description, validate=validate, ptparams=self._v_file.params |
| 1106 | ) |
| 1107 | |
| 1108 | # 3. Compute or get chunk shape and buffer size parameters. |
| 1109 | if chunksize == 0: |
| 1110 | self._v_chunkshape = self._calc_chunkshape( |
| 1111 | self._v_expectedrows, self.rowsize, self.rowsize |
| 1112 | ) |
| 1113 | else: |
| 1114 | self._v_chunkshape = (chunksize,) |
| 1115 | self.nrowsinbuf = self._calc_nrowsinbuf() |
| 1116 | |
| 1117 | # 4. If there are field fill attributes, get them from disk and |
| 1118 | # set them in the table description. |
| 1119 | if self._v_file.params["PYTABLES_SYS_ATTRS"]: |
| 1120 | if "FIELD_0_FILL" in self._v_attrs._f_list("sys"): |
| 1121 | i = 0 |
| 1122 | get_attr = self._v_attrs.__getattr__ |
| 1123 | for objcol in self.description._f_walk(type="Col"): |
| 1124 | colname = objcol._v_pathname |
| 1125 | # Get the default values for each column |
| 1126 | fieldname = "FIELD_%s_FILL" % i |
| 1127 | defval = get_attr(fieldname) |
| 1128 | if defval is not None: |
| 1129 | objcol.dflt = defval |
| 1130 | else: |
| 1131 | warnings.warn( |
| 1132 | "could not load default value " |
| 1133 | "for the ``%s`` column of table ``%s``; " |
| 1134 | "using ``%r`` instead" |
| 1135 | % (colname, self._v_pathname, objcol.dflt) |
| 1136 | ) |
| 1137 | defval = objcol.dflt |
| 1138 | i += 1 |
| 1139 | |
| 1140 | # Set also the correct value in the desc._v_dflts dictionary |
| 1141 | for descr in self.description._f_walk(type="Description"): |
| 1142 | for name in descr._v_names: |
| 1143 | objcol = descr._v_colobjects[name] |
| 1144 | if isinstance(objcol, Col): |
| 1145 | descr._v_dflts[objcol._v_name] = objcol.dflt |
| 1146 | |
| 1147 | # 5. Cache some data which is already in the description. |
| 1148 | self._cache_description_data() |
nothing calls this directly
no test coverage detected