summaryrefslogtreecommitdiff
path: root/examples/block-size-column.py
blob: 6f94158b2d1294076048f7a2f2e3fe21710b182a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
import urllib

import caja

class ColumnExtension(caja.ColumnProvider, caja.InfoProvider):
    def __init__(self):
        pass
    
    def get_columns(self):
        return caja.Column("CajaPython::block_size_column",
                               "block_size",
                               "Block size",
                               "Get the block size"),

    def update_file_info(self, file):
        if file.get_uri_scheme() != 'file':
            return
        
        filename = urllib.unquote(file.get_uri()[7:])
        
        file.add_string_attribute('block_size', str(os.stat(filename).st_blksize))