kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
				
				
				
			linting
							rodzic
							
								
									d0dad2a746
								
							
						
					
					
						commit
						630d6fafc3
					
				|  | @ -115,17 +115,13 @@ def format_complex_adm(z: complex, allow_negative: bool = False) -> str: | |||
|         return "- S" | ||||
|     adm = 1/z | ||||
| 
 | ||||
|     fmt_re = FMT_COMPLEX | ||||
|     if allow_negative: | ||||
|         fmt_re = FMT_COMPLEX_NEG | ||||
|     fmt_re = FMT_COMPLEX_NEG if allow_negative else FMT_COMPLEX | ||||
|     re = SITools.Value(adm.real, fmt=fmt_re) | ||||
|     im = SITools.Value(abs(adm.imag), fmt=FMT_COMPLEX) | ||||
|     return f"{re}{'-' if adm.imag < 0 else '+'}j{im} S" | ||||
| 
 | ||||
| def format_complex_imp(z: complex, allow_negative: bool = False) -> str: | ||||
|     fmt_re = FMT_COMPLEX | ||||
|     if allow_negative: | ||||
|         fmt_re = FMT_COMPLEX_NEG | ||||
|     fmt_re = FMT_COMPLEX_NEG if allow_negative else FMT_COMPLEX | ||||
|     re = SITools.Value(z.real, fmt=fmt_re) | ||||
|     im = SITools.Value(abs(z.imag), fmt=FMT_COMPLEX) | ||||
|     return f"{re}{'-' if z.imag < 0 else '+'}j{im} ""\N{OHM SIGN}" | ||||
|  |  | |||
|  | @ -114,11 +114,5 @@ class TinySA(VNA): | |||
|     def readValues(self, value) -> List[str]: | ||||
|         logger.debug("Read: %s", value) | ||||
|         if value == "data 0": | ||||
|             self._sweepdata = [] | ||||
|             for line in self.exec_command("data"): | ||||
|                 self._sweepdata.append(f"0 {line.strip()}") | ||||
|             self._sweepdata = [f"0 {line.strip()}" for line in self.exec_command("data")] | ||||
|         return self._sweepdata | ||||
|         if value == "data 0": | ||||
|             return [x[0] for x in self._sweepdata] | ||||
|         if value == "data 1": | ||||
|             return [x[0] for x in self._sweepdata] | ||||
|  |  | |||
|  | @ -141,9 +141,8 @@ class VNA: | |||
|             return [1000, ] | ||||
| 
 | ||||
|     def set_bandwidth(self, bandwidth: int): | ||||
|         bw_val = bandwidth | ||||
|         if self.bw_method == "dislord": | ||||
|             bw_val = DISLORD_BW[bandwidth] | ||||
|         bw_val = DISLORD_BW[bandwidth] \ | ||||
|             if self.bw_method == "dislord" else bandwidth | ||||
|         result = " ".join(self.exec_command(f"bandwidth {bw_val}")) | ||||
|         if self.bw_method == "ttrftech" and result: | ||||
|             raise IOError(f"set_bandwith({bandwidth}: {result}") | ||||
|  |  | |||
|  | @ -62,10 +62,10 @@ class BandsModel(QtCore.QAbstractTableModel): | |||
|         self.settings.setIniCodec("UTF-8") | ||||
| 
 | ||||
|         self.enabled = self.settings.value("ShowBands", False, bool) | ||||
|         self.bands = [] | ||||
| 
 | ||||
|         for band in self.settings.value("bands", _DEFAULT_BANDS): | ||||
|             self.bands.append(band.split(";")) | ||||
|         self.bands = [ | ||||
|             band.split(";") | ||||
|             for band in self.settings.value("bands", _DEFAULT_BANDS) | ||||
|         ] | ||||
| 
 | ||||
|     def saveSettings(self): | ||||
|         self.settings.setValue( | ||||
|  | @ -74,9 +74,7 @@ class BandsModel(QtCore.QAbstractTableModel): | |||
|         self.settings.sync() | ||||
| 
 | ||||
|     def resetBands(self): | ||||
|         self.bands = [] | ||||
|         for band in _DEFAULT_BANDS: | ||||
|             self.bands.append(band.split(";")) | ||||
|         self.bands = [band.split(";") for band in _DEFAULT_BANDS] | ||||
|         self.layoutChanged.emit() | ||||
|         self.saveSettings() | ||||
| 
 | ||||
|  | @ -87,8 +85,9 @@ class BandsModel(QtCore.QAbstractTableModel): | |||
|         return len(self.bands) | ||||
| 
 | ||||
|     def data(self, index: QModelIndex, role: int = ...) -> QtCore.QVariant: | ||||
|         if (role == QtCore.Qt.DisplayRole or | ||||
|                 role == QtCore.Qt.ItemDataRole or role == QtCore.Qt.EditRole): | ||||
|         if role in [ | ||||
|             QtCore.Qt.DisplayRole, QtCore.Qt.ItemDataRole, QtCore.Qt.EditRole, | ||||
|         ]: | ||||
|             return QtCore.QVariant(self.bands[index.row()][index.column()]) | ||||
|         if role == QtCore.Qt.TextAlignmentRole: | ||||
|             if index.column() == 0: | ||||
|  |  | |||
|  | @ -85,11 +85,13 @@ class Sweep(): | |||
|         return round(self.span / (self.points  * self.segments - 1)) | ||||
| 
 | ||||
|     def check(self): | ||||
|         if not(self.segments > 0 and | ||||
|                self.points > 0 and | ||||
|                self.start > 0 and | ||||
|                self.end > 0 and | ||||
|                self.stepsize >= 1): | ||||
|         if ( | ||||
|             self.segments <= 0 | ||||
|             or self.points <= 0 | ||||
|             or self.start <= 0 | ||||
|             or self.end <= 0 | ||||
|             or self.stepsize < 1 | ||||
|         ): | ||||
|             raise ValueError(f"Illegal sweep settings: {self}") | ||||
| 
 | ||||
|     def _exp_factor(self, index: int) -> float: | ||||
|  |  | |||
|  | @ -154,7 +154,7 @@ class AboutWindow(QtWidgets.QWidget): | |||
|         latest_url = "" | ||||
|         try: | ||||
|             req = request.Request(VERSION_URL) | ||||
|             req.add_header('User-Agent', "NanoVNA-Saver/" + self.app.version) | ||||
|             req.add_header('User-Agent', f'NanoVNA-Saver/{self.app.version}') | ||||
|             for line in request.urlopen(req, timeout=3): | ||||
|                 line = line.decode("utf-8") | ||||
|                 if line.startswith("VERSION ="): | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Holger Müller
						Holger Müller