-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLibraries.py
52 lines (40 loc) · 1.07 KB
/
Libraries.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
46
47
48
49
50
51
52
import json
import sublime
try:
from urllib.request import urlopen, Request
from urllib.error import URLError
from urllib.parse import urlencode
except ImportError:
from urllib2 import urlopen, URLError
from urllib2.parse import urlencode
class Libraries():
def __init__(self):
# lib_json = open(sublime.packages_path() + '/AddLibrary/Libraries.json')
self.libraries = json.loads(sublime.load_resource("Packages/AddLibrary/Libraries.json"))
def getLibrariesName(self):
r = []
for l in self.libraries:
r.append(l['name'])
return r
def getLibraryByName(self, lib_name):
r = ''
for lib in self.libraries:
if lib['name'] == lib_name:
r = lib
return r
def getLibraryBySearchName(self, lib_name):
r = ''
for lib in self.libraries:
if lib['search_name'] == lib_name:
r = lib
return r
def getFileNameByLib(self, lib_name):
r = ''
for lib in self.libraries:
if lib['name'] == lib_name:
r = lib['file_name']
return r
def httpGet(self, url):
request_obj = Request(url, method='GET')
req = urlopen(url=request_obj)
return req