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

#15 json naming convention #56

Closed
wants to merge 6 commits into from

Conversation

evolverine
Copy link
Contributor

I'm suggesting a naming convention, where all the json files are named 'deck.json', which can simplify naming issues especially for the importer. Then it's both the folder they're in and also the github repo that offer the user the knowledge of which deck they have there.

…ing the file, so that the user can check whether it exists. This was useful for me, for example, for noticing that, although the json file existed, it was one folder deeper in the github repository than the plugin expected.
… jsons be called deck.json. This way their name doesn't need to be tied to the deck name or to the folder name or to the github repo name. Did some tests and it seems to work just fine. A repo called 'myRepo', when imported, will create a deck called 'Spanish castellano' from a json called 'deck.json'
@Stvad
Copy link
Owner

Stvad commented Apr 19, 2019

This, makes sense, but I'd like to ensure backward compatibility on import. I.e. the import with the old convention should still work.

@@ -28,7 +28,7 @@ def export_to_directory(self, deck: AnkiDeck, output_dir=Path("."), copy_media=T
deck = deck_initializer.from_collection(self.collection, deck.name)
self.last_exported_count = deck.get_note_count()

deck_filename = deck_directory.joinpath(deck_fsname).with_suffix(DECK_FILE_EXTENSION)
deck_filename = deck_directory.joinpath('deck').with_suffix(DECK_FILE_EXTENSION)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, done in the latest commit.

@@ -42,7 +42,7 @@ def load_from_directory(self, directory_path, import_media=True):
aqt.mw.progress.start(immediate=True)

try:
self.load_from_file(directory_path.joinpath(directory_path.name).with_suffix(DECK_FILE_EXTENSION))
self.load_from_file(directory_path.joinpath('deck').with_suffix(DECK_FILE_EXTENSION))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should update the docstring of the function to describe new convention

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in the latest commit.

@Stvad
Copy link
Owner

Stvad commented Apr 19, 2019

Btw, I see several merge commits on the branch - please look into using the git pull --rebase instead to maintain the git history cleaner

@Stvad
Copy link
Owner

Stvad commented Apr 20, 2019

Also, the Readme should be updated to reflect new convention

@evolverine
Copy link
Contributor Author

Apologies for the delay. I will look at implementing your suggestions next weekend.

…kwards compatibility in the importer, and changed the function description
@evolverine
Copy link
Contributor Author

This, makes sense, but I'd like to ensure backward compatibility on import. I.e. the import with the old convention should still work.

I've implemented this in the latest commit (and tested it too, locally; seems to work just fine).

@evolverine
Copy link
Contributor Author

Also, the Readme should be updated to reflect new convention

I've checked the Readme, and the only places that the file naming convention comes up seems to be in the screenshots. And I haven't changed them, partly because I didn't want my git username and projects to replace yours; it only makes sense that they reflect your workspace, given that you are the author of the plugin, at least that's what I reasoned. But let me know if you'd like these updated too, and I can do that.

@Stvad
Copy link
Owner

Stvad commented Jul 30, 2019

Hey, sorry for the delay in looking at this. I've checked it and merged it with minor updates

@Stvad Stvad closed this Jul 30, 2019
@evolverine
Copy link
Contributor Author

evolverine commented Aug 19, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants