22# -*- coding: utf-8 -*-
33#
44# paths.py
5- """Functions for paths and files"""
5+ """
6+ Functions for paths and files
7+ """
68#
79# Copyright 2018-2019 Dominic Davis-Foster <dominic@davis-foster.co.uk>
810#
911# check_dependencies based on https://stackoverflow.com/a/29044693/3092681
1012# Copyright 2015 TehTechGuy
11- # Licensed under CC-BY-SA
13+ # Licensed under CC-BY-SA
1214#
1315# 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
1618#
1719# 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
2122#
2223# This program is free software; you can redistribute it and/or modify
2324# it under the terms of the GNU Lesser General Public License as published by
3940import os
4041import pathlib
4142
43+
4244def copytree (src , dst , symlinks = False , ignore = None ):
4345 """
4446 Because shutil.copytree is borked
@@ -70,6 +72,7 @@ def copytree(src, dst, symlinks=False, ignore=None):
7072 else :
7173 return shutil .copy2 (s , d )
7274
75+
7376def maybe_make (directory ):
7477 """
7578 Makes a directory only if it doesn't already exist
@@ -82,6 +85,7 @@ def maybe_make(directory):
8285 if not os .path .exists (directory ):
8386 os .makedirs (directory )
8487
88+
8589def parent_path (path ):
8690 """
8791 Returns the path of the parent directory for the given file or directory
@@ -94,6 +98,7 @@ def parent_path(path):
9498
9599 return os .path .abspath (os .path .join (path ,os .pardir ))
96100
101+
97102def relpath (path , relative_to = None ):
98103 """
99104 Returns the path for the given file or directory relative to the given directory
@@ -209,4 +214,3 @@ def append(var, filename):
209214
210215 with open (os .path .join (os .getcwd (), filename ), 'a' ) as f :
211216 f .write (var )
212-
0 commit comments