示例#1
0
 def initStyleOption(self, option, index):
     # type: (QStyleOptionViewItem, QModelIndex) -> None
     super().initStyleOption(option, index)
     value = index.data(Qt.DisplayRole)
     if isinstance(value, numbers.Integral):
         option.text = sizeformat(int(value))
         option.displayAlignment = Qt.AlignRight | Qt.AlignVCenter
示例#2
0
    def _update_summary(self):
        size = self._data_loader.file_size
        ncols = self._data_loader.n_cols
        nrows = self._data_loader.n_rows
        text = []
        if size is not None:
            text += [sizeformat(size)]
        if nrows is not None:
            text += ["{:n} rows".format(nrows)]
        if nrows is not None:
            text += ["{:n} columns".format(ncols)]

        self.summary_label.setText(", ".join(text))
示例#3
0
    def _update_summary(self):
        path = self._current_path

        size = None
        ncols = None
        nrows = None

        try:
            st = os.stat(path)
        except OSError:
            pass
        else:
            size = st.st_size

        if os.path.splitext(path)[1] == ".mtx":
            try:
                with open(path, "rb") as f:
                    nrows, ncols = scipy.io.mminfo(f)[:2]
            except OSError:
                pass
            except ValueError:
                pass
        else:
            try:
                with open(path, "rt", encoding="latin-1") as f:
                    sep = separator_from_filename(path)
                    ncols = len(next(csv.reader(f, delimiter=sep)))
                    nrows = sum(1 for _ in f)
            except OSError:
                pass
            except StopIteration:
                pass

        text = []
        if size is not None:
            text += [sizeformat(size)]
        if nrows is not None:
            text += ["{:n} rows".format(nrows)]
        if nrows is not None:
            text += ["{:n} columns".format(ncols)]

        self.summary_label.setText(", ".join(text))
示例#4
0
def sizeformat(size):
    return serverfiles.sizeformat(size)
 def initStyleOption(self, option, index):
     super().initStyleOption(option, index)
     data = index.data(Qt.DisplayRole)
     if isinstance(data, numbers.Integral):
         option.text = sizeformat(int(data))
         option.displayAlignment = Qt.AlignRight | Qt.AlignVCenter