@matheusbsbs / matheus-bagliano / commits / bce4c5fc0b
Fork 0

cleanup

- use re.sub() iso. if for stripping ... - spacing nits Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>

Han-Wen Nienhuys committed May 23, 2007 at 17:14 UTC bce4c5fc0b6aa9e599fc181c5350b461dafecee2
1 file changed +19 -21
contrib/fast-import/git-p4
+19 -21
@@ -16,39 +16,39 @@ from sets import Set;
16 gitdir = os.environ.get("GIT_DIR", "")
17 silent = False
18
19 -def write_pipe (c, str):
19 +def write_pipe(c, str):
20 if not silent:
21 - sys.stderr.write ('writing pipe: %s\n' % c)
21 + sys.stderr.write('writing pipe: %s\n' % c)
22
23 ## todo: check return status
24 - pipe = os.popen (c, 'w')
24 + pipe = os.popen(c, 'w')
25 val = pipe.write(str)
26 - if pipe.close ():
27 - sys.stderr.write ('Command failed')
28 - sys.exit (1)
26 + if pipe.close():
27 + sys.stderr.write('Command failed')
28 + sys.exit(1)
29
30 return val
31
32 -def read_pipe (c):
33 - sys.stderr.write ('reading pipe: %s\n' % c)
32 +def read_pipe(c):
33 + sys.stderr.write('reading pipe: %s\n' % c)
34 ## todo: check return status
35 - pipe = os.popen (c, 'rb')
35 + pipe = os.popen(c, 'rb')
36 val = pipe.read()
37 - if pipe.close ():
38 - sys.stderr.write ('Command failed')
39 - sys.exit (1)
37 + if pipe.close():
38 + sys.stderr.write('Command failed')
39 + sys.exit(1)
40
41 return val
42
43
44 -def read_pipe_lines (c):
45 - sys.stderr.write ('reading pipe: %s\n' % c)
44 +def read_pipe_lines(c):
45 + sys.stderr.write('reading pipe: %s\n' % c)
46 ## todo: check return status
47 - pipe = os.popen (c, 'rb')
47 + pipe = os.popen(c, 'rb')
48 val = pipe.readlines()
49 - if pipe.close ():
50 - sys.stderr.write ('Command failed')
51 - sys.exit (1)
49 + if pipe.close():
50 + sys.stderr.write('Command failed')
51 + sys.exit(1)
52
53 return val
54
@@ -986,9 +986,7 @@ class P4Sync(Command):
986 elif len(self.previousDepotPath) == 0:
987 self.revision = "#head"
988
989 - if self.depotPath.endswith("..."):
990 - self.depotPath = self.depotPath[:-3]
991 -
989 + self.depotPath = re.sub ("\.\.\.$", "", self.depotPath)
990 if not self.depotPath.endswith("/"):
991 self.depotPath += "/"
992