Ejemplo n.º 1
0
 def get_HexString(self):
     stringBuilder = StringBuilder()
     for i in range(40):
         str0 = hex(ord(chr(self.bytes[i]))).replace("0x", "").upper()
         if len(str0) == 1:
             str0 = "0" + str0
         stringBuilder.Append(str0)
         if (i < 39):
             stringBuilder.Append(" ")
     return stringBuilder.ToString()
Ejemplo n.º 2
0
 def ToString(self):
     if (self == None):
         return "";
     stringBuilder = StringBuilder();
     strArrays = self;
     for i in range(len(strArrays)):
         strS = strArrays[i];
         if (not String.IsNullOrEmpty(strS)):
             if (stringBuilder.Length > 0):
                 stringBuilder.Append(", ");
             stringBuilder.Append(strS);
     return stringBuilder.ToString();
Ejemplo n.º 3
0
 def smethod_7(bool_0):
     stringBuilder = StringBuilder()
     i = 0
     while i < len(bool_0):
         stringBuilder.Append(CRC.smethod_8(i, bool_0))
         i = i + 4
     # for (int i = 0; i < (int)bool_0.Length; i = i + 4)
     # {
     #     stringBuilder.Append(CRC.smethod_8(i, bool_0));
     # }
     return stringBuilder.ToString().upper()
Ejemplo n.º 4
0
 def ToString(self, format_0 = None):
     stringBuilder = StringBuilder()
     if format_0 == None:
         format_0 = ""
     if not isinstance(format_0, QString):
         format_0 = String.Str2QString(format_0)
     # if (provider == null)
     # {
     #     provider = CultureInfo.CurrentCulture
     # }
     if (not String.IsNullOrEmpty(format_0)):
         format_0 = format_0.toUpper()
         if (format_0.contains("QA:")):
             format_0 = format_0.replace("QA:", "")
             num = 0
             try:
                 num = int(format_0)
             except:
                 num = 0
             stringBuilder = StringBuilder()
             str0 = ""
             for i in range(num):
                 str0 = QString(String.Concat([str0, " "]))
             if (not String.IsNullOrEmpty(self.id)):
                 stringBuilder.AppendLine("{0}{1}\t{2}".format(str0, Captions.ID, self.id))
             if (not self.xy):
                 lATITUDE = Captions.LATITUDE
                 degree = Degrees.smethod_1(self.xlat)
                 stringBuilder.AppendLine("{0}{1}\t{2}".format(str0, lATITUDE, degree.method_2()))
                 lONGITUDE = Captions.LONGITUDE
                 degree1 = Degrees.smethod_5(self.ylon)
                 stringBuilder.Append("{0}{1}\t{2}".format(str0, lONGITUDE, degree1.method_2()))
             else:
                 stringBuilder.AppendLine("{0}{1}\t{2}".format(str0, Captions.X, str(self.xlat)))#.ToString(Formats.GridXYFormat, provider)))
                 stringBuilder.Append("{0}{1}\t{2}".format(str0, Captions.Y, str(self.ylon)))#.ToString(Formats.GridXYFormat, provider)))
             if (not self.altitude == None):
                 altitude = Altitude(self.altitude)
                 stringBuilder.AppendLine("")
                 aLTITUDE = [str0, Captions.ALTITUDE, altitude.ToString(":m"), altitude.ToString(":ft")]
                 stringBuilder.Append("{0}{1}\t{2} ({3})".format(str0, Captions.ALTITUDE, altitude.ToString(":m"), altitude.ToString(":ft")))
             return stringBuilder.ToString()
     stringBuilder = StringBuilder()
     if (not String.IsNullOrEmpty(self.id)):
         stringBuilder.Append(self.id + ", ")
     if (not self.xy):
         degree2 = Degrees.smethod_1(self.xlat)
         str1 = degree2.method_2()
         degree3 = Degrees.smethod_5(self.ylon)
         stringBuilder.Append(str1 + ", " + degree3.method_2())
     else:
         stringBuilder.Append(str(self.xlat) + ", " + str(self.ylon))
     if (not self.altitude == None):
         altitude1 = Altitude(self.altitude)
         stringBuilder.Append(", {0} ({1})", ", " + altitude1.ToString(":m") + " (" + altitude1.ToString(":ft") + ")")
     return stringBuilder.ToString()
Ejemplo n.º 5
0
 def smethod_11(string_0, string_1, string_2):
     if (String.IsNullOrEmpty(string_1)):
         return string_0
     stringBuilder = StringBuilder()
     if not isinstance(string_0, QString):
         string_0 = QString(string_0)
     if not isinstance(string_1, QString):
         string_1 = QString(string_1)
     if not isinstance(string_2, QString):
         string_2 = QString(string_2)
     length = string_1.length()
     num = -1
     num1 = 0
     while (True):
         num = string_0.indexOf(string_1, num + 1)
         if (num < 0):
             break
         stringBuilder.Append(string_0, num1, num - num1)
         stringBuilder.Append(string_2)
         num1 = num + length
     stringBuilder.Append(string_0, num1, string_0.length() - num1)
     return QString(stringBuilder.ToString())
Ejemplo n.º 6
0
 def method_11(self):
     clipboard = QApplication.clipboard()
     clipboard.clear()
     # if (self.childName == "QASnapshot"):
     #     clipboard.setImage(self.Image);
     #     return;
     # dataObject = DataObject();
     dataObject = ""
     stringBuilder = StringBuilder()
     stringBuilder.Append("Version:0.9\r\n")
     stringBuilder.Append("StartHTML:aaaaaaaaaa\r\n")
     stringBuilder.Append("EndHTML:bbbbbbbbbb\r\n")
     stringBuilder.Append("StartFragment:cccccccccc\r\n")
     stringBuilder.Append("EndFragment:dddddddddd\r\n")
     length = stringBuilder.Length
     num = stringBuilder.Length
     stringBuilder.Append("<!--StartFragment-->\r\n")
     stringBuilder.Append(self.method_5())
     stringBuilder.Append("<!--EndFragment-->\r\n")
     length1 = stringBuilder.Length
     num1 = stringBuilder.Length
     stringBuilder.Replace("aaaaaaaaaa",
                           String.Number2String(length, "0000000000"), 0,
                           length)
     stringBuilder.Replace("bbbbbbbbbb",
                           String.Number2String(num1, "0000000000"), 0,
                           length)
     stringBuilder.Replace("cccccccccc",
                           String.Number2String(num, "0000000000"), 0,
                           length)
     stringBuilder.Replace("dddddddddd",
                           String.Number2String(length1, "0000000000"), 0,
                           length)
     dataObject += stringBuilder.ToString() + "\n"
     dataObject += self.ToString() + "\n"
     # dataObject.SetData(DataFormats.Html, stringBuilder.ToString());
     # dataObject.SetData(DataFormats.UnicodeText, this.ToString());
     clipboard.setText(dataObject)
Ejemplo n.º 7
0
    def CRC_Calculation(byteArray):
        numArray = [0, 2577006594, 2553349383, 27985157, 2607222541, 50138895, 55970314, 2597063176, 2647333657, 72424219, 100277790, 2623544860, 111940628, 2671121430, 2661093651, 117903633, 2425566001, 151597875, 144848438, 2436380212, 200555580, 2456697918, 2479175995, 174012729, 223881256, 2495752234, 2506698031, 217263405, 2520721189, 262481703, 235807266, 2543067680, 2317575009, 330916707, 303195750, 2340972132, 289696876, 2296278126, 2306173291, 284125545, 401111160, 2389866618, 2413395327, 373521789, 2358212469, 353728375, 348025458, 2367976048, 447762512, 2200588370, 2189514071, 454776149, 2178375517, 407723871, 434526810, 2155633240, 2273004361, 518081355, 524963406, 2261798476, 471614532, 2240169030, 2217558339, 498549057, 3208889281, 651805635, 661833414, 3202926276, 606391500, 3183398094, 3155544523, 630180297, 579393752, 3138574554, 3132743135, 589553117, 3119503317, 544593879, 568251090, 3091518160, 802222320, 3058364658, 3085039095, 779875829, 3031957501, 757989375, 747043578, 3038575352, 2988174313, 729934827, 707456750, 3014717164, 696050916, 2967921894, 2974671331, 685236705, 895525024, 2902106274, 2907809191, 885761445, 2919739309, 933081007, 909552298, 2947328680, 2829827001, 825342907, 815447742, 2835398332, 869053620, 2857809078, 2885530035, 845656497, 2784203665, 1013552019, 1036162710, 2757269140, 1049926812, 2802752670, 2795870619, 1061132697, 943229064, 2711783562, 2684980623, 965971341, 2740946821, 986023815, 997098114, 2733933184, 3582100097, 1276674691, 1303611270, 3559491460, 1323666828, 3615460750, 3604252811, 1330546825, 1212783000, 3520305562, 3497565343, 1239587997, 3543045781, 1253349015, 1260360594, 3531969424, 1158787504, 3700142514, 3709908151, 1153086645, 3732324029, 1206697663, 1179106234, 3755850680, 3638209193, 1094757035, 1089187758, 3648106412, 1136502180, 3660031398, 3683426467, 1108779169, 1604444640, 3325813218, 3348161767, 1577772261, 3301371629, 1566371567, 1559751658, 3312315368, 3261790969, 1542519547, 1515978750, 3284271100, 1494087156, 3231184374, 3241996531, 1487335665, 3476214481, 1453904595, 1459869654, 3466188756, 1414913500, 3452952030, 3429161179, 1442765017, 1392101832, 3412314570, 3402157263, 1397935309, 3382625989, 1342490311, 1370473410, 3358966720, 1791050048, 4082843970, 4075832391, 1802126405, 4054208077, 1748782671, 1771522890, 4027403080, 4144650841, 1854954075, 1866162014, 4137770844, 1819104596, 4126627158, 4099690579, 1841713233, 4199707249, 1674080883, 1650685814, 4227430260, 1630895484, 4172250494, 4177819771, 1620998265, 1738107240, 4261636458, 4289227887, 1714580589, 4244530789, 1701078631, 1691312994, 4250231648, 3772916257, 2037916195, 2027104038, 3779667748, 2072325420, 3793693998, 3820234795, 2049845289, 2099853624, 3836950842, 3843570751, 2088909885, 3863885365, 2144613943, 2122265394, 3890557744, 1886458128, 3924496658, 3896513559, 1910117397, 3944095261, 1921785375, 1931942682, 3938261784, 3988392457, 1948256779, 1972047630, 3960540940, 1994196228, 4014408966, 4008443907, 2004221953]
        num = 0
        j = 0

        progressMessageBar = define._messagBar.createMessage("Reading the file ...")
        progress = QProgressBar()
        progress.setAlignment(Qt.AlignLeft|Qt.AlignVCenter)
        progressMessageBar.layout().addWidget(progress)
        define._messagBar.pushWidget(progressMessageBar, define._messagBar.INFO)
        maxium = len(byteArray)
        progress.setMaximum(maxium)
        progress.setValue(0)

        for i in range(len(byteArray)):
            byte0 = None
            if isinstance(byteArray, bytearray):
                byte0 = Type.ByteFunc.d2b(num ^ ord(chr(byteArray[i])))
            else:
                byte0 = Type.ByteFunc.d2b(num ^ ord(byteArray[i]))
            num = num >> 8
            num = num ^ numArray[ord(byte0) % 36]
            progress.setValue(i)
            QApplication.processEvents()
        progress.setValue(maxium)
        define._messagBar.hide()

        resultByteArray = bytearray(4)
        for i in range(4):
            resultByteArray[i] = '0'
        resultByteArray[0] = Type.ByteFunc.d2b(num)
        resultByteArray[1] = Type.ByteFunc.d2b(num >> 8)
        resultByteArray[2] = Type.ByteFunc.d2b(num >> 16)
        resultByteArray[3] = Type.ByteFunc.d2b(num >> 24)

        stringBuilder = StringBuilder()
        for i in range(4):
            stringBuilder.Append(hex(ord(chr(resultByteArray[i]))).replace("0x", "").upper())
        return stringBuilder.ToString()
Ejemplo n.º 8
0
    def ToString(self, formatStr=None):
        if formatStr == None:
            return self.ToString("G")
        num = 0.0
        num1 = 0.0
        num2 = 0.0
        if (self.IsNaN):
            return ""
        if (formatStr == None or formatStr == ""):
            formatStr = self.defaultformatStr
        # if (provider == null)
        # {
        #     provider = CultureInfo.CurrentCulture;
        # }
        # s = QString(45)
        # s.toUpper()

        if isinstance(formatStr, QString):
            formatStr = formatStr.toUpper()
        else:
            formatStr = formatStr.upper()
        if (formatStr == "G"):
            formatStr = self.defaultformatStr.upper()
        stringBuilder = StringBuilder()
        strS = None
        str1 = None
        str2 = None
        num3 = 0
        num4 = 0
        num5 = 0
        length = -1
        length1 = -1
        length2 = -1
        num6 = 0
        while (len(formatStr) > num6):
            chr = formatStr[num6]
            if (chr == 'D'):
                if (strS != None):
                    return None
                    # throw new ArgumentException("formatStr");
                strS = "0"
                num6 += 1
                flag = False
                while (len(formatStr) > num6):
                    if (formatStr[num6] != 'D'):
                        if (formatStr[num6] != '.'):
                            break
                        strS = String.Concat([strS, "."])
                        flag = True
                        num6 += 1
                    else:
                        strS = String.Concat([strS, "0"])
                        if (flag):
                            num3 += 1
                        num6 += 1
                length = stringBuilder.Length
            elif (chr == 'M'):
                if (strS == None):
                    return None
                    # throw new ArgumentException("formatStr");
                if (str1 != None):
                    return None
                    # throw new ArgumentException("formatStr");
                str1 = "0"
                num6 += 1
                flag1 = False
                while (len(formatStr) > num6):
                    if (formatStr[num6] != 'M'):
                        if (formatStr[num6] != '.'):
                            break
                        str1 = String.Concat([str1, "."])
                        flag1 = True
                        num6 += 1
                    else:
                        str1 = String.Concat([str1, "0"])
                        if (flag1):
                            num4 += 1
                        num6 += 1
                length1 = stringBuilder.Length
            elif (chr == 'S'):
                if (strS == None):
                    return None
                    # throw new ArgumentException("formatStr");
                if (str1 == None):
                    return None
                    # throw new ArgumentException("formatStr");
                if (str2 != None):
                    return None
                    # throw new ArgumentException("formatStr");
                str2 = "0"
                num6 += 1
                flag2 = False
                while (len(formatStr) > num6):
                    if (formatStr[num6] != 'S'):
                        if (formatStr[num6] != '.'):
                            break
                        str2 = String.Concat([str2, "."])
                        flag2 = True
                        num6 += 1
                    else:
                        str2 = String.Concat([str2, "0"])
                        if (flag2):
                            num5 += 1
                        num6 += 1
                length2 = stringBuilder.Length
            elif (chr == 'H'):
                if (self.type == DegreesType.Latitude):
                    if (self.value >= 0):
                        stringBuilder.Append("N")
                    else:
                        stringBuilder.Append("S")
                elif (self.type == DegreesType.Longitude
                      or self.type == DegreesType.Variation):
                    if (self.value >= 0):
                        stringBuilder.Append("E")
                    else:
                        stringBuilder.Append("W")
                num6 += 1
            elif (chr != '-'):
                stringBuilder.Append(chr)
                num6 += 1
            else:
                if (self.value < 0):
                    stringBuilder.Append("-")
                num6 += 1
        if (str2 != None):
            num = math.fabs(self.value) if (not math.isinf(self.value)) else 0
            num7 = math.trunc(num)
            num8 = (num - num7) * 60
            num9 = math.trunc(num8)
            num10 = round((num8 - num9) * 60, num5)
            if (num10 >= 60):
                num10 = num10 - 60
                num9 = num9 + 1
            if (num9 >= 60):
                num9 = num9 - 60
                num7 = num7 + 1

            stringBuilder.Insert(length2, String.Number2String(num10, str2))
            stringBuilder.Insert(length1, String.Number2String(num9, str1))
            stringBuilder.Insert(length, String.Number2String(num7, strS))
        elif (str1 == None):
            if (strS == None):
                return None
                # throw new ArgumentException("formatStr");
            num2 = math.fabs(self.value) if (not math.isinf(self.value)) else 0
            num11 = round(num2, num3)
            stringBuilder.Insert(length, String.Number2String(num11, strS))
        else:
            num1 = math.fabs(self.value) if (not math.isinf(self.value)) else 0
            num12 = math.trunc(num1)
            num13 = round((num1 - num12) * 60, num4)
            if (num13 >= 60):
                num13 = num13 - 60
                num12 = num12 + 1
            stringBuilder.Insert(length1, String.Number2String(num13, str1))
            stringBuilder.Insert(length, String.Number2String(num12, strS))

        return stringBuilder.ToString()
Ejemplo n.º 9
0
 def method_14(self, string_0, int_0, int_1):
     str0 = "";
     stringBuilder = StringBuilder();
     strArrays = Extensions.smethod_4(string_0);
     for i in range(len(strArrays) - 1):
         str1 = strArrays[i];
         for case in switch (self.tableType):
             if case(QATableType.General):
                 stringBuilder.Append("<td>{0}</td>".format(self.method_13(str1, True)));
                 break;
             elif case(QATableType.OCAH):
                 if (int_0 == 0 or i == 0):
                     stringBuilder.Append("<th>{0}</th>".format(self.method_13(str1, False)));
                     break;
                 else:
                     stringBuilder.Append("<td>{0}</td>".format(self.method_13(str1, False)));
                     break;
             elif case(QATableType.ObstacleList):
                 if (int_0 != 0):
                     stringBuilder.Append("<td>{0}</td>".format(self.method_13(str1, False)));
                     break;
                 else:
                     stringBuilder.Append("<th>{0}</th>".format(self.method_13(str1, False)));
                     break;
     str0 = "<br>" if(len(strArrays) <= 0) else strArrays[len(strArrays) - 1];
     for case in switch (self.tableType):
         if case(QATableType.General):
             if (len(strArrays) == 1 and int_1 > 1):
                 num = str0.smethod_6();
                 if (num < 4):
                     str0 = "<b>{0}</b>".format(str0);
                 elif (num < 8):
                     str0 = "<b><i>{0}</i></b>".format(str0);
             if (len(strArrays) >= int_1):
                 stringBuilder.Append("<td>{0}</td>".format(self.method_13(str, True)));
                 break;
             else:
                 int1 = int_1 - len(strArrays) + 1;
                 stringBuilder.Append("<td colspan=\"{0}\">{1}</td>".format(str(int1), self.method_13(str, True)));
                 break;
         elif case(QATableType.OCAH):
             if (int_0 != 0):
                 if (len(strArrays) == 1):
                     stringBuilder.Append("<th>{0}</th>".format(self.method_13(str, False)));
                     for j in range(len(strArrays), int_1):
                         stringBuilder.Append("<td><br></td>");
                     break;
                 stringBuilder.Append("<td>{0}</td>".format(self.method_13(str, False)));
             stringBuilder.Append("<th>{0}</th>".format(self.method_13(str, False)));
             for j in range(len(strArrays), int_1):
                 stringBuilder.Append("<td><br></td>");
             break;
         elif case(QATableType.ObstacleList):
             if (int_0 != 0):
                 stringBuilder.Append("<td>{0}</td>".format(self.method_13(str, False)));
             else:
                 stringBuilder.Append("<th>{0}</th>".format(self.method_13(str, False)));
             for k in range(len(strArrays), int_1):
                 stringBuilder.Append("<td><br></td>");
             break;
     return stringBuilder.ToString();
Ejemplo n.º 10
0
 def get_CRC(self):
     stringBuilder = StringBuilder()
     for i in range(36, 40):
         stringBuilder.Append(
             hex(ord(chr(self.bytes[i]))).replace("0x", "").upper())
     return stringBuilder.ToString()