Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Acidham committed Dec 8, 2019
1 parent ae33bcd commit 7593b84
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 163 deletions.
6 changes: 4 additions & 2 deletions src/MyNotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def url_search(self, search_terms):
content = self._getFileContent(f['path'])
matches = re.findall(r'\[(.*)\]\((https?.*)\)', content)
link_list = list()
# TODO: Implement url only match, links without markdown syntax
# url_only_matches = re.findall(r'https?://', content)
for m in matches:
url_title = m[0]
url = m[1]
Expand Down Expand Up @@ -150,11 +152,11 @@ def tagSearch(self, tag, sort_by='tag', reverse=False):
matches = list()
sorted_file_list = self.getFilesListSorted()
regex = re.compile(
r'#{1}(\w+)\s?', re.I) if tag == '' else re.compile(r'#{1}(' + tag + '\w*)\s?', re.I)
r'#{1}(\w+)\s?', re.I) if tag == '' else re.compile(r'#{1}(' + tag + '\w*)\s?', re.I | re.UNICODE)
for f in sorted_file_list:
content = self._getFileContent(f['path'])
if content != str():
match_obj = re.search(r'\bTags:.*', content, re.IGNORECASE)
match_obj = re.search(r'\bTags:.*', content, re.IGNORECASE | re.UNICODE)
if match_obj:
r = match_obj.group(0)
results = re.findall(regex, r)
Expand Down
19 changes: 19 additions & 0 deletions src/asset_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@


def getAssetsFolder():
"""
Get Assets Upload Folder from config
Returns:
str: Asset Folder for md Notes
"""
my_notes = MyNotes.Search()
notes_path = my_notes.getNotesPath()
assets_path = notes_path + ASSETS_FOLDER
Expand All @@ -18,6 +24,19 @@ def getAssetsFolder():


def copyFile(source, target):
"""
Copy file to target folder
Args:
source (str): Source File path
target (str): Target folder
Raises:
ValueError: if source file does not exists
Returns:
str: path to file after copied
"""
file_name = str()
if os.path.isfile(source):
copy2(source, target)
Expand Down
7 changes: 4 additions & 3 deletions src/delete_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ def is_in_notes(f_path):

# Create Notification Message
if len(files_to_delete) == 1:
return_text = '- MD Note DELETED'if is_file_deleted else "Cannot delete file: %s" % file_name
return_text = '- MD Note DELETED'if is_file_deleted else "Cannot delete file: {0}".format(
file_name)
return_text += '\n- Assets DELETED' if is_asset_deleted else str()

if len(files_to_delete) > 1:
return_text = "%s Notes and coresponding Assets deleted" % len(
files_to_delete)
return_text = "{0} Notes and coresponding Assets deleted".format(len(
files_to_delete))

Tools.notify('MD Note deleted!', return_text)

Expand Down
2 changes: 0 additions & 2 deletions src/evernote_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,9 @@ def _exhange_image_links(self, md_content, md_link, en_link):
return re.sub(r'!\[.*\]\(' + md_link + '\)', en_link, md_content)

def _url_decode(self, url):
# TODO: to test
return urllib.url2pathname(url.encode('utf8'))

def _url_encode(self, url):
# TODO: to test
return urllib.pathname2url(url.encode('utf8'))

def _delete_all_tags(self, md_content):
Expand Down
Loading

0 comments on commit 7593b84

Please sign in to comment.