<jupyter_start><jupyter_text>Keys<jupyter_code>import re
with open("../Doc /DS1000DE_ProgrammingGuide_EN.txt", "r") as file:
    DS1000DE_ProgrammingGuide_EN = file.read()
command_re = re.compile("(:KEY:[\w]+)")
for result in command_re.findall(DS1000DE_ProgrammingGuide_EN):
    if result.startswith(":KEY"):
        print(result)
class CommandsFactory:
    def __init__(self, *args, **kwargs):
        if len(args)>0:
            raise Exception("No.")
            
        for key, value in kwargs.items():
            setattr(self, key, value)
    
    def __str__(self):
        return f"{self.__class__.__name__.upper()}"
Subsystem=type("Subsystem", (CommandsFactory, ), {})
Key=type("Key", (Subsystem, ), {})
key = Key(device=device)t
f"{key}"
command_re = re.compile("(:KEY:[\w]+)")
for result in command_re.findall(DS1000DE_ProgrammingGuide_EN):
    if result.startswith(":KEY"):
        print(result)
        break
def key_factory(key_str:str, wait: int=0):
    def press_key(self):
        command_string = f":{self}:{key_str}"
        print(command_string)
        self.device.write(f":{self}:{key_str}")
    return press_key
                          
                          
def key_factory2(key_str:str, wait: int=0):
    key_str = key_str.strip().strip(":").split(":")[-1].upper()
    key_function = key_factory(key_str, wait)                   
    return key_str.lower(), key_function
result
key_factory(result)
key_factory(result)(key)
key_factory2(result)
key_str, key_function = key_factory2(result)
key_str
key_function(key)
setattr(Key, key_str, key_function)
command_re = re.compile("(:KEY:[\w]+)")
subsystem_commands=dict()
for result in command_re.findall(DS1000DE_ProgrammingGuide_EN):
    if result.startswith(":KEY"):
        key_str, key_function = key_factory2(result)
        subsystem_commands[key_str] = key_function
Key=type("Key", (Subsystem, ), subsystem_commands)
key=Key(device=device)
key.auto
key.auto()
key.auto()
key.device.reset()
key.channel1()
key.measure()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15029469548133595, 'fraction_numerical': 0.01424361493123772, 'mean_word_length': 3.8615751789976134, 'pattern_counts': {'":': 7, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '127778', 'license': 'MIT', 'n_tokens_mistral': 715, 'n_tokens_neox': 698, 'n_words': 118, 'path': 'DevelopmentNotebooks/rigol_keys_subsystem.ipynb', 'repo_name': 'dapperfu/python_Rigol', 'size': '2036'}