| import json |
| import os |
| from re import sub |
|
|
| entityNameReplacements = [ |
| ['adam_s', 'adams'], |
| ['zoey_s', 'zoeys'], |
| ['adams_phone', 'myphone'], |
| ['zoeys_phone', 'herphone'], |
| ['adams\'phone', 'myphone'], |
| ['zoeys\'phone', 'herphone'], |
| ['adamsphone', 'myphone'], |
| ['zoeysphone', 'herphone'], |
| ['prologue', 'episode0'], |
| ['flashback', 'fb'], |
| ['cutscenesandsequences', 'special'], |
| ['sequences', 'events'], |
| ['dad', 'zoeysdad'], |
| ['mom', 'zoeysmom'], |
| ['png', ''], |
| ['jpg', ''], |
| ['jpeg', ''], |
| ] |
|
|
| skipMarkers = [ |
| '(Not to be translated)', |
| 'Media', |
| 'Voiceovers and Subtitles', |
| 'Store' |
| ] |
|
|
| def toSimpleCase(s, joiner=''): |
| return joiner.join( |
| sub('([A-Z][a-z]+)', r' \1', |
| sub('([A-Z]+)', r' \1', |
| s.replace('-', ' ').replace('\'', '').replace('.', ''))).split()).lower() |
|
|
| def toSnakeCase(s): |
| return toSimpleCase(s, '_') |
|
|
| def toSafeEntityName(s): |
| s = toSimpleCase(s) |
| for replacement in entityNameReplacements: |
| s = s.replace(replacement[0], replacement[1]) |
| return s |
|
|
| def are_keys_sequential(d): |
| keys = list(d.keys()) |
| cursor = None |
| for index, key in enumerate(keys): |
| if index == 0: |
| if key != "0" and key != "1": |
| return False |
| if not key.isnumeric(): |
| return False |
| if index > 0: |
| if int(key) - cursor != 1: |
| return False |
| cursor = int(key) |
| return True |
|
|
| def getMarkedFields(filePath, markers): |
| fileCheck = [m for m in markers if m["identifier"] in filePath] |
| file = None if len(fileCheck) == 0 else fileCheck[0] |
| return None if file is None else file["fields"] |
|
|
| def is_skippable(name): |
| return any(marker in name for marker in skipMarkers) |
|
|