mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03: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:
parent
96e71bfdb3
commit
cb10f0df09
7 changed files with 35 additions and 35 deletions
|
@ -117,12 +117,12 @@ For more info on this idea:
|
||||||
jarin.close()
|
jarin.close()
|
||||||
gitrepo.index.add([repof, ])
|
gitrepo.index.add([repof, ])
|
||||||
|
|
||||||
files = []
|
output_files = []
|
||||||
for root, dirs, filenames in os.walk(repodir):
|
for root, dirs, files in os.walk(repodir):
|
||||||
for f in filenames:
|
for f in files:
|
||||||
files.append(os.path.relpath(os.path.join(root, f), repodir))
|
output_files.append(os.path.relpath(os.path.join(root, f), repodir))
|
||||||
output = collections.OrderedDict()
|
output = collections.OrderedDict()
|
||||||
for f in sorted(files):
|
for f in sorted(output_files):
|
||||||
repofile = os.path.join(repodir, f)
|
repofile = os.path.join(repodir, f)
|
||||||
stat = os.stat(repofile)
|
stat = os.stat(repofile)
|
||||||
output[f] = (
|
output[f] = (
|
||||||
|
|
|
@ -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...
|
# Helper to copy the contents of a directory to the server...
|
||||||
def send_dir(path):
|
def send_dir(path):
|
||||||
root = os.path.dirname(path)
|
startroot = os.path.dirname(path)
|
||||||
main = os.path.basename(path)
|
main = os.path.basename(path)
|
||||||
ftp.mkdir(main)
|
ftp.mkdir(main)
|
||||||
for r, d, f in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
rr = os.path.relpath(r, root)
|
rr = os.path.relpath(root, startroot)
|
||||||
ftp.chdir(rr)
|
ftp.chdir(rr)
|
||||||
for dd in d:
|
for d in dirs:
|
||||||
ftp.mkdir(dd)
|
ftp.mkdir(d)
|
||||||
for ff in f:
|
for f in files:
|
||||||
lfile = os.path.join(root, rr, ff)
|
lfile = os.path.join(startroot, rr, f)
|
||||||
if not os.path.islink(lfile):
|
if not os.path.islink(lfile):
|
||||||
ftp.put(lfile, ff)
|
ftp.put(lfile, f)
|
||||||
ftp.chmod(ff, os.stat(lfile).st_mode)
|
ftp.chmod(f, os.stat(lfile).st_mode)
|
||||||
for i in range(len(rr.split('/'))):
|
for i in range(len(rr.split('/'))):
|
||||||
ftp.chdir('..')
|
ftp.chdir('..')
|
||||||
ftp.chdir('..')
|
ftp.chdir('..')
|
||||||
|
|
|
@ -302,10 +302,10 @@ def check_gplay(app):
|
||||||
# Return all directories under startdir that contain any of the manifest
|
# Return all directories under startdir that contain any of the manifest
|
||||||
# files, and thus are probably an Android project.
|
# files, and thus are probably an Android project.
|
||||||
def dirs_with_manifest(startdir):
|
def dirs_with_manifest(startdir):
|
||||||
for r, d, f in os.walk(startdir):
|
for root, dirs, files in os.walk(startdir):
|
||||||
if any(m in f for m in [
|
if any(m in files for m in [
|
||||||
'AndroidManifest.xml', 'pom.xml', 'build.gradle']):
|
'AndroidManifest.xml', 'pom.xml', 'build.gradle']):
|
||||||
yield r
|
yield root
|
||||||
|
|
||||||
|
|
||||||
# Tries to find a new subdir starting from the root build_dir. Returns said
|
# Tries to find a new subdir starting from the root build_dir. Returns said
|
||||||
|
|
|
@ -1022,9 +1022,9 @@ def retrieve_string(app_dir, string, xmlfiles=None):
|
||||||
os.path.join(app_dir, 'res'),
|
os.path.join(app_dir, 'res'),
|
||||||
os.path.join(app_dir, 'src', 'main', 'res'),
|
os.path.join(app_dir, 'src', 'main', 'res'),
|
||||||
]:
|
]:
|
||||||
for r, d, f in os.walk(res_dir):
|
for root, dirs, files in os.walk(res_dir):
|
||||||
if os.path.basename(r) == 'values':
|
if os.path.basename(root) == 'values':
|
||||||
xmlfiles += [os.path.join(r, x) for x in f if x.endswith('.xml')]
|
xmlfiles += [os.path.join(root, x) for x in files if x.endswith('.xml')]
|
||||||
|
|
||||||
name = string[len('@string/'):]
|
name = string[len('@string/'):]
|
||||||
|
|
||||||
|
|
|
@ -358,21 +358,21 @@ def check_license_tag(app):
|
||||||
|
|
||||||
def check_extlib_dir(apps):
|
def check_extlib_dir(apps):
|
||||||
dir_path = os.path.join('build', 'extlib')
|
dir_path = os.path.join('build', 'extlib')
|
||||||
files = set()
|
unused_extlib_files = set()
|
||||||
for root, dirs, names in os.walk(dir_path):
|
for root, dirs, files in os.walk(dir_path):
|
||||||
for name in names:
|
for name in files:
|
||||||
files.add(os.path.join(root, name)[len(dir_path) + 1:])
|
unused_extlib_files.add(os.path.join(root, name)[len(dir_path) + 1:])
|
||||||
|
|
||||||
used = set()
|
used = set()
|
||||||
for app in apps:
|
for app in apps:
|
||||||
for build in app.builds:
|
for build in app.builds:
|
||||||
for path in build.extlibs:
|
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)
|
yield "%s: Unknown extlib %s in build '%s'" % (app.id, path, build.versionName)
|
||||||
else:
|
else:
|
||||||
used.add(path)
|
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 [
|
if any(path.endswith(s) for s in [
|
||||||
'.gitignore',
|
'.gitignore',
|
||||||
'source.txt', 'origin.txt', 'md5.txt',
|
'source.txt', 'origin.txt', 'md5.txt',
|
||||||
|
|
|
@ -165,20 +165,20 @@ def scan_source(build_dir, build):
|
||||||
return any(command.match(line) for command in gradle_compile_commands)
|
return any(command.match(line) for command in gradle_compile_commands)
|
||||||
|
|
||||||
# Iterate through all files in the source code
|
# 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
|
# It's topdown, so checking the basename is enough
|
||||||
for ignoredir in ('.hg', '.git', '.svn', '.bzr'):
|
for ignoredir in ('.hg', '.git', '.svn', '.bzr'):
|
||||||
if ignoredir in dirnames:
|
if ignoredir in dirs:
|
||||||
dirnames.remove(ignoredir)
|
dirs.remove(ignoredir)
|
||||||
|
|
||||||
for curfile in filenames:
|
for curfile in files:
|
||||||
|
|
||||||
if curfile in ['.DS_Store']:
|
if curfile in ['.DS_Store']:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Path (relative) to the file
|
# Path (relative) to the file
|
||||||
filepath = os.path.join(dirpath, curfile)
|
filepath = os.path.join(root, curfile)
|
||||||
|
|
||||||
if os.path.islink(filepath):
|
if os.path.islink(filepath):
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -154,7 +154,7 @@ def update_awsbucket_libcloud(repo_section):
|
||||||
if obj.name.startswith(upload_dir + '/'):
|
if obj.name.startswith(upload_dir + '/'):
|
||||||
objs[obj.name] = obj
|
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:
|
for name in files:
|
||||||
upload = False
|
upload = False
|
||||||
file_to_upload = os.path.join(root, name)
|
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='.'):
|
def _get_size(start_path='.'):
|
||||||
'''get size of all files in a dir https://stackoverflow.com/a/1392549'''
|
'''get size of all files in a dir https://stackoverflow.com/a/1392549'''
|
||||||
total_size = 0
|
total_size = 0
|
||||||
for dirpath, dirnames, filenames in os.walk(start_path):
|
for root, dirs, files in os.walk(start_path):
|
||||||
for f in filenames:
|
for f in files:
|
||||||
fp = os.path.join(dirpath, f)
|
fp = os.path.join(root, f)
|
||||||
total_size += os.path.getsize(fp)
|
total_size += os.path.getsize(fp)
|
||||||
return total_size
|
return total_size
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue