fix PEP8 "E302 expected 2 blank lines, found 1"

This commit is contained in:
Hans-Christoph Steiner 2014-05-01 23:39:33 -04:00
parent 2f2618e06c
commit 3f4f7a544b
16 changed files with 84 additions and 0 deletions

View file

@ -36,6 +36,7 @@ import metadata
config = None
options = None
def get_default_config():
return {
'sdk_path': os.getenv("ANDROID_HOME"),
@ -58,6 +59,7 @@ def get_default_config():
'keyaliases': {},
}
def read_config(opts, config_file='config.py'):
"""Read the repository config
@ -122,6 +124,7 @@ def read_config(opts, config_file='config.py'):
return config
def test_sdk_exists(c):
if c['sdk_path'] is None:
# c['sdk_path'] is set to the value of ANDROID_HOME by default
@ -140,6 +143,7 @@ def test_sdk_exists(c):
return False
return True
def write_password_file(pwtype, password=None):
'''
writes out passwords to a protected file instead of passing passwords as
@ -154,6 +158,7 @@ def write_password_file(pwtype, password=None):
os.close(fd)
config[pwtype + 'file'] = filename
# Given the arguments in the form of multiple appid:[vc] strings, this returns
# a dictionary with the set of vercodes specified for each package.
def read_pkg_args(args, allow_vercodes=False):
@ -175,6 +180,7 @@ def read_pkg_args(args, allow_vercodes=False):
return vercodes
# On top of what read_pkg_args does, this returns the whole app metadata, but
# limiting the builds list to the builds matching the vercodes specified.
def read_app_args(args, allapps, allow_vercodes=False):
@ -213,6 +219,7 @@ def read_app_args(args, allapps, allow_vercodes=False):
return apps
def has_extension(filename, extension):
name, ext = os.path.splitext(filename)
ext = ext.lower()[1:]
@ -220,6 +227,7 @@ def has_extension(filename, extension):
apk_regex = None
def apknameinfo(filename):
global apk_regex
filename = os.path.basename(filename)
@ -232,12 +240,15 @@ def apknameinfo(filename):
raise Exception("Invalid apk name: %s" % filename)
return result
def getapkname(app, build):
return "%s_%s.apk" % (app['id'], build['vercode'])
def getsrcname(app, build):
return "%s_%s_src.tar.gz" % (app['id'], build['vercode'])
def getappname(app):
if app['Name']:
return app['Name']
@ -245,9 +256,11 @@ def getappname(app):
return app['Auto Name']
return app['id']
def getcvname(app):
return '%s (%s)' % (app['Current Version'], app['Current Version Code'])
def getvcs(vcstype, remote, local):
if vcstype == 'git':
return vcs_git(remote, local)
@ -265,12 +278,14 @@ def getvcs(vcstype, remote, local):
return getsrclib(remote, 'build/srclib', raw=True)
raise VCSException("Invalid vcs type " + vcstype)
def getsrclibvcs(name):
srclib_path = os.path.join('srclibs', name + ".txt")
if not os.path.exists(srclib_path):
raise VCSException("Missing srclib " + name)
return metadata.parse_srclib(srclib_path)['Repo Type']
class vcs:
def __init__(self, remote, local):
@ -356,6 +371,7 @@ class vcs:
def getsrclib(self):
return self.srclib
class vcs_git(vcs):
def repotype(self):
@ -564,6 +580,7 @@ class vcs_gitsvn(vcs):
return None
return p.stdout.strip()
class vcs_svn(vcs):
def repotype(self):
@ -606,6 +623,7 @@ class vcs_svn(vcs):
return line[18:]
return None
class vcs_hg(vcs):
def repotype(self):
@ -678,6 +696,7 @@ class vcs_bzr(vcs):
return [tag.split(' ')[0].strip() for tag in
p.stdout.splitlines()]
def retrieve_string(app_dir, string, xmlfiles=None):
res_dirs = [
@ -708,6 +727,7 @@ def retrieve_string(app_dir, string, xmlfiles=None):
return string.replace("\\'", "'")
# Return list of existing files that will be used to find the highest vercode
def manifest_paths(app_dir, flavour):
@ -722,6 +742,7 @@ def manifest_paths(app_dir, flavour):
return [path for path in possible_manifests if os.path.isfile(path)]
# Retrieve the package name. Returns the name, or None if not found.
def fetch_real_name(app_dir, flavour):
app_search = re.compile(r'.*<application.*').search
@ -746,6 +767,7 @@ def fetch_real_name(app_dir, flavour):
return result
return None
# Retrieve the version name
def version_name(original, app_dir, flavour):
for f in manifest_paths(app_dir, flavour):
@ -756,6 +778,7 @@ def version_name(original, app_dir, flavour):
return string
return original
def get_library_references(root_dir):
libraries = []
proppath = os.path.join(root_dir, 'project.properties')
@ -773,6 +796,7 @@ def get_library_references(root_dir):
libraries.append(path)
return libraries
def ant_subprojects(root_dir):
subprojects = get_library_references(root_dir)
for subpath in subprojects:
@ -783,6 +807,7 @@ def ant_subprojects(root_dir):
subprojects.insert(0, relp)
return subprojects
def remove_debuggable_flags(root_dir):
# Remove forced debuggable flags
logging.info("Removing debuggable flags")
@ -793,6 +818,7 @@ def remove_debuggable_flags(root_dir):
if p.returncode != 0:
raise BuildException("Failed to remove debuggable flags of %s" % path)
# Extract some information from the AndroidManifest.xml at the given path.
# Returns (version, vercode, package), any or all of which might be None.
# All values returned are strings.
@ -858,6 +884,7 @@ def parse_androidmanifests(paths):
return (max_version, max_vercode, max_package)
class BuildException(Exception):
def __init__(self, value, detail=None):
self.value = value
@ -879,6 +906,7 @@ class BuildException(Exception):
ret += "\n==== detail begin ====\n%s\n==== detail end ====" % self.detail.strip()
return ret
class VCSException(Exception):
def __init__(self, value):
self.value = value
@ -886,6 +914,7 @@ class VCSException(Exception):
def __str__(self):
return repr(self.value)
# Get the specified source library.
# Returns the path to it. Normally this is the path to be used when referencing
# it, which may be a subdirectory of the actual project. If you want the base
@ -1212,6 +1241,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
return (root_dir, srclibpaths)
# Split and extend via globbing the paths from a field
def getpaths(build_dir, build, field):
paths = []
@ -1224,6 +1254,7 @@ def getpaths(build_dir, build, field):
paths += [r[len(build_dir)+1:] for r in glob.glob(full_path)]
return paths
# Scan the source code in the given directory (and all subdirectories)
# and return the number of fatal problems encountered
def scan_source(build_dir, root_dir, thisbuild):
@ -1423,6 +1454,7 @@ class KnownApks:
lst.reverse()
return lst
def isApkDebuggable(apkfile, config):
"""Returns True if the given apk file is debuggable
@ -1463,13 +1495,16 @@ class AsynchronousFileReader(threading.Thread):
'''Check whether there is no more content to expect.'''
return not self.is_alive() and self._queue.empty()
class PopenResult:
returncode = None
stdout = ''
def SilentPopen(commands, cwd=None, shell=False):
return FDroidPopen(commands, cwd=cwd, shell=shell, output=False)
def FDroidPopen(commands, cwd=None, shell=False, output=True):
"""
Run a command and capture the possibly huge output.
@ -1509,6 +1544,7 @@ def FDroidPopen(commands, cwd=None, shell=False, output=True):
result.returncode = p.returncode
return result
def remove_signing_keys(build_dir):
comment = re.compile(r'[ ]*//')
signing_configs = re.compile(r'^[\t ]*signingConfigs[ \t]*{[ \t]*$')
@ -1570,12 +1606,14 @@ def remove_signing_keys(build_dir):
logging.info("Cleaned %s of keysigning configs at %s" % (propfile, path))
def replace_config_vars(cmd):
cmd = cmd.replace('$$SDK$$', config['sdk_path'])
cmd = cmd.replace('$$NDK$$', config['ndk_path'])
cmd = cmd.replace('$$MVN3$$', config['mvn3'])
return cmd
def place_srclib(root_dir, number, libpath):
if not number:
return