Skip to content

Commit 5201c6f

Browse files
📝 Add docstrings to BB-276-symlinks
Docstrings generation was requested by @Franr. * #297 (comment) The following files were modified: * `leverage/modules/project.py`
1 parent 3086db4 commit 5201c6f

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

leverage/modules/project.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,22 @@ def init():
116116

117117

118118
def _copy_account(account, primary_region):
119-
"""Copy account directory and all its files.
120-
119+
"""
120+
Copy an account's directory structure from the template repository to the project directory.
121+
122+
This function creates the account directory under the project root and replicates the necessary subdirectories by:
123+
- Copying the configuration directory.
124+
- Duplicating all global layers as defined in the project structure.
125+
- Copying primary region-specific layers into the designated region folder.
126+
127+
All copy operations utilize a predefined ignore pattern (IGNORE_PATTERNS). Notably, the copy procedures for global and primary region layers are performed with symbolic link preservation (symlinks=True) to ensure that any symbolic links in the template are maintained in the destination.
128+
121129
Args:
122-
account (str): Account name.
123-
primary_region (str): Projects primary region.
130+
account (str): The account name corresponding to a directory in the template.
131+
primary_region (str): The project’s primary region, used to determine the target subdirectory for region-specific layers.
132+
133+
Raises:
134+
OSError: If directory creation or file copy operations fail.
124135
"""
125136
(PROJECT_ROOT / account).mkdir()
126137

@@ -149,11 +160,22 @@ def _copy_account(account, primary_region):
149160

150161

151162
def _copy_project_template(config):
152-
"""Copy all files and directories from the Leverage project template to the project directory.
153-
It excludes al jinja templates as those will be rendered directly to their final location.
154-
163+
"""
164+
Copy project template files and directories to the project directory.
165+
166+
This function initializes the project directory by copying essential files from the Leverage
167+
project template. It performs the following actions:
168+
1. Copies the .gitignore file from the template directory to the project root.
169+
2. Copies the configuration directory (excluding Jinja templates and other ignored patterns)
170+
from the template to the project's configuration directory.
171+
3. Iterates over each account defined in the project structure and copies account-specific
172+
files by calling the _copy_account helper, using the "primary_region" specified in the config.
173+
155174
Args:
156-
config (dict): Project configuration.
175+
config (dict): Project configuration containing at least the "primary_region" key.
176+
177+
Raises:
178+
OSError: If any file or directory operation fails.
157179
"""
158180
logger.info("Creating project directory structure.")
159181

0 commit comments

Comments
 (0)