Skip to content

Commit e8bd3ed

Browse files
committed
Fixed LICENSE; Update README.md; New easyfile
1 parent 286fa97 commit e8bd3ed

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 leoweyr
3+
Copyright (c) 2023-present, leoweyr
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# Python-Easyfile
2-
A simple Python package that object-oriented wraps Python traditional built-in file operations.
1+
# Easyfile
2+
3+
A simple Python package that object-oriented encapsulates Python traditional built-in file operations. It's also easier than `easygui`. o((>ω< ))o

easyfile/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .file import (
2+
File
3+
)

easyfile/file.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
3+
class File:
4+
def __init__(self, filePath):
5+
self.__m_filePath = filePath
6+
self.__m_dirPath = os.path.dirname(self.__m_filePath)
7+
if os.path.exists(self.__m_dirPath) == False: # If the directory of the file path does not exist, it will be created.
8+
os.mkdir(self.__m_dirPath)
9+
try: # If the file does not exist, it will be created.
10+
self.__m_file = open(self.__m_filePath, "x")
11+
except:
12+
pass
13+
else:
14+
self.__m_file.close()
15+
16+
@property
17+
def content(self):
18+
self.__m_file = open(self.__m_filePath, "r")
19+
self.__m_content = self.__m_file.read()
20+
self.__m_file.close()
21+
return self.__m_content
22+
23+
def ReWrite(self,content):
24+
self.__m_file = open(self.__m_filePath, "w")
25+
self.__m_file.write(content)
26+
self.__m_file.close()
27+
28+
def Append(self,content):
29+
self.__m_file = open(self.__m_filePath, "a")
30+
self.__m_file.write(content)
31+
self.__m_file.close()
32+
33+
def Delete(self):
34+
if os.path.exists(self.__m_filePath):
35+
os.remove(self.__m_filePath)

0 commit comments

Comments
 (0)