mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-30 05:05:02 +08:00
We don't need 3 slightly different implementations of Data
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
import netlib.utils
|
||||
|
||||
|
||||
SIZE_UNITS = dict(
|
||||
@@ -75,27 +76,7 @@ def escape_unprintables(s):
|
||||
return s
|
||||
|
||||
|
||||
class Data(object):
|
||||
|
||||
def __init__(self, name):
|
||||
m = __import__(name)
|
||||
dirname, _ = os.path.split(m.__file__)
|
||||
self.dirname = os.path.abspath(dirname)
|
||||
|
||||
def path(self, path):
|
||||
"""
|
||||
Returns a path to the package data housed at 'path' under this
|
||||
module.Path can be a path to a file, or to a directory.
|
||||
|
||||
This function will raise ValueError if the path does not exist.
|
||||
"""
|
||||
fullpath = os.path.join(self.dirname, path)
|
||||
if not os.path.exists(fullpath):
|
||||
raise ValueError("dataPath: %s does not exist." % fullpath)
|
||||
return fullpath
|
||||
|
||||
|
||||
data = Data(__name__)
|
||||
data = netlib.utils.Data(__name__)
|
||||
|
||||
|
||||
def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): # pragma: no cover
|
||||
|
||||
Reference in New Issue
Block a user