mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 11:58:55 +00:00
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:
parent
ecfbd80102
commit
ccb7771759
@ -93,7 +93,7 @@ def main():
|
|||||||
print('======== Fluent ========')
|
print('======== Fluent ========')
|
||||||
print(ftl.encode("utf-8"))
|
print(ftl.encode("utf-8"))
|
||||||
if not dry_run:
|
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__':
|
if __name__ == '__main__':
|
||||||
|
@ -2,7 +2,9 @@ from __future__ import absolute_import
|
|||||||
|
|
||||||
|
|
||||||
def to_chrome_path(path):
|
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
|
return path
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ def make_header():
|
|||||||
|
|
||||||
def build_migration(messages, dtds, data):
|
def build_migration(messages, dtds, data):
|
||||||
res = make_header()
|
res = make_header()
|
||||||
desc = 'Bug {0} - {1}, part {{index}}'.format(
|
desc = 'Bug {0} - {1}, part {{index}}.'.format(
|
||||||
data['bug_id'], data['description'])
|
data['bug_id'], data['description'])
|
||||||
res += '\n\ndef migrate(ctx):\n """{0}"""\n\n'.format(desc)
|
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()
|
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:
|
if base_path is not None:
|
||||||
path = os.path.join(base_path, path)
|
path = os.path.join(base_path, path)
|
||||||
path = path.replace('\\', '/')
|
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)
|
text_file.write(text)
|
||||||
|
@ -45,6 +45,17 @@ vector = 0
|
|||||||
is_l10n = False
|
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):
|
def tagrepl(m):
|
||||||
global vector
|
global vector
|
||||||
global is_l10n
|
global is_l10n
|
||||||
@ -77,9 +88,11 @@ def tagrepl(m):
|
|||||||
"value": l10n_val,
|
"value": l10n_val,
|
||||||
"attrs": l10n_attrs
|
"attrs": l10n_attrs
|
||||||
}
|
}
|
||||||
|
indent = get_indent(tag[0:len(m.group(1)) + 1 - vector])
|
||||||
tag = \
|
tag = \
|
||||||
tag[0:len(m.group(1)) + 1 - vector] + \
|
tag[0:len(m.group(1)) + 1 - vector] + \
|
||||||
' data-l10n-id="' + \
|
indent + \
|
||||||
|
'data-l10n-id="' + \
|
||||||
l10n_id + \
|
l10n_id + \
|
||||||
'"' + \
|
'"' + \
|
||||||
m.group(2) + \
|
m.group(2) + \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user