| 135 | return self.fileContentEncode(content, encoding, single, chunkSize) |
| 136 | |
| 137 | def fileContentEncode(self, content, encoding, single, chunkSize=256): |
| 138 | retVal = [] |
| 139 | |
| 140 | if encoding == "hex": |
| 141 | content = encodeHex(content) |
| 142 | elif encoding == "base64": |
| 143 | content = encodeBase64(content) |
| 144 | else: |
| 145 | content = codecs.encode(content, encoding) |
| 146 | |
| 147 | content = getText(content).replace("\n", "") |
| 148 | |
| 149 | if not single: |
| 150 | if len(content) > chunkSize: |
| 151 | for i in xrange(0, len(content), chunkSize): |
| 152 | _ = content[i:i + chunkSize] |
| 153 | |
| 154 | if encoding == "hex": |
| 155 | _ = "0x%s" % _ |
| 156 | elif encoding == "base64": |
| 157 | _ = "'%s'" % _ |
| 158 | |
| 159 | retVal.append(_) |
| 160 | |
| 161 | if not retVal: |
| 162 | if encoding == "hex": |
| 163 | content = "0x%s" % content |
| 164 | elif encoding == "base64": |
| 165 | content = "'%s'" % content |
| 166 | |
| 167 | retVal = [content] |
| 168 | |
| 169 | return retVal |
| 170 | |
| 171 | def askCheckWrittenFile(self, localFile, remoteFile, forceCheck=False): |
| 172 | choice = None |