зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1581185 - Fix relative paths in migration script generation. r=bgrins
Differential Revision: https://phabricator.services.mozilla.com/D45880 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6482d542e8
Коммит
24d44bff69
|
@ -93,7 +93,7 @@ def main():
|
|||
print('======== Fluent ========')
|
||||
print(ftl.encode("utf-8"))
|
||||
if not dry_run:
|
||||
write_file(data['ftl'], ftl.encode("utf-8"), data['mozilla-central'])
|
||||
write_file(data['ftl'], ftl.encode("utf-8"), data['mozilla-central'], append=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -2,7 +2,9 @@ from __future__ import absolute_import
|
|||
|
||||
|
||||
def to_chrome_path(path):
|
||||
return path.replace('/locales/en-US', '')
|
||||
path = path.replace('/locales/en-US', '')
|
||||
if path.startswith("./"):
|
||||
path = path[2:]
|
||||
return path
|
||||
|
||||
|
||||
|
@ -39,7 +41,7 @@ def make_header():
|
|||
|
||||
def build_migration(messages, dtds, data):
|
||||
res = make_header()
|
||||
desc = 'Bug {0} - {1}, part {{index}}'.format(
|
||||
desc = 'Bug {0} - {1}, part {{index}}.'.format(
|
||||
data['bug_id'], data['description'])
|
||||
res += '\n\ndef migrate(ctx):\n """{0}"""\n\n'.format(desc)
|
||||
|
||||
|
|
|
@ -10,9 +10,10 @@ def read_file(path, base_path=None):
|
|||
return fptr.read()
|
||||
|
||||
|
||||
def write_file(path, text, base_path=None):
|
||||
def write_file(path, text, base_path=None, append=False):
|
||||
if base_path is not None:
|
||||
path = os.path.join(base_path, path)
|
||||
path = path.replace('\\', '/')
|
||||
with open(path, "w") as text_file:
|
||||
mode = "a" if append and os.path.exists(path) else "w"
|
||||
with open(path, mode) as text_file:
|
||||
text_file.write(text)
|
||||
|
|
|
@ -44,6 +44,15 @@ def construct_l10n_id(val, attrs):
|
|||
vector = 0
|
||||
is_l10n = False
|
||||
|
||||
def get_indent(pre_tag):
|
||||
if "\n" not in pre_tag:
|
||||
return " "
|
||||
last_bl = pre_tag.rindex("\n")
|
||||
indent = 0
|
||||
for ch in pre_tag[last_bl:]:
|
||||
if ch == " ":
|
||||
indent += 1
|
||||
return "\n" + " " * indent
|
||||
|
||||
def tagrepl(m):
|
||||
global vector
|
||||
|
@ -77,9 +86,11 @@ def tagrepl(m):
|
|||
"value": l10n_val,
|
||||
"attrs": l10n_attrs
|
||||
}
|
||||
indent = get_indent(tag[0:len(m.group(1)) + 1 - vector])
|
||||
tag = \
|
||||
tag[0:len(m.group(1)) + 1 - vector] + \
|
||||
' data-l10n-id="' + \
|
||||
indent + \
|
||||
'data-l10n-id="' + \
|
||||
l10n_id + \
|
||||
'"' + \
|
||||
m.group(2) + \
|
||||
|
|
Загрузка…
Ссылка в новой задаче