]>
git.ipfire.org Git - people/stevee/pakfire.git/blob - src/pakfire/filelist.py
2 ###############################################################################
4 # Pakfire - The IPFire package management system #
5 # Copyright (C) 2011 Pakfire development team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 TYPE_REG
= tarfile
.REGTYPE
# regular file
25 TYPE_AREG
= tarfile
.AREGTYPE
# regular file
26 TYPE_LNK
= tarfile
.LNKTYPE
# link (inside tarfile)
27 TYPE_SYM
= tarfile
.SYMTYPE
# symbolic link
28 TYPE_CHR
= tarfile
.CHRTYPE
# character special device
29 TYPE_BLK
= tarfile
.BLKTYPE
# block special device
30 TYPE_DIR
= tarfile
.DIRTYPE
# directory
31 TYPE_FIFO
= tarfile
.FIFOTYPE
# fifo special device
32 TYPE_CONT
= tarfile
.CONTTYPE
# contiguous file
34 TYPE_DIR_INT
= int(TYPE_DIR
)
37 def __init__(self
, pakfire
):
38 self
.pakfire
= pakfire
40 def __cmp__(self
, other
):
41 ret
= cmp(self
.name
, other
.name
)
44 ret
= cmp(self
.pkg
, other
.pkg
)
51 return self
.name
.endswith("/")
57 def is_datafile(self
):
62 def __init__(self
, pakfire
):
63 _File
.__init
__(self
, pakfire
)
75 self
.capabilities
= None
79 return self
.type == TYPE_DIR_INT \
80 or self
.name
.endswith("/")
85 def is_datafile(self
):
89 class FileDatabase(_File
):
90 def __init__(self
, pakfire
, db
, row_id
, row
=None):
91 _File
.__init
__(self
, pakfire
)
100 Lazy fetching of the database row.
102 if self
.__row
is None:
104 c
.execute("SELECT * FROM files WHERE id = ? LIMIT 1", (self
.row_id
,))
106 self
.__row
= c
.fetchone()
112 return self
.type == TYPE_DIR_INT \
113 or self
.name
.endswith("/")
116 return self
.row
["config"] == 1
118 def is_datafile(self
):
119 return self
.row
["datafile"] == 1
123 return self
.db
.get_package_by_id(self
.row
["pkg"])
127 return self
.row
["name"]
131 return self
.row
["size"]
135 return self
.row
["hash1"]
139 return self
.row
["type"]
143 return self
.row
["mode"]
147 return self
.row
["user"]
151 return self
.row
["group"]
155 return self
.row
["mtime"]
158 def capabilities(self
):
159 return self
.row
["capabilities"]