Skip to content

Commit d22baa5

Browse files
committed
debug configurations, loop optimizations
1 parent 495743b commit d22baa5

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

php2python.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@
99

1010
# create logger
1111
logger = logging.getLogger('php2python')
12-
logger.setLevel(logging.INFO)
12+
13+
debug = True
1314

1415
# console handler
1516
ch = logging.StreamHandler()
17+
if debug:
18+
logger.setLevel(logging.DEBUG)
19+
else:
20+
logger.setLevel(logging.INFO)
21+
1622
ch.setLevel(logging.DEBUG)
1723

1824
formatter1 = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
@@ -41,11 +47,11 @@ def replace(f, o, n):
4147
def remove_lines_bound(f, start, end=None, ignore_leading_spaces=True):
4248
php_file = fileinput.FileInput(f, inplace=True)
4349
end = '[' + end + ']$' if end else ''
50+
if ignore_leading_spaces:
51+
reg = '^(( )*' + start + ').*' + end
52+
else:
53+
reg = '^' + start + '.*' + end
4454
for line in php_file:
45-
if ignore_leading_spaces:
46-
reg = '^(( )*' + start + ').*' + end
47-
else:
48-
reg = '^' + start + '.*' + end
4955
if re.match(reg, line):
5056
continue
5157

0 commit comments

Comments
 (0)