Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-fake-useragent for
openSUSE:Factory checked in at 2022-12-06 14:24:17
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-fake-useragent (Old)
and /work/SRC/openSUSE:Factory/.python-fake-useragent.new.1835 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-fake-useragent"
Tue Dec 6 14:24:17 2022 rev:5 rq:1040545 version:1.1.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-fake-useragent/python-fake-useragent.changes
2022-11-21 16:19:39.679875016 +0100
+++
/work/SRC/openSUSE:Factory/.python-fake-useragent.new.1835/python-fake-useragent.changes
2022-12-06 14:24:31.762217136 +0100
@@ -1,0 +2,9 @@
+Tue Dec 6 03:26:51 UTC 2022 - Yogalakshmi Arunachalam <[email protected]>
+
+- Update to v1.1.1
+ * Remove whitespaces from user agent strings, this is a patch release
+
+- Update to v1.1.0
+ * Add pkg_resource as fallback mechanism in trying to retrieve the local
JSON data file
+
+-------------------------------------------------------------------
Old:
----
fake-useragent-1.0.1.tar.gz
New:
----
fake-useragent-1.1.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-fake-useragent.spec ++++++
--- /var/tmp/diff_new_pack.gntt6U/_old 2022-12-06 14:24:32.278221535 +0100
+++ /var/tmp/diff_new_pack.gntt6U/_new 2022-12-06 14:24:32.282221569 +0100
@@ -19,7 +19,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-fake-useragent
-Version: 1.0.1
+Version: 1.1.0
Release: 0
License: Apache-2.0
Summary: Useragent faker package for Python
++++++ fake-useragent-1.0.1.tar.gz -> fake-useragent-1.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/fake-useragent-1.0.1/README.md
new/fake-useragent-1.1.0/README.md
--- old/fake-useragent-1.0.1/README.md 2022-11-19 22:05:49.000000000 +0100
+++ new/fake-useragent-1.1.0/README.md 2022-11-26 21:09:40.000000000 +0100
@@ -170,6 +170,17 @@
### Changelog
+- 1.1.0 November 26, 2022
+
+ - Add `pkg_resource` as fallback mechanism in trying to retrieve the local
JSON data file
+
+- 1.0.1 November 10, 2022
+
+ - Add `importlib-metadata` & `importlib-resources` as dependencies
+ - Check on specific Python version regarding the importlib resources (python
v3.10 or higher) in order to have `files()` working
+ - `importlib_metadata` should now also work on Python version before 3.8
+ - Remove obsolete `MANIFEST.in` file
+
- 1.0.0 November 17, 2022
- Make the JSON Lines data file part of the Python package, data is
retrieved locally
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/fake-useragent-1.0.1/pyproject.toml
new/fake-useragent-1.1.0/pyproject.toml
--- old/fake-useragent-1.0.1/pyproject.toml 2022-11-19 22:05:49.000000000
+0100
+++ new/fake-useragent-1.1.0/pyproject.toml 2022-11-26 21:09:40.000000000
+0100
@@ -4,7 +4,7 @@
[project]
name = "fake-useragent"
-version = "1.0.1"
+version = "1.1.0"
authors = [
{name = "Victor Kovtun", email = "[email protected]"},
{name = "Melroy van den Berg", email = "[email protected]"},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/fake-useragent-1.0.1/src/fake_useragent/utils.py
new/fake-useragent-1.1.0/src/fake_useragent/utils.py
--- old/fake-useragent-1.0.1/src/fake_useragent/utils.py 2022-11-19
22:05:49.000000000 +0100
+++ new/fake-useragent-1.1.0/src/fake_useragent/utils.py 2022-11-26
21:09:40.000000000 +0100
@@ -20,6 +20,12 @@
from urllib import request
from fake_useragent.log import logger
+# Fallback method for retrieving data file
+try:
+ from pkg_resources import resource_filename
+except:
+ pass
+
str_types = (str,)
text = str
urlopen_args = inspect.getfullargspec(request.urlopen).kwonlyargs
@@ -123,16 +129,31 @@
)
for line in json_lines.splitlines():
data.update(json.loads(line))
+ fetch_online = False
+ ret = data
except Exception as exc:
- # Empty data again
+ # Empty data just to be sure
data = {}
logger.warning(
- "Could not find local data/json file or could not parse the
contents. Fallback to external resource.",
+ "Unable to find local data/json file or could not parse the
contents using importlib-resources. Try pkg-resource next.",
exc_info=exc,
)
- else:
- fetch_online = False
- ret = data
+ try:
+ with open(
+ resource_filename("fake_useragent", "data/browsers.json")
+ ) as file:
+ json_lines = file.read()
+ for line in json_lines.splitlines():
+ data.update(json.loads(line))
+ fetch_online = False
+ ret = data
+ except Exception as exc2:
+ # Empty data just to be sure
+ data = {}
+ logger.warning(
+ "Could not find local data/json file or could not parse
the contents using pkg-resource. Fallback to external resource.",
+ exc_info=exc2,
+ )
# Fallback behaviour or use_external_data parameter is explicitly set to
True
if fetch_online:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/fake-useragent-1.0.1/tests/test_utils.py
new/fake-useragent-1.1.0/tests/test_utils.py
--- old/fake-useragent-1.0.1/tests/test_utils.py 2022-11-19
22:05:49.000000000 +0100
+++ new/fake-useragent-1.1.0/tests/test_utils.py 2022-11-26
21:09:40.000000000 +0100
@@ -1,9 +1,15 @@
-import io
-import json
+import sys
import os
import time
+import io
+import json
from functools import partial
+if sys.version_info >= (3, 10):
+ import importlib.resources as ilr
+else:
+ import importlib_resources as ilr
+
import urllib
from urllib.error import HTTPError
import unittest
@@ -169,6 +175,35 @@
self.assertTrue(data["chrome"])
self.assertTrue(data["edge"])
+ self.assertTrue(data["firefox"])
+ self.assertTrue(data["opera"])
+ self.assertTrue(data["safari"])
+ self.assertTrue(data["internet explorer"])
+ self.assertIsInstance(data["chrome"], list)
+ self.assertIsInstance(data["edge"], list)
+ self.assertIsInstance(data["firefox"], list)
+ self.assertIsInstance(data["opera"], list)
+ self.assertIsInstance(data["safari"], list)
+ self.assertIsInstance(data["internet explorer"], list)
+
+ def test_utils_load_use_local_file_pkg_resource_fallback(self):
+ browsers = [
+ "chrome",
+ "edge",
+ "internet explorer",
+ "firefox",
+ "safari",
+ "opera",
+ ]
+ # By default use_local_file is also True during production
+ # We will not allow the default importlib resources to be used, by
triggering an Exception
+ with patch.object(ilr, "files") as mocked_importlib_resources_files:
+ # This exception should trigger the alternative path, trying to
use pkg_resource as fallback
+ mocked_importlib_resources_files.side_effect = Exception("Error")
+ data = utils.load(browsers, use_local_file=True)
+
+ self.assertTrue(data["chrome"])
+ self.assertTrue(data["edge"])
self.assertTrue(data["firefox"])
self.assertTrue(data["opera"])
self.assertTrue(data["safari"])