Skip to content

Commit b8ef69a

Browse files
authored
fix: invalid CLI use in scripts/{enable,disable}_log_statements.sh #546
- `find -name` => `find . -name` - `xargs -i` => `xargs -I` (or can be replaced by the for loop) - Use bash for loop instead of xargs to abort early when error happens - Have one whitespace after `#` in the comments to conform with the standard python code style
1 parent 86cc50e commit b8ef69a

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

scripts/disable_log_statements.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
#!/bin/sh -e
1+
#!/bin/bash
2+
3+
set -e
24

35
cd pynvim
4-
find -name '*.py' | xargs -i{} ../scripts/logging_statement_modifier.py {}
6+
for f in $(find . -name '*.py'); do
7+
echo "Processing: $f"
8+
../scripts/logging_statement_modifier.py "$f"
9+
done

scripts/enable_log_statements.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
#!/bin/sh -e
1+
#!/bin/bash
2+
3+
set -e
24

35
cd pynvim
4-
find -name '*.py' | xargs -i{} ../scripts/logging_statement_modifier.py --restore {}
6+
for f in $(find . -name '*.py'); do
7+
echo "Processing: $f"
8+
../scripts/logging_statement_modifier.py --restore "$f"
9+
done

scripts/logging_statement_modifier.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
# include the whitespace, the logging method called, and the first argument if
6767
# possible
6868
RE_LOGGING_START = re.compile(r'^(\s+)' + STR_RE_LOGGING_CALL)
69-
RE_LOGGING_START_IN_COMMENT = re.compile(r'^(\s+)#' + STR_RE_LOGGING_CALL)
69+
RE_LOGGING_START_IN_COMMENT = re.compile(r'^(\s+)# ' + STR_RE_LOGGING_CALL)
7070

7171
def main(argv=sys.argv[1:]):
7272
"""Parses the command line comments."""
@@ -128,11 +128,11 @@ def comment_lines(lines):
128128
ret = []
129129
for line in lines:
130130
ws_prefix, rest, ignore = RE_LINE_SPLITTER_COMMENT.match(line).groups()
131-
ret.append(ws_prefix + '#' + rest)
131+
ret.append(ws_prefix + '# ' + rest)
132132
return ''.join(ret)
133133

134134
# matches two main groups: 1) leading whitespace and 2) all following text
135-
RE_LINE_SPLITTER_UNCOMMENT = re.compile(r'^(\s*)#((.|\n)*)$')
135+
RE_LINE_SPLITTER_UNCOMMENT = re.compile(r'^(\s*)# ((.|\n)*)$')
136136
def uncomment_lines(lines):
137137
"""Uncomment the given list of lines and return them. The first hash mark
138138
following any amount of whitespace will be removed on each line."""

0 commit comments

Comments
 (0)