MCPcopy Index your code
hub / github.com/arrowtype/recursive / copyFiles

Function copyFiles

mastering/prep_fonts.py:50–86  ·  view source on GitHub ↗

Copies the supplied designspace and all of it's sources to *outRoot* This updates the source paths in the the designspace file. *designspacePath* is a `string` of the path to a designspace file *outRoot* is a `string` of the root directory to copy files to

(designspacePath, outRoot)

Source from the content-addressed store, hash-verified

48
49
50def copyFiles(designspacePath, outRoot):
51 """
52 Copies the supplied designspace and all of it's sources to *outRoot*
53
54 This updates the source paths in the the designspace file.
55
56 *designspacePath* is a `string` of the path to a designspace file
57 *outRoot* is a `string` of the root directory to copy files to
58 """
59
60 ignore = shutil.ignore_patterns(".git", ".git*")
61
62 if os.path.exists(outRoot):
63 print("🛑 new folder path exists, stopping")
64 raise ValueError
65 os.mkdir(outRoot)
66
67 newDesignspacePath = os.path.join(outRoot,
68 os.path.split(designspacePath)[1])
69
70 shutil.copy(designspacePath, newDesignspacePath)
71
72 ds = DesignSpaceDocument.fromfile(designspacePath)
73 sources = [source.path for source in ds.sources]
74 paths = {}
75 for fontPath in sources:
76 f = os.path.split(fontPath)[1]
77 newPath = os.path.join(outRoot, f)
78 paths[f] = newPath
79 shutil.copytree(fontPath, newPath, ignore=ignore)
80
81 ds = DesignSpaceDocument.fromfile(newDesignspacePath)
82 for source in ds.sources:
83 source.path = paths[os.path.split(source.path)[1]]
84 ds.write(newDesignspacePath)
85
86 return newDesignspacePath
87
88
89def writeReport(path):

Callers 2

makeSourcesFunction · 0.90
prep_fonts.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected