|
21 | 21 | from fnmatch import fnmatch |
22 | 22 | import jinja2 |
23 | 23 |
|
| 24 | +from pythonforandroid.util import rmdir, ensure_dir |
| 25 | + |
24 | 26 |
|
25 | 27 | def get_dist_info_for(key, error_if_missing=True): |
26 | 28 | try: |
@@ -93,11 +95,6 @@ def get_bootstrap_name(): |
93 | 95 | DEFAULT_PYTHON_SERVICE_JAVA_CLASS = 'org.kivy.android.PythonService' |
94 | 96 |
|
95 | 97 |
|
96 | | -def ensure_dir(path): |
97 | | - if not exists(path): |
98 | | - makedirs(path) |
99 | | - |
100 | | - |
101 | 98 | def render(template, dest, **kwargs): |
102 | 99 | '''Using jinja2, render `template` to the filename `dest`, supplying the |
103 | 100 |
|
@@ -241,7 +238,7 @@ def make_package(args): |
241 | 238 | assets_dir = "src/main/assets" |
242 | 239 |
|
243 | 240 | # Delete the old assets. |
244 | | - shutil.rmtree(assets_dir, ignore_errors=True) |
| 241 | + rmdir(assets_dir, ignore_errors=True) |
245 | 242 | ensure_dir(assets_dir) |
246 | 243 |
|
247 | 244 | # Add extra environment variable file into tar-able directory: |
@@ -290,7 +287,7 @@ def make_package(args): |
290 | 287 | not exists( |
291 | 288 | join(main_py_only_dir, dir_path) |
292 | 289 | )): |
293 | | - os.mkdir(join(main_py_only_dir, dir_path)) |
| 290 | + ensure_dir(join(main_py_only_dir, dir_path)) |
294 | 291 | # Copy actual file: |
295 | 292 | shutil.copyfile( |
296 | 293 | join(args.private, variant), |
@@ -328,17 +325,17 @@ def make_package(args): |
328 | 325 | ) |
329 | 326 | finally: |
330 | 327 | for directory in _temp_dirs_to_clean: |
331 | | - shutil.rmtree(directory) |
| 328 | + rmdir(directory) |
332 | 329 |
|
333 | 330 | # Remove extra env vars tar-able directory: |
334 | | - shutil.rmtree(env_vars_tarpath) |
| 331 | + rmdir(env_vars_tarpath) |
335 | 332 |
|
336 | 333 | # Prepare some variables for templating process |
337 | 334 | res_dir = "src/main/res" |
338 | 335 | res_dir_initial = "src/res_initial" |
339 | 336 | # make res_dir stateless |
340 | 337 | if exists(res_dir_initial): |
341 | | - shutil.rmtree(res_dir, ignore_errors=True) |
| 338 | + rmdir(res_dir, ignore_errors=True) |
342 | 339 | shutil.copytree(res_dir_initial, res_dir) |
343 | 340 | else: |
344 | 341 | shutil.copytree(res_dir, res_dir_initial) |
|
0 commit comments