# Buggy code
def _get_include_path(self, arg):
    """Converts an Apache Include directive into Augeas path.

    Converts an Apache Include directive argument into an Augeas
    searchable path

    .. todo:: convert to use os.path.join()

    :param str arg: Argument of Include directive

    :returns: Augeas path string
    :rtype: str

    """
    # Check to make sure only expected characters are used <- maybe remove
    # validChars = re.compile("[a-zA-Z0-9.*?_-/]*")
    # matchObj = validChars.match(arg)
    # if matchObj.group() != arg:
    #     logger.error("Error: Invalid regexp characters in %s", arg)
    #     return []

    # Standardize the include argument based on server root
    if not arg.startswith("/"):
        # Normpath will condense ../
        arg = os.path.normpath(os.path.join(self.root, arg))

    # Attempts to add a transform to the file if one does not already exist
    if os.path.isdir(arg):
        self._parse_file(os.path.join(arg, "*"))
    else:
        self._parse_file(arg)

    # Argument represents an fnmatch regular expression, convert it
    # Split up the path and convert each into an Augeas accepted regex
    # then reassemble
    split_arg = arg.split("/")
    for idx, split in enumerate(split_arg):
        if any(char in ApacheParser.fnmatch_chars for char in split):
            # Turn it into a augeas regex
            # TODO: Can this instead be an augeas glob instead of regex
            split_arg[idx] = "* [label()=~regexp('%s')]" % self.fnmatch_to_re(split)
    # Reassemble the argument
    # Note: This also normalizes the argument /serverroot/ -> /serverroot
    arg = "/".join(split_arg)

    return get_aug_path(arg)


# Traceback (RuntimeError)
The log file says the following:
2015-09-17 04:37:46,230:DEBUG:letsencrypt.cli:Root logging level set at 30
2015-09-17 04:37:46,231:INFO:letsencrypt.cli:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2015-09-17 04:37:46,231:DEBUG:letsencrypt.cli:Arguments: ['-d', 'ssl.zzap.org', 'auth']
2015-09-17 04:37:46,232:DEBUG:letsencrypt.cli:Discovered plugins: PluginsRegistry(PluginEntryPoint#apache,PluginEntryPoint#nginx,PluginEntryPoint#null,PluginEntryPoint#manual,PluginEntryPoint#standalone)
2015-09-17 04:37:47,377:DEBUG:letsencrypt.cli:Exiting abnormally:
Traceback (most recent call last):
File "/usr/local/bin/letsencrypt", line 9, in
load_entry_point('letsencrypt==0.1', 'console_scripts', 'letsencrypt')()
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/cli.py", line 920, in main
return args.func(args, config, plugins)
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/cli.py", line 312, in auth
config, args.authenticator, plugins)
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/display/ops.py", line 98, in pick_authenticator
config, default, plugins, question, (interfaces.IAuthenticator,))
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/display/ops.py", line 72, in pick_plugin
verified.prepare()
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/plugins/disco.py", line 197, in prepare
return [plugin_ep.prepare() for plugin_ep in self._plugins.itervalues()]
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/plugins/disco.py", line 98, in prepare
self._initialized.prepare()
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt_apache/configurator.py", line 144, in prepare
self.aug, self.conf("server-root"), self.conf("ctl"))
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt_apache/parser.py", line 54, in init
self.init_modules()
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt_apache/parser.py", line 72, in init_modules
matches = self.find_dir("LoadModule")
...skipping...
return args.func(args, config, plugins)
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/cli.py", line 312, in auth
config, args.authenticator, plugins)
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/display/ops.py", line 98, in pick_authenticator
config, default, plugins, question, (interfaces.IAuthenticator,))
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/display/ops.py", line 72, in pick_plugin
verified.prepare()
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/plugins/disco.py", line 197, in prepare
return [plugin_ep.prepare() for plugin_ep in self._plugins.itervalues()]
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt/plugins/disco.py", line 98, in prepare
self._initialized.prepare()
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt_apache/configurator.py", line 144, in prepare
self.aug, self.conf("server-root"), self.conf("ctl"))
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt_apache/parser.py", line 54, in init
self.init_modules()
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt_apache/parser.py", line 72, in init_modules
matches = self.find_dir("LoadModule")
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt_apache/parser.py", line 304, in find_dir
exclude))
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/letsencrypt_apache/parser.py", line 282, in find_dir
"%s//*[self::directive=~regexp('%s')]" % (start, regex))
File "/usr/local/src/letsencrypt/venv/local/lib/python2.7/site-packages/augeas.py", line 415, in match
raise RuntimeError("Error during match procedure!", path)
RuntimeError: ('Error during match procedure!', u"/files/etc/apache2/sites-enabled///*[self::directive=~regexp('([Ll][Oo][Aa][Dd][Mm][Oo][Dd][Uu][Ll][Ee])|([Ii][Nn][Cc][Ll][Uu][Dd][Ee])|([Ii][Nn][Cc][Ll][Uu][Dd][Ee][Oo][Pp][Tt][Ii][Oo][Nn][Aa][Ll])')]")

# Fixed code
def _get_include_path(self, arg):
    """Converts an Apache Include directive into Augeas path.

    Converts an Apache Include directive argument into an Augeas
    searchable path

    .. todo:: convert to use os.path.join()

    :param str arg: Argument of Include directive

    :returns: Augeas path string
    :rtype: str

    """
    # Check to make sure only expected characters are used <- maybe remove
    # validChars = re.compile("[a-zA-Z0-9.*?_-/]*")
    # matchObj = validChars.match(arg)
    # if matchObj.group() != arg:
    #     logger.error("Error: Invalid regexp characters in %s", arg)
    #     return []

    # Standardize the include argument based on server root
    if not arg.startswith("/"):
        # Normpath will condense ../
        arg = os.path.normpath(os.path.join(self.root, arg))
    else:
        arg = os.path.normpath(arg)

    # Attempts to add a transform to the file if one does not already exist
    if os.path.isdir(arg):
        self._parse_file(os.path.join(arg, "*"))
    else:
        self._parse_file(arg)

    # Argument represents an fnmatch regular expression, convert it
    # Split up the path and convert each into an Augeas accepted regex
    # then reassemble
    split_arg = arg.split("/")
    for idx, split in enumerate(split_arg):
        if any(char in ApacheParser.fnmatch_chars for char in split):
            # Turn it into a augeas regex
            # TODO: Can this instead be an augeas glob instead of regex
            split_arg[idx] = "* [label()=~regexp('%s')]" % self.fnmatch_to_re(split)
    # Reassemble the argument
    # Note: This also normalizes the argument /serverroot/ -> /serverroot
    arg = "/".join(split_arg)

    return get_aug_path(arg)