Permalink
Browse files

Merge branch 'stepler' of https://github.com/VitaliyRodnenko/geeknote

…into stepler
  • Loading branch information...
2 parents e85f584 + 6ff24a6 commit 4c2deb69db6259f7d50c5122683c704fb91cad34 @varche1 varche1 committed Jul 2, 2012
Showing with 246 additions and 176 deletions.
  1. +42 −46 argparser.py
  2. +33 −5 config.py
  3. +11 −8 editor.py
  4. +80 −74 geeknote.py
  5. +4 −1 gnsync.py
  6. +10 −10 oauth.py
  7. +44 −27 out.py
  8. +4 −4 storage.py
  9. +18 −1 tools.py
View
@@ -8,108 +8,107 @@
COMMANDS_DICT = {
# User
"user": {
- "help": "Create note",
+ "help": "Show information about active user.",
"flags": {
- "--full": {"help": "Add tag to note", "value": True, "default": False},
+ "--full": {"help": "Show full information.", "value": True, "default": False},
}
},
"login": {
- "help": "Create note",
+ "help": "Authorize in Evernote.",
},
"logout": {
- "help": "Create note",
+ "help": "Logout from Evernote.",
"flags": {
- "--force": {"help": "Add tag to note", "value": True, "default": False},
+ "--force": {"help": "Don't ask about logging out.", "value": True, "default": False},
}
},
"settings": {
- "help": "Create note",
+ "help": "Show and edit current settings.",
"arguments": {
- "--editor": {"help": "Set system editor", "emptyValue": '#GET#'},
+ "--editor": {"help": "Set the editor, which use to edit and create notes.", "emptyValue": '#GET#'},
}
},
# Notes
"create": {
- "help": "Create note",
+ "help": "Create note in evernote.",
"arguments": {
- "--title": {"help": "Set note title", "required": True},
- "--content": {"help": "Set note content", "required": True},
- "--tags": {"help": "Add tag to note"},
- "--notebook": {"help": "Add location marker to note"}
+ "--title": {"help": "The note title.", "required": True},
+ "--content": {"help": "The note content.", "required": True},
+ "--tags": {"help": "One tag or the list of tags which will be added to the note."},
+ "--notebook": {"help": "Set the notebook where to save note."}
}
},
"edit": {
- "help": "Create note",
+ "help": "Edit note in Evernote.",
"firstArg": "--note",
"arguments": {
- "--note": {"help": "Set note title"},
- "--title": {"help": "Set note title"},
- "--content": {"help": "Set note content"},
- "--tags": {"help": "Add tag to note"},
- "--notebook": {"help": "Add location marker to note"}
+ "--note": {"help": "The name or ID from the previous search of a note to edit."},
+ "--title": {"help": "Set new title of the note."},
+ "--content": {"help": "Set new content of the note."},
+ "--tags": {"help": "Set new list o tags for the note."},
+ "--notebook": {"help": "Assign new notebook for the note."}
}
},
"remove": {
- "help": "Create note",
+ "help": "Remove note from Evernote.",
"firstArg": "--note",
"arguments": {
- "--note": {"help": "Set note title"},
+ "--note": {"help": "The name or ID from the previous search of a note to remove."},
},
"flags": {
- "--force": {"help": "Add tag to note", "value": True, "default": False},
+ "--force": {"help": "Don't ask about removing.", "value": True, "default": False},
}
},
"show": {
- "help": "Create note",
+ "help": "Output note in the terminal.",
"firstArg": "--note",
"arguments": {
- "--note": {"help": "Set note title"},
+ "--note": {"help": "The name or ID from the previous search of a note to show."},
}
},
"find": {
- "help": "Create note",
+ "help": "Search notes in Evernote.",
"firstArg": "--search",
"arguments": {
- "--search": {"help": "Add tag to note", "emptyValue": "*"},
- "--tags": {"help": "Add tag to note"},
- "--notebooks": {"help": "Add location marker to note"},
- "--date": {"help": "Add location marker to note"},
- "--count": {"help": "Add location marker to note", "type": int},
+ "--search": {"help": "Text to search.", "emptyValue": "*"},
+ "--tags": {"help": "Notes with which tag/tags to search."},
+ "--notebooks": {"help": "In which notebook search the note."},
+ "--date": {"help": "Set date in format dd.mm.yyyy or date range dd.mm.yyyy-dd.mm.yyyy."},
+ "--count": {"help": "How many notes show in the result list.", "type": int},
},
"flags": {
- "--exact-entry": {"help": "Add tag to note", "value": True, "default": False},
- "--content-search": {"help": "Add tag to note", "value": True, "default": False},
- "--url-only": {"help": "Add tag to note", "value": True, "default": False},
+ "--exact-entry": {"help": "Search for exact entry of the request.", "value": True, "default": False},
+ "--content-search": {"help": "Search by content, not by title.", "value": True, "default": False},
}
},
# Notebooks
"notebook-list": {
- "help": "Create note",
+ "help": "Show the list of existing notebooks in your Evernote.",
},
"notebook-create": {
- "help": "Create note",
+ "help": "Create new notebook.",
"arguments": {
- "--title": {"help": "Set note title"},
+ "--title": {"help": "Set the title of new notebook."},
}
},
"notebook-edit": {
- "help": "Create note",
+ "help": "Edit/rename notebook.",
"firstArg": "--notebook",
"arguments": {
- "--notebook": {"help": "Set note title"},
- "--title": {"help": "Set note title"},
+ "--notebook": {"help": "The name of a notebook to rename."},
+ "--title": {"help": "Set the new name of notebook."},
}
},
"notebook-remove": {
- "help": "Create note",
+ "help": "Remove notebook.",
"firstArg": "--notebook",
"arguments": {
- "--notebook": {"help": "Set note title"},
+ "--notebook": {"help": "The name of a notebook to remove."},
},
"flags": {
- "--force": {"help": "Add tag to note", "value": True, "default": False},
+ "--force": {"help": "Don't ask about removing.", "value": True, "default": False},
}
},
}
@@ -179,11 +178,8 @@ def parse(self):
if self.COMMANDS[self.CMD].has_key('firstArg'):
firstArg = self.COMMANDS[self.CMD]['firstArg']
if len(self.INP) > 0:
- # смотрим что первое знаение не аршумент по умолчанию, а другой аргумент
- if self.INP[0] != firstArg and self.INP[0] in (self.CMD_ARGS.keys() + self.CMD_FLAGS.keys()):
- self.printErrorReqArgument(firstArg)
- return False
- elif self.INP[0] != firstArg:
+ # смотрим что первое знаение не аргумент по умолчанию, а другой аргумент
+ if self.INP[0] not in (self.CMD_ARGS.keys() + self.CMD_FLAGS.keys()):
self.INP = [firstArg, ] + self.INP
else:
self.INP = [firstArg, ]
View
@@ -1,22 +1,50 @@
# -*- coding: utf-8 -*-
-import os
+import os, sys
# Evernote config
# !!! DO NOT EDIT !!! >>>
+USER_BASE_URL = "www.evernote.com"
+USER_STORE_URI = "https://www.evernote.com/edam/user"
CONSUMER_KEY = "skaizer-1250"
CONSUMER_SECRET = "ed0fcc0c97c032a5"
+
+USER_BASE_URL_SANDBOX = "sandbox.evernote.com"
+USER_STORE_URI_SANDBOX = "https://sandbox.evernote.com/edam/user"
+CONSUMER_KEY_SANDBOX = "skaizer-1250"
+CONSUMER_SECRET_SANDBOX = "ed0fcc0c97c032a5"
# !!! DO NOT EDIT !!! <<<
-# Application path
-APP_DIR = os.path.join(os.getenv("USERPROFILE") or os.getenv("HOME"), ".geeknote")
+IS_IN_TERMINAL = sys.stdin.isatty()
+IS_OUT_TERMINAL = sys.stdout.isatty()
+# Application path
+APP_DIR = os.path.join(os.getenv("USERPROFILE") or os.getenv("HOME"), ".geeknote")
ERROR_LOG = os.path.join(APP_DIR, "error.log")
# Set default system editor
DEF_UNIX_EDITOR = "nano"
DEF_WIN_EDITOR = "notepad.exe"
-EDITOR_OPEN_PARAM = "WRITE"
+EDITOR_OPEN = "WRITE"
DEV_MODE = True
-DEBUG = False
+DEBUG = False
+
+# Url view the note
+NOTE_URL = "https://%domain%/Home.action?#n=%s"
+
+# validate config
+try:
+ if not os.path.exists(APP_DIR):
+ os.mkdir(APP_DIR)
+except Exception, e:
+ sys.stdout.write("Can not create application dirictory : %s" % APP_DIR)
+ exit()
+
+if DEV_MODE:
+ USER_STORE_URI = USER_STORE_URI_SANDBOX
+ CONSUMER_KEY = CONSUMER_KEY_SANDBOX
+ CONSUMER_SECRET = CONSUMER_SECRET_SANDBOX
+ USER_BASE_URL = USER_BASE_URL_SANDBOX
+
+NOTE_URL = NOTE_URL.replace('%domain%', USER_BASE_URL)
View
@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-
import os, sys
-
import tempfile
-import html2text
-import markdown
+import lib.html2text as html2text
+import lib.markdown as markdown
import tools
import out
import sys
import os
import re
import config
from storage import Storage
+from log import logging
def ENMLtoText(contentENML):
@@ -38,11 +38,11 @@ def textToENML(content):
contentHTML = markdown.markdown(content).encode("utf-8")
# remove all new-lines characters in html
contentHTML = re.sub(r'\n', r'', contentHTML)
+ return wrapENML(contentHTML)
except:
- out.failureMessage("Error. Content must be an UTF-8 encode.")
- return None
-
- return wrapENML(contentHTML)
+ logging.error("Error while parsing text to html. Content must be an UTF-8 encode.")
+ out.failureMessage("Error while parsing text to html. Content must be an UTF-8 encode.")
+ return tools.exit()
def edit(content=None):
"""
@@ -78,8 +78,11 @@ def edit(content=None):
editor = os.environ.get("EDITOR")
# Make a system call to open file for editing.
- os.system(editor + " " + tmpFileName)
+ logging.debug("launch system editor: %s %s" % (editor, tmpFileName))
+ out.preloader.stop()
+ os.system(editor + " " + tmpFileName)
+ out.preloader.launch()
newContent = open(tmpFileName, 'r').read()
return newContent
Oops, something went wrong. Retry.

0 comments on commit 4c2deb6

Please sign in to comment.