mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-21 21:57:38 +01:00
projects.py fix: Read_value() does not return entire section
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
305cc0a1a7
commit
3a180033d4
2 changed files with 32 additions and 30 deletions
|
|
@ -2,6 +2,7 @@ TOPDIR = ../..
|
||||||
|
|
||||||
SUBTREE_INSTALL_PREFIX ?= /etc/jcs
|
SUBTREE_INSTALL_PREFIX ?= /etc/jcs
|
||||||
SUBTREE_FILES += ./templates/dir/module/Makefile ./templates/dir/src/Makefile
|
SUBTREE_FILES += ./templates/dir/module/Makefile ./templates/dir/src/Makefile
|
||||||
|
SUBTREE_DIRS += $(dir $(SUBTREE_FILES))
|
||||||
|
|
||||||
include $(TOPDIR)/make/proj.mk
|
include $(TOPDIR)/make/proj.mk
|
||||||
include $(MODDIR)/make/subtree.mk
|
include $(MODDIR)/make/subtree.mk
|
||||||
|
|
|
||||||
|
|
@ -181,43 +181,44 @@ class Projects(object):
|
||||||
return r.rstrip()
|
return r.rstrip()
|
||||||
|
|
||||||
def read_value(self, path, section, key):
|
def read_value(self, path, section, key):
|
||||||
self.debug("opening ", path)
|
|
||||||
|
def scan_section(f, key):
|
||||||
|
if key is None:
|
||||||
|
r = ''
|
||||||
|
for line in f:
|
||||||
|
if len(line) and line[0] == '[':
|
||||||
|
break
|
||||||
|
r += line
|
||||||
|
return r if len(r) else None
|
||||||
|
for line in f:
|
||||||
|
if len(line) and line[0] == '[':
|
||||||
|
return None
|
||||||
|
rr = re.findall('^ *' + key + ' *= *(.*)', line)
|
||||||
|
if len(rr) > 0:
|
||||||
|
return rr[0]
|
||||||
|
return None
|
||||||
|
|
||||||
|
def scan_section_debug(f, key):
|
||||||
|
rr = scan_section(f, key)
|
||||||
|
#self.debug(" returning", rr)
|
||||||
|
return rr
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file = open(path)
|
#self.debug("looking for {}::[{}].{}".format(path, section, key))
|
||||||
|
with open(path, 'r') as f:
|
||||||
|
if not len(section):
|
||||||
|
rr = scan_section(f, key)
|
||||||
|
pat = '[' + section + ']'
|
||||||
|
for line in f:
|
||||||
|
if line.rstrip() == pat:
|
||||||
|
return scan_section(f, key)
|
||||||
|
return None
|
||||||
except:
|
except:
|
||||||
self.debug(path, "not found")
|
self.debug(path, "not found")
|
||||||
# TODO: handle this special case cleaner somewhere up the stack
|
# TODO: handle this special case cleaner somewhere up the stack
|
||||||
if section == 'build' and key == 'libname':
|
if section == 'build' and key == 'libname':
|
||||||
return 'none'
|
return 'none'
|
||||||
return None
|
return None
|
||||||
r = []
|
|
||||||
if not len(section):
|
|
||||||
for line in file:
|
|
||||||
r = re.findall('^ *' + key + ' *= *(.*)', line)
|
|
||||||
if (len(r) > 0):
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
in_section = False
|
|
||||||
pat = '[' + section + ']'
|
|
||||||
for line in file:
|
|
||||||
if (line.rstrip() == pat):
|
|
||||||
in_section = True
|
|
||||||
continue
|
|
||||||
if in_section:
|
|
||||||
if len(line) and line[0] == '[':
|
|
||||||
break
|
|
||||||
if key is None:
|
|
||||||
r.append(line)
|
|
||||||
else:
|
|
||||||
r = re.findall('^ *' + key + ' *= *(.*)', line)
|
|
||||||
#self.debug("key " + key + ": parsed line >" + line + "<, result is " + ' '.join(r))
|
|
||||||
if (len(r) > 0):
|
|
||||||
break
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
if len(r):
|
|
||||||
return r[0]
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_value(self, name, section, key):
|
def get_value(self, name, section, key):
|
||||||
self.debug("getting value [%s].%s for project %s (%s)" %(section, key, name, self.top_name))
|
self.debug("getting value [%s].%s for project %s (%s)" %(section, key, name, self.top_name))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue