Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Yejin-Ha/To-do-List

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

28 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ To-do list Program

ย  ย  Team : ๋ฐ•์ฒ ํฌ, ์ด์žฌ์„ , ์žฅ์ˆ˜์ •, ํ•˜์˜ˆ์ง„

Notion ์œผ๋กœ ๋ณด๊ธฐ -> ํด๋ฆญํ•˜์„ธ์š”!


โœ… Index

1. ์ฃผ์ œ์„ ์ • ์ด์œ 

ย  ย  : Step13 ์ˆ˜์—…๊นŒ์ง€ ๋“ค์œผ๋ฉฐ ์ผ์ƒ์ƒํ™œ์†์—์„œ ์ž์ฃผ ์“ฐ์ด๋Š” To-do list๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์–ด ์ด ์ฃผ์ œ๋ฅผ ์„ ์ •ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.


2. ๊ธฐ๋Šฅ๊ตฌํ˜„

  • ๋“ฑ๋ก๋œ ์œ ์ €์ธ์ง€ ์ฒดํฌ

  • ์œ ์ €๋“ฑ๋ก

  • ํ• ์ผ๋“ฑ๋ก(๋‚ด์šฉ, ๋‚ ์งœ)

  • ํ•ด๋‹น ์œ ์ €์˜ To-do list ์ถœ๋ ฅ


3. Code

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)

4. Pylint

์ฒ˜์Œ ์ฝ”๋“œ๋ฅผ 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๋ฅผ ๋”ฐ๋ผ์„œ ์ฝ”๋“œ๋ฅผ ๊ณ„์† ์ˆ˜์ •


5. ์ตœ์ด Code ์‹คํ–‰ ๊ฒฐ๊ณผ

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)

์‹คํ–‰ ๊ฒฐ๊ณผ


6. ์ถ”ํ›„ ๋ณด์™„ํ•  ๋ถ€๋ถ„

  1. ์ฒ˜์Œ ๋“ฑ๋กํ•œ ์œ ์ €์—๊ฒŒ๋Š” todo_list()์™€ print_list()๊ฐ€ ์ž‘๋™ํ•˜์ง€ ์•Š๋Š”๋‹ค.
  2. ์ƒˆ๋กœ์šด ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ•˜๋Š” ๊ฒƒ์— ๋Œ€ํ•œ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• ๋ชจ์ƒ‰
  3. ํ•˜๋‹จ์˜ pep8์— ๊ทœ์น™ ์˜ค๋ฅ˜์— ๋Œ€ํ•œ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• ๋ชจ์ƒ‰
  • C0114 : Missing module docstring(missing-module-docstring)
  • R0201 : Method could be a function (no-self-use)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •