def player_kill_count_date(self): self.cursor.execute("SELECT username,killcam_path, date FROM griefers") self.player_kc_dict = {} for tup in (self.cursor.fetchall()): if tup[0] in self.player_kc_dict and QDateTime.fromString( tup[2]) < QDateTime.fromString( self.player_kc_dict[tup[0]][1]): self.player_kc_dict[tup[0]] = (self.player_kc_dict[tup[0]][0] + 1, tup[2]) elif tup[0] in self.player_kc_dict and QDateTime.fromString( tup[2]) >= QDateTime.fromString( self.player_kc_dict[tup[0]][1]): self.player_kc_dict[tup[0]][0] += 1 else: self.player_kc_dict[tup[0]] = [1, tup[2]] return self.player_kc_dict
def from_string(self, text, original_value): if isinstance(original_value, QColor): match = self.color_exp.match(text) return QColor(min(int(match.captured(1)), 255), min(int(match.captured(2)), 255), min(int(match.captured(3)), 255), min(int(match.captured(4)), 255)) if isinstance(original_value, QDate): value = QDate.fromString(text, Qt.ISODate) return value if value.isValid() else None if isinstance(original_value, QDateTime): value = QDateTime.fromString(text, Qt.ISODate) return value if value.isValid() else None if isinstance(original_value, QTime): value = QTime.fromString(text, Qt.ISODate) return value if value.isValid() else None if isinstance(original_value, QPoint): match = self.point_exp.match(text) return QPoint(int(match.captured(1)), int(match.captured(2))) if isinstance(original_value, QRect): match = self.rect_exp.match(text) return QRect(int(match.captured(1)), int(match.captured(2)), int(match.captured(3)), int(match.captured(4))) if isinstance(original_value, QSize): match = self.size_exp.match(text) return QSize(int(match.captured(1)), int(match.captured(2))) if isinstance(original_value, list): return text.split(',') return type(original_value)(text)
def getAreaChartData(fname): df = pd.read_csv(fname) # получает 0-й столбец df (временные метки) timeStamps = df.iloc[:, 0] timeStamps = [QDateTime.fromString(str(x), "yyyy") for x in timeStamps] values = [] names = [] for x in df.iloc[:, 1:]: values.append(list(df[x])) names.append(x) return timeStamps, values, names
def parseQRdata(self, qr_data): self.QR_data = qr_data logging.info(g_tr('ImportSlipDialog', "QR: " + self.QR_data)) parts = re.match(self.QR_pattern, qr_data) if not parts: logging.warning( g_tr( 'ImportSlipDialog', "QR available but pattern isn't recognized: " + self.QR_data)) for timestamp_pattern in self.timestamp_patterns: datetime = QDateTime.fromString(parts.group(1), timestamp_pattern) if datetime.isValid(): self.SlipTimstamp.setDateTime(datetime) self.SlipAmount.setText(parts.group(2)) self.FN.setText(parts.group(3)) self.FD.setText(parts.group(4)) self.FP.setText(parts.group(5)) self.SlipType.setCurrentIndex(int(parts.group(6)) - 1) self.qr_data_validated.emit()
def analysisList() -> list: files = QDir(HistoryManager.appDirectory()).entryList( ["*.json"], QDir.Files | QDir.Readable) analysis = {} for f in files: f = f.rstrip(".json") name, date_str = "@".join(f.split("@")[:-1]), f.split("@")[-1] date = QDateTime.fromString(date_str, HistoryManager.DATE_FORMAT) analysis[date] = { "name": name, "file": f, "date": date.toString("dd/MM/yyyy") } names = [] for k in sorted(analysis.keys(), reverse=True): names.append(analysis[k]) return names
def fromJSON(obj): params = Parameters.fromJSON(obj["_parameters"]) analysis = Analysis(params) for k, v in obj.items(): if k == "_parameters": pass elif k == "_detected_sponges": analysis.__dict__[k] = {int(i): m for i, m in v.items()} elif k == "_processed_images": analysis.__dict__[k] = [] for img in obj["_processed_images"]: analysis.__dict__[k].append(ProcessedImage.fromJSON(img)) elif k in ["_start_datetime", "_end_datetime"]: analysis.__dict__[k] = QDateTime.fromString(v, Qt.ISODate) else: analysis.__dict__[k] = v return analysis
def transform_date(utc, timezone=None): utc_fmt = "yyyy-MM-ddTHH:mm:ss.zzzZ" new_date = QDateTime.fromString(utc, utc_fmt) if timezone: new_date.setTimeZone(timezone) return new_date
def widgets(self): self.dropdownData = IssuesDropdownData() # Top layout widgets self.issueImg = QLabel() self.img = QPixmap('assets/icons/logo-dark.png') self.issueImg.setPixmap(self.img) self.issueImg.setAlignment(Qt.AlignCenter) self.titleText = QLabel("Display issue") self.titleText.setAlignment(Qt.AlignCenter) # Bottom layout widgets self.idEntry = QLabel(str(self.id)) self.dateEntry = QDateTimeEdit(calendarPopup=True) self.dateEntry.setDateTime( QDateTime.fromString(self.date, "yyyy-MM-dd h:mm AP")) self.priorityEntry = QComboBox() self.priorityEntry.addItems(self.dropdownData.priorityItems()) self.priorityEntry.setCurrentText(self.priority) self.observerEntry = QComboBox() self.observerEntry.addItems(self.dropdownData.observerItems()) self.observerEntry.setCurrentText(self.observer) self.revTeamEntry = QComboBox() self.revTeamEntry.addItems(self.dropdownData.revTeamItems()) self.revTeamEntry.setCurrentText(self.revTeam) self.inspectionNameEntry = QComboBox() self.inspectionNameEntry.addItems(self.dropdownData.inspNameItems()) self.inspectionNameEntry.setCurrentText(self.inspectorName) self.themeEntry = QComboBox() self.themeEntry.addItems(self.dropdownData.hseThemeItems()) self.themeEntry.setCurrentText(self.theme) self.facilityEntry = QComboBox() self.facilityEntry.addItems(self.dropdownData.facilityItems()) self.facilityEntry.setCurrentText(self.facility) self.facilitySupervisorEntry = QComboBox() self.facilitySupervisorEntry.addItems( self.dropdownData.facSupervisorItems()) self.facilitySupervisorEntry.setCurrentText(self.facilitySupervisor) self.specLocationEntry = QTextEdit() self.specLocationEntry.setText(self.specLocation) self.inspectedDeptEntry = QComboBox() self.inspectedDeptEntry.addItems(self.dropdownData.inspDeptItems()) self.inspectedDeptEntry.setCurrentText(self.inspectedDept) self.inspectedContrEntry = QComboBox() self.inspectedContrEntry.addItems(self.dropdownData.inspContrItems()) self.inspectedContrEntry.setCurrentText(self.inspectedContr) self.inspectedSubcontrEntry = QComboBox() self.inspectedSubcontrEntry.addItems( self.dropdownData.inspSubcontrItems()) self.inspectedSubcontrEntry.setCurrentText(self.inspectedSubcontr) self.statusEntry = QComboBox() self.statusEntry.addItems(self.dropdownData.statusItems()) self.statusEntry.setCurrentText(self.status) self.deadlineEntry = QDateTimeEdit(calendarPopup=True) self.deadlineEntry.setDateTime( QDateTime.fromString(self.deadline, "yyyy-MM-dd h:mm AP")) self.updateBtn = QPushButton("Update") self.updateBtn.clicked.connect(self.updateIssue) self.deleteBtn = QPushButton("Delete") self.deleteBtn.clicked.connect(self.Parent.funcDeleteIssue) self.cancelBtn = QPushButton("Cancel") self.cancelBtn.clicked.connect(self.closeWindow)
def fromDateToQDate(date) -> QDate: return QDateTime.fromString(date, 'yyyy-MM-dd')