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
|
import os
import sys
import json
import gzip
import platform
import re
import zlib
import zipfile
import inspect
import pkgutil
# find_executable() is only needed by channels/configwin
try:
from distutils.spawn import find_executable
except:
def find_executable(bin):
exists = [os.path.exists(dir+"/"+bin) for dir in os.environ.get("PATH").split(":")+["/"]]
return exists[0] if len(exists) else None
# export symbols
__all__ = ["conf", "__print__", "dbg", "plugin_meta", "module_list", "get_data", "find_executable"]
#-- create a stub instance of config object
conf = object()
|
>
<
<
<
<
<
<
<
<
<
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import os
import sys
import json
import gzip
import platform
import re
from compat2and3 import gzip_decode, find_executable
import zlib
import zipfile
import inspect
import pkgutil
# export symbols
__all__ = ["conf", "__print__", "dbg", "plugin_meta", "module_list", "get_data", "find_executable"]
#-- create a stub instance of config object
conf = object()
|
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
if server in netrc:
return netrc[server]
# Retrieve content from install path or pyzip archive (alias for pkgutil.get_data)
#
def get_data(fn, decode=False, z=False, file_base="config"):
try:
bin = pkgutil.get_data(file_base, fn)
if z:
bin = zlib.decompress(bin)
if decode:
return bin.decode("utf-8")
else:
return str(bin)
except:
pass
|
|
|
|
|
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
if server in netrc:
return netrc[server]
# Retrieve content from install path or pyzip archive (alias for pkgutil.get_data)
#
def get_data(fn, decode=False, gz=False, file_base="config"):
try:
bin = pkgutil.get_data(file_base, fn)
if gz:
bin = gzip_decode(bin)
if decode:
return bin.decode("utf-8")
else:
return str(bin)
except:
pass
|