# Path: src/imgbased/utils.py
# class File(object):
#     filename = None
# 
#     @property
#     def contents(self):
#         return self.read()
# 
#     @property
#     def stat(self):
#         return os.stat(self.filename)
# 
#     def __init__(self, fn):
#         self.filename = fn
# 
#     def __str__(self):
#         return "<%s %s>" % (self.__class__.__name__, self.filename)
# 
#     def read(self):
#         with open(self.filename) as src:
#             return src.read()
# 
#     def exists(self):
#         return os.path.exists(self.filename)
# 
#     def replace(self, pat, repl):
#         self.write(self.contents.replace(pat, repl))
# 
#     def sub(self, pat, repl):
#         self.write(re.sub(pat, repl, self.contents))
# 
#     def write(self, data, mode="w", mkdir=False):
#         if mkdir:
#             os.makedirs(os.path.dirname(self.filename))
#         with open(self.filename, mode) as dst:
#             dst.write(data)
# 
#     def writen(self, data, mode="w"):
#         self.write(data + "\n", mode)
# 
#     def remove(self):
#         os.unlink(self.filename)
# 
#     def lines(self, keepends=False):
#         for line in self.contents.splitlines(keepends):
#             yield line
# 
#     def findall(self, pat):
#         r = []
#         for line in self.lines():
#             r += re.findall(pat, line)
#         return r
# 
#     def chmod(self, mode):
#         return os.chmod(self.filename, mode)
# 
#     def basename(self):
#         return os.path.basename(self.filename)
# 
#     def truncate(self, size=0):
#         """Truncate the file to size
#         """
#         with open(self.filename, "w") as fd:
#             fd.truncate(size)


import logging
import re
from .utils import File
# Copyright (C) 2017  Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author(s): Ryan Barry <rbarry@redhat.com>
#


log = logging.getLogger(__package__)


class TimeserverError(Exception):
    pass


class NoKeyFoundError(TimeserverError):
    pass



# Path: src/imgbased/utils.py
# class File(object):
#     filename = None
# 
#     @property
#     def contents(self):
#         return self.read()
# 
#     @property
#     def stat(self):
#         return os.stat(self.filename)
# 
#     def __init__(self, fn):
#         self.filename = fn
# 
#     def __str__(self):
#         return "<%s %s>" % (self.__class__.__name__, self.filename)
# 
#     def read(self):
#         with open(self.filename) as src:
#             return src.read()
# 
#     def exists(self):
#         return os.path.exists(self.filename)
# 
#     def replace(self, pat, repl):
#         self.write(self.contents.replace(pat, repl))
# 
#     def sub(self, pat, repl):
#         self.write(re.sub(pat, repl, self.contents))
# 
#     def write(self, data, mode="w", mkdir=False):
#         if mkdir:
#             os.makedirs(os.path.dirname(self.filename))
#         with open(self.filename, mode) as dst:
#             dst.write(data)
# 
#     def writen(self, data, mode="w"):
#         self.write(data + "\n", mode)
# 
#     def remove(self):
#         os.unlink(self.filename)
# 
#     def lines(self, keepends=False):
#         for line in self.contents.splitlines(keepends):
#             yield line
# 
#     def findall(self, pat):
#         r = []
#         for line in self.lines():
#             r += re.findall(pat, line)
#         return r
# 
#     def chmod(self, mode):
#         return os.chmod(self.filename, mode)
# 
#     def basename(self):
#         return os.path.basename(self.filename)
# 
#     def truncate(self, size=0):
#         """Truncate the file to size
#         """
#         with open(self.filename, "w") as fd:
#             fd.truncate(size)


# Path: src/imgbased/timeserver.py
import logging
import re
from .utils import File

# Copyright (C) 2017  Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author(s): Ryan Barry <rbarry@redhat.com>
#


log = logging.getLogger(__package__)


class TimeserverError(Exception):
    pass


class NoKeyFoundError(TimeserverError):
    pass



class TimeserverConfiguration(File):