26
26
def expand_dir (_dir , cwd = os .getcwd ()):
27
27
"""Return path with environmental variables and tilde ~ expanded.
28
28
29
- :param _dir:
30
- :type _dir: str
31
- :param cwd: current working dir (for deciphering relative _dir paths)
32
- :type cwd: str
33
- :rtype; str
29
+ Parameters
30
+ ----------
31
+ _dir : str
32
+ cwd : str, optional
33
+ current working dir (for deciphering relative _dir paths), defaults to
34
+ :py:meth:`os.getcwd()`
35
+
36
+ Returns
37
+ -------
38
+ str :
39
+ Absolute directory path
34
40
"""
35
41
_dir = os .path .expanduser (os .path .expandvars (_dir ))
36
42
if not os .path .isabs (_dir ):
@@ -44,12 +50,16 @@ def extract_repos(config, cwd=os.getcwd()):
44
50
end-user configuration permit inline configuration shortcuts, expand to
45
51
identical format for parsing.
46
52
47
- :param config: the repo config in :py:class:`dict` format.
48
- :type config: dict
49
- :param cwd: current working dir (for deciphering relative paths)
50
- :type cwd: str
51
- :rtype: list
53
+ Parameters
54
+ ----------
55
+ config : dict
56
+ the repo config in :py:class:`dict` format.
57
+ cwd : str
58
+ current working dir (for deciphering relative paths)
52
59
60
+ Returns
61
+ -------
62
+ list : List of normalized repository information
53
63
"""
54
64
configs = []
55
65
for directory , repos in config .items ():
@@ -137,20 +147,26 @@ def find_config_files(
137
147
):
138
148
"""Return repos from a directory and match. Not recursive.
139
149
140
- :param path: list of paths to search
141
- :type path: list
142
- :param match: list of globs to search against
143
- :type match: list
144
- :param filetype: list of filetypes to search against
145
- :type filetype: list
146
- :param include_home: Include home configuration files
147
- :type include_home: bool
148
- :raises:
149
- - LoadConfigRepoConflict: There are two configs that have same path
150
- and name with different repo urls.
151
- :returns: list of absolute paths to config files.
152
- :rtype: list
153
-
150
+ Parameters
151
+ ----------
152
+ path : list
153
+ list of paths to search
154
+ match : list
155
+ list of globs to search against
156
+ filetype: list
157
+ of filetypes to search against
158
+ include_home : bool
159
+ Include home configuration files
160
+
161
+ Raises
162
+ ------
163
+ LoadConfigRepoConflict :
164
+ There are two configs that have same path and name with different repo urls.
165
+
166
+ Returns
167
+ -------
168
+ list :
169
+ list of absolute paths to config files.
154
170
"""
155
171
configs = []
156
172
@@ -182,14 +198,21 @@ def find_config_files(
182
198
def load_configs (files , cwd = os .getcwd ()):
183
199
"""Return repos from a list of files.
184
200
185
- :todo: Validate scheme, check for duplciate destinations, VCS urls
186
-
187
- :param files: paths to config file
188
- :type files: list
189
- :param cwd: current path (pass down for :func:`extract_repos`
190
- :type cwd: str
191
- :returns: expanded config dict item
192
- :rtype: list of dict
201
+ Parameters
202
+ ----------
203
+ files : list
204
+ paths to config file
205
+ cwd : str
206
+ current path (pass down for :func:`extract_repos`
207
+
208
+ Returns
209
+ -------
210
+ list of dict :
211
+ expanded config dict item
212
+
213
+ Todo
214
+ ----
215
+ Validate scheme, check for duplciate destinations, VCS urls
193
216
"""
194
217
repos = []
195
218
for f in files :
@@ -215,12 +238,18 @@ def load_configs(files, cwd=os.getcwd()):
215
238
def detect_duplicate_repos (repos1 , repos2 ):
216
239
"""Return duplicate repos dict if repo_dir same and vcs different.
217
240
218
- :param repos1: list of repo expanded dicts
219
- :type repos1: list of :py:dict
220
- :param repos2: list of repo expanded dicts
221
- :type repos2: list of :py:dict
222
- :rtype: list of dicts or None
223
- :returns: Duplicate lists
241
+ Parameters
242
+ ----------
243
+ repos1 : dict
244
+ list of repo expanded dicts
245
+
246
+ repos2 : dict
247
+ list of repo expanded dicts
248
+
249
+ Returns
250
+ -------
251
+ list of dict, or None
252
+ Duplicate repos
224
253
"""
225
254
dupes = []
226
255
path_dupe_repos = []
@@ -249,12 +278,16 @@ def detect_duplicate_repos(repos1, repos2):
249
278
def in_dir (config_dir = CONFIG_DIR , extensions = ['.yml' , '.yaml' , '.json' ]):
250
279
"""Return a list of configs in ``config_dir``.
251
280
252
- :param config_dir: directory to search
253
- :type config_dir: str
254
- :param extensions: filetypes to check (e.g. ``['.yaml', '.json']``).
255
- :type extensions: list
256
- :rtype: list
281
+ Parameters
282
+ ----------
283
+ config_dir : str
284
+ directory to search
285
+ extensions : list
286
+ filetypes to check (e.g. ``['.yaml', '.json']``).
257
287
288
+ Returns
289
+ -------
290
+ list
258
291
"""
259
292
configs = []
260
293
@@ -270,16 +303,21 @@ def filter_repos(config, repo_dir=None, vcs_url=None, name=None):
270
303
271
304
repo_dir, vcs_url and name all support fnmatch.
272
305
273
- :param config: the expanded repo config in :py:class:`dict` format.
274
- :type config: dict
275
- :param repo_dir: directory of checkout location, fnmatch pattern supported
276
- :type repo_dir: str or None
277
- :param vcs_url: url of vcs remote, fn match pattern supported
278
- :type vcs_url: str or None
279
- :param name: project name, fnmatch pattern supported
280
- :type name: str or None
281
- :rtype: list
282
-
306
+ Parameters
307
+ ----------
308
+ config : dist
309
+ the expanded repo config in :py:class:`dict` format.
310
+ repo_dir : str, Optional
311
+ directory of checkout location, fnmatch pattern supported
312
+ vcs_url : str, Optional
313
+ url of vcs remote, fn match pattern supported
314
+ name : str, Optional
315
+ project name, fnmatch pattern supported
316
+
317
+ Returns
318
+ -------
319
+ list :
320
+ Repos
283
321
"""
284
322
repo_list = []
285
323
@@ -302,12 +340,16 @@ def filter_repos(config, repo_dir=None, vcs_url=None, name=None):
302
340
def is_config_file (filename , extensions = ['.yml' , '.yaml' , '.json' ]):
303
341
"""Return True if file has a valid config file type.
304
342
305
- :param filename: filename to check (e.g. ``mysession.json``).
306
- :type filename: str
307
- :param extensions: filetypes to check (e.g. ``['.yaml', '.json']``).
308
- :type extensions: list or str
309
- :rtype: bool
343
+ Parameters
344
+ ----------
345
+ filename : str
346
+ filename to check (e.g. ``mysession.json``).
347
+ extensions : list or str
348
+ filetypes to check (e.g. ``['.yaml', '.json']``).
310
349
350
+ Returns
351
+ -------
352
+ bool : True if is a valid config file type
311
353
"""
312
354
extensions = [extensions ] if isinstance (extensions , string_types ) else extensions
313
355
return any (filename .endswith (e ) for e in extensions )
0 commit comments