summaryrefslogtreecommitdiff
path: root/pygnulib/GLModuleSystem.py
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2022-07-31 18:39:19 +0200
committerBruno Haible <bruno@clisp.org>2022-07-31 23:52:27 +0200
commit6bdf668e5748a511082efed773b2b127e93fcb1d (patch)
tree4096874c27798c4bb6a647899436b1aa0304a3b0 /pygnulib/GLModuleSystem.py
parent18dcc627ddeced96bc192e169bf19e1a38c53374 (diff)
downloadgnulib-6bdf668e5748a511082efed773b2b127e93fcb1d.tar.gz
gnulib-tool.py: Follow gnulib-tool changes, part 19.
Follow gnulib-tool changes 2015-12-09 Pavel Raiskup <praiskup@redhat.com> gnulib-tool: allow multiple --local-dir usage 2019-02-14 Bruno Haible <bruno@clisp.org> gnulib-tool: Improve handling of multiple --local-dir options. * gnulib-tool (func_reconstruct_cached_dir): When the argument is absolute, return it unmodified. (func_compute_relative_local_gnulib_path): Renamed from func_count_relative_local_gnulib_path. Add comment. * gnulib-tool.py: Accept multiple --local-dir options and collect the values into localpath. * pygnulib/GLConfig.py: Take a localpath argument instead of a localdir argument. (getLocalDir, setLocalDir, resetLocalDir): Remove methods. (getLocalPath, setLocalPath, resetLocalPath): New methods. * pygnulib/GLFileSystem.py (CopyAction): New class. (GLFileSystem.lookup): Consider all dirs in localpath. (GLFileSystem.shouldLink): New method. (GLFileAssistant): Use shouldLink. * pygnulib/GLModuleSystem.py (GLModuleSystem.exists): Iterate over all dirs in localpath. (GLModuleSystem.list): Likewise. * pygnulib/GLEmiter.py: Update. * pygnulib/GLImport.py (GLImport.__init__): Put the argument of gl_LOCAL_DIR into localpath, not localdir. (GLImport.actioncmd): Consider all dirs in localpath. (GLImport.relative_to_destdir, GLImport.relative_to_currdir): New methods. (GLImport.gnulib_cache): Combine all dirs in localpath. Use self.relative_to_destdir. * pygnulib/GLTestDir.py (GLTestDir.execute): Use shouldLink.
Diffstat (limited to 'pygnulib/GLModuleSystem.py')
-rw-r--r--pygnulib/GLModuleSystem.py45
1 files changed, 23 insertions, 22 deletions
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 48515ce36d..00b2c5f035 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -60,7 +60,7 @@ class GLModuleSystem(object):
'''GLModuleSystem.__init__(config) -> GLModuleSystem
Create new GLModuleSystem instance. Some functions use GLFileSystem class
- to look up a file in localdir or gnulib directories, or combine it through
+ to look up a file in localpath or gnulib directories, or combine it through
'patch' utility.'''
self.args = dict()
if type(config) is not GLConfig:
@@ -78,22 +78,22 @@ class GLModuleSystem(object):
'''GLModuleSystem.exists(module) -> bool
Check whether the given module exists.
- GLConfig: localdir.'''
+ GLConfig: localpath.'''
if type(module) is not str:
raise TypeError(
'module must be a string, not %s' % type(module).__name__)
- result = bool()
+ localpath = self.config['localpath']
+ result = False
badnames = ['ChangeLog', 'COPYING', 'README', 'TEMPLATE',
'TEMPLATE-EXTENDED', 'TEMPLATE-TESTS']
- if isfile(joinpath(DIRS['modules'], module)) or \
- all([ # Begin all(iterable) function
- self.config['localdir'],
- isdir(joinpath(self.config['localdir'], 'modules')),
- isfile(
- joinpath(self.config['localdir'], 'modules', module))
- ]): # Close all(iterable) function
- if module not in badnames:
- result = True
+ if module not in badnames:
+ result = isfile(joinpath(DIRS['modules'], module))
+ if not result:
+ for localdir in localpath:
+ if isdir(joinpath(localdir, 'modules')) \
+ and isfile(joinpath(localdir, 'modules', module)):
+ result = True
+ break
return result
def find(self, module):
@@ -122,7 +122,7 @@ class GLModuleSystem(object):
complete, so this version uses subprocess to run shell commands.'''
result = ''
listing = list()
- localdir = self.config['localdir']
+ localpath = self.config['localpath']
find_args = ['find', 'modules', '-type', 'f', '-print']
sed_args = \
[
@@ -146,16 +146,18 @@ class GLModuleSystem(object):
os.chdir(constants.DIRS['root'])
find = sp.Popen(find_args, stdout=sp.PIPE)
result += find.stdout.read().decode("UTF-8")
+ os.chdir(DIRS['cwd'])
- # Read modules from local directory.
- if localdir and isdir(joinpath(localdir, 'modules')):
- os.chdir(localdir)
- find = sp.Popen(find_args, stdout=sp.PIPE)
- result += find.stdout.read().decode("UTF-8")
+ # Read modules from local directories.
+ if len(localpath) > 0:
+ for localdir in localpath:
+ os.chdir(localdir)
+ find = sp.Popen(find_args, stdout=sp.PIPE)
+ result += find.stdout.read().decode("UTF-8")
+ os.chdir(DIRS['cwd'])
sed_args += ['-e', r's,\.diff$,,']
# Save the list of the modules to file.
- os.chdir(DIRS['cwd'])
path = joinpath(self.config['tempdir'], 'list')
with codecs.open(path, 'wb', 'UTF-8') as file:
file.write(result)
@@ -538,8 +540,7 @@ Include:|Link:|License:|Maintainer:)'
'''GLModule.getDependencies() -> list
Return list of dependencies.
- GLConfig: localdir.'''
- localdir = self.config['localdir']
+ GLConfig: localpath.'''
result = list()
section = 'Depends-on:'
if 'dependencies' not in self.cache:
@@ -871,7 +872,7 @@ class GLModuleTable(object):
included in the final modules list. If testflags iterable is enabled, then
don't add module which status is in the testflags. If conddeps are enabled,
then store condition for each dependency if it has a condition.
- The only necessary argument is localdir, which is needed just to create
+ The only necessary argument is localpath, which is needed just to create
modulesystem instance to look for dependencies.'''
self.avoids = list() # Avoids
self.dependers = dict() # Dependencies