mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-19 21:30:10 +01:00
fix PEP8 W605 invalid escape sequence
Python 3.7 will get a lot stricter with escape sequences. They must be valid. * https://lintlyci.github.io/Flake8Rules/rules/W605.html * https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
This commit is contained in:
parent
e6d5260c3c
commit
ff90c0246e
@ -560,7 +560,7 @@ def clean_description(description):
|
||||
paragraph = re.sub('\r', '', paragraph)
|
||||
paragraph = re.sub('\n', ' ', paragraph)
|
||||
paragraph = re.sub(' {2,}', ' ', paragraph)
|
||||
paragraph = re.sub('^\s*(\w)', r'\1', paragraph)
|
||||
paragraph = re.sub(r'^\s*(\w)', r'\1', paragraph)
|
||||
returnstring += paragraph + '\n\n'
|
||||
return returnstring.rstrip('\n')
|
||||
|
||||
@ -575,8 +575,8 @@ def publishednameinfo(filename):
|
||||
return result
|
||||
|
||||
|
||||
apk_release_filename = re.compile('(?P<appid>[a-zA-Z0-9_\.]+)_(?P<vercode>[0-9]+)\.apk')
|
||||
apk_release_filename_with_sigfp = re.compile('(?P<appid>[a-zA-Z0-9_\.]+)_(?P<vercode>[0-9]+)_(?P<sigfp>[0-9a-f]{7})\.apk')
|
||||
apk_release_filename = re.compile(r'(?P<appid>[a-zA-Z0-9_\.]+)_(?P<vercode>[0-9]+)\.apk')
|
||||
apk_release_filename_with_sigfp = re.compile(r'(?P<appid>[a-zA-Z0-9_\.]+)_(?P<vercode>[0-9]+)_(?P<sigfp>[0-9a-f]{7})\.apk')
|
||||
|
||||
|
||||
def apk_parse_release_filename(apkname):
|
||||
@ -2479,7 +2479,7 @@ def metadata_find_signing_files(appid, vercode):
|
||||
sigs = glob.glob(os.path.join(sigdir, '*.DSA')) + \
|
||||
glob.glob(os.path.join(sigdir, '*.EC')) + \
|
||||
glob.glob(os.path.join(sigdir, '*.RSA'))
|
||||
extre = re.compile('(\.DSA|\.EC|\.RSA)$')
|
||||
extre = re.compile(r'(\.DSA|\.EC|\.RSA)$')
|
||||
for sig in sigs:
|
||||
sf = extre.sub('.SF', sig)
|
||||
if os.path.isfile(sf):
|
||||
@ -3011,9 +3011,9 @@ def write_to_config(thisconfig, key, value=None, config_file=None):
|
||||
|
||||
# regex for finding and replacing python string variable
|
||||
# definitions/initializations
|
||||
pattern = re.compile('^[\s#]*' + key + '\s*=\s*"[^"]*"')
|
||||
pattern = re.compile(r'^[\s#]*' + key + r'\s*=\s*"[^"]*"')
|
||||
repl = key + ' = "' + value + '"'
|
||||
pattern2 = re.compile('^[\s#]*' + key + "\s*=\s*'[^']*'")
|
||||
pattern2 = re.compile(r'^[\s#]*' + key + r"\s*=\s*'[^']*'")
|
||||
repl2 = key + " = '" + value + "'"
|
||||
|
||||
# If we replaced this line once, we make sure won't be a
|
||||
|
@ -32,7 +32,7 @@ from . import metadata
|
||||
from .exception import FDroidException
|
||||
|
||||
|
||||
SETTINGS_GRADLE = re.compile('''include\s+['"]:([^'"]*)['"]''')
|
||||
SETTINGS_GRADLE = re.compile(r'''include\s+['"]:([^'"]*)['"]''')
|
||||
|
||||
|
||||
# Get the repo type and address from the given web page. The page is scanned
|
||||
|
@ -39,7 +39,7 @@ def disable_in_config(key, value):
|
||||
'''write a key/value to the local config.py, then comment it out'''
|
||||
with open('config.py', 'r', encoding='utf8') as f:
|
||||
data = f.read()
|
||||
pattern = '\n[\s#]*' + key + '\s*=\s*"[^"]*"'
|
||||
pattern = r'\n[\s#]*' + key + r'\s*=\s*"[^"]*"'
|
||||
repl = '\n#' + key + ' = "' + value + '"'
|
||||
data = re.sub(pattern, repl, data)
|
||||
with open('config.py', 'w', encoding='utf8') as f:
|
||||
@ -106,7 +106,7 @@ def main():
|
||||
except KeyboardInterrupt:
|
||||
print('')
|
||||
sys.exit(1)
|
||||
if re.match('^\s*$', s) is not None:
|
||||
if re.match(r'^\s*$', s) is not None:
|
||||
test_config['sdk_path'] = default_sdk_path
|
||||
else:
|
||||
test_config['sdk_path'] = s
|
||||
|
@ -811,7 +811,7 @@ def get_default_app_info(metadatapath=None):
|
||||
if os.path.exists('AndroidManifest.xml'):
|
||||
manifestroot = fdroidserver.common.parse_xml('AndroidManifest.xml')
|
||||
else:
|
||||
pattern = re.compile(""".*manifest\.srcFile\s+'AndroidManifest\.xml'.*""")
|
||||
pattern = re.compile(r""".*manifest\.srcFile\s+'AndroidManifest\.xml'.*""")
|
||||
for root, dirs, files in os.walk(os.getcwd()):
|
||||
if 'build.gradle' in files:
|
||||
p = os.path.join(root, 'build.gradle')
|
||||
@ -1036,7 +1036,7 @@ def write_yaml(mf, app):
|
||||
raise FDroidException('ruamel.yaml not instlled, can not write metadata.') from e
|
||||
if not ruamel.yaml.__version__:
|
||||
raise FDroidException('ruamel.yaml.__version__ not accessible. Please make sure a ruamel.yaml >= 0.13 is installed..')
|
||||
m = re.match('(?P<major>[0-9]+)\.(?P<minor>[0-9]+)\.(?P<patch>[0-9]+)(-.+)?',
|
||||
m = re.match(r'(?P<major>[0-9]+)\.(?P<minor>[0-9]+)\.(?P<patch>[0-9]+)(-.+)?',
|
||||
ruamel.yaml.__version__)
|
||||
if not m:
|
||||
raise FDroidException('ruamel.yaml version malfored, please install an upstream version of ruamel.yaml')
|
||||
|
@ -85,7 +85,7 @@ def read_fingerprints_from_keystore():
|
||||
raise FDroidException('could not read keysotre {}'.format(config['keystore']))
|
||||
|
||||
realias = re.compile('Alias name: (?P<alias>.+)\n')
|
||||
resha256 = re.compile('\s+SHA256: (?P<sha256>[:0-9A-F]{95})\n')
|
||||
resha256 = re.compile(r'\s+SHA256: (?P<sha256>[:0-9A-F]{95})\n')
|
||||
fps = {}
|
||||
for block in p.output.split(('*' * 43) + '\n' + '*' * 43):
|
||||
s_alias = realias.search(block)
|
||||
|
@ -57,7 +57,7 @@ def extract(options):
|
||||
sys.exit(1)
|
||||
|
||||
# iterate over supplied APKs downlaod and extract them…
|
||||
httpre = re.compile('https?:\/\/')
|
||||
httpre = re.compile(r'https?:\/\/')
|
||||
for apk in options.APK:
|
||||
try:
|
||||
if os.path.isfile(apk):
|
||||
|
@ -135,9 +135,9 @@ def main():
|
||||
logging.info('Processing logs...')
|
||||
appscount = Counter()
|
||||
appsvercount = Counter()
|
||||
logexpr = '(?P<ip>[.:0-9a-fA-F]+) - - \[(?P<time>.*?)\] ' + \
|
||||
'"GET (?P<uri>.*?) HTTP/1.\d" (?P<statuscode>\d+) ' + \
|
||||
'\d+ "(?P<referral>.*?)" "(?P<useragent>.*?)"'
|
||||
logexpr = r'(?P<ip>[.:0-9a-fA-F]+) - - \[(?P<time>.*?)\] ' \
|
||||
+ r'"GET (?P<uri>.*?) HTTP/1.\d" (?P<statuscode>\d+) ' \
|
||||
+ r'\d+ "(?P<referral>.*?)" "(?P<useragent>.*?)"'
|
||||
logsearch = re.compile(logexpr).search
|
||||
for logfile in glob.glob(os.path.join(logsdir, 'access-*.log.gz')):
|
||||
logging.debug('...' + logfile)
|
||||
|
@ -53,7 +53,7 @@ UNSET_VERSION_CODE = -0x100000000
|
||||
APK_NAME_PAT = re.compile(".*name='([a-zA-Z0-9._]*)'.*")
|
||||
APK_VERCODE_PAT = re.compile(".*versionCode='([0-9]*)'.*")
|
||||
APK_VERNAME_PAT = re.compile(".*versionName='([^']*)'.*")
|
||||
APK_LABEL_ICON_PAT = re.compile(".*\s+label='(.*)'\s+icon='(.*?)'")
|
||||
APK_LABEL_ICON_PAT = re.compile(r".*\s+label='(.*)'\s+icon='(.*?)'")
|
||||
APK_SDK_VERSION_PAT = re.compile(".*'([0-9]*)'.*")
|
||||
APK_PERMISSION_PAT = \
|
||||
re.compile(".*(name='(?P<name>.*?)')(.*maxSdkVersion='(?P<maxSdkVersion>.*?)')?.*")
|
||||
@ -1083,7 +1083,7 @@ def _get_apk_icons_src(apkfile, icon_name):
|
||||
|
||||
"""
|
||||
icons_src = dict()
|
||||
density_re = re.compile('^res/(.*)/{}\.(png|xml)$'.format(icon_name))
|
||||
density_re = re.compile(r'^res/(.*)/{}\.(png|xml)$'.format(icon_name))
|
||||
with zipfile.ZipFile(apkfile) as zf:
|
||||
for filename in zf.namelist():
|
||||
m = density_re.match(filename)
|
||||
|
@ -61,13 +61,13 @@ class BuildTest(unittest.TestCase):
|
||||
os.path.join(testdir, 'source-files'))
|
||||
teststring = 'FAKE_VERSION_FOR_TESTING'
|
||||
fdroidserver.build.force_gradle_build_tools(testdir, teststring)
|
||||
pattern = re.compile(bytes("buildToolsVersion[\s=]+'%s'\s+" % teststring, 'utf8'))
|
||||
pattern = re.compile(r"buildToolsVersion[\s=]+'%s'\s+" % teststring)
|
||||
for p in ('source-files/fdroid/fdroidclient/build.gradle',
|
||||
'source-files/Zillode/syncthing-silk/build.gradle',
|
||||
'source-files/open-keychain/open-keychain/build.gradle',
|
||||
'source-files/osmandapp/osmand/build.gradle',
|
||||
'source-files/open-keychain/open-keychain/OpenKeychain/build.gradle'):
|
||||
with open(os.path.join(testdir, p), 'rb') as f:
|
||||
with open(os.path.join(testdir, p), 'r') as f:
|
||||
filedata = f.read()
|
||||
self.assertIsNotNone(pattern.search(filedata))
|
||||
|
||||
|
@ -204,7 +204,7 @@ class CommonTest(unittest.TestCase):
|
||||
|
||||
with open(os.path.join(fdroidclient_testdir, 'build.gradle'), 'r') as f:
|
||||
filedata = f.read()
|
||||
self.assertIsNotNone(re.search("\s+compileSdkVersion %s\s+" % testint, filedata))
|
||||
self.assertIsNotNone(re.search(r"\s+compileSdkVersion %s\s+" % testint, filedata))
|
||||
|
||||
with open(os.path.join(fdroidclient_testdir, 'AndroidManifest.xml')) as f:
|
||||
filedata = f.read()
|
||||
|
@ -53,9 +53,9 @@ class IndexTest(unittest.TestCase):
|
||||
_, fingerprint = fdroidserver.index.get_public_key_from_jar(jar)
|
||||
# comparing fingerprints should be sufficient
|
||||
if f == 'testy.jar':
|
||||
self.assertTrue(fingerprint ==
|
||||
'818E469465F96B704E27BE2FEE4C63AB' +
|
||||
'9F83DDF30E7A34C7371A4728D83B0BC1')
|
||||
self.assertEqual(fingerprint,
|
||||
'818E469465F96B704E27BE2FEE4C63AB'
|
||||
+ '9F83DDF30E7A34C7371A4728D83B0BC1')
|
||||
if f == 'guardianproject.jar':
|
||||
self.assertTrue(fingerprint == GP_FINGERPRINT)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user