{"action":"created","comment":{"url":"https://api.github.com/repos/claytron/ever2simple/pulls/comments/63189367","id":63189367,"diff_hunk":"@@ -100,4 +108,19 @@ def _convert_json(self, notes):\n         if self.simple_filename is None:\n             sys.stdout.write(json.dumps(notes))\n         else:\n-            json.dump(notes, self.simple_filename)\n+            with open(self.simple_filename, 'w') as output_file:\n+                json.dump(notes, output_file)\n+\n+    def _convert_dir(self, notes):\n+        if self.simple_filename is None:\n+            sys.stdout.write(json.dumps(notes))\n+        else:\n+            if os.path.exists(self.simple_filename) and not os.path.isdir(self.simple_filename):\n+                print '\"%s\" exists but is not a directory. %s' % self.simple_filename\n+                sys.exit(1)\n+            elif not os.path.exists(self.simple_filename):\n+                os.makedirs(self.simple_filename)\n+            for i, note in enumerate(notes):\n+                output_file_path = os.path.join(self.simple_filename, str(i) + '.txt')","path":"ever2simple/converter.py","position":53,"original_position":53,"commit_id":"ae9063bc58bc1f0a7c231b8b0120a02f789e3bf2","original_commit_id":"ae9063bc58bc1f0a7c231b8b0120a02f789e3bf2","user":{"login":"tiangolo","id":1326112,"avatar_url":"https://avatars.githubusercontent.com/u/1326112?v=3","gravatar_id":"","url":"https://api.github.com/users/tiangolo","html_url":"https://github.com/tiangolo","followers_url":"https://api.github.com/users/tiangolo/followers","following_url":"https://api.github.com/users/tiangolo/following{/other_user}","gists_url":"https://api.github.com/users/tiangolo/gists{/gist_id}","starred_url":"https://api.github.com/users/tiangolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiangolo/subscriptions","organizations_url":"https://api.github.com/users/tiangolo/orgs","repos_url":"https://api.github.com/users/tiangolo/repos","events_url":"https://api.github.com/users/tiangolo/events{/privacy}","received_events_url":"https://api.github.com/users/tiangolo/received_events","type":"User","site_admin":false},"body":"I thought about that first, but I found the following issues:\r\n\r\n* It would be needed to parse the `note['content']` to read the first line, taking the markdown out (to just have the title without the `#`)\r\n* The title could have characters not allowed by the OS (depending on the OS), not allowing to create the file or creating a misbehaving file.\r\n* The title could lead to security issues\r\n  * These two things could probably be solved using [`werkzeug.utils.secure_filename`](http://werkzeug.pocoo.org/docs/0.11/utils/#werkzeug.utils.secure_filename), but that would mean adding another dependency\r\n* As Simplenote doesn't read the file title, it seemed enough for me (and easier / faster) to have just numbered files.\r\n* I also thought that one way to get the notes named by the titles would be to:\r\n  * Unlink the Dropbox account\r\n  * Remove the files in the `Simplenote` directory\r\n  * Re-enable Drobox sync (Simplenote would then sync and name the notes using their titles)\r\n* In case there were two notes with the same title, one would override the other. So it would be needed to add some book keeping of the titles already used, etc.\r\n* Also, I wasn't sure you would check the PR (that you certainly did :smile: ), so I just focused on my own simple use case first.\r\n\r\nWhat's your opinion? Do you think it's worthwhile the effort of parsing the title, adding more dependencies, book keeping of names, etc?","created_at":"2016-05-13T14:14:44Z","updated_at":"2016-05-13T14:14:44Z","html_url":"https://github.com/claytron/ever2simple/pull/5#discussion_r63189367","pull_request_url":"https://api.github.com/repos/claytron/ever2simple/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/claytron/ever2simple/pulls/comments/63189367"},"html":{"href":"https://github.com/claytron/ever2simple/pull/5#discussion_r63189367"},"pull_request":{"href":"https://api.github.com/repos/claytron/ever2simple/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/claytron/ever2simple/pulls/5","id":69252106,"html_url":"https://github.com/claytron/ever2simple/pull/5","diff_url":"https://github.com/claytron/ever2simple/pull/5.diff","patch_url":"https://github.com/claytron/ever2simple/pull/5.patch","issue_url":"https://api.github.com/repos/claytron/ever2simple/issues/5","number":5,"state":"open","locked":false,"title":"Enable exporting to a directory as txt files","user":{"login":"tiangolo","id":1326112,"avatar_url":"https://avatars.githubusercontent.com/u/1326112?v=3","gravatar_id":"","url":"https://api.github.com/users/tiangolo","html_url":"https://github.com/tiangolo","followers_url":"https://api.github.com/users/tiangolo/followers","following_url":"https://api.github.com/users/tiangolo/following{/other_user}","gists_url":"https://api.github.com/users/tiangolo/gists{/gist_id}","starred_url":"https://api.github.com/users/tiangolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiangolo/subscriptions","organizations_url":"https://api.github.com/users/tiangolo/orgs","repos_url":"https://api.github.com/users/tiangolo/repos","events_url":"https://api.github.com/users/tiangolo/events{/privacy}","received_events_url":"https://api.github.com/users/tiangolo/received_events","type":"User","site_admin":false},"body":"Enable exporting to a directory as `*.txt` Markdown files, as currently, the only way to import is by asking for Dropbox synchronization and adding the notes as text files to the Simplenote directory in Dropbox.\r\n\r\nUpdate the instructions in the README to include that.\r\n\r\nInclude the fix done by @austinjp for dates as it wasn't working without it.\r\n\r\nUpdate and improve the command line interface, allowing to export to CSV, JSON and a directory of Markdown files, additionally to outputting to the `stdout`.","created_at":"2016-05-07T20:22:44Z","updated_at":"2016-05-13T14:14:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a1fcacc6b40d28c11b07f37c394e6f539da14ed","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/claytron/ever2simple/pulls/5/commits","review_comments_url":"https://api.github.com/repos/claytron/ever2simple/pulls/5/comments","review_comment_url":"https://api.github.com/repos/claytron/ever2simple/pulls/comments{/number}","comments_url":"https://api.github.com/repos/claytron/ever2simple/issues/5/comments","statuses_url":"https://api.github.com/repos/claytron/ever2simple/statuses/ae9063bc58bc1f0a7c231b8b0120a02f789e3bf2","head":{"label":"tiangolo:master","ref":"master","sha":"ae9063bc58bc1f0a7c231b8b0120a02f789e3bf2","user":{"login":"tiangolo","id":1326112,"avatar_url":"https://avatars.githubusercontent.com/u/1326112?v=3","gravatar_id":"","url":"https://api.github.com/users/tiangolo","html_url":"https://github.com/tiangolo","followers_url":"https://api.github.com/users/tiangolo/followers","following_url":"https://api.github.com/users/tiangolo/following{/other_user}","gists_url":"https://api.github.com/users/tiangolo/gists{/gist_id}","starred_url":"https://api.github.com/users/tiangolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiangolo/subscriptions","organizations_url":"https://api.github.com/users/tiangolo/orgs","repos_url":"https://api.github.com/users/tiangolo/repos","events_url":"https://api.github.com/users/tiangolo/events{/privacy}","received_events_url":"https://api.github.com/users/tiangolo/received_events","type":"User","site_admin":false},"repo":{"id":58276884,"name":"ever2simple","full_name":"tiangolo/ever2simple","owner":{"login":"tiangolo","id":1326112,"avatar_url":"https://avatars.githubusercontent.com/u/1326112?v=3","gravatar_id":"","url":"https://api.github.com/users/tiangolo","html_url":"https://github.com/tiangolo","followers_url":"https://api.github.com/users/tiangolo/followers","following_url":"https://api.github.com/users/tiangolo/following{/other_user}","gists_url":"https://api.github.com/users/tiangolo/gists{/gist_id}","starred_url":"https://api.github.com/users/tiangolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiangolo/subscriptions","organizations_url":"https://api.github.com/users/tiangolo/orgs","repos_url":"https://api.github.com/users/tiangolo/repos","events_url":"https://api.github.com/users/tiangolo/events{/privacy}","received_events_url":"https://api.github.com/users/tiangolo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tiangolo/ever2simple","description":"Migrate from evernote to simplenote with markdown formatting","fork":true,"url":"https://api.github.com/repos/tiangolo/ever2simple","forks_url":"https://api.github.com/repos/tiangolo/ever2simple/forks","keys_url":"https://api.github.com/repos/tiangolo/ever2simple/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tiangolo/ever2simple/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tiangolo/ever2simple/teams","hooks_url":"https://api.github.com/repos/tiangolo/ever2simple/hooks","issue_events_url":"https://api.github.com/repos/tiangolo/ever2simple/issues/events{/number}","events_url":"https://api.github.com/repos/tiangolo/ever2simple/events","assignees_url":"https://api.github.com/repos/tiangolo/ever2simple/assignees{/user}","branches_url":"https://api.github.com/repos/tiangolo/ever2simple/branches{/branch}","tags_url":"https://api.github.com/repos/tiangolo/ever2simple/tags","blobs_url":"https://api.github.com/repos/tiangolo/ever2simple/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tiangolo/ever2simple/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tiangolo/ever2simple/git/refs{/sha}","trees_url":"https://api.github.com/repos/tiangolo/ever2simple/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tiangolo/ever2simple/statuses/{sha}","languages_url":"https://api.github.com/repos/tiangolo/ever2simple/languages","stargazers_url":"https://api.github.com/repos/tiangolo/ever2simple/stargazers","contributors_url":"https://api.github.com/repos/tiangolo/ever2simple/contributors","subscribers_url":"https://api.github.com/repos/tiangolo/ever2simple/subscribers","subscription_url":"https://api.github.com/repos/tiangolo/ever2simple/subscription","commits_url":"https://api.github.com/repos/tiangolo/ever2simple/commits{/sha}","git_commits_url":"https://api.github.com/repos/tiangolo/ever2simple/git/commits{/sha}","comments_url":"https://api.github.com/repos/tiangolo/ever2simple/comments{/number}","issue_comment_url":"https://api.github.com/repos/tiangolo/ever2simple/issues/comments{/number}","contents_url":"https://api.github.com/repos/tiangolo/ever2simple/contents/{+path}","compare_url":"https://api.github.com/repos/tiangolo/ever2simple/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tiangolo/ever2simple/merges","archive_url":"https://api.github.com/repos/tiangolo/ever2simple/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tiangolo/ever2simple/downloads","issues_url":"https://api.github.com/repos/tiangolo/ever2simple/issues{/number}","pulls_url":"https://api.github.com/repos/tiangolo/ever2simple/pulls{/number}","milestones_url":"https://api.github.com/repos/tiangolo/ever2simple/milestones{/number}","notifications_url":"https://api.github.com/repos/tiangolo/ever2simple/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tiangolo/ever2simple/labels{/name}","releases_url":"https://api.github.com/repos/tiangolo/ever2simple/releases{/id}","deployments_url":"https://api.github.com/repos/tiangolo/ever2simple/deployments","created_at":"2016-05-07T17:27:50Z","updated_at":"2016-05-07T17:27:50Z","pushed_at":"2016-05-07T20:16:36Z","git_url":"git://github.com/tiangolo/ever2simple.git","ssh_url":"git@github.com:tiangolo/ever2simple.git","clone_url":"https://github.com/tiangolo/ever2simple.git","svn_url":"https://github.com/tiangolo/ever2simple","homepage":"","size":20,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"claytron:master","ref":"master","sha":"153a7378caa75e617473d3fdb748acbd289fd264","user":{"login":"claytron","id":41368,"avatar_url":"https://avatars.githubusercontent.com/u/41368?v=3","gravatar_id":"","url":"https://api.github.com/users/claytron","html_url":"https://github.com/claytron","followers_url":"https://api.github.com/users/claytron/followers","following_url":"https://api.github.com/users/claytron/following{/other_user}","gists_url":"https://api.github.com/users/claytron/gists{/gist_id}","starred_url":"https://api.github.com/users/claytron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claytron/subscriptions","organizations_url":"https://api.github.com/users/claytron/orgs","repos_url":"https://api.github.com/users/claytron/repos","events_url":"https://api.github.com/users/claytron/events{/privacy}","received_events_url":"https://api.github.com/users/claytron/received_events","type":"User","site_admin":false},"repo":{"id":1895906,"name":"ever2simple","full_name":"claytron/ever2simple","owner":{"login":"claytron","id":41368,"avatar_url":"https://avatars.githubusercontent.com/u/41368?v=3","gravatar_id":"","url":"https://api.github.com/users/claytron","html_url":"https://github.com/claytron","followers_url":"https://api.github.com/users/claytron/followers","following_url":"https://api.github.com/users/claytron/following{/other_user}","gists_url":"https://api.github.com/users/claytron/gists{/gist_id}","starred_url":"https://api.github.com/users/claytron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claytron/subscriptions","organizations_url":"https://api.github.com/users/claytron/orgs","repos_url":"https://api.github.com/users/claytron/repos","events_url":"https://api.github.com/users/claytron/events{/privacy}","received_events_url":"https://api.github.com/users/claytron/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/claytron/ever2simple","description":"Migrate from evernote to simplenote with markdown formatting","fork":false,"url":"https://api.github.com/repos/claytron/ever2simple","forks_url":"https://api.github.com/repos/claytron/ever2simple/forks","keys_url":"https://api.github.com/repos/claytron/ever2simple/keys{/key_id}","collaborators_url":"https://api.github.com/repos/claytron/ever2simple/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/claytron/ever2simple/teams","hooks_url":"https://api.github.com/repos/claytron/ever2simple/hooks","issue_events_url":"https://api.github.com/repos/claytron/ever2simple/issues/events{/number}","events_url":"https://api.github.com/repos/claytron/ever2simple/events","assignees_url":"https://api.github.com/repos/claytron/ever2simple/assignees{/user}","branches_url":"https://api.github.com/repos/claytron/ever2simple/branches{/branch}","tags_url":"https://api.github.com/repos/claytron/ever2simple/tags","blobs_url":"https://api.github.com/repos/claytron/ever2simple/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/claytron/ever2simple/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/claytron/ever2simple/git/refs{/sha}","trees_url":"https://api.github.com/repos/claytron/ever2simple/git/trees{/sha}","statuses_url":"https://api.github.com/repos/claytron/ever2simple/statuses/{sha}","languages_url":"https://api.github.com/repos/claytron/ever2simple/languages","stargazers_url":"https://api.github.com/repos/claytron/ever2simple/stargazers","contributors_url":"https://api.github.com/repos/claytron/ever2simple/contributors","subscribers_url":"https://api.github.com/repos/claytron/ever2simple/subscribers","subscription_url":"https://api.github.com/repos/claytron/ever2simple/subscription","commits_url":"https://api.github.com/repos/claytron/ever2simple/commits{/sha}","git_commits_url":"https://api.github.com/repos/claytron/ever2simple/git/commits{/sha}","comments_url":"https://api.github.com/repos/claytron/ever2simple/comments{/number}","issue_comment_url":"https://api.github.com/repos/claytron/ever2simple/issues/comments{/number}","contents_url":"https://api.github.com/repos/claytron/ever2simple/contents/{+path}","compare_url":"https://api.github.com/repos/claytron/ever2simple/compare/{base}...{head}","merges_url":"https://api.github.com/repos/claytron/ever2simple/merges","archive_url":"https://api.github.com/repos/claytron/ever2simple/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/claytron/ever2simple/downloads","issues_url":"https://api.github.com/repos/claytron/ever2simple/issues{/number}","pulls_url":"https://api.github.com/repos/claytron/ever2simple/pulls{/number}","milestones_url":"https://api.github.com/repos/claytron/ever2simple/milestones{/number}","notifications_url":"https://api.github.com/repos/claytron/ever2simple/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/claytron/ever2simple/labels{/name}","releases_url":"https://api.github.com/repos/claytron/ever2simple/releases{/id}","deployments_url":"https://api.github.com/repos/claytron/ever2simple/deployments","created_at":"2011-06-14T18:18:53Z","updated_at":"2016-05-06T05:20:38Z","pushed_at":"2016-05-07T20:22:46Z","git_url":"git://github.com/claytron/ever2simple.git","ssh_url":"git@github.com:claytron/ever2simple.git","clone_url":"https://github.com/claytron/ever2simple.git","svn_url":"https://github.com/claytron/ever2simple","homepage":"","size":108,"stargazers_count":26,"watchers_count":26,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/claytron/ever2simple/pulls/5"},"html":{"href":"https://github.com/claytron/ever2simple/pull/5"},"issue":{"href":"https://api.github.com/repos/claytron/ever2simple/issues/5"},"comments":{"href":"https://api.github.com/repos/claytron/ever2simple/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/claytron/ever2simple/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/claytron/ever2simple/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/claytron/ever2simple/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/claytron/ever2simple/statuses/ae9063bc58bc1f0a7c231b8b0120a02f789e3bf2"}}}}