2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# paths.py
5
- """Functions for paths and files"""
5
+ """
6
+ Functions for paths and files
7
+ """
6
8
#
7
9
# Copyright 2018-2019 Dominic Davis-Foster <[email protected] >
8
10
#
9
11
# check_dependencies based on https://stackoverflow.com/a/29044693/3092681
10
12
# Copyright 2015 TehTechGuy
11
- # Licensed under CC-BY-SA
13
+ # Licensed under CC-BY-SA
12
14
#
13
15
# as_text from https://stackoverflow.com/a/40935194
14
- # Copyright 2016 User3759685
15
- # Available under the MIT License
16
+ # Copyright 2016 User3759685
17
+ # Available under the MIT License
16
18
#
17
19
# chunks from https://stackoverflow.com/a/312464/3092681
18
- # Copytight 2008 Ned Batchelder
19
- # Licensed under CC-BY-SA
20
- #
20
+ # Copytight 2008 Ned Batchelder
21
+ # Licensed under CC-BY-SA
21
22
#
22
23
# This program is free software; you can redistribute it and/or modify
23
24
# it under the terms of the GNU Lesser General Public License as published by
39
40
import os
40
41
import pathlib
41
42
43
+
42
44
def copytree (src , dst , symlinks = False , ignore = None ):
43
45
"""
44
46
Because shutil.copytree is borked
@@ -70,6 +72,7 @@ def copytree(src, dst, symlinks=False, ignore=None):
70
72
else :
71
73
return shutil .copy2 (s , d )
72
74
75
+
73
76
def maybe_make (directory ):
74
77
"""
75
78
Makes a directory only if it doesn't already exist
@@ -82,6 +85,7 @@ def maybe_make(directory):
82
85
if not os .path .exists (directory ):
83
86
os .makedirs (directory )
84
87
88
+
85
89
def parent_path (path ):
86
90
"""
87
91
Returns the path of the parent directory for the given file or directory
@@ -94,6 +98,7 @@ def parent_path(path):
94
98
95
99
return os .path .abspath (os .path .join (path ,os .pardir ))
96
100
101
+
97
102
def relpath (path , relative_to = None ):
98
103
"""
99
104
Returns the path for the given file or directory relative to the given directory
@@ -209,4 +214,3 @@ def append(var, filename):
209
214
210
215
with open (os .path .join (os .getcwd (), filename ), 'a' ) as f :
211
216
f .write (var )
212
-
0 commit comments