mirror of
https://github.com/sudoxnym/fdroiddata.git
synced 2026-05-17 11:19:13 +00:00
Format Python tools with Black
This commit is contained in:
parent
ea5bf01a8f
commit
141d71ba44
7 changed files with 53 additions and 23 deletions
|
|
@ -6,7 +6,9 @@ import sys
|
|||
|
||||
# find all repositories that use plain HTTP urls (e.g. not HTTPS)
|
||||
url_pattern = re.compile(
|
||||
r'repositories\s*{[^}]*http://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|%[0-9a-fA-F][0-9a-fA-F])+[^}]*}', re.DOTALL)
|
||||
r'repositories\s*{[^}]*http://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|%[0-9a-fA-F][0-9a-fA-F])+[^}]*}',
|
||||
re.DOTALL,
|
||||
)
|
||||
|
||||
exit_value = 0
|
||||
for appid in sys.argv:
|
||||
|
|
@ -20,11 +22,15 @@ for appid in sys.argv:
|
|||
with open(path) as fp:
|
||||
data = fp.read()
|
||||
for url in url_pattern.findall(data):
|
||||
print('Found plain HTTP URL for gradle repository:\n%s\n%s'
|
||||
% (path, url))
|
||||
print(
|
||||
'Found plain HTTP URL for gradle repository:\n%s\n%s'
|
||||
% (path, url)
|
||||
)
|
||||
exit_value += 1
|
||||
|
||||
if exit_value:
|
||||
print('gradle build uses plain HTTP URLs for repositories! This is insecure!')
|
||||
print('https://max.computer/blog/how-to-take-over-the-computer-of-any-java-or-clojure-or-scala-developer/')
|
||||
print(
|
||||
'https://max.computer/blog/how-to-take-over-the-computer-of-any-java-or-clojure-or-scala-developer/'
|
||||
)
|
||||
sys.exit(exit_value)
|
||||
|
|
|
|||
|
|
@ -48,13 +48,18 @@ for f in files:
|
|||
|
||||
# from class vcs_git() in fdroidserver/common.py
|
||||
git_config = [
|
||||
'-c', 'core.askpass=/bin/true',
|
||||
'-c', 'core.sshCommand=/bin/false',
|
||||
'-c', 'url.https://.insteadOf=ssh://',
|
||||
'-c',
|
||||
'core.askpass=/bin/true',
|
||||
'-c',
|
||||
'core.sshCommand=/bin/false',
|
||||
'-c',
|
||||
'url.https://.insteadOf=ssh://',
|
||||
]
|
||||
for domain in ('bitbucket.org', 'github.com', 'gitlab.com'):
|
||||
git_config.append('-c')
|
||||
git_config.append('url.https://u:p@' + domain + '/.insteadOf=git@' + domain + ':')
|
||||
git_config.append(
|
||||
'url.https://u:p@' + domain + '/.insteadOf=git@' + domain + ':'
|
||||
)
|
||||
git_config.append('-c')
|
||||
git_config.append('url.https://u:p@' + domain + '.insteadOf=git://' + domain)
|
||||
git_config.append('-c')
|
||||
|
|
@ -66,10 +71,16 @@ for f in files:
|
|||
'GIT_SSH': '/bin/false', # for git < 2.3
|
||||
}
|
||||
|
||||
p = subprocess.run(['git', ] + git_config + ['ls-remote', '--exit-code', '-h', url],
|
||||
env=env,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.PIPE)
|
||||
p = subprocess.run(
|
||||
[
|
||||
'git',
|
||||
]
|
||||
+ git_config
|
||||
+ ['ls-remote', '--exit-code', '-h', url],
|
||||
env=env,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
if p.returncode != 0:
|
||||
with open(f) as fp:
|
||||
raw = fp.read()
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ def generate_keyalias(s):
|
|||
|
||||
|
||||
base = os.path.realpath(
|
||||
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
|
||||
metadata_files = sorted(glob.glob(base + '/metadata/*.txt')
|
||||
+ glob.glob(base + '/metadata/*.yml'))
|
||||
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..')
|
||||
)
|
||||
metadata_files = sorted(
|
||||
glob.glob(base + '/metadata/*.txt') + glob.glob(base + '/metadata/*.yml')
|
||||
)
|
||||
|
||||
if not metadata_files:
|
||||
print('No metadata files found!')
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ for appid in sorted(changed):
|
|||
metadata_file = 'metadata/%s.yml' % appid
|
||||
diff = subprocess.check_output(
|
||||
(
|
||||
'git diff --no-color --diff-filter=d FETCH_HEAD...HEAD -- ' + metadata_file
|
||||
'git diff --no-color --diff-filter=d FETCH_HEAD...HEAD -- ' + metadata_file
|
||||
).split(' ')
|
||||
)
|
||||
|
||||
|
|
@ -71,7 +71,8 @@ for appid in sorted(changed):
|
|||
signatures_dir = 'metadata/%s/signatures/' % appid
|
||||
diff = subprocess.check_output(
|
||||
(
|
||||
'git diff --name-only --no-color --diff-filter=d FETCH_HEAD...HEAD -- ' + signatures_dir
|
||||
'git diff --name-only --no-color --diff-filter=d FETCH_HEAD...HEAD -- '
|
||||
+ signatures_dir
|
||||
).split(' ')
|
||||
)
|
||||
for f in diff.split():
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@ for f in glob.glob('metadata/*.yml'):
|
|||
raw = fp.read()
|
||||
data = yaml.load(raw)
|
||||
archive_policy = data.get('ArchivePolicy')
|
||||
if 'Disabled' not in data and 'Summary' in data \
|
||||
and (archive_policy is None or not archive_policy.startswith('0 ')):
|
||||
if (
|
||||
'Disabled' not in data
|
||||
and 'Summary' in data
|
||||
and (archive_policy is None or not archive_policy.startswith('0 '))
|
||||
):
|
||||
en_US_dir = f[:-4] + '/en-US/'
|
||||
os.makedirs(en_US_dir, exist_ok=True)
|
||||
with open(en_US_dir + '/summary.txt', 'w') as fp:
|
||||
|
|
@ -22,8 +25,9 @@ for f in glob.glob('metadata/*.yml'):
|
|||
with open(f, 'w') as out:
|
||||
out.write(re.sub(r'Summary:[^\n]+\n', r'', raw))
|
||||
packageName = f[9:-4]
|
||||
scraped_glob = os.path.join('/path/to/scraper/metadata/',
|
||||
packageName, '[a-z]*', 'short_description.txt')
|
||||
scraped_glob = os.path.join(
|
||||
'/path/to/scraper/metadata/', packageName, '[a-z]*', 'short_description.txt'
|
||||
)
|
||||
for df in glob.glob(scraped_glob):
|
||||
locale = os.path.basename(os.path.dirname(df))
|
||||
with open(df) as fp:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,11 @@ for f in files:
|
|||
repo_url = None
|
||||
if 'Repo' in data:
|
||||
repo_url = data['Repo'].strip().rstrip('/')
|
||||
if repo_url and not repo_url.endswith('.git') and repo_url.startswith('https://gitlab'):
|
||||
if (
|
||||
repo_url
|
||||
and not repo_url.endswith('.git')
|
||||
and repo_url.startswith('https://gitlab')
|
||||
):
|
||||
new_url = repo_url + '.git'
|
||||
print("Repo:", data['Repo'], "\n --> " + new_url + "'")
|
||||
with open(f) as fp:
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ for mr in project.mergerequests.list(state='opened', order_by='updated_at'):
|
|||
if m:
|
||||
commit_ids.append(m.group(1))
|
||||
if not commit_ids and found_issuebot_post:
|
||||
print(mr.iid, 'issuebot has posted without trigger commit ID, not running again')
|
||||
print(
|
||||
mr.iid, 'issuebot has posted without trigger commit ID, not running again'
|
||||
)
|
||||
elif mr.sha in commit_ids:
|
||||
print(mr.iid, 'issuebot has run on %s, not running again' % mr.sha)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue