1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 22:40:12 +01:00

standardize os.walk() var names based on Python 3.5 docs

There were multiple conventions used in the code, but mostly it was already
using the convention from the docs, so this converts things to using that
convention:

https://docs.python.org/3/library/os.html#os.walk
This commit is contained in:
Hans-Christoph Steiner 2017-09-14 08:44:43 +02:00
parent 96e71bfdb3
commit cb10f0df09
7 changed files with 35 additions and 35 deletions

View File

@ -117,12 +117,12 @@ For more info on this idea:
jarin.close()
gitrepo.index.add([repof, ])
files = []
for root, dirs, filenames in os.walk(repodir):
for f in filenames:
files.append(os.path.relpath(os.path.join(root, f), repodir))
output_files = []
for root, dirs, files in os.walk(repodir):
for f in files:
output_files.append(os.path.relpath(os.path.join(root, f), repodir))
output = collections.OrderedDict()
for f in sorted(files):
for f in sorted(output_files):
repofile = os.path.join(repodir, f)
stat = os.stat(repofile)
output[f] = (

View File

@ -96,19 +96,19 @@ def build_server(app, build, vcs, build_dir, output_dir, log_dir, force):
# Helper to copy the contents of a directory to the server...
def send_dir(path):
root = os.path.dirname(path)
startroot = os.path.dirname(path)
main = os.path.basename(path)
ftp.mkdir(main)
for r, d, f in os.walk(path):
rr = os.path.relpath(r, root)
for root, dirs, files in os.walk(path):
rr = os.path.relpath(root, startroot)
ftp.chdir(rr)
for dd in d:
ftp.mkdir(dd)
for ff in f:
lfile = os.path.join(root, rr, ff)
for d in dirs:
ftp.mkdir(d)
for f in files:
lfile = os.path.join(startroot, rr, f)
if not os.path.islink(lfile):
ftp.put(lfile, ff)
ftp.chmod(ff, os.stat(lfile).st_mode)
ftp.put(lfile, f)
ftp.chmod(f, os.stat(lfile).st_mode)
for i in range(len(rr.split('/'))):
ftp.chdir('..')
ftp.chdir('..')

View File

@ -302,10 +302,10 @@ def check_gplay(app):
# Return all directories under startdir that contain any of the manifest
# files, and thus are probably an Android project.
def dirs_with_manifest(startdir):
for r, d, f in os.walk(startdir):
if any(m in f for m in [
for root, dirs, files in os.walk(startdir):
if any(m in files for m in [
'AndroidManifest.xml', 'pom.xml', 'build.gradle']):
yield r
yield root
# Tries to find a new subdir starting from the root build_dir. Returns said

View File

@ -1022,9 +1022,9 @@ def retrieve_string(app_dir, string, xmlfiles=None):
os.path.join(app_dir, 'res'),
os.path.join(app_dir, 'src', 'main', 'res'),
]:
for r, d, f in os.walk(res_dir):
if os.path.basename(r) == 'values':
xmlfiles += [os.path.join(r, x) for x in f if x.endswith('.xml')]
for root, dirs, files in os.walk(res_dir):
if os.path.basename(root) == 'values':
xmlfiles += [os.path.join(root, x) for x in files if x.endswith('.xml')]
name = string[len('@string/'):]

View File

@ -358,21 +358,21 @@ def check_license_tag(app):
def check_extlib_dir(apps):
dir_path = os.path.join('build', 'extlib')
files = set()
for root, dirs, names in os.walk(dir_path):
for name in names:
files.add(os.path.join(root, name)[len(dir_path) + 1:])
unused_extlib_files = set()
for root, dirs, files in os.walk(dir_path):
for name in files:
unused_extlib_files.add(os.path.join(root, name)[len(dir_path) + 1:])
used = set()
for app in apps:
for build in app.builds:
for path in build.extlibs:
if path not in files:
if path not in unused_extlib_files:
yield "%s: Unknown extlib %s in build '%s'" % (app.id, path, build.versionName)
else:
used.add(path)
for path in files.difference(used):
for path in unused_extlib_files.difference(used):
if any(path.endswith(s) for s in [
'.gitignore',
'source.txt', 'origin.txt', 'md5.txt',

View File

@ -165,20 +165,20 @@ def scan_source(build_dir, build):
return any(command.match(line) for command in gradle_compile_commands)
# Iterate through all files in the source code
for dirpath, dirnames, filenames in os.walk(build_dir, topdown=True):
for root, dirs, files in os.walk(build_dir, topdown=True):
# It's topdown, so checking the basename is enough
for ignoredir in ('.hg', '.git', '.svn', '.bzr'):
if ignoredir in dirnames:
dirnames.remove(ignoredir)
if ignoredir in dirs:
dirs.remove(ignoredir)
for curfile in filenames:
for curfile in files:
if curfile in ['.DS_Store']:
continue
# Path (relative) to the file
filepath = os.path.join(dirpath, curfile)
filepath = os.path.join(root, curfile)
if os.path.islink(filepath):
continue

View File

@ -154,7 +154,7 @@ def update_awsbucket_libcloud(repo_section):
if obj.name.startswith(upload_dir + '/'):
objs[obj.name] = obj
for root, _, files in os.walk(os.path.join(os.getcwd(), repo_section)):
for root, dirs, files in os.walk(os.path.join(os.getcwd(), repo_section)):
for name in files:
upload = False
file_to_upload = os.path.join(root, name)
@ -307,9 +307,9 @@ def update_localcopy(repo_section, local_copy_dir):
def _get_size(start_path='.'):
'''get size of all files in a dir https://stackoverflow.com/a/1392549'''
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
for root, dirs, files in os.walk(start_path):
for f in files:
fp = os.path.join(root, f)
total_size += os.path.getsize(fp)
return total_size