add an asset method to get absolute path of module local files
This commit is contained in:
parent
a3b51902b9
commit
2a6fa3fb36
1 changed files with 10 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ except ImportError:
|
|||
import os
|
||||
import sys
|
||||
from copy import deepcopy
|
||||
import inspect
|
||||
|
||||
try:
|
||||
import requests
|
||||
|
|
@ -82,6 +83,15 @@ class Browser(object):
|
|||
Maximum of threads for asynchronous requests.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def asset(cls, localfile):
|
||||
"""
|
||||
Absolute file path for a module local file.
|
||||
"""
|
||||
if os.path.isabs(localfile):
|
||||
return localfile
|
||||
return os.path.join(os.path.dirname(inspect.getfile(cls)), localfile)
|
||||
|
||||
def __init__(self, logger=None, proxy=None, responses_dirname=None):
|
||||
self.logger = getLogger('browser', logger)
|
||||
self.PROXIES = proxy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue