src/eric7/WebBrowser/Passwords/PasswordWriter.py

branch
eric7
changeset 10436
f6881d10e995
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10435:c712d09cc839 10436:f6881d10e995
25 25
26 def write(self, fileNameOrDevice, logins, forms, nevers): 26 def write(self, fileNameOrDevice, logins, forms, nevers):
27 """ 27 """
28 Public method to write an login data file. 28 Public method to write an login data file.
29 29
30 @param fileNameOrDevice name of the file to write (string) 30 @param fileNameOrDevice name of the file to write or device to write to
31 or device to write to (QIODevice) 31 @type str or QIODevice
32 @param logins dictionary with login data (user name, password) 32 @param logins dictionary with login data (user name, password)
33 @param forms list of forms data (list of LoginForm) 33 @type dict
34 @param nevers list of URLs to never store data for (list of strings) 34 @param forms list of forms data
35 @return flag indicating success (boolean) 35 @type list of LoginForm
36 @param nevers list of URLs to never store data for
37 @type list of str
38 @return flag indicating success
39 @rtype bool
36 """ 40 """
37 if isinstance(fileNameOrDevice, QIODevice): 41 if isinstance(fileNameOrDevice, QIODevice):
38 f = fileNameOrDevice 42 f = fileNameOrDevice
39 else: 43 else:
40 f = QFile(fileNameOrDevice) 44 f = QFile(fileNameOrDevice)
47 def __write(self, logins, forms, nevers): 51 def __write(self, logins, forms, nevers):
48 """ 52 """
49 Private method to write an login data file. 53 Private method to write an login data file.
50 54
51 @param logins dictionary with login data (user name, password) 55 @param logins dictionary with login data (user name, password)
52 @param forms list of forms data (list of LoginForm) 56 @type dict
53 @param nevers list of URLs to never store data for (list of strings) 57 @param forms list of forms data
54 @return flag indicating success (boolean) 58 @type list of LoginForm
59 @param nevers list of URLs to never store data for
60 @type list of str
61 @return flag indicating success
62 @rtype bool
55 """ 63 """
56 self.writeStartDocument() 64 self.writeStartDocument()
57 self.writeDTD("<!DOCTYPE passwords>") 65 self.writeDTD("<!DOCTYPE passwords>")
58 self.writeStartElement("Password") 66 self.writeStartElement("Password")
59 self.writeAttribute("version", "2.0") 67 self.writeAttribute("version", "2.0")
71 def __writeLogins(self, logins): 79 def __writeLogins(self, logins):
72 """ 80 """
73 Private method to write the login data. 81 Private method to write the login data.
74 82
75 @param logins dictionary with login data (user name, password) 83 @param logins dictionary with login data (user name, password)
84 @type dict
76 """ 85 """
77 self.writeStartElement("Logins") 86 self.writeStartElement("Logins")
78 for key, login in logins.items(): 87 for key, login in logins.items():
79 self.writeEmptyElement("Login") 88 self.writeEmptyElement("Login")
80 self.writeAttribute("key", key) 89 self.writeAttribute("key", key)
84 93
85 def __writeForms(self, forms): 94 def __writeForms(self, forms):
86 """ 95 """
87 Private method to write forms data. 96 Private method to write forms data.
88 97
89 @param forms list of forms data (list of LoginForm) 98 @param forms list of forms data
99 @type list of LoginForm
90 """ 100 """
91 self.writeStartElement("Forms") 101 self.writeStartElement("Forms")
92 for key, form in forms.items(): 102 for key, form in forms.items():
93 self.writeStartElement("Form") 103 self.writeStartElement("Form")
94 self.writeAttribute("key", key) 104 self.writeAttribute("key", key)
100 110
101 def __writeNevers(self, nevers): 111 def __writeNevers(self, nevers):
102 """ 112 """
103 Private method to write the URLs never to store login data for. 113 Private method to write the URLs never to store login data for.
104 114
105 @param nevers list of URLs to never store data for (list of strings) 115 @param nevers list of URLs to never store data for
116 @type list of str
106 """ 117 """
107 self.writeStartElement("Nevers") 118 self.writeStartElement("Nevers")
108 for never in nevers: 119 for never in nevers:
109 self.writeEmptyElement("Never") 120 self.writeEmptyElement("Never")
110 self.writeAttribute("url", never) 121 self.writeAttribute("url", never)

eric ide

mercurial