Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the provider user_agent #420

Merged
merged 1 commit into from Apr 14, 2017

Conversation

illia-v
Copy link
Contributor

@illia-v illia-v commented Nov 4, 2016

No description provided.

)

linux_processors = ('i686', 'x86_64',)

mac_processors = ('Intel', 'PPC', 'U; Intel', 'U; PPC',)

langs = ('en-US', 'sl-SI', 'it-IT',)
# Language codes from ISO 639-1
langs = (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what I've seen, user agent strings usually use a locale (eg: en-us) rather than languages.

Maybe this can be refactored to make use of https://github.com/joke2k/faker/blob/master/faker/providers/misc/__init__.py#L71, and you can exapnd the list there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a mistake to use language codes in UA strings.
A quote from this page:
The golden rule when creating language tags is to keep the tag as short as possible. Avoid region, script or other subtags except where they add useful distinguishing information. For instance, use ja for Japanese and not ja-JP, unless there is a particular reason that you need to say that this is Japanese as spoken in Japan, rather than elsewhere.
Herefrom. I think we should not care about using region code. It won't influence on something.

I will transfer the language codes to the provider misc and use the method language_code from it in the provider user_agent. Will it be OK?

And the method locale is very rough because it returns some weird things: it_QA, el_IN, el_PA. I think, I will fix it soon.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using just language might be technically better, but I think the purpose of Faker is to generate data as close as possible to what the user may actually encounter in practice.

In other words, it's technically correct and considered best practice to use just the language, but how common is it in practice for user agent string? Does it happen often?

For the same reason, I agree that the locale method needs to be fixed.

@@ -163,6 +182,13 @@ def internet_explorer(cls):
random.randint(0, 1))

@classmethod
def microsoft_edge(cls):
tmplt = ('Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, '
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this have some part randomized?

@illia-v
Copy link
Contributor Author

illia-v commented Apr 13, 2017

@fcurella, I won't add Microsoft Edge UA in the PR.

@fcurella
Copy link
Collaborator

Thanks! ✨

@fcurella fcurella merged commit 1b692d8 into joke2k:master Apr 14, 2017
@illia-v illia-v deleted the update-user-agent-provider branch April 14, 2017 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants