Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions geeknote/gnsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import string
import unicodedata, re
import sys

from geeknote import GeekNote
from storage import Storage
Expand Down Expand Up @@ -193,6 +194,7 @@ def _update_file(self, file_note, note):
GeekNote().loadNoteContent(note)
content = Editor.ENMLtoText(note.content)
open(file_note['path'], "w").write(content)
logger.info('File "{0}" was updated'.format(os.path.basename(file_note['path'])))

@log
def _create_note(self, file_note):
Expand Down Expand Up @@ -228,6 +230,7 @@ def _create_file(self, note):
content = Editor.ENMLtoText(note.content)
path = os.path.join(self.path, note.title + self.extension)
open(path, "w").write(content)
logger.info('File "{0}" was created'.format(os.path.basename(path)))
return True

@log
Expand Down Expand Up @@ -316,6 +319,7 @@ def main():
parser.add_argument('--notebook', '-n', action='store', help='Notebook name for synchronize. Default is default notebook')
parser.add_argument('--logpath', '-l', action='store', help='Path to log file. Default is GeekNoteSync in home dir')
parser.add_argument('--two-way', '-t', action='store', help='Two-way sync')
parser.add_argument('--verbose', '-v', action='store_true', help='Verbose mode. Let GNSync print more logs about its progress')

args = parser.parse_args()

Expand All @@ -328,6 +332,12 @@ def main():

reset_logpath(logpath)

if args.verbose:
handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter('%(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)

GNS = GNSync(notebook, path, mask, format, twoway)
GNS.sync()

Expand Down