31 lines
609 B
Python
31 lines
609 B
Python
#! /bin/env python3
|
|
# encoding: utf-8
|
|
|
|
class Command:
|
|
def __init__(self, sequence):
|
|
self.__dict__["sequence"] = list(sequence)
|
|
|
|
def __setattr__(self, name, value):
|
|
found = False
|
|
|
|
for i, word in enumerate(self.sequence):
|
|
if word == name:
|
|
self.sequence[i] = value
|
|
found = True
|
|
|
|
if not found:
|
|
raise AttributeError("Command has no attribute \'%s\'" %(name))
|
|
|
|
def dump(self, sequence=None):
|
|
out = []
|
|
|
|
if not sequence:
|
|
sequence = self.sequence
|
|
|
|
for item in sequence:
|
|
if type(item) is list:
|
|
out += self.dump(item)
|
|
else:
|
|
out.append(str(item))
|
|
|
|
return out
|