1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
--- portell.py.orig Thu Jun 24 07:41:00 2004
+++ portell.py Thu Jun 24 07:42:12 2004
@@ -2,6 +2,7 @@
# portell.py
# Description: prints a port's descr-file from whatever directory you're in.
# Author: Ryan "gt3" Kulla
+# Bugfixes: Radim "HSN" Kolar
# Email: ambiod@sbcglobal.net
# Version: 0.1
# Usage: portell.py <portname>
@@ -23,20 +24,31 @@
PORTELL_DB_FILE = "/var/db/portell.db"
PORTS_DIR = "/usr/ports/"
+IGNORE_DIRS = { "distfiles":None, "Tools":None, "packages":None }
def write_pathname(d, dirname, names):
- dirname = join(dirname.split('/')[:5], '/') # chop port path subdirs
- d[os.path.basename(dirname)] = dirname
+ dirs=dirname.split('/')
+ if len(dirs)==4:
+ if IGNORE_DIRS.has_key(dirs[3]):
+ del names[:]
+ elif len(dirs)==5:
+ d[dirs[4]] = dirname
+ del names[:]
def update_db():
- if os.access(PORTELL_DB_FILE, os.F_OK):
- os.unlink(PORTELL_DB_FILE)
+ try:
+ os.unlink(PORTELL_DB_FILE)
+ except:
+ pass
try:
d = shelve.open(PORTELL_DB)
- os.chmod(PORTELL_DB_FILE, 0666)
except:
print "can't read or write %s. are you root?" % PORTELL_DB_FILE
sys.exit(0)
+ try:
+ os.chmod(PORTELL_DB_FILE, 0666)
+ except:
+ pass
os.path.walk(PORTS_DIR, write_pathname, d)
d.close()
|