I have my wallet file and it is encrypted with a password.
How to decrypt wallet file using code? Encryption seems similar to Fernet.
The electrum FAQ answers "How is the wallet encrypted?" as follows:
Electrum uses two separate levels of encryption:
Your seed and private keys are encrypted using AES-256-CBC. The private keys are decrypted only briefly, when you need to sign a transaction; for this you need to enter your password. This is done in order to minimize the amount of time during which sensitive information is unencrypted in your computer’s memory.
In addition, your wallet file may be encrypted on disk. Note that the wallet information will remain unencrypted in the memory of your computer for the duration of your session. If a wallet is encrypted, then its password will be required in order to open it. Note that the password will not be kept in memory; Electrum does not need it in order to save the wallet on disk, because it uses asymmetric encryption (ECIES).
Wallet file encryption is activated by default since version 2.8. It is intended to protect your privacy, but also to prevent you from requesting bitcoins on a wallet that you do not control.
The above doesn't seem to me to be sufficient to decrypt the information but I expect inspecting some Electrum source code would provide the missing dertails.
Searching for decrypt electrum wallet file locates tools ind information that might be of some help.