liluo / mime Goto Github PK
View Code? Open in Web Editor NEWMIME Types, Python clone of halostatue/mime-types
License: MIT License
MIME Types, Python clone of halostatue/mime-types
License: MIT License
would you consider updating to the latest mime types defined in the Ruby version?
Note that their format has changed from plain text as used here to JSON (and yaml but I am not sure that the yaml format is the reference one... the JSON seems to be.)
@halostatue : is the mime-types JSON dataset the reference data format now and is the yaml something used only internally and that could be ignored by this Python port?
>>> foo= mime.Types['text/plain']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "./packages\mime\type.py", line 483, in __getitem__
elif isinstance(type_id, re._pattern_type):
AttributeError: module 're' has no attribute '_pattern_type'
I think it's obsolete. The closest to what it probably is supposed to do is re.Pattern
which is returned by re.compile(pattern,flags)
Would it be possible to update this package to work with python3 ?
I tried to fork & fix it (satreix/mime
) but had issues with cmp
function that has been removed in py3.
I am trying to get your python version of linguist to work with python3.
I did a small fix on liluo/pygments-github-lexers
and your mime package is the next one failing.
I'm using mime==0.1.0 and python version 3.6.8
If I import mime
then I get an exception:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7213: ordinal not in range(128)
because of the line:
data = open(type_file).read() (inside mime package)
where file_type is: /Users/my-user/Desktop/dev/project/.venv3/lib/python3.6/site-packages/mime/types/applicati
on
So I opened the folder: /Users/my-user/Desktop/dev/project/.venv3/lib/python3.6/site-packages/mime/types
and saw that there is an application
file (text file) and a application.mac
file (also text) so I simply removed the application file and that fixed the issue (but I guess that's not a great solution...)
Things are working now but I would like to get a better solution or at least some information about this issue if possible.
Thanks.
I am working on getting this package to support Python 2 and Python 3 code, but I am stuck on something.
The Types()
class appears to be 'initialized' by the MimeTypes()
class in mime_types.py
on import. I do not know how this works and it doesn't work on Python 3.
Attempting to access Types.type_veriants
dictionary in Python 3 just returns None for all Mimetypes. The dictionary is empty. However in Python 2 the import initializes the Types()
class correctly and the code functions.
How is it that simply importing Type
and Types
from the mime
package initializes the Types()
class by running the load_from_file()
class method?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.