Commit f8eede33 authored by Robin Schoonover's avatar Robin Schoonover

Add cli flag to disable failing on missing localization

parent 81b6e335
Pipeline #1454 failed with stages
in 2 minutes and 23 seconds
......@@ -308,13 +308,17 @@ class Package(object):
help="Build directory")
@click.option('--dist-dir', '-d', type=click.Path(file_okay=False, dir_okay=True),
help="Destination directory")
@click.option('--allow-missing-localization/--forbid-missing-localization', default=False,
help="Allow build even if configuration is unavailable to perform localization")
@click.option('--curse-api-token', envvar='CURSE_API_TOKEN')
@click.option('--curse-localization-url', envvar='CURSE_LOCALIZATION_URL', default='https://wow.curseforge.com/api/projects/{project_id}/localization/export')
@click.option('--curse-project-id', envvar='CURSE_PROJECT_ID', help='The project id (used for localization)')
@click.option('--vcs-tag', help='VCS tag we are building against. Verified against version. If blank or mismatch, mark as alpha')
@click.option('--version')
@click.argument('source', type=click.Path(exists=True), default=".")
def build_cli(source, build_dir, dist_dir, curse_api_token, curse_project_id, curse_localization_url, vcs_tag, version):
def build_cli(source, build_dir, dist_dir, allow_missing_localization,
curse_api_token, curse_project_id, curse_localization_url, vcs_tag, version):
pkg = Package(source, vcs_tag=vcs_tag, version=version)
if dist_dir is None:
......@@ -324,6 +328,7 @@ def build_cli(source, build_dir, dist_dir, curse_api_token, curse_project_id, cu
sys.exit(1)
localizer = AutoLocalizer(
allow_missing_localization = allow_missing_localization,
curse_api_token=curse_api_token,
curse_project_id=curse_project_id,
curse_localization_url=curse_localization_url
......
......@@ -91,7 +91,8 @@ class CurseLocalizer(object):
return self.api_token and self.project_id and self.localization_url
class AutoLocalizer(object):
def __init__(self, curse_api_token=None, curse_project_id=None, curse_localization_url=None):
def __init__(self, allow_missing_localization=False, curse_api_token=None, curse_project_id=None, curse_localization_url=None):
self.allow_missing_localization = allow_missing_localization
self._curse = CurseLocalizer(
curse_api_token=curse_api_token,
curse_project_id=curse_project_id,
......@@ -104,4 +105,6 @@ class AutoLocalizer(object):
def __call__(self, kwargs):
if self._curse.valid():
return self._curse(kwargs)
if self.allow_missing_localization:
return None
raise LocalizationError("No localizers available (only curse supported currently, please set environment variables)")
......@@ -232,11 +232,12 @@ class BaseProcessor(object):
if self.localizer is not None:
try:
return self.localizer(kwargs)
result = self.localizer(kwargs)
return result if result is not None else outer
except LocalizationError as exc:
raise PreProcessorError(str(exc))
else:
raise PreProcessorError('No localizer available!')
raise PreProcessorError('No localizer set!')
class LuaPreProcessor(BaseProcessor):
def __init__(self, alpha=True, lib_strip=False, **kwargs):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment