def LoadNames(self):
        try:
            f = open(self.names_path(), "r")
        except __HOLE__:
            return 0

        stat = os.fstat(f.fileno())
        self.update_time = stat.st_mtime

        item = DigestItem(self.path())

        hostname = ''
        _id = 0
        bms_only = 0
        sysop_only = 0
        zixia_only = 0
        while (True):
            line = f.readline()
            if (line == ""): break
            npos = line.find("\n")
            if (npos != -1): line = line[:npos]

            if (line[:1] == '#'):
                if (line[:8] == "# Title="):
                    if (not self.mtitle):
                        self.mtitle = line[8:]
            result = re.match('([^=]*)=(.*)', line)
            if (result):
                key = result.group(1)
                value = result.group(2)
                if (key == "Name"):
                    item.title = value
                    item.attachpos = 0
                elif (key == "Path"):
                    if (value[:2] == "~/"):
                        item.fname = value[2:]
                    else:
                        item.fname = value
                    if (item.fname.find("..") != -1):
                        continue
                    if (item.title.find("(BM: BMS)") != -1):
                        bms_only += 1
                    elif (item.title.find("(BM: SYSOPS)") != -1):
                        sysop_only += 1
                    elif (item.title.find("(BM: ZIXIAs)") != -1):
                        zixia_only += 1
                    if (item.fname.find("!@#$%") != -1):
                        parts = re.split('[!@#$%]', item.fname)
                        newparts = []
                        for part in parts:
                            if (part):
                                newparts += [part]
                        hostname = newparts[0]
                        item.fname = newparts[1]
                        try:
                            item.port = int(newparts[2])
                        except:
                            item.port = 0
                    item.id = _id
                    _id += 1
                    item.bms_only = bms_only
                    item.sysop_only = sysop_only
                    item.zixia_only = zixia_only
                    item.host = hostname
                    self.items += [item]
                    item = DigestItem(self.path())
                    hostname = ''
                elif (key == "Host"):
                    hostname = value
                elif (key == "Port"):
                    try:
                        item.port = int(value)
                    except:
                        item.port = 0
                elif (key == "Attach"):
                    try:
                        item.attachpos = int(value)
                    except:
                        item.attachpos = 0

        f.close()
        return 1
dataset/ETHPy150Open HenryHu/pybbs/digest.py/DigestItem.LoadNames