# Path: mdk/command.py
# class Command(object):
#     """Represents a command"""
# 
#     _arguments = [
#             (
#                 ['foo'],
#                 {
#                     'help': 'I\'m an argument'
#                 }
#             ),
#             (
#                 ['-b', '--bar'],
#                 {
#                     'action': 'store_true',
#                     'help': 'I\'m a flag'
#                 }
#             )
#         ]
#     _description = 'Undocumented command'
# 
#     __C = None
#     __Wp = None
# 
#     def __init__(self, config):
#         self.__C = config
# 
#     def argumentError(self, message):
#         raise CommandArgumentError(message)
# 
#     @property
#     def arguments(self):
#         return self._arguments
# 
#     @property
#     def C(self):
#         return self.__C
# 
#     @property
#     def description(self):
#         return self._description
# 
#     def run(self, args):
#         return True
# 
#     @property
#     def Wp(self):
#         if not self.__Wp:
#             from .workplace import Workplace
#             self.__Wp = Workplace()
#         return self.__Wp
# 
# Path: mdk/tools.py
# def mkdir(path, perms=0o755):
#     """Creates a directory ignoring the OS umask"""
#     oldumask = os.umask(0000)
#     os.mkdir(path, perms)
#     os.umask(oldumask)
# 
# def resolveEditor():
#     """Try to resolve the editor that the user would want to use.
#        This does actually checks if it is executable"""
#     editor = C.get('editor')
#     if not editor:
#         editor = os.environ.get('EDITOR')
#     if not editor:
#         editor = os.environ.get('VISUAL')
#     if not editor and os.path.isfile('/usr/bin/editor'):
#         editor = '/usr/bin/editor'
#     return editor


import os
import re
import shutil
import subprocess
from .. import git
from ..command import Command
from ..tools import mkdir, resolveEditor
                editor = None

        if not editor:
            print('  Could not resolve the path to your editor')
            if args.fix:
                print('    Set $EDITOR, /usr/bin/editor, or use: mdk config set editor [path]')

    def directories(self, args):
        """Check that the directories are valid"""

        print('Checking directories')
        for k, d in list(self.C.get('dirs').items()):
            d = os.path.abspath(os.path.realpath(os.path.expanduser(d)))
            if not os.path.isdir(d):
                print('  %s does not exist' % d)
                if args.fix:
                    print('    Creating %s' % d)
                    mkdir(d, 0o777)

        if not self._checkWorkplace():
            return

        # Checking extra directory.
        instances = self.Wp.list()
        for identifier in instances:
            d = self.Wp.getPath(identifier, 'extra')
            if not os.path.isdir(d):
                print('  %s does not exist' % d)
                if args.fix:
                    print('    Creating %s' % d)

# Path: mdk/command.py
# class Command(object):
#     """Represents a command"""
# 
#     _arguments = [
#             (
#                 ['foo'],
#                 {
#                     'help': 'I\'m an argument'
#                 }
#             ),
#             (
#                 ['-b', '--bar'],
#                 {
#                     'action': 'store_true',
#                     'help': 'I\'m a flag'
#                 }
#             )
#         ]
#     _description = 'Undocumented command'
# 
#     __C = None
#     __Wp = None
# 
#     def __init__(self, config):
#         self.__C = config
# 
#     def argumentError(self, message):
#         raise CommandArgumentError(message)
# 
#     @property
#     def arguments(self):
#         return self._arguments
# 
#     @property
#     def C(self):
#         return self.__C
# 
#     @property
#     def description(self):
#         return self._description
# 
#     def run(self, args):
#         return True
# 
#     @property
#     def Wp(self):
#         if not self.__Wp:
#             from .workplace import Workplace
#             self.__Wp = Workplace()
#         return self.__Wp
# 
# Path: mdk/tools.py
# def mkdir(path, perms=0o755):
#     """Creates a directory ignoring the OS umask"""
#     oldumask = os.umask(0000)
#     os.mkdir(path, perms)
#     os.umask(oldumask)
# 
# def resolveEditor():
#     """Try to resolve the editor that the user would want to use.
#        This does actually checks if it is executable"""
#     editor = C.get('editor')
#     if not editor:
#         editor = os.environ.get('EDITOR')
#     if not editor:
#         editor = os.environ.get('VISUAL')
#     if not editor and os.path.isfile('/usr/bin/editor'):
#         editor = '/usr/bin/editor'
#     return editor


# Path: mdk/commands/doctor.py
import os
import re
import shutil
import subprocess
from .. import git
from ..command import Command
from ..tools import mkdir, resolveEditor

                editor = None

        if not editor:
            print('  Could not resolve the path to your editor')
            if args.fix:
                print('    Set $EDITOR, /usr/bin/editor, or use: mdk config set editor [path]')

    def directories(self, args):
        """Check that the directories are valid"""

        print('Checking directories')
        for k, d in list(self.C.get('dirs').items()):
            d = os.path.abspath(os.path.realpath(os.path.expanduser(d)))
            if not os.path.isdir(d):
                print('  %s does not exist' % d)
                if args.fix:
                    print('    Creating %s' % d)
                    mkdir(d, 0o777)

        if not self._checkWorkplace():
            return

        # Checking extra directory.
        instances = self.Wp.list()
        for identifier in instances:
            d = self.Wp.getPath(identifier, 'extra')
            if not os.path.isdir(d):
                print('  %s does not exist' % d)
                if args.fix:
                    print('    Creating %s' % d)

                    mkdir(d, 0o777)