bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* gnulib-tool.py: Fix extra arguments to function call.
@ 2024-04-13 17:12 Collin Funk
  2024-04-13 17:26 ` Collin Funk
  2024-04-13 18:03 ` gnulib-tool.py: Fix extra arguments to function call Bruno Haible
  0 siblings, 2 replies; 6+ messages in thread
From: Collin Funk @ 2024-04-13 17:12 UTC (permalink / raw)
  To: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 916 bytes --]

I see a warning for this section of code because isfile() is called
with two arguments. It looks like the correct way to write this is to
joinpath() the two arguments, since that is what is done in
self.assistant.super_update() when not self.config['dryrun'].

diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index d44ceedcec..098bbc59ac 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -1230,7 +1230,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
                     os.remove(tmpfile)
             else:  # if not self.config['dryrun']
                 backupname = '%s~' % basename
-                if isfile(destdir, basename):
+                if isfile(joinpath(destdir, basename)):
                     print('Update %s (backup in %s)' % (basename, backupname))
                 else:  # if not isfile(destdir, basename)
                     print('Create %s' % basename)

Collin

[-- Attachment #2: 0001-gnulib-tool.py-Fix-extra-arguments-to-function-call.patch --]
[-- Type: text/x-patch, Size: 1563 bytes --]

From f0990590b62f0a5e18970643ac31c967b4a5f19d Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Sat, 13 Apr 2024 10:09:17 -0700
Subject: [PATCH] gnulib-tool.py: Fix extra arguments to function call.

* pygnulib/GLImport.py (GLImport.execute): Add the missing joinpath call
on two file name components before calling isfile().
---
 ChangeLog            | 6 ++++++
 pygnulib/GLImport.py | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index c72165e268..d65595122c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-04-13  Collin Funk  <collin.funk1@gmail.com>
+
+	gnulib-tool.py: Fix extra arguments to function call.
+	* pygnulib/GLImport.py (GLImport.execute): Add the missing joinpath call
+	on two file name components before calling isfile().
+
 2024-04-13  Bruno Haible  <bruno@clisp.org>
 
 	gnulib-tool.py: Code tweak.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index d44ceedcec..098bbc59ac 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -1230,7 +1230,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
                     os.remove(tmpfile)
             else:  # if not self.config['dryrun']
                 backupname = '%s~' % basename
-                if isfile(destdir, basename):
+                if isfile(joinpath(destdir, basename)):
                     print('Update %s (backup in %s)' % (basename, backupname))
                 else:  # if not isfile(destdir, basename)
                     print('Create %s' % basename)
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: gnulib-tool.py: Fix extra arguments to function call.
  2024-04-13 17:12 gnulib-tool.py: Fix extra arguments to function call Collin Funk
@ 2024-04-13 17:26 ` Collin Funk
  2024-04-13 18:08   ` .gitattributes Bruno Haible
  2024-04-13 18:03 ` gnulib-tool.py: Fix extra arguments to function call Bruno Haible
  1 sibling, 1 reply; 6+ messages in thread
From: Collin Funk @ 2024-04-13 17:26 UTC (permalink / raw)
  To: bug-gnulib

On 4/13/24 10:12 AM, Collin Funk wrote:
> diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
> index d44ceedcec..098bbc59ac 100644
> --- a/pygnulib/GLImport.py
> +++ b/pygnulib/GLImport.py
> @@ -1230,7 +1230,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix

Also, I found out that adding '*.py diff=python' to .gitattributes
will give a better diff hunk header [1]:

diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index d44ceedcec..098bbc59ac 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -1230,7 +1230,7 @@ def execute(self, filetable: dict[str, list[str]], transformers: dict[str, str])

[1] https://github.com/git/git/blob/8f7582d995682f785e80e344197cc715e6bc7d8e/userdiff.c#L270

Collin


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: gnulib-tool.py: Fix extra arguments to function call.
  2024-04-13 17:12 gnulib-tool.py: Fix extra arguments to function call Collin Funk
  2024-04-13 17:26 ` Collin Funk
@ 2024-04-13 18:03 ` Bruno Haible
  1 sibling, 0 replies; 6+ messages in thread
From: Bruno Haible @ 2024-04-13 18:03 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Collin Funk

Collin Funk wrote:
> I see a warning for this section of code because isfile() is called
> with two arguments. It looks like the correct way to write this is to
> joinpath() the two arguments

Yes, I agree. Thanks! Applied.

Bruno





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: .gitattributes
  2024-04-13 17:26 ` Collin Funk
@ 2024-04-13 18:08   ` Bruno Haible
  2024-04-13 18:18     ` Improve 'git diff' of Python files Collin Funk
  0 siblings, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2024-04-13 18:08 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Collin Funk

Collin Funk wrote:
> Also, I found out that adding '*.py diff=python' to .gitattributes
> will give a better diff hunk header [1]:
> 
> diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
> index d44ceedcec..098bbc59ac 100644
> --- a/pygnulib/GLImport.py
> +++ b/pygnulib/GLImport.py
> @@ -1230,7 +1230,7 @@ def execute(self, filetable: dict[str, list[str]], transformers: dict[str, str])

That will be nice, indeed. Please, can you provide a patch (with a ChangeLog
entry)?

Bruno





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Improve 'git diff' of Python files.
  2024-04-13 18:08   ` .gitattributes Bruno Haible
@ 2024-04-13 18:18     ` Collin Funk
  2024-04-13 18:29       ` Bruno Haible
  0 siblings, 1 reply; 6+ messages in thread
From: Collin Funk @ 2024-04-13 18:18 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 175 bytes --]

Hi Bruno,

On 4/13/24 11:08 AM, Bruno Haible wrote:
> That will be nice, indeed. Please, can you provide a patch (with a ChangeLog
> entry)?

Sure, I attached a patch.

Collin

[-- Attachment #2: 0001-Improve-git-diff-of-Python-files.patch --]
[-- Type: text/x-patch, Size: 1106 bytes --]

From 9e2fcc6d5e8f30b402627cc73b7da1109c047249 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Sat, 13 Apr 2024 11:16:44 -0700
Subject: [PATCH] Improve 'git diff' of Python files.

* .gitattributes: Add a rule for *.py files.
---
 .gitattributes | 3 +++
 ChangeLog      | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/.gitattributes b/.gitattributes
index bad5997b57..c7fecf66a5 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -8,3 +8,6 @@ ChangeLog	merge=merge-changelog
 # Run this to make 'git diff' on .m4 files give nicer hunk context:
 #   git config diff.m4.xfuncname '^((AC_DEFUN|m4_define)[^,)]*)'
 *.m4	diff=m4
+
+# Improve diff hunk context on Python files.
+*.py	diff=python
diff --git a/ChangeLog b/ChangeLog
index 4a5594c5cd..c9349f22ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-04-13  Collin Funk  <collin.funk1@gmail.com>
+
+	Improve 'git diff' of Python files.
+	* .gitattributes: Add a rule for *.py files.
+
 2024-04-13  Collin Funk  <collin.funk1@gmail.com>
 
 	gnulib-tool.py: Fix extra arguments to function call.
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: Improve 'git diff' of Python files.
  2024-04-13 18:18     ` Improve 'git diff' of Python files Collin Funk
@ 2024-04-13 18:29       ` Bruno Haible
  0 siblings, 0 replies; 6+ messages in thread
From: Bruno Haible @ 2024-04-13 18:29 UTC (permalink / raw)
  To: bug-gnulib, Collin Funk

Thanks, applied.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-13 18:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-13 17:12 gnulib-tool.py: Fix extra arguments to function call Collin Funk
2024-04-13 17:26 ` Collin Funk
2024-04-13 18:08   ` .gitattributes Bruno Haible
2024-04-13 18:18     ` Improve 'git diff' of Python files Collin Funk
2024-04-13 18:29       ` Bruno Haible
2024-04-13 18:03 ` gnulib-tool.py: Fix extra arguments to function call Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).