Skip to content

Commit ae9ca43

Browse files
committed
Add origin property. Ref #404.
1 parent 8e7b968 commit ae9ca43

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

importlib_metadata/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import abc
44
import csv
55
import sys
6+
import json
67
import zipp
78
import email
9+
import types
810
import inspect
911
import pathlib
1012
import operator
@@ -618,6 +620,16 @@ def url_req_space(req):
618620
space = url_req_space(section.value)
619621
yield section.value + space + quoted_marker(section.name)
620622

623+
@property
624+
def origin(self):
625+
return self._load_json('direct_url.json')
626+
627+
def _load_json(self, filename):
628+
return pass_none(json.loads)(
629+
self.read_text(filename),
630+
object_hook=lambda data: types.SimpleNamespace(**data),
631+
)
632+
621633

622634
class DistributionFinder(MetaPathFinder):
623635
"""

0 commit comments

Comments
 (0)