Fix a few coding style nits in Buck build Python scripts
- Prefix regex strings with `r` - Remove unused imports - Rename variables and parameters to avoid redefinition of built-in types `dir` and `type` Change-Id: Ia21667b89631c751f241dd6499a2e460e3435697
This commit is contained in:
@@ -14,13 +14,12 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
PAT_GERRIT = re.compile('^GERRIT')
|
PAT_GERRIT = re.compile(r'^GERRIT')
|
||||||
PAT_INCLUDE = re.compile('^(include::.*)(\[\])$')
|
PAT_INCLUDE = re.compile(r'^(include::.*)(\[\])$')
|
||||||
PAT_GET = re.compile('^get::([^ \t\n]*)')
|
PAT_GET = re.compile(r'^get::([^ \t\n]*)')
|
||||||
|
|
||||||
GERRIT_UPLINK = """
|
GERRIT_UPLINK = """
|
||||||
|
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ def gen_classpath():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
for env in ['main', 'test']:
|
for env in ['main', 'test']:
|
||||||
for type in ['java', 'resources']:
|
for srctype in ['java', 'resources']:
|
||||||
p = path.join(s, 'src', env, type)
|
p = path.join(s, 'src', env, srctype)
|
||||||
if path.exists(p):
|
if path.exists(p):
|
||||||
classpathentry('src', p)
|
classpathentry('src', p)
|
||||||
|
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ else:
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
for spec in args.s:
|
for spec in args.s:
|
||||||
artifact, type, src = spec.split(':')
|
artifact, packaging_type, src = spec.split(':')
|
||||||
try:
|
try:
|
||||||
check_output(cmd + [
|
check_output(cmd + [
|
||||||
'-DartifactId=%s' % artifact,
|
'-DartifactId=%s' % artifact,
|
||||||
'-Dpackaging=%s' % type,
|
'-Dpackaging=%s' % packaging_type,
|
||||||
'-Dfile=%s' % src,
|
'-Dfile=%s' % src,
|
||||||
])
|
])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ war = environ['TMP']
|
|||||||
root = war[:war.index('buck-out')]
|
root = war[:war.index('buck-out')]
|
||||||
jars = set()
|
jars = set()
|
||||||
|
|
||||||
def link_jars(libs, dir):
|
def link_jars(libs, directory):
|
||||||
makedirs(dir)
|
makedirs(directory)
|
||||||
cp = check_output(['buck', 'audit', 'classpath'] + libs)
|
cp = check_output(['buck', 'audit', 'classpath'] + libs)
|
||||||
for j in cp.strip().splitlines():
|
for j in cp.strip().splitlines():
|
||||||
if j not in jars:
|
if j not in jars:
|
||||||
@@ -37,7 +37,7 @@ def link_jars(libs, dir):
|
|||||||
n = path.basename(j)
|
n = path.basename(j)
|
||||||
if j.startswith('buck-out/gen/gerrit-'):
|
if j.startswith('buck-out/gen/gerrit-'):
|
||||||
n = j.split('/')[2] + '-' + n
|
n = j.split('/')[2] + '-' + n
|
||||||
symlink(path.join(root, j), path.join(dir, n))
|
symlink(path.join(root, j), path.join(directory, n))
|
||||||
|
|
||||||
if args.lib:
|
if args.lib:
|
||||||
link_jars(args.lib, path.join(war, 'WEB-INF', 'lib'))
|
link_jars(args.lib, path.join(war, 'WEB-INF', 'lib'))
|
||||||
|
|||||||
Reference in New Issue
Block a user