-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
861813d
commit 1db0188
Showing
4 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.csv | ||
*.jsonl | ||
*.jsonl.gz |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import gzip | ||
import pathlib | ||
from typing import Dict | ||
|
||
import msgspec | ||
|
||
|
||
class OpenSourceString(msgspec.Struct): | ||
string: str | ||
library_name: str | ||
library_version: str | ||
file_path: str | ||
function_name: str | ||
line_number: int | None = None | ||
|
||
|
||
class OpenSourceStringDatabase: | ||
metadata_by_string: Dict[str, OpenSourceString] | ||
|
||
@classmethod | ||
def from_file(cls, path: pathlib.Path) -> "OpenSourceStringDatabase": | ||
metadata_by_string: Dict[str, OpenSourceString] = {} | ||
decoder = msgspec.json.Decoder(type=OpenSourceString) | ||
for line in gzip.decompress(path.read_bytes()).split(b"\n"): | ||
s = decoder.decode(line) | ||
metadata_by_string[s.string] = s | ||
|
||
return cls(metadata_by_string=metadata_by_string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
"networkx==2.5.1", | ||
"halo==0.0.31", | ||
"rich==13.3.4", | ||
"msgspec==0.14.2", | ||
] | ||
|
||
# this sets __version__ | ||
|