import sys


def downgrade_to_2011(src_path, dst_path):
    
    if not src_path.endswith('.ma') or not dst_path.endswith('.ma'):
        raise ValueError('can only operate on MayaAscii files')
        
    # Track if the last command was to create an image plane.
    command_block = ()
            
    fh = open(dst_path, 'w')
    for raw_line in open(src_path):
        
        # Skip comments.
        if raw_line.startswith('//'):
            fh.write(raw_line)
            continue
        
        # This will always have one item, but it may be an empty string.
        raw_line = raw_line.rstrip()
        line = raw_line.lstrip('\t')
        indent = len(raw_line) - len(line)
        is_end_of_command = line[-1] == ';'
        line_parts = line.strip().rstrip(';').strip().split() or ['']
        
        # Track what command block we are in.
        is_command_block = raw_line.strip() and not raw_line[0].isspace()
        if is_command_block:
            command_block = tuple(line_parts)
                
        # Strip all requires, but add a 2011 requires.
        if is_command_block and line_parts[0] == 'requires':
            if line_parts[1] == 'maya':
                line_parts[2] = '"2011"'
            else:
                continue
                
        # Strip '-p' off of image planes.
        if command_block[:2] == ('createNode', 'imagePlane'):
            if is_command_block:
                # Can't have '-p' flag.
                try:
                    p_index = line_parts.index('-p')
                    line_parts = line_parts[:p_index] + line_parts[p_index + 2:]
                except ValueError:
                    pass
            else:
                # A couple attributes no longer exist.
                if (line_parts[0] == 'setAttr' and (
                    line_parts[1] == '".ic"' or
                    line_parts[-1] == '".v"'
                )):
                    continue
        
        # Write the transformed line back out.
        fh.write('%s%s%s\n' % (
            '\t' * indent,
            ' '.join(line_parts),
            ';' if is_end_of_command else ''
        ))


def main():
    downgrade_to_2011(*sys.argv[1:])
    
@@ -1000,32 +1000,294 @@
 _parts)%0A        
+%0A        # Strip out some flags.%0A        if line_parts%5B0%5D == 'setAttr':%0A            try:%0A                index = line_parts.index('-ch')%0A                line_parts = line_parts%5B:index%5D + line_parts%5Bindex + 2:%5D%0A            except ValueError:%0A                pass%0A
         %0A       
@@ -1754,18 +1754,16 @@
         
-p_
 index = 
@@ -1830,18 +1830,16 @@
 _parts%5B:
-p_
 index%5D +
@@ -1854,10 +1854,8 @@
 rts%5B
-p_
 inde
@@ -2191,32 +2191,234 @@
 ntinue%0A        %0A
+        # Not entirely sure what this attribute does...%0A        if command_block%5B:2%5D == ('createNode', 'mesh'):%0A            if line_parts%5B:2%5D == %5B'setAttr', '%22.vnm%22'%5D:%0A                continue%0A        %0A
         # Write 
@@ -2648,12 +2648,48 @@
 gv%5B1:%5D)%0A
-    
+%0Aif __name__ == '__main__':%0A    main()%0A%0A

Expand the downgrader