ย ย Team : ๋ฐ์ฒ ํฌ, ์ด์ฌ์ , ์ฅ์์ , ํ์์ง
Notion ์ผ๋ก ๋ณด๊ธฐ -> ํด๋ฆญํ์ธ์!
ย ย : Step13 ์์ ๊น์ง ๋ค์ผ๋ฉฐ ์ผ์์ํ์์์ ์์ฃผ ์ฐ์ด๋ To-do list๋ฅผ ๊ตฌํํ๋ ํ๋ก๊ทธ๋จ์ ๋ง๋ค ์ ์์ ๊ฒ ๊ฐ๋ค๋ ์๊ฐ์ด ๋ค์ด ์ด ์ฃผ์ ๋ฅผ ์ ์ ํ๊ฒ ๋์์ต๋๋ค.
-
๋ฑ๋ก๋ ์ ์ ์ธ์ง ์ฒดํฌ
-
์ ์ ๋ฑ๋ก
-
ํ ์ผ๋ฑ๋ก(๋ด์ฉ, ๋ ์ง)
-
ํด๋น ์ ์ ์ To-do list ์ถ๋ ฅ
class Planner:
def __init__(self, name):
self.name = name;
# ๋ฑ๋ก๋ ์ ์ ์ธ์ง ์ฒดํฌ
def checkUser(self):
with open('./DataBase/users.txt', 'r', encoding='utf-8') as f:
self.user_list = f.read().splitlines()
if self.name in self.user_list:
print('๋ฐ๊ฐ์ต๋๋ค:) ํ์์ ๋ณด๊ฐ ํ์ธ๋์์ต๋๋ค.')
print(' ' * 20)
else:
print('ํ์์ ๋ณด๊ฐ ์์ต๋๋ค. ์ ์ ๋ฅผ ๋ฑ๋กํด์ฃผ์ธ์.')
def getUser(self):
input_name = input('์ด๋ฆ์ ์
๋ ฅํ์ธ์ : ')
with open('./DataBase/users.txt','a', encoding='utf-8') as f:
f.write('\n'+input_name)
getUser(self)
# ์ ์ ๋ฑ๋ก
def getUser(self):
input_name = input('์ด๋ฆ์ ์
๋ ฅํ์ธ์ : ')
with open('./DataBase/users.txt','a', encoding='utf-8') as f:
f.write('\n'+input_name)
# ํ ์ผ๋ฑ๋ก(๋ด์ฉ, ๋ ์ง)
def todoList(self, todo, date):
self.dates = []
with open(f'./DataBase/Users/{self.name}.txt', 'r', encoding='utf-8') as f:
self.todo_list = f.readlines()
for idx in range(len(self.todo_list)):
if self.todo_list[idx].startswith('#'):
self.dates.append(idx)
if self.todo_list[idx].startswith(f'# {date}'):
self.today = idx
self.next = self.dates.index(self.today)+1
today_list = self.todo_list[self.today:self.next]
today_list.insert(1, f'- {todo}\n')
add_list = self.todo_list[:self.today]+ today_list + self.todo_list[self.next:]
with open(f'./DataBase/Users/{self.name}.txt', 'w', encoding='utf-8') as f:
f.writelines(add_list)
# ํด๋น ์ ์ ์ To-do list ์ถ๋ ฅ
def print_list(self, date):
with open(f'./DataBase/Users/{self.name}.txt', 'r', encoding='utf-8') as file:
self.my_list = file.read().splitlines()
for idx in range(len(self.my_list)):
if self.my_list[idx].startswith('#'):
self.dates.append(idx)
if self.my_list[idx].startswith(f'# {date}'):
self.today = idx
self.next = self.dates.index(self.today)+1
today_list = self.my_list[self.today:self.dates[self.next]]
for item in today_list:
print(item)์ฒ์ ์ฝ๋๋ฅผ pylint์ ๋์
- C0303: Trailing whitespace (trailing-whitespace) : ๋ถํ์ํ ์ฌ๋ฐฑ์ด ์กด์ฌ
- W0301: Unnecessary semicolon (unnecessary-semicolon) : ๋ถํ์ํ ์ธ๋ฏธ์ฝ๋ก ์ด ์กด์ฌ
- C0115: Missing class docstring (missing-class-docstring) : class์ ๋ํ docstring์ด ์๋ต๋ ๊ฒฝ์ฐ
- C0116: Missing function or method docstring (missing-function-docstring) : method์ ๋ํ docstring์ด ์๋ต๋ ๊ฒฝ์ฐ
- W0613: Unused argument 'self' (unused-argument) : self ์์ _์ด ์๋ต๋ ๊ฒฝ์ฐ
- W0201: Attribute 'user_list' defined outside init(attribute-defined-outside-init) : ์ฒ์ init ๋ถ๋ถ์ ์ ์ธ์ ์ํ ๊ฒฝ์ฐ
pylint๋ฅผ ๋ฐ๋ผ์ ์ฝ๋๋ฅผ ๊ณ์ ์์
class Planner:
"""
ํฌ๋๋ฆฌ์คํธ๋ฅผ ์์ฑํ๋ ํด๋์ค์
๋๋ค.
"""
def __init__(self, name):
self.name = name
self.next = ""
self.today = ""
self.my_list = []
self.dates = []
self.user_list = []
def check_user(self):
"""
์กด์ฌํ๋ ์ ์ ์ธ์ง ํ์ธ์
๋๋ค.
"""
with open('./DataBase/users.txt', 'r', encoding='utf-8') as file:
self.user_list = file.read().splitlines()
if self.name in self.user_list:
print('๋ฐ๊ฐ์ต๋๋ค:) ํ์์ ๋ณด๊ฐ ํ์ธ๋์์ต๋๋ค.')
print(' ' * 20)
else:
print('ํ์์ ๋ณด๊ฐ ์์ต๋๋ค. ์ ์ ๋ฅผ ๋ฑ๋กํด์ฃผ์ธ์.')
def get_user(_self):
input_name = input('์ด๋ฆ์ ์
๋ ฅํ์ธ์ : ')
with open('./DataBase/users.txt','a', encoding='utf-8') as file:
file.write('\n'+input_name)
get_user(self)
def get_user(self):
"""
์ ์ ๋ฅผ ๋ฑ๋กํฉ๋๋ค.
"""
input_name = input('์ด๋ฆ์ ์
๋ ฅํ์ธ์ : ')
with open('./DataBase/users.txt','a', encoding='utf-8') as file:
file.write('\n'+input_name)
def todo_list(self, todo, date):
"""
ํ ์ผ๊ณผ ๋ ์ง๋ฅผ ์
๋ ฅ๋ฐ์์ ์ถ๊ฐํฉ๋๋ค.
"""
with open(f'./DataBase/Users/{self.name}.txt', 'r', encoding='utf-8') as file:
self.my_list = file.readlines()
for idx in range(len(self.my_list)):
if self.my_list[idx].startswith('#'):
self.dates.append(idx)
if self.my_list[idx].startswith(f'# {date}'):
self.today = idx
self.next = self.dates.index(self.today)+1
today_list = self.my_list[self.today:self.next]
today_list.insert(1, f'- {todo}\n')
add_list = self.my_list[:self.today]+ today_list + self.my_list[self.next:]
with open(f'./DataBase/Users/{self.name}.txt', 'w', encoding='utf-8') as file:
file.writelines(add_list)
def print_list(self, date):
"""
๋ ์ง๋ฅผ ์
๋ ฅ๋ฐ์์ ์ ์ ์ To-do list๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
"""
with open(f'./DataBase/Users/{self.name}.txt', 'r', encoding='utf-8') as file:
self.my_list = file.read().splitlines()
for idx in range(len(self.my_list)):
if self.my_list[idx].startswith('#'):
self.dates.append(idx)
if self.my_list[idx].startswith(f'# {date}'):
self.today = idx
self.next = self.dates.index(self.today)+1
today_list = self.my_list[self.today:self.dates[self.next]]
for item in today_list:
print(item)์คํ ๊ฒฐ๊ณผ
- ์ฒ์ ๋ฑ๋กํ ์ ์ ์๊ฒ๋ todo_list()์ print_list()๊ฐ ์๋ํ์ง ์๋๋ค.
- ์๋ก์ด ๋ ์ง๋ฅผ ์ ๋ ฅํ๋ ๊ฒ์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ ๋ชจ์
- ํ๋จ์ pep8์ ๊ท์น ์ค๋ฅ์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ ๋ชจ์
- C0114 : Missing module docstring(missing-module-docstring)
- R0201 : Method could be a function (no-self-use)