2013-07-08 05:38:01 +04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
wakatime.project
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Returns a project for the given file.
|
|
|
|
|
|
|
|
:copyright: (c) 2013 Alan Hamlett.
|
|
|
|
:license: BSD, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from .projects.git import Git
|
|
|
|
from .projects.mercurial import Mercurial
|
2013-12-13 18:35:49 +04:00
|
|
|
from .projects.projectmap import ProjectMap
|
2013-07-08 05:38:01 +04:00
|
|
|
from .projects.subversion import Subversion
|
2013-12-13 18:35:49 +04:00
|
|
|
from .projects.wakatime import WakaTime
|
2013-07-08 05:38:01 +04:00
|
|
|
|
|
|
|
|
2014-07-25 12:01:39 +04:00
|
|
|
log = logging.getLogger('WakaTime')
|
2013-07-08 05:38:01 +04:00
|
|
|
|
2013-12-13 18:35:49 +04:00
|
|
|
|
|
|
|
# List of plugin classes to find a project for the current file path.
|
|
|
|
# Project plugins will be processed with priority in the order below.
|
2013-07-08 05:38:01 +04:00
|
|
|
PLUGINS = [
|
2013-11-14 06:06:55 +04:00
|
|
|
WakaTime,
|
2013-12-13 18:35:49 +04:00
|
|
|
ProjectMap,
|
2013-07-08 05:38:01 +04:00
|
|
|
Git,
|
|
|
|
Mercurial,
|
|
|
|
Subversion,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2013-12-13 18:35:49 +04:00
|
|
|
def find_project(path, configs=None):
|
2013-07-08 05:38:01 +04:00
|
|
|
for plugin in PLUGINS:
|
2013-12-13 18:35:49 +04:00
|
|
|
plugin_name = plugin.__name__.lower()
|
|
|
|
plugin_configs = None
|
|
|
|
if configs and configs.has_section(plugin_name):
|
|
|
|
plugin_configs = dict(configs.items(plugin_name))
|
|
|
|
project = plugin(path, configs=plugin_configs)
|
2013-07-10 11:14:44 +04:00
|
|
|
if project.process():
|
2013-07-08 05:38:01 +04:00
|
|
|
return project
|
2013-07-21 21:44:23 +04:00
|
|
|
return None
|