2013-07-06 07:51:09 +00: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
|
|
|
|
import os
|
|
|
|
|
2013-11-13 18:41:56 +00:00
|
|
|
from .projects.wakatime import WakaTime
|
2013-11-14 08:52:00 +00:00
|
|
|
from .projects.projectmap import ProjectMap
|
2013-07-06 07:51:09 +00:00
|
|
|
from .projects.git import Git
|
|
|
|
from .projects.mercurial import Mercurial
|
|
|
|
from .projects.subversion import Subversion
|
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
PLUGINS = [
|
2013-11-13 18:41:56 +00:00
|
|
|
WakaTime,
|
2013-11-14 08:52:00 +00:00
|
|
|
ProjectMap,
|
2013-07-06 07:51:09 +00:00
|
|
|
Git,
|
|
|
|
Mercurial,
|
|
|
|
Subversion,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2013-11-19 14:31:48 +00:00
|
|
|
def find_project(path, config):
|
2013-07-06 07:51:09 +00:00
|
|
|
for plugin in PLUGINS:
|
2013-12-10 07:57:47 +00:00
|
|
|
plugin_name = plugin.__name__.lower()
|
|
|
|
if config.has_section(plugin_name):
|
|
|
|
plugin_config = config
|
|
|
|
else:
|
|
|
|
plugin_config = None
|
|
|
|
project = plugin(path, plugin_config)
|
2013-07-10 03:11:49 +00:00
|
|
|
if project.process():
|
2013-07-06 07:51:09 +00:00
|
|
|
return project
|
2013-07-21 17:30:06 +00:00
|
|
|
return None
|