-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest2.py
45 lines (34 loc) · 1.28 KB
/
test2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import sys
import subprocess
import pkg_resources
import requests
import inspect
import re
import logging
import os
import argparse
from glob import glob
import importlib
pipreqs_mapping_url="https://raw.githubusercontent.com/bndr/pipreqs/master/pipreqs/mapping"
superimport_mappin_url="https://raw.githubusercontent.com/probml/superimport/main/superimport/mapping2"
def load_file_from_url(url):
with requests.get(url) as r:
return r.content.decode("utf-8")
def get_packages_from_string(packages_string, dim="="):
if dim:
packages = {
c.split(dim)[0]: c.split(dim)[1] for c in packages_string.split("\n") if c
}
else:
packages = {c: True for c in packages_string.split("\n") if c}
return packages
pipreqs_mapping_string = load_file_from_url(pipreqs_mapping_url)
superimport_mapping_string = load_file_from_url(superimport_mappin_url)
mapping = get_packages_from_string(pipreqs_mapping_string, ":")
mapping2= get_packages_from_string(superimport_mapping_string, ":")
dir_name = os.path.dirname(__file__)
maping = {**mapping, **mapping2} # adding two dictionaries
maping2={(k,v) for k,v in maping.items() if v =="pyro" or k=="pyro"}
gnippam = {v: k for k, v in maping.items() if v =="pyro" or k=="pyro"}
print(maping2)
print(gnippam)