Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9312476
D6384.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
D6384.diff
View Options
diff --git a/swh/loader/git/converters.py b/swh/loader/git/converters.py
--- a/swh/loader/git/converters.py
+++ b/swh/loader/git/converters.py
@@ -74,7 +74,7 @@
return Content(data=blob.as_raw_string(), status="visible", **hashes,)
-def dulwich_tree_to_directory(obj: ShaFile, log=None) -> Directory:
+def dulwich_tree_to_directory(obj: ShaFile) -> Directory:
"""Format a tree as a directory"""
if obj.type_name != b"tree":
raise ValueError("Argument is not a tree.")
@@ -122,7 +122,7 @@
)
-def dulwich_commit_to_revision(obj: ShaFile, log=None) -> Revision:
+def dulwich_commit_to_revision(obj: ShaFile) -> Revision:
if obj.type_name != b"commit":
raise ValueError("Argument is not a commit.")
commit = cast(Commit, obj)
@@ -180,7 +180,7 @@
}
-def dulwich_tag_to_release(obj: ShaFile, log=None) -> Release:
+def dulwich_tag_to_release(obj: ShaFile) -> Release:
if obj.type_name != b"tag":
raise ValueError("Argument is not a tag.")
tag = cast(Tag, obj)
diff --git a/swh/loader/git/from_disk.py b/swh/loader/git/from_disk.py
--- a/swh/loader/git/from_disk.py
+++ b/swh/loader/git/from_disk.py
@@ -2,9 +2,9 @@
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
-
from collections import defaultdict
from datetime import datetime
+import logging
import os
import shutil
from typing import Dict, Optional
@@ -28,6 +28,8 @@
from . import converters, utils
+logger = logging.getLogger(__name__)
+
def _check_tag(tag):
"""Copy-paste of dulwich.objects.Tag, minus the tagger and time checks,
@@ -174,7 +176,7 @@
self._check(obj)
except KeyError:
_id = oid.decode("utf-8")
- self.log.warn(
+ logger.warn(
"object %s not found, skipping" % _id,
extra={
"swh_type": "swh_loader_git_missing_object",
@@ -185,7 +187,7 @@
return None
except ObjectFormatException as e:
id_ = oid.decode("utf-8")
- self.log.warn(
+ logger.warn(
"object %s malformed (%s), skipping",
id_,
e.args[0],
@@ -198,7 +200,7 @@
return None
except EmptyFileException:
id_ = oid.decode("utf-8")
- self.log.warn(
+ logger.warn(
"object %s corrupted (empty file), skipping",
id_,
extra={
@@ -265,7 +267,7 @@
for oid in missing_dirs:
yield converters.dulwich_tree_to_directory(
- self.repo[hashutil.hash_to_bytehex(oid)], log=self.log
+ self.repo[hashutil.hash_to_bytehex(oid)],
)
def has_revisions(self):
@@ -286,7 +288,7 @@
for oid in missing_revs:
yield converters.dulwich_commit_to_revision(
- self.repo[hashutil.hash_to_bytehex(oid)], log=self.log
+ self.repo[hashutil.hash_to_bytehex(oid)],
)
def has_releases(self):
@@ -303,7 +305,7 @@
for oid in missing_rels:
yield converters.dulwich_tag_to_release(
- self.repo[hashutil.hash_to_bytehex(oid)], log=self.log
+ self.repo[hashutil.hash_to_bytehex(oid)],
)
def get_snapshot(self):
@@ -335,7 +337,7 @@
branches[target] = None
utils.warn_dangling_branches(
- branches, dangling_branches, self.log, self.origin_url
+ branches, dangling_branches, logger, self.origin_url
)
self.snapshot = Snapshot(branches=branches)
@@ -428,7 +430,7 @@
project_name, self.archive_path
)
- self.log.info(
+ logger.info(
"Project %s - Uncompressing archive %s at %s",
self.origin_url,
os.path.basename(self.archive_path),
@@ -443,6 +445,6 @@
"""
if self.temp_dir and os.path.exists(self.temp_dir):
shutil.rmtree(self.temp_dir)
- self.log.info(
+ logger.info(
"Project %s - Done injecting %s" % (self.origin_url, self.repo_path)
)
diff --git a/swh/loader/git/loader.py b/swh/loader/git/loader.py
--- a/swh/loader/git/loader.py
+++ b/swh/loader/git/loader.py
@@ -294,7 +294,7 @@
self.ref_object_types = {sha1: None for sha1 in self.remote_refs.values()}
- self.log.info(
+ logger.info(
"Listed %d refs for repo %s",
len(self.remote_refs),
self.origin.url,
@@ -360,7 +360,7 @@
if raw_obj.id in self.ref_object_types:
self.ref_object_types[raw_obj.id] = TargetType.DIRECTORY
- yield converters.dulwich_tree_to_directory(raw_obj, log=self.log)
+ yield converters.dulwich_tree_to_directory(raw_obj)
def get_revisions(self) -> Iterable[Revision]:
"""Format commits as swh revisions"""
@@ -368,7 +368,7 @@
if raw_obj.id in self.ref_object_types:
self.ref_object_types[raw_obj.id] = TargetType.REVISION
- yield converters.dulwich_commit_to_revision(raw_obj, log=self.log)
+ yield converters.dulwich_commit_to_revision(raw_obj)
def get_releases(self) -> Iterable[Release]:
"""Retrieve all the release objects from the git repository"""
@@ -376,7 +376,7 @@
if raw_obj.id in self.ref_object_types:
self.ref_object_types[raw_obj.id] = TargetType.RELEASE
- yield converters.dulwich_tag_to_release(raw_obj, log=self.log)
+ yield converters.dulwich_tag_to_release(raw_obj)
def get_snapshot(self) -> Snapshot:
"""Get the snapshot for the current visit.
@@ -458,7 +458,7 @@
)
utils.warn_dangling_branches(
- branches, dangling_branches, self.log, self.origin_url
+ branches, dangling_branches, logger, self.origin_url
)
self.snapshot = Snapshot(branches=branches)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 2, 10:54 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217115
Attached To
D6384: Unify log instruction to use the module logger instance
Event Timeline
Log In to Comment