mirror of
https://git.yoctoproject.org/poky
synced 2026-05-01 15:32:12 +02:00
bitbake: fetch2/gitsm: use configparser to parse .gitmodules
.gitmodules is basically ini-style, so use configparser instead of manually parsing by hand. (Bitbake rev: a4f42e396e2942fde94b8b4944487c1c45f7a295) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
4d1697fb87
commit
d016d18a9f
@@ -47,18 +47,20 @@ class GitSM(Git):
|
||||
subrevision = {}
|
||||
|
||||
def parse_gitmodules(gitmodules):
|
||||
"""
|
||||
Parse .gitmodules and return a dictionary of submodule paths to dictionaries with path and url members.
|
||||
"""
|
||||
import configparser
|
||||
cp = configparser.ConfigParser()
|
||||
cp.read_string(gitmodules)
|
||||
|
||||
modules = {}
|
||||
module = ""
|
||||
for line in gitmodules.splitlines():
|
||||
if line.startswith('[submodule'):
|
||||
module = line.split('"')[1]
|
||||
modules[module] = {}
|
||||
elif module and line.strip().startswith('path'):
|
||||
path = line.split('=')[1].strip()
|
||||
modules[module]['path'] = path
|
||||
elif module and line.strip().startswith('url'):
|
||||
url = line.split('=')[1].strip()
|
||||
modules[module]['url'] = url
|
||||
for section in [s for s in cp.sections() if s.startswith("submodule ")]:
|
||||
module = section.split('"')[1]
|
||||
modules[module] = {
|
||||
'path': cp.get(section, 'path'),
|
||||
'url': cp.get(section, 'url')
|
||||
}
|
||||
return modules
|
||||
|
||||
# Collect the defined submodules, and their attributes
|
||||
|
||||
Reference in New Issue
Block a user