mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-30 13:56:31 -04:00
port-jobs: COMMENTS.py now acts on all Python files in the lib directory
Former-commit-id: 7cae54dec389cc649f2165cb723353ad72292992 Former-commit-id: 2ab248feeeed74b5b2ffab0d5cf8ee79955cc585
This commit is contained in:
@@ -36,15 +36,15 @@ else:
|
|||||||
s_exit()
|
s_exit()
|
||||||
|
|
||||||
# define PORT target
|
# define PORT target
|
||||||
string1 = "# PORT START CLIPBOARD"
|
string1 = '# PORT START CLIPBOARD'
|
||||||
string2 = "# PORT END CLIPBOARD"
|
string2 = '# PORT END CLIPBOARD'
|
||||||
|
|
||||||
# read input file
|
# read input file
|
||||||
text = open("working/sshyp.py", "r").read()
|
text = open('working/sshyp.py', 'r').read()
|
||||||
|
|
||||||
# find and replace the defined PORT target
|
# find and replace the defined PORT target
|
||||||
regex = re.compile(f"{string1}.*?{string2}", re.DOTALL)
|
regex = re.compile(f"{string1}.*?{string2}", re.DOTALL)
|
||||||
new_text = re.sub(regex, replacement, text)
|
new_text = re.sub(regex, replacement, text)
|
||||||
|
|
||||||
# write the updated text
|
# write updated text
|
||||||
open("working/sshyp.py", "w").write(new_text)
|
open('working/sshyp.py', 'w').write(new_text)
|
||||||
|
|||||||
+10
-8
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
from os import listdir
|
||||||
import re
|
import re
|
||||||
from sys import argv
|
from sys import argv
|
||||||
|
|
||||||
@@ -11,11 +12,12 @@ if len(arguments) > 0 and arguments[0] == 'ALL':
|
|||||||
else:
|
else:
|
||||||
regex = re.compile(r'^\s*# PORT.*$\n?', re.MULTILINE)
|
regex = re.compile(r'^\s*# PORT.*$\n?', re.MULTILINE)
|
||||||
|
|
||||||
# read input file
|
for filename in listdir('working'):
|
||||||
text = open("working/sshyp.py", "r").read()
|
if filename.endswith('.py'):
|
||||||
|
filepath = 'working/' + filename
|
||||||
# run the defined regular expression
|
# read input file
|
||||||
new_text = re.sub(regex, '', text)
|
text = open(filepath, 'r').read()
|
||||||
|
# run the defined regular expression
|
||||||
# write the updated text
|
new_text = re.sub(regex, '', text)
|
||||||
open("working/sshyp.py", "w").write(new_text)
|
# write updated text
|
||||||
|
open(filepath, 'w').write(new_text)
|
||||||
|
|||||||
Reference in New Issue
Block a user