{"action":"created","comment":{"url":"https://api.github.com/repos/danlapko/SD/pulls/comments/189457650","pull_request_review_id":121642468,"id":189457650,"diff_hunk":"@@ -0,0 +1,514 @@\n+import os\n+import sys\n+import subprocess\n+from collections import deque\n+from pathlib import Path\n+import heapq\n+\n+\n+class Lexer:\n+    '''\n+    You should first launch instance of lexer on inputString\n+    from console to proceed all occurrences of variables from environment.\n+    '''\n+\n+    def __init__(self):\n+        self.defaultInitilizate()\n+\n+    def show(self):\n+        '''\n+        :return: result of last processed string by this instance\n+        '''\n+        return self.lexerOut\n+\n+    def defaultInitilizate(self):\n+        '''\n+        I am not sure that this method have right to exist but anyway.\n+        Set default state for instance of Lexer\n+        '''\n+        self.lexerOut = \"\"\n+        self.skipMode = False\n+        self.replaceMode = False\n+        self.curNameOfVariables = \"\"\n+\n+    def launch(self, userInput):\n+        '''\n+        Take string and replace all occurrences of $name.\n+        name could include alphabet symbols, numbers, all kind of\n+        special symbols like !@#$%^&*())_+. Separator for name are\n+        space, ', '', $\n+        :param userInput: String\n+        :return: String\n+        '''\n+        self.defaultInitilizate()\n+        for character in userInput:\n+            if self.skipMode:  # just skip everything inside of ' '\n+                if character == '\\'':\n+                    self.skipMode = False\n+\n+                self.lexerOut += character\n+                continue\n+\n+            def dump():\n+                '''\n+                Service function. Change variable on it value.\n+                '''\n+                if self.curNameOfVariables in variabls:\n+                    self.lexerOut += variabls[self.curNameOfVariables]\n+                self.curNameOfVariables = \"\"\n+                self.replaceMode = False\n+\n+            if not character.isspace():\n+                # get name of variable until next separator\n+                if self.replaceMode:\n+                    if character == '$':\n+                        dump()\n+                        self.replaceMode = True\n+                    else:\n+                        if character == '\\'':\n+                            dump()\n+                            self.skipMode = True\n+                            self.lexerOut += character\n+                        else:\n+                            self.curNameOfVariables += character\n+                else:\n+                    if character == '$':\n+                        self.replaceMode = True\n+                    else:\n+                        if character == '\\'':\n+                            self.skipMode = True\n+                        self.lexerOut += character\n+            else:\n+                if self.replaceMode:\n+                    dump()\n+                self.lexerOut += character\n+        if self.replaceMode:\n+            if self.curNameOfVariables in variabls:\n+                self.lexerOut += variabls[self.curNameOfVariables]\n+            self.replaceMode = False\n+        if self.skipMode:\n+            self.skipMode = False\n+            raise Exception(\"There is not closing '\")\n+\n+\n+class Token:\n+    '''\n+    Abstarct class for diagram\n+    '''\n+    pass\n+\n+\n+class Arguments(Token):  # not used but might be in next version\n+    pass\n+\n+\n+class Parametrs(Token):  # not used but might be in next version\n+    pass\n+\n+\n+class Command(Token):\n+    \"\"\"\n+    Abstract class for commands\n+    All commands use string as interface for communication\n+    \"\"\"\n+\n+    def __init__(self):\n+        self.argsFromInput = []\n+        self.paramsFromInput = []\n+        self.maxNumberOfArgs = 100\n+        self.minNumberOfArgs = 0\n+        self.listOfSupportedParam = {}\n+\n+    def check(self):\n+        \"\"\"\n+        command check its parameters before launch\n+        \"\"\"\n+        if len(self.argsFromInput) > self.maxNumberOfArgs or len(self.argsFromInput) < self.minNumberOfArgs:\n+            raise Exception(\"Unsupported numbers of args for command {}\".format(self.__class__.__name__))\n+        for param in self.paramsFromInput:\n+            if param not in self.listOfSupportedParam:\n+                raise Exception(\"Unsupported params for command {}\".format(self.__class__.__name__))\n+\n+    def run(self):\n+        raise Exception(\"Unimplemented Command\")\n+\n+\n+class Exit(Command):\n+    def __init__(self):\n+        super(Exit, self).__init__()\n+        self.maxNumberOfArgs = 0\n+        self.minNumberOfArgs = 0\n+\n+    def run(self):\n+        self.check()\n+        global run\n+        run = False\n+\n+\n+class Cat(Command):\n+    \"\"\"\n+    Cat can only open files by relative name from current directory\n+    \"\"\"\n+\n+    def __init__(self):\n+        super(Cat, self).__init__()\n+\n+    def run(self):\n+        self.check()\n+        numberOfRow = 0\n+        outputString = \"\"\n+\n+        for fileName in self.argsFromInput:\n+            file_in = open(curDir + \"/\" + fileName, \"r\")\n+            for line in file_in.read().splitlines():\n+                numberOfRow = numberOfRow + 1\n+                outputString += '{0}. {1}\\n'.format(numberOfRow, line)\n+            file_in.close()\n+\n+        return outputString\n+\n+\n+class Wc(Command):\n+    '''\n+    Take string for evaluations\n+    '''\n+\n+    def __init__(self):\n+        super(Wc, self).__init__()\n+\n+    def run(self):\n+        self.check()\n+        numberOfLine, numberOfChar, numberOfByte = 0, 0, 0\n+        outputString = \"0 0 0\\n\"\n+        for text in self.argsFromInput:\n+            lineInFile = len(text.splitlines())\n+            charInFile = len(text.split())\n+            byteInFile = sys.getsizeof(text) - 49\n+            outputString += (\"{} {} {}\\n\".format(lineInFile, charInFile, byteInFile))\n+            numberOfLine, numberOfChar, numberOfByte = numberOfLine + lineInFile, numberOfChar + charInFile, numberOfByte + byteInFile\n+\n+        if len(self.argsFromInput) > 1:\n+            outputString += (\"{} {} {} {}\\n\".format(numberOfLine, numberOfChar, numberOfByte, \"total\"))\n+        return outputString\n+\n+\n+class Echo(Command):\n+    '''\n+    Just remove '' and \"\"\n+    '''\n+\n+    def run(self):\n+        self.check()\n+        output = \"\"\n+        for word in self.argsFromInput:\n+            output += word\n+            output += \" \"\n+        output += \"\\n\"\n+        return output\n+\n+\n+class Pwd(Command):\n+    def __init__(self):\n+        super(Pwd, self).__init__()\n+        self.maxNumberOfArgs = 0\n+        self.minNumberOfArgs = 0\n+\n+    def run(self):\n+        self.check()\n+        return curDir + \"\\n\"\n+\n+\n+class Assignment(Command):\n+    '''\n+    Always execute first.\n+    '''\n+\n+    def __init__(self):\n+        super(Assignment, self).__init__()\n+        self.maxNumberOfArgs = 2\n+        self.minNumberOfArgs = 2\n+\n+    def run(self):\n+        self.check()\n+        variabls[self.argsFromInput[0]] = self.argsFromInput[1]\n+\n+\n+class Cd(Command):\n+    def __init__(self):\n+        super(Cd, self).__init__()\n+        self.maxNumberOfArgs = 1\n+        self.minNumberOfArgs = 0\n+\n+    def run(self):\n+        self.check()\n+\n+        global curDir\n+        cur_path = Path(curDir)\n+\n+        if len(self.argsFromInput) == 0:\n+            cur_path = Path.home()\n+        else:\n+            path_to = Path(self.argsFromInput[0])\n+\n+            if path_to.is_absolute():\n+                cur_path = path_to\n+            else:\n+                cur_path = cur_path.joinpath(path_to)\n+\n+        os.chdir(str(cur_path.absolute()))\n+        curDir = str(Path.cwd())\n+\n+\n+class Ls(Command):\n+    \"\"\"\n+    Supports wildcard '*'","path":"CLI/cli.py","position":264,"original_position":264,"commit_id":"70a67d8c0875418d9ca29190d92cff375271456c","original_commit_id":"70a67d8c0875418d9ca29190d92cff375271456c","user":{"login":"yurii-litvinov","id":706768,"avatar_url":"https://avatars3.githubusercontent.com/u/706768?v=4","gravatar_id":"","url":"https://api.github.com/users/yurii-litvinov","html_url":"https://github.com/yurii-litvinov","followers_url":"https://api.github.com/users/yurii-litvinov/followers","following_url":"https://api.github.com/users/yurii-litvinov/following{/other_user}","gists_url":"https://api.github.com/users/yurii-litvinov/gists{/gist_id}","starred_url":"https://api.github.com/users/yurii-litvinov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yurii-litvinov/subscriptions","organizations_url":"https://api.github.com/users/yurii-litvinov/orgs","repos_url":"https://api.github.com/users/yurii-litvinov/repos","events_url":"https://api.github.com/users/yurii-litvinov/events{/privacy}","received_events_url":"https://api.github.com/users/yurii-litvinov/received_events","type":"User","site_admin":false},"body":"Нужен более подробный комментарий :)","created_at":"2018-05-20T11:44:58Z","updated_at":"2018-05-20T12:00:32Z","html_url":"https://github.com/danlapko/SD/pull/1#discussion_r189457650","pull_request_url":"https://api.github.com/repos/danlapko/SD/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/danlapko/SD/pulls/comments/189457650"},"html":{"href":"https://github.com/danlapko/SD/pull/1#discussion_r189457650"},"pull_request":{"href":"https://api.github.com/repos/danlapko/SD/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/danlapko/SD/pulls/1","id":181400321,"html_url":"https://github.com/danlapko/SD/pull/1","diff_url":"https://github.com/danlapko/SD/pull/1.diff","patch_url":"https://github.com/danlapko/SD/pull/1.patch","issue_url":"https://api.github.com/repos/danlapko/SD/issues/1","number":1,"state":"open","locked":false,"title":"Ls cd","user":{"login":"danlapko","id":13206905,"avatar_url":"https://avatars3.githubusercontent.com/u/13206905?v=4","gravatar_id":"","url":"https://api.github.com/users/danlapko","html_url":"https://github.com/danlapko","followers_url":"https://api.github.com/users/danlapko/followers","following_url":"https://api.github.com/users/danlapko/following{/other_user}","gists_url":"https://api.github.com/users/danlapko/gists{/gist_id}","starred_url":"https://api.github.com/users/danlapko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danlapko/subscriptions","organizations_url":"https://api.github.com/users/danlapko/orgs","repos_url":"https://api.github.com/users/danlapko/repos","events_url":"https://api.github.com/users/danlapko/events{/privacy}","received_events_url":"https://api.github.com/users/danlapko/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-13T06:52:38Z","updated_at":"2018-05-20T12:00:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d3482cf25737529901709af0537f5f9c77dee8ea","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/danlapko/SD/pulls/1/commits","review_comments_url":"https://api.github.com/repos/danlapko/SD/pulls/1/comments","review_comment_url":"https://api.github.com/repos/danlapko/SD/pulls/comments{/number}","comments_url":"https://api.github.com/repos/danlapko/SD/issues/1/comments","statuses_url":"https://api.github.com/repos/danlapko/SD/statuses/70a67d8c0875418d9ca29190d92cff375271456c","head":{"label":"danlapko:ls_cd","ref":"ls_cd","sha":"70a67d8c0875418d9ca29190d92cff375271456c","user":{"login":"danlapko","id":13206905,"avatar_url":"https://avatars3.githubusercontent.com/u/13206905?v=4","gravatar_id":"","url":"https://api.github.com/users/danlapko","html_url":"https://github.com/danlapko","followers_url":"https://api.github.com/users/danlapko/followers","following_url":"https://api.github.com/users/danlapko/following{/other_user}","gists_url":"https://api.github.com/users/danlapko/gists{/gist_id}","starred_url":"https://api.github.com/users/danlapko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danlapko/subscriptions","organizations_url":"https://api.github.com/users/danlapko/orgs","repos_url":"https://api.github.com/users/danlapko/repos","events_url":"https://api.github.com/users/danlapko/events{/privacy}","received_events_url":"https://api.github.com/users/danlapko/received_events","type":"User","site_admin":false},"repo":{"id":129360417,"name":"SD","full_name":"danlapko/SD","owner":{"login":"danlapko","id":13206905,"avatar_url":"https://avatars3.githubusercontent.com/u/13206905?v=4","gravatar_id":"","url":"https://api.github.com/users/danlapko","html_url":"https://github.com/danlapko","followers_url":"https://api.github.com/users/danlapko/followers","following_url":"https://api.github.com/users/danlapko/following{/other_user}","gists_url":"https://api.github.com/users/danlapko/gists{/gist_id}","starred_url":"https://api.github.com/users/danlapko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danlapko/subscriptions","organizations_url":"https://api.github.com/users/danlapko/orgs","repos_url":"https://api.github.com/users/danlapko/repos","events_url":"https://api.github.com/users/danlapko/events{/privacy}","received_events_url":"https://api.github.com/users/danlapko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danlapko/SD","description":null,"fork":true,"url":"https://api.github.com/repos/danlapko/SD","forks_url":"https://api.github.com/repos/danlapko/SD/forks","keys_url":"https://api.github.com/repos/danlapko/SD/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danlapko/SD/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danlapko/SD/teams","hooks_url":"https://api.github.com/repos/danlapko/SD/hooks","issue_events_url":"https://api.github.com/repos/danlapko/SD/issues/events{/number}","events_url":"https://api.github.com/repos/danlapko/SD/events","assignees_url":"https://api.github.com/repos/danlapko/SD/assignees{/user}","branches_url":"https://api.github.com/repos/danlapko/SD/branches{/branch}","tags_url":"https://api.github.com/repos/danlapko/SD/tags","blobs_url":"https://api.github.com/repos/danlapko/SD/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danlapko/SD/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danlapko/SD/git/refs{/sha}","trees_url":"https://api.github.com/repos/danlapko/SD/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danlapko/SD/statuses/{sha}","languages_url":"https://api.github.com/repos/danlapko/SD/languages","stargazers_url":"https://api.github.com/repos/danlapko/SD/stargazers","contributors_url":"https://api.github.com/repos/danlapko/SD/contributors","subscribers_url":"https://api.github.com/repos/danlapko/SD/subscribers","subscription_url":"https://api.github.com/repos/danlapko/SD/subscription","commits_url":"https://api.github.com/repos/danlapko/SD/commits{/sha}","git_commits_url":"https://api.github.com/repos/danlapko/SD/git/commits{/sha}","comments_url":"https://api.github.com/repos/danlapko/SD/comments{/number}","issue_comment_url":"https://api.github.com/repos/danlapko/SD/issues/comments{/number}","contents_url":"https://api.github.com/repos/danlapko/SD/contents/{+path}","compare_url":"https://api.github.com/repos/danlapko/SD/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danlapko/SD/merges","archive_url":"https://api.github.com/repos/danlapko/SD/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danlapko/SD/downloads","issues_url":"https://api.github.com/repos/danlapko/SD/issues{/number}","pulls_url":"https://api.github.com/repos/danlapko/SD/pulls{/number}","milestones_url":"https://api.github.com/repos/danlapko/SD/milestones{/number}","notifications_url":"https://api.github.com/repos/danlapko/SD/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danlapko/SD/labels{/name}","releases_url":"https://api.github.com/repos/danlapko/SD/releases{/id}","deployments_url":"https://api.github.com/repos/danlapko/SD/deployments","created_at":"2018-04-13T06:44:55Z","updated_at":"2018-04-13T06:44:57Z","pushed_at":"2018-04-13T16:25:22Z","git_url":"git://github.com/danlapko/SD.git","ssh_url":"git@github.com:danlapko/SD.git","clone_url":"https://github.com/danlapko/SD.git","svn_url":"https://github.com/danlapko/SD","homepage":null,"size":46,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"danlapko:master","ref":"master","sha":"a64c8c322b85c28fdb68846e7f838a8eee3fc0fb","user":{"login":"danlapko","id":13206905,"avatar_url":"https://avatars3.githubusercontent.com/u/13206905?v=4","gravatar_id":"","url":"https://api.github.com/users/danlapko","html_url":"https://github.com/danlapko","followers_url":"https://api.github.com/users/danlapko/followers","following_url":"https://api.github.com/users/danlapko/following{/other_user}","gists_url":"https://api.github.com/users/danlapko/gists{/gist_id}","starred_url":"https://api.github.com/users/danlapko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danlapko/subscriptions","organizations_url":"https://api.github.com/users/danlapko/orgs","repos_url":"https://api.github.com/users/danlapko/repos","events_url":"https://api.github.com/users/danlapko/events{/privacy}","received_events_url":"https://api.github.com/users/danlapko/received_events","type":"User","site_admin":false},"repo":{"id":129360417,"name":"SD","full_name":"danlapko/SD","owner":{"login":"danlapko","id":13206905,"avatar_url":"https://avatars3.githubusercontent.com/u/13206905?v=4","gravatar_id":"","url":"https://api.github.com/users/danlapko","html_url":"https://github.com/danlapko","followers_url":"https://api.github.com/users/danlapko/followers","following_url":"https://api.github.com/users/danlapko/following{/other_user}","gists_url":"https://api.github.com/users/danlapko/gists{/gist_id}","starred_url":"https://api.github.com/users/danlapko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danlapko/subscriptions","organizations_url":"https://api.github.com/users/danlapko/orgs","repos_url":"https://api.github.com/users/danlapko/repos","events_url":"https://api.github.com/users/danlapko/events{/privacy}","received_events_url":"https://api.github.com/users/danlapko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danlapko/SD","description":null,"fork":true,"url":"https://api.github.com/repos/danlapko/SD","forks_url":"https://api.github.com/repos/danlapko/SD/forks","keys_url":"https://api.github.com/repos/danlapko/SD/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danlapko/SD/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danlapko/SD/teams","hooks_url":"https://api.github.com/repos/danlapko/SD/hooks","issue_events_url":"https://api.github.com/repos/danlapko/SD/issues/events{/number}","events_url":"https://api.github.com/repos/danlapko/SD/events","assignees_url":"https://api.github.com/repos/danlapko/SD/assignees{/user}","branches_url":"https://api.github.com/repos/danlapko/SD/branches{/branch}","tags_url":"https://api.github.com/repos/danlapko/SD/tags","blobs_url":"https://api.github.com/repos/danlapko/SD/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danlapko/SD/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danlapko/SD/git/refs{/sha}","trees_url":"https://api.github.com/repos/danlapko/SD/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danlapko/SD/statuses/{sha}","languages_url":"https://api.github.com/repos/danlapko/SD/languages","stargazers_url":"https://api.github.com/repos/danlapko/SD/stargazers","contributors_url":"https://api.github.com/repos/danlapko/SD/contributors","subscribers_url":"https://api.github.com/repos/danlapko/SD/subscribers","subscription_url":"https://api.github.com/repos/danlapko/SD/subscription","commits_url":"https://api.github.com/repos/danlapko/SD/commits{/sha}","git_commits_url":"https://api.github.com/repos/danlapko/SD/git/commits{/sha}","comments_url":"https://api.github.com/repos/danlapko/SD/comments{/number}","issue_comment_url":"https://api.github.com/repos/danlapko/SD/issues/comments{/number}","contents_url":"https://api.github.com/repos/danlapko/SD/contents/{+path}","compare_url":"https://api.github.com/repos/danlapko/SD/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danlapko/SD/merges","archive_url":"https://api.github.com/repos/danlapko/SD/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danlapko/SD/downloads","issues_url":"https://api.github.com/repos/danlapko/SD/issues{/number}","pulls_url":"https://api.github.com/repos/danlapko/SD/pulls{/number}","milestones_url":"https://api.github.com/repos/danlapko/SD/milestones{/number}","notifications_url":"https://api.github.com/repos/danlapko/SD/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danlapko/SD/labels{/name}","releases_url":"https://api.github.com/repos/danlapko/SD/releases{/id}","deployments_url":"https://api.github.com/repos/danlapko/SD/deployments","created_at":"2018-04-13T06:44:55Z","updated_at":"2018-04-13T06:44:57Z","pushed_at":"2018-04-13T16:25:22Z","git_url":"git://github.com/danlapko/SD.git","ssh_url":"git@github.com:danlapko/SD.git","clone_url":"https://github.com/danlapko/SD.git","svn_url":"https://github.com/danlapko/SD","homepage":null,"size":46,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/danlapko/SD/pulls/1"},"html":{"href":"https://github.com/danlapko/SD/pull/1"},"issue":{"href":"https://api.github.com/repos/danlapko/SD/issues/1"},"comments":{"href":"https://api.github.com/repos/danlapko/SD/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/danlapko/SD/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/danlapko/SD/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/danlapko/SD/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/danlapko/SD/statuses/70a67d8c0875418d9ca29190d92cff375271456c"}},"author_association":"OWNER"}}
{"actor":{"display_login":"yurii-litvinov"}}