OSDN Git Service

Accept mode.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Thu, 21 Sep 2006 19:51:55 +0000 (04:51 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Thu, 21 Sep 2006 19:51:55 +0000 (04:51 +0900)
src/FukuiNoNamari/misc.py

index 7477455..eb29558 100644 (file)
@@ -155,9 +155,10 @@ class ThreadInvoker(threading.Thread):
 
 
 class FileWrap:
-    def __init__(self, path):
-        self._file = None
-        self._path = path
+    def __init__(self, path, mode="a+"):
+        self.__file = None
+        self.__path = path
+        self.__mode = mode
     def __del__(self):
         self.close()
     def seek(self, size):
@@ -165,13 +166,13 @@ class FileWrap:
     def write(self, data):
         self.file().write(data)
     def close(self):
-        if self._file:
-            self._file.close()
-            self._file = None
+        if self.__file:
+            self.__file.close()
+            self.__file = None
     def file(self):
-        if not self._file:
-            basedir = os.path.dirname(self._path)
+        if not self.__file:
+            basedir = os.path.dirname(self.__path)
             if not os.path.isdir(basedir):
                 os.makedirs(basedir)
-            self._file = file(self._path, "a+")
-        return self._file
+            self.__file = file(self.__path, self.__mode)
+        return self.__file