Skip to content

Commit bc06a3b

Browse files
committed
Added --py2 option
1 parent 40161d4 commit bc06a3b

6 files changed

Lines changed: 72 additions & 30 deletions

File tree

find-project-root/utils/clean.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
from pathlib import Path
2-
import shutil
2+
import shutil, sys
33
from types import SimpleNamespace as sn
44

55
from lib import data, log
66

77
def main():
88
msgs_path = Path(__file__).parent / 'data/messages.json'
99
msgs = sn(**{ key:val['message'] for key,val in data.json.read(msgs_path)['clean'].items() })
10-
11-
for target in ['dist', 'build', '*_cache', '__pycache__', '*.egg-info', '*.pyc']:
10+
targets = ['*.pyc']
11+
if '--py2' not in sys.argv:
12+
targets.extend(['dist', 'build', '*_cache', '__pycache__', '*.egg-info'])
13+
print(targets)
14+
for target in targets:
1215
for path in Path('.').rglob(target):
13-
if path.is_dir() : shutil.rmtree(path) ; log.info(f'{msgs.log_REMOVED} {path}/')
14-
16+
if path.is_dir():
17+
shutil.rmtree(path)
18+
log.info(f'{msgs.log_REMOVED} {path}/')
19+
elif path.is_file():
20+
path.unlink()
21+
log.info(f'{msgs.log_REMOVED} {path}')
1522
log.success(f'{msgs.log_CLEAN_COMPLETE}!')
1623

1724
if __name__ == '__main__' : main()

latin-locales/utils/clean.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
from pathlib import Path
2-
import shutil
2+
import shutil, sys
33
from types import SimpleNamespace as sn
44

55
from lib import data, log
66

77
def main():
88
msgs_path = Path(__file__).parent / 'data/messages.json'
99
msgs = sn(**{ key:val['message'] for key,val in data.json.read(msgs_path)['clean'].items() })
10-
11-
for target in ['dist', 'build', '*_cache', '__pycache__', '*.egg-info', '*.pyc']:
10+
targets = ['*.pyc']
11+
if '--py2' not in sys.argv:
12+
targets.extend(['dist', 'build', '*_cache', '__pycache__', '*.egg-info'])
13+
print(targets)
14+
for target in targets:
1215
for path in Path('.').rglob(target):
13-
if path.is_dir() : shutil.rmtree(path) ; log.info(f'{msgs.log_REMOVED} {path}/')
14-
16+
if path.is_dir():
17+
shutil.rmtree(path)
18+
log.info(f'{msgs.log_REMOVED} {path}/')
19+
elif path.is_file():
20+
path.unlink()
21+
log.info(f'{msgs.log_REMOVED} {path}')
1522
log.success(f'{msgs.log_CLEAN_COMPLETE}!')
1623

1724
if __name__ == '__main__' : main()

non-latin-locales/utils/clean.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
from pathlib import Path
2-
import shutil
2+
import shutil, sys
33
from types import SimpleNamespace as sn
44

55
from lib import data, log
66

77
def main():
88
msgs_path = Path(__file__).parent / 'data/messages.json'
99
msgs = sn(**{ key:val['message'] for key,val in data.json.read(msgs_path)['clean'].items() })
10-
11-
for target in ['dist', 'build', '*_cache', '__pycache__', '*.egg-info', '*.pyc']:
10+
targets = ['*.pyc']
11+
if '--py2' not in sys.argv:
12+
targets.extend(['dist', 'build', '*_cache', '__pycache__', '*.egg-info'])
13+
print(targets)
14+
for target in targets:
1215
for path in Path('.').rglob(target):
13-
if path.is_dir() : shutil.rmtree(path) ; log.info(f'{msgs.log_REMOVED} {path}/')
14-
16+
if path.is_dir():
17+
shutil.rmtree(path)
18+
log.info(f'{msgs.log_REMOVED} {path}/')
19+
elif path.is_file():
20+
path.unlink()
21+
log.info(f'{msgs.log_REMOVED} {path}')
1522
log.success(f'{msgs.log_CLEAN_COMPLETE}!')
1623

1724
if __name__ == '__main__' : main()

project-markers/utils/clean.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
from pathlib import Path
2-
import shutil
2+
import shutil, sys
33
from types import SimpleNamespace as sn
44

55
from lib import data, log
66

77
def main():
88
msgs_path = Path(__file__).parent / 'data/messages.json'
99
msgs = sn(**{ key:val['message'] for key,val in data.json.read(msgs_path)['clean'].items() })
10-
11-
for target in ['dist', 'build', '*_cache', '__pycache__', '*.egg-info', '*.pyc']:
10+
targets = ['*.pyc']
11+
if '--py2' not in sys.argv:
12+
targets.extend(['dist', 'build', '*_cache', '__pycache__', '*.egg-info'])
13+
print(targets)
14+
for target in targets:
1215
for path in Path('.').rglob(target):
13-
if path.is_dir() : shutil.rmtree(path) ; log.info(f'{msgs.log_REMOVED} {path}/')
14-
16+
if path.is_dir():
17+
shutil.rmtree(path)
18+
log.info(f'{msgs.log_REMOVED} {path}/')
19+
elif path.is_file():
20+
path.unlink()
21+
log.info(f'{msgs.log_REMOVED} {path}')
1522
log.success(f'{msgs.log_CLEAN_COMPLETE}!')
1623

1724
if __name__ == '__main__' : main()

remove-json-keys/utils/clean.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
from pathlib import Path
2-
import shutil
2+
import shutil, sys
33
from types import SimpleNamespace as sn
44

55
from remove_json_keys.lib import data, log
66

77
def main():
88
msgs_path = Path(__file__).parent / 'data/messages.json'
99
msgs = sn(**{ key:val['message'] for key,val in data.json.read(msgs_path)['clean'].items() })
10-
11-
for target in ['dist', 'build', '*_cache', '__pycache__', '*.egg-info', '*.pyc']:
10+
targets = ['*.pyc']
11+
if '--py2' not in sys.argv:
12+
targets.extend(['dist', 'build', '*_cache', '__pycache__', '*.egg-info'])
13+
print(targets)
14+
for target in targets:
1215
for path in Path('.').rglob(target):
13-
if path.is_dir() : shutil.rmtree(path) ; log.info(f'{msgs.log_REMOVED} {path}/')
14-
16+
if path.is_dir():
17+
shutil.rmtree(path)
18+
log.info(f'{msgs.log_REMOVED} {path}/')
19+
elif path.is_file():
20+
path.unlink()
21+
log.info(f'{msgs.log_REMOVED} {path}')
1522
log.success(f'{msgs.log_CLEAN_COMPLETE}!')
1623

1724
if __name__ == '__main__' : main()

translate-messages/utils/clean.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
from pathlib import Path
2-
import shutil
2+
import shutil, sys
33
from types import SimpleNamespace as sn
44

55
from translate_messages.lib import data, log
66

77
def main():
88
msgs_path = Path(__file__).parent / 'data/messages.json'
99
msgs = sn(**{ key:val['message'] for key,val in data.json.read(msgs_path)['clean'].items() })
10-
11-
for target in ['dist', 'build', '*_cache', '__pycache__', '*.egg-info', '*.pyc']:
10+
targets = ['*.pyc']
11+
if '--py2' not in sys.argv:
12+
targets.extend(['dist', 'build', '*_cache', '__pycache__', '*.egg-info'])
13+
print(targets)
14+
for target in targets:
1215
for path in Path('.').rglob(target):
13-
if path.is_dir() : shutil.rmtree(path) ; log.info(f'{msgs.log_REMOVED} {path}/')
14-
16+
if path.is_dir():
17+
shutil.rmtree(path)
18+
log.info(f'{msgs.log_REMOVED} {path}/')
19+
elif path.is_file():
20+
path.unlink()
21+
log.info(f'{msgs.log_REMOVED} {path}')
1522
log.success(f'{msgs.log_CLEAN_COMPLETE}!')
1623

1724
if __name__ == '__main__' : main()

0 commit comments

Comments
 (0)