Skip to contentSkip to conversation

gitview: revamped to use string.join, stripped a function def

PATCH In review Denis Cheng 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitview: revamped to use string.join, stripped a function def

---
 contrib/gitview/gitview |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)
contrib/gitview/gitview +1 -12
index 5931766..2eb72b1 100755
@@ -36,17 +36,6 @@ except ImportError:
 
 re_ident = re.compile('(author|committer) (?P<ident>.*) (?P<epoch>\d+) (?P<tz>[+-]\d{4})')
 
-def list_to_string(args, skip):
-	count = len(args)
-	i = skip
-	str_arg=" "
-	while (i < count ):
-		str_arg = str_arg + args[i]
-		str_arg = str_arg + " "
-		i = i+1
-
-	return str_arg
-
 def show_date(epoch, tz):
 	secs = float(epoch)
 	tzsecs = float(tz[1:3]) * 3600
@@ -1115,7 +1104,7 @@ class GitView(object):
 
 	def set_branch(self, args):
 		"""Fill in different windows with info from the reposiroty"""
-		fp = os.popen("git rev-parse --sq --default HEAD " + list_to_string(args, 1))
+		fp = os.popen("git rev-parse --sq --default HEAD " + " ".join(args[1:]))
 		git_rev_list_cmd = fp.read()
 		fp.close()
 		fp = os.popen("git rev-list  --header --topo-order --parents " + git_rev_list_cmd)
Signature · 1 line
1.5.3.2
author
#1 lore raw

Please give some comments.

Quoted 38 lines · Denis Cheng
---
 contrib/gitview/gitview |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)
contrib/gitview/gitview +1 -13
index 5931766..2eb72b1 100755
@@ -36,17 +36,6 @@ except ImportError:
 
 re_ident = re.compile('(author|committer) (?P<ident>.*) (?P<epoch>\d+) (?P<tz>[+-]\d{4})')
 
-def list_to_string(args, skip):
-       count = len(args)
-       i = skip
-       str_arg=" "
-       while (i < count ):
-               str_arg = str_arg + args[i]
-               str_arg = str_arg + " "
-               i = i+1
-
-       return str_arg
-
 def show_date(epoch, tz):
        secs = float(epoch)
        tzsecs = float(tz[1:3]) * 3600
@@ -1115,7 +1104,7 @@ class GitView(object):
 
        def set_branch(self, args):
                """Fill in different windows with info from the reposiroty"""
-               fp = os.popen("git rev-parse --sq --default HEAD " + list_to_string(args, 1))
+               fp = os.popen("git rev-parse --sq --default HEAD " + " ".join(args[1:]))
                git_rev_list_cmd = fp.read()
                fp.close()
                fp = os.popen("git rev-list  --header --topo-order --parents " + git_rev_list_cmd)
--

1.5.3.2

Signature · 1 line
Cheng
#2 lore raw
Quoted 1 line · * rae l ([email protected]) [071120 21:19]:

Please give some comments.

Well I'm just an outside observer, but it looks like a good change to me.

Signature · 1 line
http://www.doorstop.net/
#3 lore raw
In reply to rae l
Quoted 4 lines · rae l

Please give some comments.

Quoted 1 line · Denis Cheng

Blast from the past ;-).

Quoted 6 lines
Quoted 6 lines
contrib/gitview/gitview +0 -6
-def list_to_string(args, skip):
-       count = len(args)
-       i = skip
-       str_arg=" "
-       while (i < count ):
-               str_arg = str_arg + args[i]
Quoted 8 lines

contrib/gitview/gitview except ImportError:

Quoted 8 lines
contrib/gitview/gitview +1 -5
-               str_arg = str_arg + " "
-               i = i+1
-
-       return str_arg
...
                """Fill in different windows with info from the reposiroty"""
-               fp = os.popen("git rev-parse --sq --default HEAD " + list_to_string(args, 1))
+               fp = os.popen("git rev-parse --sq --default HEAD " + " ".join(args[1:]))

Obviously correct, loses extra SPs on both ends of the args string, and reads more Pythonic.