STOP USING MAGIC NUMBERS
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
:( 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. :(
@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.
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.
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...
oh, and something like this, really...
if dict_type and dict_type != u'不是字典字段' and dict_type != 'Not dict field' and dict_field:
lol