Skip to content

Commit 52b543e

Browse files
committed
formatting according to style guide
1 parent 739e8b0 commit 52b543e

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

scripts/update_ios_android_dependencies.py

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ def get_files_from_directory(dirpath, file_extension, file_name=None,
7777
Args:
7878
dirpath (str): Root directory to search in.
7979
file_extension (str): File extension to search for.
80-
Eg: '.gradle'
80+
Eg: '.gradle'
8181
file_name (str, optional): Exact file name to search for.
82-
Defaults to None. Eg: 'foo.gradle'
82+
Defaults to None. Eg: 'foo.gradle'
8383
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.
8686
8787
Returns:
8888
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)
9191
"""
9292
files = []
9393
for dirpath, _, filenames in os.walk(dirpath):
@@ -104,16 +104,17 @@ def get_files_from_directory(dirpath, file_extension, file_name=None,
104104

105105

106106
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+
108109
If a directory is passed, it is searched recursively.
109110
110111
Args:
111112
dirs_and_files (iterable(str)): List of paths which could be files or
112-
directories.
113+
directories.
113114
file_extension (str): File extension to search for.
114-
Eg: '.gradle'
115+
Eg: '.gradle'
115116
file_name (str, optional): Exact file name to search for.
116-
Defaults to None. Eg: 'foo.gradle'
117+
Defaults to None. Eg: 'foo.gradle'
117118
118119
Returns:
119120
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):
125126
continue
126127
if os.path.isdir(abspath):
127128
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)
130131
elif os.path.isfile(abspath):
131132
files.append(abspath)
132133
return files
@@ -163,11 +164,11 @@ def get_pod_versions(specs_repo, pods=PODS):
163164
Args:
164165
local_repo_dir (str): Directory mirroring Cocoapods specs repo
165166
pods (iterable(str), optional): List of pods whose versions we need.
166-
Defaults to PODS.
167+
Defaults to PODS.
167168
168169
Returns:
169170
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.
171172
"""
172173
all_versions = defaultdict(list)
173174
logging.info('Fetching pod versions from Specs repo...')
@@ -191,12 +192,12 @@ def get_latest_pod_versions(specs_repo=None, pods=PODS):
191192
192193
Args:
193194
pods (iterable(str) optional): Pods for which we need latest version.
194-
Defaults to PODS.
195+
Defaults to PODS.
195196
specs_repo (str optional): Local checkout of Cocoapods specs repo.
196197
197198
Returns:
198199
dict: Map of the form {<str>:<str>} containing a mapping of podnames to
199-
latest version.
200+
latest version.
200201
"""
201202
cleanup_required = False
202203
if specs_repo is None:
@@ -230,11 +231,12 @@ def get_latest_pod_versions(specs_repo=None, pods=PODS):
230231

231232
def get_pod_files(dirs_and_files):
232233
"""Get final list of podfiles to update.
234+
233235
If a directory is passed, it is searched recursively.
234236
235237
Args:
236238
dirs_and_files (iterable(str)): List of paths which could be files or
237-
directories.
239+
directories.
238240
239241
Returns:
240242
iterable(str): Final list of podfiles after recursively searching dirs.
@@ -254,7 +256,8 @@ def get_pod_files(dirs_and_files):
254256
return pod_files
255257

256258
# 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")
258261

259262
def modify_pod_file(pod_file, pod_version_map, dryrun=True):
260263
"""Update pod versions in specified podfile.
@@ -314,9 +317,9 @@ def modify_readme_file_pods(readme_filepath, version_map, dryrun=True):
314317
Args:
315318
readme_filepath: Path to readme file to edit.
316319
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' }
318321
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.
320323
"""
321324
logging.debug('Reading readme file: {0}'.format(readme_filepath))
322325

@@ -402,9 +405,9 @@ def modify_dependency_file(dependency_filepath, version_map, dryrun=True):
402405
Args:
403406
dependency_filename: Relative path to the dependency file to edit.
404407
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' }
406409
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.
408411
"""
409412
logging.debug('Reading dependency file: {0}'.format(dependency_filepath))
410413
lines = None
@@ -433,7 +436,7 @@ def replace_dependency(m):
433436
to_update = False
434437
for line in lines:
435438
substituted_line = re.sub(RE_GENERIC_DEPENDENCY_MODULE, replace_dependency,
436-
line)
439+
line)
437440
output_lines.append(substituted_line)
438441
if substituted_line != line:
439442
substituted_pairs.append((line, substituted_line))
@@ -464,9 +467,9 @@ def modify_readme_file_android(readme_filepath, version_map, dryrun=True):
464467
Args:
465468
readme_filepath: Path to readme file to edit.
466469
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' }
468471
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.
470473
"""
471474
logging.debug('Reading readme file: {0}'.format(readme_filepath))
472475

@@ -475,7 +478,7 @@ def modify_readme_file_android(readme_filepath, version_map, dryrun=True):
475478
lines = readme_file.readlines()
476479
if not lines:
477480
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))
479482

480483
output_lines = []
481484

@@ -526,9 +529,9 @@ def modify_gradle_file(gradle_filepath, version_map, dryrun=True):
526529
Args:
527530
gradle_filename: Relative path to build.gradle file to edit.
528531
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' }
530533
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.
532535
"""
533536
logging.debug("Reading gradle file: %s", gradle_filepath)
534537

@@ -537,7 +540,7 @@ def modify_gradle_file(gradle_filepath, version_map, dryrun=True):
537540
lines = gradle_file.readlines()
538541
if not lines:
539542
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))
541544
output_lines = []
542545

543546
# Replacement function, look up the version number of the given pkg.
@@ -614,9 +617,9 @@ def parse_cmdline_args():
614617
level = log_levels.get(args.log_level.lower())
615618
if level is None:
616619
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())))
618621
logging.basicConfig(level=level)
619-
logger = logging.getLogger(__name__)
622+
logging.getLogger(__name__)
620623
return args
621624

622625

0 commit comments

Comments
 (0)