+2024-06-09 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Handle absolute path checks consistently.
+ * pygnulib/GLImport.py (GLImport.relative_to_destdir)
+ (GLImport.relative_to_currdir): Use os.path.isabs() instead of checking
+ for a slash.
+ * pygnulib/constants.py (symlink_relative, as_link_value_at_dest)
+ (hardlink): Use os.path.isabs() instead of checking for a slash or drive
+ prefix.
+
2024-06-09 Bruno Haible <bruno@clisp.org>
c32width tests: Avoid a test failure on Solaris 11 OpenIndiana, OmniOS.
directory, to a filename relative to destdir.
GLConfig: destdir.'''
destdir = self.config['destdir']
- if dir.startswith('/'):
+ if os.path.isabs(dir):
return dir
else:
- if destdir.startswith('/'):
+ if os.path.isabs(destdir):
# XXX This doesn't look right.
return dir
else:
to a filename relative to the current directory.
GLConfig: destdir.'''
destdir = self.config['destdir']
- if dir.startswith('/'):
+ if os.path.isabs(dir):
return dir
else:
- if destdir.startswith('/'):
+ if os.path.isabs(destdir):
# XXX This doesn't look right.
return joinpath(destdir, dir)
else:
os.symlink(src, dest)
except PermissionError:
sys.stderr.write('%s: ln -s failed; falling back on cp -p\n' % APP['name'])
- if src.startswith('/') or (len(src) >= 2 and src[1] == ':'):
+ if os.path.isabs(src):
# src is absolute.
cp_src = src
else:
raise TypeError('src must be a string, not %s' % (type(src).__name__))
if type(dest) is not str:
raise TypeError('dest must be a string, not %s' % (type(dest).__name__))
- if src.startswith('/') or (len(src) >= 2 and src[1] == ':'):
+ if os.path.isabs(src):
return src
else: # if src is not absolute
- if dest.startswith('/') or (len(dest) >= 2 and dest[1] == ':'):
- cwd = os.getcwd()
- return joinpath(cwd, src)
+ if os.path.isabs(dest):
+ return joinpath(os.getcwd(), src)
else: # if dest is not absolute
destdir = os.path.dirname(dest)
if not destdir:
os.link(src, dest)
except PermissionError:
sys.stderr.write('%s: ln failed; falling back on cp -p\n' % APP['name'])
- if src.startswith('/') or (len(src) >= 2 and src[1] == ':'):
+ if os.path.isabs(src):
# src is absolute.
cp_src = src
else: