# Path: libxyz/core/utils.py
# def bstring(bstr, enc=None):
#     """
#     Return encoded byte string
#     """
# 
#     if isinstance(bstr, str):
#         return bstr
#     
#     if enc is None:
#         enc = xyzenc
# 
#     if not isinstance(bstr, unicode):
#         return str(bstr)
# 
#     return bstr.encode(enc, 'replace')
# 
# def split_cmd(cmd):
#     """
#     Split command line
#     """
# 
#     lexer = Lexer(ustring(cmd), [], comment=None, macro=None)
#     lexer.escaping_on()
# 
#     data = []
# 
#     while True:
#         res = lexer.lexer()
# 
#         if res is None:
#             break
#         else:
#             __, val = res
#             data.append(val)
# 
#     return data


import os
import itertools
from libxyz.core.utils import bstring, split_cmd
from domain_base import BaseDomain
# XYZCommander is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# XYZCommander is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
# You should have received a copy of the GNU Lesser Public License
# along with XYZCommander. If not, see <http://www.gnu.org/licenses/>.




class Domain(BaseDomain):
    """
    service(8) domain
    """

    INITD_DIR = "/etc/init.d"

    def complete(self, buf):
        """
        Take current buffer and return list-generator of all
                matched entries in current domain.

        @param buf: Current buffer
        @return: list-generator
        """


# Path: libxyz/core/utils.py
# def bstring(bstr, enc=None):
#     """
#     Return encoded byte string
#     """
# 
#     if isinstance(bstr, str):
#         return bstr
#     
#     if enc is None:
#         enc = xyzenc
# 
#     if not isinstance(bstr, unicode):
#         return str(bstr)
# 
#     return bstr.encode(enc, 'replace')
# 
# def split_cmd(cmd):
#     """
#     Split command line
#     """
# 
#     lexer = Lexer(ustring(cmd), [], comment=None, macro=None)
#     lexer.escaping_on()
# 
#     data = []
# 
#     while True:
#         res = lexer.lexer()
# 
#         if res is None:
#             break
#         else:
#             __, val = res
#             data.append(val)
# 
#     return data


# Path: plugins/core/complete/domain_service.py
import os
import itertools
from libxyz.core.utils import bstring, split_cmd
from domain_base import BaseDomain

# XYZCommander is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# XYZCommander is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
# You should have received a copy of the GNU Lesser Public License
# along with XYZCommander. If not, see <http://www.gnu.org/licenses/>.




class Domain(BaseDomain):
    """
    service(8) domain
    """

    INITD_DIR = "/etc/init.d"

    def complete(self, buf):
        """
        Take current buffer and return list-generator of all
                matched entries in current domain.

        @param buf: Current buffer
        @return: list-generator
        """


        cmd = split_cmd(bstring(buf))