Skip to content

Commit

Permalink
Added more Python src_utils (TRIVIAL)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremybarnes committed Sep 6, 2018
1 parent a35ec64 commit fbe5060
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src_tools/ident_replace_all_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [ $# -lt 2 ] ;
then
echo "usage: " $0 "<regex> <replacement> [<directory>]";
echo "(directory defaults to '.')";
exit;
fi

REGEX=$1
REPLACEMENT=$2
DIR="."
if [ $# -eq 3 ];
then
DIR=$3
fi

FILES=`find $DIR -name "*.py" | xargs grep -l "$REGEX"`

#echo "files = " $FILES

for file in $FILES ;
do
echo $file
cp -f $file $file~
cat $file~ | sed "s!$REGEX!$REPLACEMENT!g" > $file~~ && mv $file~~ $file
chmod --reference=$file~ $file
done
23 changes: 23 additions & 0 deletions src_tools/ident_replace_list_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

if [ $# -lt 2 ] ;
then
echo "usage: " $0 "<regex> <replacement> file...";
exit;
fi

REGEX=$1
REPLACEMENT=$2
shift 2

FILES=$@

#echo "files = " $FILES

for file in $FILES ;
do
echo $file
cp -f $file $file~
cat $file~ | sed "s!$REGEX!$REPLACEMENT!g" > $file~~ && mv $file~~ $file
chmod --reference=$file~ $file
done

0 comments on commit fbe5060

Please sign in to comment.