Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #23

Merged
merged 3 commits into from
Jul 18, 2024
Merged

Dev #23

Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Pre Commit

on:
push:
# branches:
# - main
# pull_request:
# branches:
# - main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
python-version: 3.8.18

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit

- name: Run pre-commit
run: pre-commit run --all-files
5 changes: 3 additions & 2 deletions simplenote.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ def load_notes():
logger.debug((f"Created new objects cache file: {SIMPLENOTE_NOTE_CACHE_FILE}"))


def clear_orphaned_filepaths():
list__filepath = [note.filename for note in Note.mapper_id_note.values()]
def clear_orphaned_filepaths(list__filepath: List[str] = []):
if not list__filepath:
list__filepath = [note.filename for note in Note.mapper_id_note.values()]
if not os.path.exists(SIMPLENOTE_NOTES_DIR):
os.makedirs(SIMPLENOTE_NOTES_DIR)
for filepath in os.listdir(SIMPLENOTE_NOTES_DIR):
Expand Down
7 changes: 5 additions & 2 deletions simplenotecommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,18 @@ def run(self):

self.list__modificationDate: List[float] = []
self.list__title: List[str] = []
list__filepath: List[str] = []
for note in Note.tree.iter(reverse=True):
if not isinstance(note, Note):
raise Exception("note is not a Note: %s" % type(note))
if note.d.deleted == True:
continue
self.list__modificationDate.append(note.d.modificationDate)
self.list__title.append(note.title)
list__filepath.append(note.filepath)

# TODO: Maybe doesn't need to run every time
clear_orphaned_filepaths(list__filepath)

sublime.active_window().show_quick_panel(
self.list__title,
Expand All @@ -163,8 +168,6 @@ def merge_note(self, updated_notes: List[Note]):
for note in updated_notes:
if note.need_flush:
on_note_changed(note)
# TODO: Maybe doesn't need to run every time
clear_orphaned_filepaths()

def run(self):
show_message(self.__class__.__name__)
Expand Down
1 change: 1 addition & 0 deletions utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import urllib.request
import zlib


__all__ = [
"request",
"Response",
Expand Down