-
Notifications
You must be signed in to change notification settings - Fork 12
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
Reduce the number of identical get_two_letter_dir
functions to one
#1390
Comments
This had something to do with it being needed inside "models" where it can't import from the other files. The three "commands" are going to be thrown away, basically, once it's all converted. That's why I put them there, to not import other code. It's also violating other principles because the entire file system is visible inside the models. |
To circumvent circular imports, you could do the import within a function, class or method. See Can you see whether this works on your side? |
Can we make a totally new "file system related functions" file to put it in? The problem is that it also needs to use "idgloss" but that function is full of try-except clauses. So it could be failing internally yet we don't know. The glosses where video's are being uploaded are supposed to have lemma's, dataset's, lemma translations. So this should not be failing internally. I made a separate issue a few weeks ago about the idgloss property. Because there were unexplained failings in the API I was trying to localize the code to be able to debug it. If the file system related methods can be put in a file where other functions are not imported from that would help. The "database_checks" file was made to be independent because it takes a really long time to run. I assumed it would reduce the runtime if it didn't import the function. Although it makes use of idgloss. So that doesn't really solve anything. I think the idgloss property should fail if the gloss is missing a dataset or lemma or lemma translation. (But that maks for awful code elsewhere.) The entire video upload system is using this function constantly. I merged the renaming of the backup files because it's in use and it's kind of high priority. I agree completely about the 2-char function. But it's kind of in combination with idgloss. (And then that gets worse with all the right to left and pictogram characters.) In some of the code (not reviewed) I started making the "desired relative path". In order to compare to see if something was messed up |
I removed the three commands that had included the duplicated code. |
Are they not necessary for work on the live server? |
No, they're not necessary. The command remove_unused is very useful. But it's doing a traversal of the file system. I don't know what to do about the right to left paths. The traversal command works better because it isn't making paths. I was thinking it would be helpful to have a kind of "relative path" method like for the "idgloss" in order to embed the two-char folder into the path. @Woseseltops was writing the paths with underscore instead of slash. But it turned out that was just for documentation of the API. Some of the code that uses paths needs to use the string version, not the Python path. For the zip code I put the function there explicitly because I wanted the code to be self-contained. |
Function to retrieve video content type of video file. Added here to avoid duplicating it in multiple files on multiple branches
I noticed there are six identical
get_two_letter_dir
functions, see details below. This is a big violation of the Don't Repeat Yourself (DRY) principle in software development. We should get rid of five of them and avoid copying+pasting code or even rewriting the same thing in the future.The text was updated successfully, but these errors were encountered: