Giter Site home page Giter Site logo

mime's Issues

Porting to Python3 - How is Types() initialized

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?

unicode exception on a utf-8 file when using mac

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/application

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.

foo = mime.Types['text/plain'] gives error

>>> 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)

Update to latest types and tests from https://github.com/halostatue/mime-types ?

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?

Python 2to3

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.