Ejemplo n.º 1
0
            print(GwtSUtils.ir_fancy_format(GwtSUtils.encode_ir(encoded)))  # Displays IR on/off timings
        except ValueError:
            print("Bad input")


# Show Sequencer
if len(sys.argv) > 1:
    input_commands = list()
    command_dict = dict()
    # Open, format, and put file contents into input_commands
    with open(sys.argv[1], 'r') as input_file:
        for line in input_file:
            input_commands.append(line.replace(':', '').split())
    # Process input_commands and add to dictionary to resolve timing conflicts.
    for line in input_commands:
        times = (GwtSUtils.generate_delays(line))
        for key, content in times.items():
            if key in command_dict.keys():
                command_dict[key].extend(content)  # Commands with same timing played right after each other
#               command_dict[key] = content  # Newer commands overwrite older commands.
            else:
                command_dict[key] = content
    # Write to file
    try:
        output = open(sys.argv[2], 'w')
    except IndexError:  # Use default filename if no output filename supplied
        output = open("output.txt", 'w')
    for key, content in sorted(command_dict.items()):
        output.write(key + ": " + " ".join(content) + "\n")
    output.close()
    sys.exit()