Skip to content

Commit 2d99f2a

Browse files
SAPTeamDEVSAPTeamDEV
authored andcommitted
Add dry run feature to setup.py
1 parent 52e876f commit 2d99f2a

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

setup.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from lib2to3.pgen2.token import OP
21
import os
3-
from turtle import fd
2+
import sys
43

54
# Change this values according to your Project.
65
ModuleName = os.path.split(os.path.split(__file__)[0])[1]
@@ -12,11 +11,14 @@
1211

1312
ScriptName = os.path.split(__file__)[1]
1413

15-
# Check name
16-
if ' ' in ModuleName:
17-
raise NameError("Module name have space.")
18-
elif ModuleName == 'Magisk-Module-Template':
19-
raise NotImplementedError()
14+
dryRun = "--dry-run" in sys.argv
15+
16+
if not dryRun:
17+
# Check name
18+
if ' ' in ModuleName:
19+
raise NameError("Module name have space.")
20+
elif ModuleName == 'Magisk-Module-Template':
21+
raise NotImplementedError()
2022

2123
def makeTree(source = '.'):
2224
tree = []
@@ -61,8 +63,13 @@ def makeTree(source = '.'):
6163
fData = fData.replace('@(ModuleAuthorName)', ModuleAuthorName)
6264
hasModified = True
6365

64-
# Do modifications
6566
if hasModified:
66-
with open(f, 'w') as file:
67-
file.write(fData)
68-
67+
# Do modifications
68+
if not dryRun:
69+
with open(f, 'w') as file:
70+
file.write(fData)
71+
# Write modifications to console
72+
else:
73+
print('Modified file: ' + f)
74+
print(fData)
75+
print()

0 commit comments

Comments
 (0)