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] = (
# 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('..')
# 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
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/'):]
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',
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
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)
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