2016-09-19 19:04:56 +00:00
|
|
|
# Copyright 2016 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2016-09-22 12:10:02 +00:00
|
|
|
from _adb import Adb
|
2016-09-19 19:04:56 +00:00
|
|
|
import re
|
|
|
|
import subprocess
|
|
|
|
|
2016-09-22 12:10:02 +00:00
|
|
|
__ADB = None
|
2016-09-19 19:04:56 +00:00
|
|
|
|
2016-09-22 12:10:02 +00:00
|
|
|
def init(device_serial):
|
|
|
|
global __ADB
|
|
|
|
__ADB = Adb(device_serial)
|
2016-09-19 19:04:56 +00:00
|
|
|
|
|
|
|
def join(*pathnames):
|
|
|
|
return '/'.join(pathnames)
|
|
|
|
|
|
|
|
def basename(pathname):
|
|
|
|
return pathname.rsplit('/', maxsplit=1)[-1]
|
|
|
|
|
|
|
|
def find_skps(skps):
|
2016-09-22 12:10:02 +00:00
|
|
|
escapedskps = [re.sub(r'([^a-zA-Z0-9_/\.\*\?\[\!\]])', r'\\\1', x)
|
2016-09-19 19:04:56 +00:00
|
|
|
for x in skps]
|
2016-11-09 16:41:23 +00:00
|
|
|
return __ADB.check('''\
|
2016-09-19 19:04:56 +00:00
|
|
|
for PATHNAME in %s; do
|
|
|
|
if [ -d "$PATHNAME" ]; then
|
2016-09-22 19:37:21 +00:00
|
|
|
find "$PATHNAME" -maxdepth 1 -name *.skp
|
2016-09-19 19:04:56 +00:00
|
|
|
else
|
|
|
|
echo "$PATHNAME"
|
|
|
|
fi
|
2016-11-09 16:41:23 +00:00
|
|
|
done''' % ' '.join(escapedskps)).splitlines()
|