Last active
December 10, 2015 11:12
-
-
Save y-ogi/f1219db219f1b8666aee to your computer and use it in GitHub Desktop.
Insert accessibility to storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import optparse | |
import xml.etree.ElementTree as ET | |
targets = ['button', 'label', 'textField'] | |
def main(storyboard): | |
tree = ET.parse(storyboard) | |
for target in targets: | |
for element in tree.getroot().iter(target): | |
elid = element.get('id') | |
accs = ET.SubElement(element, 'accessibility') | |
accs.set('key', 'accessibilityConfiguration') | |
accs.set('identifier', elid) | |
tree.write('new_%s' % storyboard) | |
if __name__ == '__main__': | |
usage = "Usage: %prog storyboard" | |
parser = optparse.OptionParser(usage) | |
(options, args) = parser.parse_args() | |
if not args: | |
parser.error("required storyboard") | |
parser.print_help() | |
exit(1) | |
main(args[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment