OSDN Git Service

Use fileinput at idxfile.load_idx.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 16 Aug 2006 05:22:46 +0000 (14:22 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 16 Aug 2006 05:22:46 +0000 (14:22 +0900)
src/Hage1/idxfile.py

index 31c1287..18a2361 100644 (file)
@@ -17,6 +17,7 @@
 
 import os
 import os.path
+from fileinput import FileInput
 from misc import get_thread_idx_path
 
 metadata_namelist = ["title", "lineCount", "lastModified", "etag"]
@@ -37,10 +38,9 @@ def load_idx(bbs, board, thread):
     if not os.path.exists(idxfile_path):
         return {"title":None,"lineCount":0,"lastModified":None,"etag":None}
 
-    f = open(idxfile_path, "r")
     datadic = {}
-    line = f.readline()
-    while line:
+    f = FileInput(idxfile_path)
+    for line in f:
         for name in metadata_namelist:
             if line.startswith(name+"="):
                 value = line[len(name)+1:].rstrip("\n")
@@ -53,7 +53,6 @@ def load_idx(bbs, board, thread):
                     datadic[name] = value
                 #print name, datadic[name]
                 break;
-        line = f.readline()
     f.close()
 
     # if datadic does not have key, insert empty entry.