mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 01:02:08 +01:00
minor code review of Python scripts
This commit is contained in:
parent
94afd504ee
commit
c84308da6f
2 changed files with 22 additions and 8 deletions
5
dist/firefox/publish-signed-beta.py
vendored
5
dist/firefox/publish-signed-beta.py
vendored
|
@ -36,6 +36,11 @@ from string import Template
|
|||
projdir = os.path.split(os.path.abspath(__file__))[0]
|
||||
while not os.path.isdir(os.path.join(projdir, '.git')):
|
||||
projdir = os.path.normpath(os.path.join(projdir, '..'))
|
||||
# Check that found project root is valid
|
||||
version_filepath = os.path.join(projdir, 'dist', 'version')
|
||||
if not os.path.isfile(version_filepath):
|
||||
print('Version file not found.')
|
||||
exit(1)
|
||||
|
||||
extension_id = 'uBlock0@raymondhill.net'
|
||||
tmpdir = tempfile.TemporaryDirectory()
|
||||
|
|
|
@ -20,6 +20,17 @@ def mkdirs(path):
|
|||
|
||||
pj = os.path.join
|
||||
|
||||
# Find path to project root
|
||||
proj_dir = os.path.split(os.path.abspath(__file__))[0]
|
||||
while not os.path.isdir(os.path.join(proj_dir, '.git')):
|
||||
proj_dir = os.path.normpath(os.path.join(proj_dir, '..'))
|
||||
|
||||
# Check that found project root is valid
|
||||
version_filepath = os.path.join(proj_dir, 'dist', 'version')
|
||||
if not os.path.isfile(version_filepath):
|
||||
print('Version file not found.')
|
||||
exit(1)
|
||||
|
||||
build_dir = os.path.abspath(sys.argv[1])
|
||||
source_locale_dir = pj(build_dir, '_locales')
|
||||
target_locale_dir = pj(build_dir, 'locale')
|
||||
|
@ -60,19 +71,18 @@ with open(chrome_manifest, 'at', encoding='utf-8', newline='\n') as f:
|
|||
rmtree(source_locale_dir)
|
||||
|
||||
# update install.rdf
|
||||
proj_dir = pj(os.path.split(os.path.abspath(__file__))[0], '..')
|
||||
|
||||
version = ''
|
||||
with open(os.path.join(proj_dir, 'dist', 'version')) as f:
|
||||
version = f.read().strip()
|
||||
|
||||
chromium_manifest = pj(proj_dir, 'platform', 'chromium', 'manifest.json')
|
||||
with open(chromium_manifest, encoding='utf-8') as m:
|
||||
manifest = json.load(m)
|
||||
|
||||
# Fetch extension version
|
||||
# https://developer.mozilla.org/en-US/Add-ons/AMO/Policy/Maintenance#How_do_I_submit_a_Beta_add-on.3F
|
||||
# "To create a beta channel [...] '(a|alpha|b|beta|pre|rc)\d*$' "
|
||||
|
||||
version = ''
|
||||
with open(version_filepath) as f:
|
||||
version = f.read().strip()
|
||||
match = re.search('^(\d+\.\d+\.\d+)(\.\d+)$', version)
|
||||
if match:
|
||||
buildtype = int(match.group(2)[1:])
|
||||
|
@ -80,9 +90,8 @@ if match:
|
|||
builttype = 'b' + str(buildtype)
|
||||
else:
|
||||
builttype = 'rc' + str(buildtype - 100)
|
||||
manifest['version'] = match.group(1) + builttype
|
||||
else:
|
||||
manifest['version'] = version
|
||||
version = match.group(1) + builttype
|
||||
manifest['version'] = version
|
||||
|
||||
manifest['homepage'] = 'https://github.com/gorhill/uBlock'
|
||||
manifest['description'] = descriptions['en']
|
||||
|
|
Loading…
Reference in a new issue