From 1f06af64de3988ce920faa5990a71f66524cbc99 Mon Sep 17 00:00:00 2001 From: Raunaq Date: Tue, 21 Jan 2020 00:37:30 +0530 Subject: [PATCH 1/5] Readme updated --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f9aa26d..f9b3636 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -# mock-machine-coding-3 -Welcome to the 3rd Mock Machine Coding Round by [workat.tech](http://workat.tech). +# mock-machine-coding-3 : Trello + +Original Problem statement: [https://workattech.github.io/mock-machine-coding-3/](https://workattech.github.io/mock-machine-coding-3/). + -Please visit [this link](https://workattech.github.io/mock-machine-coding-3/) to participate. From c745259f670ccd0dc559b83e583249c8c45d28f0 Mon Sep 17 00:00:00 2001 From: Raunaq Date: Tue, 21 Jan 2020 00:40:29 +0530 Subject: [PATCH 2/5] Added code --- README.md | 6 + src/README.md | 9 + src/entities/__pycache__/board.cpython-37.pyc | Bin 0 -> 710 bytes src/entities/__pycache__/card.cpython-37.pyc | Bin 0 -> 549 bytes src/entities/__pycache__/list.cpython-37.pyc | Bin 0 -> 510 bytes src/entities/__pycache__/user.cpython-37.pyc | Bin 0 -> 515 bytes src/entities/board.py | 16 ++ src/entities/card.py | 12 ++ src/entities/list.py | 9 + src/entities/user.py | 14 ++ src/trello.py | 168 ++++++++++++++++++ src/utils/__pycache__/uid.cpython-37.pyc | Bin 0 -> 286 bytes src/utils/uid.py | 5 + 13 files changed, 239 insertions(+) create mode 100644 src/README.md create mode 100644 src/entities/__pycache__/board.cpython-37.pyc create mode 100644 src/entities/__pycache__/card.cpython-37.pyc create mode 100644 src/entities/__pycache__/list.cpython-37.pyc create mode 100644 src/entities/__pycache__/user.cpython-37.pyc create mode 100644 src/entities/board.py create mode 100644 src/entities/card.py create mode 100644 src/entities/list.py create mode 100644 src/entities/user.py create mode 100644 src/trello.py create mode 100644 src/utils/__pycache__/uid.cpython-37.pyc create mode 100644 src/utils/uid.py diff --git a/README.md b/README.md index f9b3636..7575080 100755 --- a/README.md +++ b/README.md @@ -2,5 +2,11 @@ Original Problem statement: [https://workattech.github.io/mock-machine-coding-3/](https://workattech.github.io/mock-machine-coding-3/). +How to run +``` +git clone https://github.com/raunaqness/mock-machine-coding-3/tree/trello-python +cd mock-machine-coding-3/src +python trello.py +``` diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..730dd0b --- /dev/null +++ b/src/README.md @@ -0,0 +1,9 @@ +# Machine Coding - Trello + +How to run + +```buildoutcfg +git clone https://github.com/raunaqness/mock-machine-coding-3/tree/trello-python +cd mock-machine-coding-3 +python trello.py +``` \ No newline at end of file diff --git a/src/entities/__pycache__/board.cpython-37.pyc b/src/entities/__pycache__/board.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f18de431b17918adcc66b6b22ef060d37351396b GIT binary patch literal 710 zcmY*XJ&zMH5VgG@*@Wa8ifcfkq1Yy-MhHa-5<)s6B)Db^tj*fw9QGrzy(e9i?(Wa< z5BM!^sc0#wnDHtIX7%38j_v31*vr{$Lco4~fByL?CFBSGoGpf60kF@2B$2cx4J{}o zZ;50wdLS}V>^>?Y8Gj^s@)Kr}och^TInlTJ&?}*3h1s()2o?bQ1W1vBN>VUMC3_&C z0y^MhnSfgAlVw*LS>X~i^oSL}z5sIMo}7rFCkhNAz>#DpvZI%nkGIH4;8YTjjMhc^ z;d*)XZgqToU*Z8kK3|Q#b|HzZCTwFQEzHLYE-jP#`>hz z*4do-*sA)ANnp`8V#eTpFZi{EDcqEOTORluWxu*^5B`?FFRL5fs#Pa-yXBw4zFf6V zJFP6=;92MUJD&-mTkV8ESvv(HETbuWQ^4^eG-ZCCRKb-6LyrjENg;qf;F;+fE(A2C zu0S)VCWEn1>p*zfx6K@Vd9s(G9Z3| ziMv*jde*%=`|jS|B^PPhXDBD1$M-*IzvjPIcHZ41Vn2FkrE$K z9zlG=hMix`VnZI%newtRdf6zcp`_PV1Uh3>cYvT+&Vl6uIEXbvmIztm5KjsVCG{pD zOH~t8cZlHGib=lWh+-uWqg8|$1H)=Q9d<0G2caRvrkJZR0Od-n7hcyUq=j>OW)#TA zDNEg)svd0zOKg{558;d19-6=N><*J$W{buY%j{CQ7hf;XzGl}&`J|1S)S%5QyS1vS z>P#80y;d$Oaf8v~EhJKEqrH^G?-B$ix}45?N?VTF_!K9>WSUpX(3f&vLsOBzFXgf+ zs%^v$kYO|14$%Lz5dx{BxXAm`b~U?gVwb~6q3_z>oeZ6 G?Tdf+8+@Pu literal 0 HcmV?d00001 diff --git a/src/entities/__pycache__/list.cpython-37.pyc b/src/entities/__pycache__/list.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ffbdc364c9a3b668e0f117cbc21ea4320c93d6e0 GIT binary patch literal 510 zcmYjOu};G<5Vf5&N~>l=%q$FDnjb(=Q6v^%0hSC{A?Fr@o3yrr1nNeAfti_K^2)?7 zFmcx^QcrsC&c5@@JLNpf1`K2Nb^P#&`G*c^xa?g$AOaKje7;GA7D5D;w`L`r-_ zMFjCJ8})v1ij8>4=E}>q)~i-Y4HeyXA+VSr+yRne1qW6L;2<^(RU%Z0Lwu#3uV|8j zGGU5vhe)2SndEDZEap^4!0;Wv8O4?cgU}G-x?HHxt4a%QBtqlXO%Hcu4=EnRxUSaZoGU8sg%0bUP@AR z2@(?tPxyOA_QzcpUC}7nkunUVTr|)cs)tgp+S2SgmVUz4*&g-jEb_NNPw!OG?QlkxcRrBDrGk zyyP-jkbLk9StO@1TPiO?tJgsZEo;2(g@H2zbq4^7lvI+ENh;X~0TvD{Nlb2?vNeYU z6tq}12X%)4o@|Jq8w$ua43J9#b@VzZq>Y#x?L7GRvFV3s`c7y<%$4h)75KCh0v|` zLLjw6YQl$fNZ&Ffp7v1~4O4L@A>vqwrjx;-KM`UbDzl4N{E6*kdoaQ~d<0a73#M#) m2GVjAyf$tcwA`&e?Czgb?YHqg4qVnEQA|&EtxsvsHevsIT5*s7 literal 0 HcmV?d00001 diff --git a/src/entities/board.py b/src/entities/board.py new file mode 100644 index 0000000..7e072ca --- /dev/null +++ b/src/entities/board.py @@ -0,0 +1,16 @@ +from utils.uid import get_unique_id + +class Board(object): + + def __init__(self, name): + + self.id = get_unique_id() + self.name = name + self.privacy = "PUBLIC" + self.url = "https://trello.com/" + self.id + self.members = [] + self.lists = [] + + def json(self): + return self.__dict__ + diff --git a/src/entities/card.py b/src/entities/card.py new file mode 100644 index 0000000..7519a2c --- /dev/null +++ b/src/entities/card.py @@ -0,0 +1,12 @@ +from utils.uid import get_unique_id + +class Card(object): + + def __init__(self, name, description, assigned_user): + + self.id = get_unique_id + self.name = name + self.description = description + self.assigned_user = assigned_user + + diff --git a/src/entities/list.py b/src/entities/list.py new file mode 100644 index 0000000..85cb51e --- /dev/null +++ b/src/entities/list.py @@ -0,0 +1,9 @@ +from utils.uid import get_unique_id + +class List(object): + + def __init__(self, name): + + self.id = get_unique_id + self.name = name + self.cards = [] diff --git a/src/entities/user.py b/src/entities/user.py new file mode 100644 index 0000000..a190279 --- /dev/null +++ b/src/entities/user.py @@ -0,0 +1,14 @@ +from utils.uid import get_unique_id + +class User(object): + + def __init__(self, name, email): + + # Initialize the User + self.id = get_unique_id + self.name = name + self.email = email + + + + diff --git a/src/trello.py b/src/trello.py new file mode 100644 index 0000000..d4cfcc6 --- /dev/null +++ b/src/trello.py @@ -0,0 +1,168 @@ +from entities import user, board, list, card +import pdb + +class Manager(object): + def __init__(self): + + # initialize stuff here + self.boards = [] + self.users = [] + self.lists = [] + self.cards = [] + + def process_main_input(self, main_input): + + tokens = main_input.split(" ") + + if tokens[0] == "SHOW": + self.show(tokens[1:]) + + if tokens[0] == "BOARD": + self.process_board_input(tokens[1:]) + + if tokens[0] == "LIST": + self.process_list_input(tokens[1:]) + + if tokens[0] == "CARD": + self.process_card_input(tokens[1:]) + + def show(self, input_data): + + if len(input_data) == 0: + res = [] + for board in self.boards: + res.append(board.json()) + + print(res) + + else: + input_type_to_show = input_data[0] + input_type_id = input_data[1] + + if input_type_to_show == "BOARD": + self.show_board(input_type_id) + + if input_type_to_show == "CARD": + self.show_card(input_type_id) + + if input_type_to_show == "LIST": + self.show_list(input_type_id) + + def show_board(self, id): + # TODO + pass + + def show_card(self, id): + # TODO + pass + + def show_list(self, id): + # TODO + pass + + def process_board_input(self, input_data): + id_or_command = input_data[0] + + if id_or_command == "CREATE": + self.create_board(input_data[1:]) + else: + self.modify_board(input_data) + + def create_board(self, properties): + board_name = properties[0] + new_board = board.Board(board_name) + self.boards.append(new_board) + print("Created Board : " + new_board.id) + + + def modify_board(self, properties): + + if len(properties) < 3: + print("Incorrect params for Board.") + return + + id, key, val = properties + + board = self.get_board_by_id(id) + + if board is None: + print("Board with id : " + id + " does not exist.") + return + + if key.upper() == "NAME": + new_name = val + board.name = new_name + print("Name updated") + + elif key.upper() == "PRIVACY": + new_privacy = val + board.privacy = new_privacy + print("Privacy updated") + + else: + print("Incorrect param") + return + + print(board.json()) + return + + def get_board_by_id(self, id): + for board in self.boards: + if board.id == id: + return board + return None + + def process_list_input(self, input_data): + id_or_command = input_data[0] + + if id_or_command == "CREATE": + self.create_list(input_data[1:]) + else: + self.modify_list(input_data[1:]) + + def create_list(self, properties): + # TODO + pass + + def modify_list(self, properties): + # TODO + pass + + def process_card_input(self, input_data): + id_or_command = input_data[0] + + if id_or_command == "CREATE": + self.create_card(input_data[1:]) + else: + self.modify_card(input_data[1:]) + + def create_card(self, properties): + # TODO + pass + + def modify_card(self, properties): + # TODO + pass + + +if __name__ == "__main__": + m = Manager() + main_input = None + + # Initialize with some Data + m.process_main_input("SHOW") + m.process_main_input("BOARD CREATE board1") + + while True: + + main_input = str(input("Enter Input : ")) + if main_input == "QUIT": + break + + m.process_main_input(main_input) + + print("Exiting.") + + + + diff --git a/src/utils/__pycache__/uid.cpython-37.pyc b/src/utils/__pycache__/uid.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..327adf9f5740446f78a3c1b5adda056d7ab8f020 GIT binary patch literal 286 zcmYLDF^XrTd`6o(?#0)t6{9iyYae;kzerL>=7M!P%qD2h5j(7zvF3H6&ZFL)$|RHjRWfJ{LO=%N1uDML1gIJnaUW^2bUxT`Uh zalsW_*cEmj?Xp?y*MYSX)0X32?Qg~RALxMg8v5_^r4ib2o!LA)@`*6}swk Date: Tue, 21 Jan 2020 00:41:58 +0530 Subject: [PATCH 3/5] Updated Readme --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7575080..7455f5f 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # mock-machine-coding-3 : Trello -Original Problem statement: [https://workattech.github.io/mock-machine-coding-3/](https://workattech.github.io/mock-machine-coding-3/). +Whats working : + +- SHOW +- BOARD CREATE +- BOARD name +- BOARD privacy How to run @@ -10,3 +15,4 @@ cd mock-machine-coding-3/src python trello.py ``` +Original Problem statement: [https://workattech.github.io/mock-machine-coding-3/](https://workattech.github.io/mock-machine-coding-3/). From 757fe31b2797a7fcfcec53366b3c8b60fb784de0 Mon Sep 17 00:00:00 2001 From: Raunaq Date: Tue, 21 Jan 2020 00:43:06 +0530 Subject: [PATCH 4/5] Updated Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7455f5f..b910446 100755 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Whats working : - SHOW - BOARD CREATE -- BOARD name -- BOARD privacy +- BOARD `id` name `name` +- BOARD `id` privacy `privacy` How to run From 1bda882e47f63fe2a1386614299954595dbdcb04 Mon Sep 17 00:00:00 2001 From: Raunaq Date: Tue, 21 Jan 2020 00:44:13 +0530 Subject: [PATCH 5/5] Updated Readme --- src/README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/README.md b/src/README.md index 730dd0b..b910446 100644 --- a/src/README.md +++ b/src/README.md @@ -1,9 +1,18 @@ -# Machine Coding - Trello +# mock-machine-coding-3 : Trello + +Whats working : + +- SHOW +- BOARD CREATE +- BOARD `id` name `name` +- BOARD `id` privacy `privacy` How to run -```buildoutcfg +``` git clone https://github.com/raunaqness/mock-machine-coding-3/tree/trello-python -cd mock-machine-coding-3 +cd mock-machine-coding-3/src python trello.py -``` \ No newline at end of file +``` + +Original Problem statement: [https://workattech.github.io/mock-machine-coding-3/](https://workattech.github.io/mock-machine-coding-3/).