@@ -77,17 +77,17 @@ def get_files_from_directory(dirpath, file_extension, file_name=None,
77
77
Args:
78
78
dirpath (str): Root directory to search in.
79
79
file_extension (str): File extension to search for.
80
- Eg: '.gradle'
80
+ Eg: '.gradle'
81
81
file_name (str, optional): Exact file name to search for.
82
- Defaults to None. Eg: 'foo.gradle'
82
+ Defaults to None. Eg: 'foo.gradle'
83
83
absolute_paths (bool, optional): Return absolute paths to files.
84
- Defaults to True.
85
- If False, just filenames are returned.
84
+ Defaults to True.
85
+ If False, just filenames are returned.
86
86
87
87
Returns:
88
88
list(str): List of files matching the specified criteria.
89
- List of filenames (if absolute_paths=False), or
90
- a list of absolute paths (if absolute_paths=True)
89
+ List of filenames (if absolute_paths=False), or
90
+ a list of absolute paths (if absolute_paths=True)
91
91
"""
92
92
files = []
93
93
for dirpath , _ , filenames in os .walk (dirpath ):
@@ -104,16 +104,17 @@ def get_files_from_directory(dirpath, file_extension, file_name=None,
104
104
105
105
106
106
def get_files (dirs_and_files , file_extension , file_name = None ):
107
- """Get final list of files after searching directories.
107
+ """Gets the final flat list of files after searching directories.
108
+
108
109
If a directory is passed, it is searched recursively.
109
110
110
111
Args:
111
112
dirs_and_files (iterable(str)): List of paths which could be files or
112
- directories.
113
+ directories.
113
114
file_extension (str): File extension to search for.
114
- Eg: '.gradle'
115
+ Eg: '.gradle'
115
116
file_name (str, optional): Exact file name to search for.
116
- Defaults to None. Eg: 'foo.gradle'
117
+ Defaults to None. Eg: 'foo.gradle'
117
118
118
119
Returns:
119
120
iterable(str): Final list of files after recursively searching dirs.
@@ -125,8 +126,8 @@ def get_files(dirs_and_files, file_extension, file_name=None):
125
126
continue
126
127
if os .path .isdir (abspath ):
127
128
files = files + get_files_from_directory (abspath ,
128
- file_extension = file_extension ,
129
- file_name = file_name )
129
+ file_extension = file_extension ,
130
+ file_name = file_name )
130
131
elif os .path .isfile (abspath ):
131
132
files .append (abspath )
132
133
return files
@@ -163,11 +164,11 @@ def get_pod_versions(specs_repo, pods=PODS):
163
164
Args:
164
165
local_repo_dir (str): Directory mirroring Cocoapods specs repo
165
166
pods (iterable(str), optional): List of pods whose versions we need.
166
- Defaults to PODS.
167
+ Defaults to PODS.
167
168
168
169
Returns:
169
170
dict: Map of the form {<str>:list(str)}
170
- Containing a mapping of podnames to available versions.
171
+ Containing a mapping of podnames to available versions.
171
172
"""
172
173
all_versions = defaultdict (list )
173
174
logging .info ('Fetching pod versions from Specs repo...' )
@@ -191,12 +192,12 @@ def get_latest_pod_versions(specs_repo=None, pods=PODS):
191
192
192
193
Args:
193
194
pods (iterable(str) optional): Pods for which we need latest version.
194
- Defaults to PODS.
195
+ Defaults to PODS.
195
196
specs_repo (str optional): Local checkout of Cocoapods specs repo.
196
197
197
198
Returns:
198
199
dict: Map of the form {<str>:<str>} containing a mapping of podnames to
199
- latest version.
200
+ latest version.
200
201
"""
201
202
cleanup_required = False
202
203
if specs_repo is None :
@@ -230,11 +231,12 @@ def get_latest_pod_versions(specs_repo=None, pods=PODS):
230
231
231
232
def get_pod_files (dirs_and_files ):
232
233
"""Get final list of podfiles to update.
234
+
233
235
If a directory is passed, it is searched recursively.
234
236
235
237
Args:
236
238
dirs_and_files (iterable(str)): List of paths which could be files or
237
- directories.
239
+ directories.
238
240
239
241
Returns:
240
242
iterable(str): Final list of podfiles after recursively searching dirs.
@@ -254,7 +256,8 @@ def get_pod_files(dirs_and_files):
254
256
return pod_files
255
257
256
258
# Look for lines like, pod 'Firebase/Core', '7.11.0'
257
- RE_PODFILE_VERSION = re .compile ("\s+pod '(?P<pod_name>.+)', '(?P<version>.+)'\n " )
259
+ RE_PODFILE_VERSION = re .compile (
260
+ r"\s+pod '(?P<pod_name>.+)', '(?P<version>.+)'\n" )
258
261
259
262
def modify_pod_file (pod_file , pod_version_map , dryrun = True ):
260
263
"""Update pod versions in specified podfile.
@@ -314,9 +317,9 @@ def modify_readme_file_pods(readme_filepath, version_map, dryrun=True):
314
317
Args:
315
318
readme_filepath: Path to readme file to edit.
316
319
version_map: Dictionary of packages to version numbers, e.g. {
317
- 'FirebaseAuth': '15.0.0', 'FirebaseDatabase': '14.0.0' }
320
+ 'FirebaseAuth': '15.0.0', 'FirebaseDatabase': '14.0.0' }
318
321
dryrun (bool, optional): Just print the substitutions.
319
- Do not write to file. Defaults to True.
322
+ Do not write to file. Defaults to True.
320
323
"""
321
324
logging .debug ('Reading readme file: {0}' .format (readme_filepath ))
322
325
@@ -402,9 +405,9 @@ def modify_dependency_file(dependency_filepath, version_map, dryrun=True):
402
405
Args:
403
406
dependency_filename: Relative path to the dependency file to edit.
404
407
version_map: Dictionary of packages to version numbers, e.g. {
405
- 'com.google.firebase.firebase_auth': '15.0.0' }
408
+ 'com.google.firebase.firebase_auth': '15.0.0' }
406
409
dryrun (bool, optional): Just print the substitutions.
407
- Do not write to file. Defaults to True.
410
+ Do not write to file. Defaults to True.
408
411
"""
409
412
logging .debug ('Reading dependency file: {0}' .format (dependency_filepath ))
410
413
lines = None
@@ -433,7 +436,7 @@ def replace_dependency(m):
433
436
to_update = False
434
437
for line in lines :
435
438
substituted_line = re .sub (RE_GENERIC_DEPENDENCY_MODULE , replace_dependency ,
436
- line )
439
+ line )
437
440
output_lines .append (substituted_line )
438
441
if substituted_line != line :
439
442
substituted_pairs .append ((line , substituted_line ))
@@ -464,9 +467,9 @@ def modify_readme_file_android(readme_filepath, version_map, dryrun=True):
464
467
Args:
465
468
readme_filepath: Path to readme file to edit.
466
469
version_map: Dictionary of packages to version numbers, e.g. {
467
- 'com.google.firebase.firebase_auth': '15.0.0' }
470
+ 'com.google.firebase.firebase_auth': '15.0.0' }
468
471
dryrun (bool, optional): Just print the substitutions.
469
- Do not write to file. Defaults to True.
472
+ Do not write to file. Defaults to True.
470
473
"""
471
474
logging .debug ('Reading readme file: {0}' .format (readme_filepath ))
472
475
@@ -475,7 +478,7 @@ def modify_readme_file_android(readme_filepath, version_map, dryrun=True):
475
478
lines = readme_file .readlines ()
476
479
if not lines :
477
480
logging .fatal ('Update failed. ' +
478
- 'Could not read contents from file {0}.' .format (readme_filepath ))
481
+ 'Could not read contents from file {0}.' .format (readme_filepath ))
479
482
480
483
output_lines = []
481
484
@@ -526,9 +529,9 @@ def modify_gradle_file(gradle_filepath, version_map, dryrun=True):
526
529
Args:
527
530
gradle_filename: Relative path to build.gradle file to edit.
528
531
version_map: Dictionary of packages to version numbers, e.g. {
529
- 'com.google.firebase.firebase_auth': '15.0.0' }
532
+ 'com.google.firebase.firebase_auth': '15.0.0' }
530
533
dryrun (bool, optional): Just print the substitutions.
531
- Do not write to file. Defaults to True.
534
+ Do not write to file. Defaults to True.
532
535
"""
533
536
logging .debug ("Reading gradle file: %s" , gradle_filepath )
534
537
@@ -537,7 +540,7 @@ def modify_gradle_file(gradle_filepath, version_map, dryrun=True):
537
540
lines = gradle_file .readlines ()
538
541
if not lines :
539
542
logging .fatal ('Update failed. ' +
540
- 'Could not read contents from file {0}.' .format (gradle_filepath ))
543
+ 'Could not read contents from file {0}.' .format (gradle_filepath ))
541
544
output_lines = []
542
545
543
546
# Replacement function, look up the version number of the given pkg.
@@ -614,9 +617,9 @@ def parse_cmdline_args():
614
617
level = log_levels .get (args .log_level .lower ())
615
618
if level is None :
616
619
raise ValueError ('Please use one of the following as'
617
- 'log levels:\n {0}' .format (',' .join (log_levels .keys ())))
620
+ 'log levels:\n {0}' .format (',' .join (log_levels .keys ())))
618
621
logging .basicConfig (level = level )
619
- logger = logging .getLogger (__name__ )
622
+ logging .getLogger (__name__ )
620
623
return args
621
624
622
625
0 commit comments