Giter Club home page Giter Club logo

python-mimeparse's People

Contributors

adamchainz avatar adewale avatar caselit avatar dbtsai avatar edsu avatar hugovk avatar merqurio avatar rafalkrupinski avatar scop avatar trendels avatar vinoski avatar wojcikstefan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-mimeparse's Issues

No python installation found in registry error on install

I have setup a new Python environment with version 3.3, and I didn't go with the default installation folder (preferring to install applications into the "C:\Program Files" folder).

When I run python-mimeparse-0.1.4.linux-x86_64.exe I get an error indicating "No python installation found in registry", and cannot manually enter the actual value. I googled python registry entries for what key it would be looking for and found it under the local machine, and added it to the current_user (since the article I found mentioned it would be under both) but to no avail.

Could you be so kind as to share what registry key your installation program is looking for so I can manually add it and see if I can successfully run the installer?

And thanks so much for creating python-mimeparse and for your help on this question.

Drop python 2

We should remove python2 support from the code. python 3.6+ (maybe 3.7 since 3.6 does eol in a couple of months)

ValueError in 1.3 python version

What steps will reproduce the problem?
In [3]: mimeparse.parse_mime_type("text/html, image/gif, image/jpeg, ; q=.2, */; q=.2")

What is the expected output? What do you see instead?

In [3]: mimeparse.parse_mime_type("text/html, image/gif, image/jpeg, ; q=.2, */; q=.2")

ValueError Traceback (most recent call last)
/tmp/ in ()
/tmp/mimeparse.py in parse_mime_type(mime_type)
36 # Turn it into a legal wildcard.
37 if full_type == '': full_type = '/*'
---> 38 (type, subtype) = full_type.split("/")
39 return (type.strip(), subtype.strip(), params)
40
ValueError: too many values to unpack

What version of the product are you using? On what operating system?
1.3

Please provide any additional information below.
https://bitbucket.org/benoitc/django-authopenid/issue/54/type-subtype-parts-0-split-valueerror-too#comment-483268

Incorrect order of best matching types?

Hi.

I've tried to do best_match() on acceptable types defined as ['application/json;q=1.0', 'text/html;q=0.9', 'text/plain;q=0.1']. Accept header was set to */*. I'm expecting that mimeparse.best_match() will return application/json as a best matching type (due to the highest qvalue), but function returns text/plain instead.

The problem lies inside best_match() function, where every acceptable media type is checked separately, and every type is scored (0, 1.0). As a result a [((0, 1.0), 'application/json;q=1.0'), ((0, 1.0), 'text/html;q=0.9'), ((0, 1.0), 'text/plain;q=0.1')] list is sorted, then the last element is returned.

I would ask - am I wrong expecting application/json as a result in that case, or is there a bug?

Modernize setup

  • move to a setup.cfg configuration
  • update trove classifiers
  • use pep517

Modernize code

Once python 2 is dropped in #37 we can modernize the code to use py3 conventions

mimeparse vs python-mimeparse

Howdy,

While doing some packaging work for Fedora, I noticed that both mimeparse and python-mimeparse are available on PyPI. After digging through the commit history, I see that python-mimeparse was originally forked from mimeparse. Mimeparse only has one commit after the fork happened.

To reduce the confusion, would it be possible for the projects to be merged back together? Or put another way, what would it take for this module to claim the mimeparse name on PyPI and become the single official source?

cgi deprecation

Hi guys,
python 3.13 is in beta now. Any chance to release a version with the dependency on cgi removed?

parse_media_range overrides quality values of 0

What steps will reproduce the problem?

mimeparse.parse_media_range('/;q=0')

Expected Output: ('', '', {'q': '0'})
Actual Output: ('', '', {'q': '1'})

I encountered this while parsing an request Accept header with
'application/xml,/;q=0' and the only acceptable type on the
server is application/json. It freely let the server return a
JSON representation, but should have failed since the user agent
explicitly defined a quality of 0 for all other mimetypes. The
value of 0 for / was being overwritten with 1.

56c56,57

< float(params['q']) > 1 or float(params['q']) < 0:

        not float(params['q']) or float(params['q']) > 1\
        or float(params['q']) < 0:

What version of the product are you using? On what operating system?

Python version of mimeparse 0.1.3
Using Python 2.7.1

Wrong ordering of candidates

What steps will reproduce the problem?

mimeparse.best_match(["image/jpeg", "text/plain"], "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5")

What is the expected output? What do you see instead?

Expected: 'image/jpeg'
Instead: 'text/plain'

What version of the product are you using? On what operating system?

Version: 0.1.3
OS: Mac OS X 10.6.4, Python 2.6.1
(Using Python version of mimeparse library)

Please provide any additional information below.

The best_match function is using fitness_and_quality_parsed() to order the candidate media ranges, but the first value from that is the fitness, which corresponds to what rfc2616 calls the "precedence", or the specificity of the range to the particular candidate type. The specificity matters, but the major ordering factor should be the quality (the client's measure of which media ranges are most preferred).

In the example above, image/jpeg should have a quality of 0.5 (from the /) and text/plain should have a quality of 0.3 (from the text/*). The type with the higher quality factor is image/jpeg, and it should win.

I'm attaching a patch that fixes this by swapping the elements returned by fitness_and_quality_parsed(), along with an extra test for your suite. Hope this helps.

See:

http://code.google.com/p/mimeparse/issues/attachmentText?id=10&aid=-7973144274275406361&name=mimeparse.patch&token=bNOf7hGoiXyduKWLI0WY4Q4q4e8%3A1345844559552

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.