WordQuery icon indicating copy to clipboard operation
WordQuery copied to clipboard

STOP USING MAGIC NUMBERS

Open GarrisonBaird opened this issue 8 years ago • 5 comments

os.path.basename(self.dict_path)[:-4] what about .idx.gz? your code is too dirty... i don't wanna work on it... fix it yourself... lol

and also, .{ifo,idx{,.gz},dict{,.dz),syn}, all those suffixes are supported by pystardict.py

GarrisonBaird avatar Apr 08 '17 15:04 GarrisonBaird

:( Sorry, I didn't care too much about stardict and just made a patch when some one pulled a request after I tested it a bit. When meeting some bugs, I just patch that until it works, so there really exits some dirty codes. But Man, please never abadon me because of the dirtiness. :(

finalion avatar Apr 10 '17 08:04 finalion

@GarrisonBaird I read the pystardict.py and found .ifo, .idx, .dict, .syn files you mentioned are basically necessary for lookups. Actually, it only requires the dict prefix as the input. So I think there is no problem taking the .idx(.gz) as the input file and no need to considering about other files.

finalion avatar Apr 10 '17 21:04 finalion

refers to the official document, .ifo is the metadata of a dictionary and always exsits, if you want to make it simple, pick .ifo instead of other suffixes

Stardict will search for the .ifo file, then open the .idx or .idx.gz file and the .dict.dz or .dict file which is in the same directory and has the same base name.

GarrisonBaird avatar Apr 11 '17 17:04 GarrisonBaird

during working on the code, I found that problems like magic numbers are everywhere I belive EVERY coding book or document for starters will alert that do NOT use magic numbers in ANY situation, use a named constant or variable instead, even simply something like len(".ifo") will be much much more better keep your code clean and well commented, or few days later when you back to your project, you will be confusing about what you were f**king doing on those messed codes... I don't want to teach someone how to do coding, but please fix it, if you want others continue working on it...

GarrisonBaird avatar Apr 11 '17 17:04 GarrisonBaird