XmlConfig : Read/Write FLDIGI XML Config File¶
-
class
pyfldigi.xmlconfig.
XmlConfig
(config_dir, read_now=True)[source]¶ Bases:
object
Placeholder for fldigi.prefs config read/write
param config_dir: The directory in which fldigi reads and writes its config files. e.g. ‘C:/Users/njansen/fldigi.files/’ type config_dir: str param read_now: If True, read() is called immediately at the end of the constructor. Otherwise, a read is not done until explicitly called. type read_now: bool Example: >>> import pyfldigi >>> xc = pyfldigi.XmlConfig(config_dir)
-
__getitem__
(key)[source]¶ Get a setting from the XML config, by its XML tag name
Example: >>> import pyfldigi >>> xc = pyfldigi.XmlConfig(config_dir) >>> xc['XMLRIGDEVICE'] 'COM1'
-
__setitem__
(key, value)[source]¶ Update a setting value.
param key: The XML tag name type key: str param value: description type value: str, bool, int, or float. Note
Settings aren’t written until save() is called!
Note
Strings will be escaped because this is an XML file. ‘<’, ‘>’, etc. will be replaced as required.
Todo
boolean values will be encoded as ‘1’ or ‘0’
Example: >>> import pyfldigi >>> xc = pyfldigi.XmlConfig(config_dir) >>> xc['XMLRIGDEVICE'] 'COM1' >>> xc['XMLRIGDEVICE'] = 'COM5' >>> xc['XMLRIGDEVICE'] 'COM5' >>> xc.save() # Settings aren't written until save() is called!
-
__str__
()[source]¶ Prints out all of the settings in a manner of: ‘{name} : {value} ‘
Example: >>> import pyfldigi >>> xc = pyfldigi.XmlConfig(config_dir) >>> str(xc) SETTING1 : 0 SETTING2 : 1 # and so on
-
read
()[source]¶ Open and parse the config XML file. :Example:
>>> import pyfldigi >>> xc = pyfldigi.XmlConfig(config_dir, read_now=False) >>> # do some other stuff >>> xc.read() >>> xc['baz'] # Read some random setting named 'baz' 42
-
save
()[source]¶ Save the config. Will only write to the file if changes have been made (self.dirty is True)
Example: >>> import pyfldigi >>> xc = pyfldigi.XmlConfig(config_dir) >>> xc['baz'] = 42 >>> xc.save()
-
set_serial_port
(comport)[source]¶ Sets the serial port device in the config.
param comport: The com port, e.g. ‘COM1’ or ‘/dev/ttys1’ type comport: str Note
There are two COM ports in the config (XMLRIGDEVICE and HAMRIGDEVICE). One for XML-RPC (flrig) and one for HamRig. Set both because they’re mutually exclusive.
-
set_sound_card
()[source]¶ PORTINDEVICE is None if not defined. Or a str (e.g. ‘Microphone (USB Audio Codec)’ if defined) PORTININDEX is -1 if not defined. Or the current index of the sound card (9) PORTOUTDEVICE is None if not defined. Or a str (e.g. ‘Speakers (High Definition Audio to Speakers (USB Audio Codec)’) AUDIOIO ?? changed from 3 to 1 PORTOUTINDEX -1 or a valid index.
-