Make ProjectMap use config section
This commit is contained in:
parent
d6e1da7073
commit
a4913289ce
1 changed files with 2 additions and 15 deletions
|
@ -23,9 +23,7 @@ log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class ProjectMap(BaseProject):
|
class ProjectMap(BaseProject):
|
||||||
def process(self):
|
def process(self):
|
||||||
self.config = self._load_config()
|
|
||||||
if self.config:
|
if self.config:
|
||||||
log.debug(self.config)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -35,22 +33,11 @@ class ProjectMap(BaseProject):
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
for path in self._path_generator():
|
for path in self._path_generator():
|
||||||
if path in self.config:
|
if self.config.has_option('projectmap', path):
|
||||||
return self.config[path]
|
return self.config.get('projectmap', path)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _load_config(self):
|
|
||||||
map_path = "%s/.waka-projectmap" % os.environ['HOME']
|
|
||||||
if os.path.isfile(map_path):
|
|
||||||
with open(map_path) as map_file:
|
|
||||||
try:
|
|
||||||
return json.load(map_file)
|
|
||||||
except (IOError, json.JSONDecodeError) as e:
|
|
||||||
log.exception("ProjectMap Exception: ")
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _path_generator(self):
|
def _path_generator(self):
|
||||||
path = self.path.replace(os.environ['HOME'], '')
|
path = self.path.replace(os.environ['HOME'], '')
|
||||||
while path != os.path.dirname(path):
|
while path != os.path.dirname(path):
|
||||||
|
|
Loading…
Reference in a new issue