File: block-size-column.py

package info (click to toggle)
python-caja 1.26.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 832 kB
  • sloc: xml: 1,745; ansic: 791; python: 297; makefile: 182; sh: 19
file content (21 lines) | stat: -rw-r--r-- 691 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os

from gi.repository import GObject, Caja

class ColumnExtension(GObject.GObject, Caja.ColumnProvider, Caja.InfoProvider):
    def __init__(self):
        pass
    
    def get_columns(self):
        return Caja.Column(name="CajaPython::block_size_column",
                               attribute="block_size",
                               label="Block size",
                               description="Get the block size"),

    def update_file_info(self, file):
        if file.get_uri_scheme() != 'file':
            return
        
        filename = file.get_location().get_path()
        
        file.add_string_attribute('block_size', str(os.stat(filename).st_blksize))