Skip to content

Commit 7cbef65

Browse files
committed
Remove debugging code and unused 'unescape()' function.
1 parent bf5693f commit 7cbef65

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

compiledb/parser.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def skip_line(cmd, reason):
8484

8585
# Process build log
8686
for line in build_log:
87-
# logger.debug("-------------> Line: {}".format(line))
8887
lineno += 1
8988
# Concatenate line if need
9089
accumulate_line = line
@@ -118,13 +117,9 @@ def skip_line(cmd, reason):
118117
if not commands:
119118
result.skipped += 1
120119

121-
# logger.debug("-------------> Commands: {}".format(commands))
122-
123120
for c in commands:
124121
filepath = c['filepath']
125-
# logger.debug("-------------> Filepath: {}".format(filepath))
126122
cmd = c['cmd']
127-
# logger.debug("-------------> Command: {}".format(cmd))
128123
if filepath is None:
129124
skip_line(cmd, 'Empty file name')
130125
continue
@@ -143,7 +138,7 @@ def skip_line(cmd, reason):
143138

144139
# add entry to database
145140
tokens = c['tokens']
146-
arguments = [unescape(a) for a in tokens[len(wrappers):]]
141+
arguments = [a for a in tokens[len(wrappers):]]
147142

148143
compiler = get_compiler(arguments[0])
149144

@@ -192,8 +187,9 @@ def cross_platform_argline(s, platform='this'):
192187
1 = POSIX;
193188
0 = Windows/CMD
194189
(other values reserved)
190+
191+
Cudos: https://stackoverflow.com/a/35900070/2349761
195192
"""
196-
logger.debug("-------------> Platform: {} - {}".format(platform, sys.platform))
197193
if platform == 'this':
198194
platform = (sys.platform != 'win32')
199195
if platform == 1:
@@ -205,9 +201,7 @@ def cross_platform_argline(s, platform='this'):
205201

206202
args = []
207203
accu = None # collects pieces of one arg
208-
# logger.debug("-------------> String: {}".format(s))
209204
for qs, qss, esc, pipe, word, white, fail in re.findall(RE_CMD_LEX, s):
210-
# logger.debug("-------------> Regex: qs:{} qss:{} esc:{} pipe:{} word:{} white:{} fail:{}".format(qs, qss, esc, pipe, word, white, fail))
211205
if word:
212206
if platform == 0:
213207
word = word.replace('\\\\', '\\').replace('\\', '\\\\')
@@ -223,10 +217,8 @@ def cross_platform_argline(s, platform='this'):
223217
elif fail:
224218
raise ValueError("invalid or incomplete shell string")
225219
elif qs:
226-
# word = qs.replace('\\"', '"').replace('\\\\', '\\')
227220
if platform == 0:
228221
word = word.replace('""', '"')
229-
# word = word.replace('\\\\', '\\').replace('\\', '\\\\')
230222
word = repr(qs).encode().decode('unicode_escape')
231223
else:
232224
word = qss # may be even empty; must be last
@@ -243,10 +235,7 @@ class CommandProcessor(bashlex.ast.nodevisitor):
243235
looking for and extracting compilation commands."""
244236
def process(line, wd):
245237
args = cross_platform_argline(line)
246-
# for arg in args:
247-
# logger.debug("-------------> Arg: {}".format(arg))
248238
line = " ".join(args)
249-
# logger.debug("-------------> Argline: {}".format(line))
250239
trees = bashlex.parser.parse(line)
251240
if not trees:
252241
return []
@@ -303,7 +292,6 @@ def visitword(self, node, word):
303292
self.compiler = word
304293
else:
305294
self.wrappers.append(word)
306-
logger.debug('Not a compiler: {}'.format(word))
307295
elif (file_regex.match(word)):
308296
self.filepath = word
309297

@@ -318,8 +306,4 @@ def check_last_cmd(self):
318306
# reset state to process new command
319307
self.reset()
320308

321-
322-
def unescape(s):
323-
return s
324-
325309
# ex: ts=2 sw=4 et filetype=python

0 commit comments

Comments
 (0)