Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 15614 Details for
Bug 13616
per package USE flags and KEYWORDS
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
a parser for /etc/portage/package.env
perpkg.py (text/plain), 1.71 KB, created by
Denys Duchier
on 2003-08-06 06:54:01 UTC
(
hide
)
Description:
a parser for /etc/portage/package.env
Filename:
MIME Type:
Creator:
Denys Duchier
Created:
2003-08-06 06:54:01 UTC
Size:
1.71 KB
patch
obsolete
>import string,re > >TOKEN_RE = re.compile(r"(?P<space>\s+)|[*]?\s*(?P<cond>(=|>=|=<)\s*(\w|[._/+-])+)|(?P<var>\w+[ \t]*(?=[=]))|(?P<comment>#.*)") >VALUE_RE = re.compile(r"=[ \t]*(\"(?P<val1>(\\.|[^\"])*)\"|(?P<val2>[^ \t\n\r\f\v\#]+))") > >def parse(filename): > file = open(filename) > text = file.read() > file.close() > index = index0 = 0 > line = 1 > length = len(text) > hunks = [] > current_hunk = None > state = 'preamble' > def signal_error(msg): > raise "%s (file: %s, line: %s, column: %s)" \ > % (msg,filename,line,index-index0) > def read_result(): > for key,val in res.groupdict().items(): > if val is not None: > return key,val > while index<length: > res = TOKEN_RE.match(text,index) > if not res: > signal_error("syntax error") > type,value = read_result() > line = line + string.count(text,'\n',index,res.end()) > nlidx = string.rfind(text,'\n',index,res.end()) > if nlidx>0: > index0 = nlidx + 1 > index = res.end() > if type=='space' : pass > elif type=='comment': pass > elif type=='cond' : > if state != 'conds': > current_hunk = {'conds':[],'env':{}} > hunks.append(current_hunk) > state = 'conds' > current_hunk['conds'].append(value) > elif type=='var' : > res = VALUE_RE.match(text,index) > if not res: > signal_error("syntax error for assignment to %s" % value) > if state != 'env': > if state != 'conds': > current_hunk = {'conds':[],'env':{}} > hunks.append(current_hunk) > state = 'env' > var = value > type,value = read_result() > line = line + string.count(text,'\n',index,res.end()) > nlidx = string.rfind(text,'\n',index,res.end()) > if nlidx>0: > index0 = nlidx + 1 > index = res.end() > current_hunk['env'][var] = value > else: > signal_error("this should never happen") > return hunks
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 13616
:
7155
|
7156
|
7264
|
7265
|
9218
|
9219
|
10588
|
10589
|
12254
|
12255
|
13752
|
13753
|
14390
|
14678
|
14679
|
14847
|
14873
|
15239
|
15240
|
15241
|
15291
|
15303
|
15304
|
15347
|
15348
|
15349
| 15614 |
15715
|
16609
|
16610
|
16611
|
16768
|
17925
|
17926
|
19128
|
20637
|
20652
|
21575
|
21577