Adding newline character in raw format was fixed.

master
root 3 years ago
parent aed9be1eee
commit 1ee3326431

@ -2,8 +2,12 @@ from ..variables.loader import Datavars
from ..commands.commands import Command
from ..logging import dictLogConfig
from logging.config import dictConfig
from typing import (
Callable,
Optional,
NoReturn
)
from logging import getLogger
from typing import Callable
from fastapi import FastAPI
from .worker import Worker
import importlib
@ -119,13 +123,13 @@ class Server:
# Обработчики сообщений воркеров.
# Вспомогательные методы.
def _add_routes(self, method: Callable, routes: dict) -> None:
def _add_routes(self, method: Callable, routes: dict) -> NoReturn:
'''Метод для добавления методов.'''
for path, handler in routes.items():
router = method(path)
router(handler)
def _make_worker(self, wid: int = None):
def _make_worker(self, wid: Optional[int] = None):
'''Метод для создания воркера для команды.'''
if wid is not None:
self._workers[wid] = Worker(wid, self._event_loop)

@ -387,6 +387,7 @@ class Format:
template_paths.append(template_path)
header = self._make_header(template_paths)
print(header)
document_text = re.sub(header_pattern, '', input_text)
if check_shebang:

@ -38,17 +38,19 @@ class RawFormat(Format):
self._document_text)
def join_template(self, template):
sep = ""
if self._before:
if (template._document_text
and not template._document_text.endswith("\n")):
sep = "\n"
self._document_text = '{0}{1}{2}'.format(
template._document_text,
"" if template._document_text.
endswith("\n") else "\n",
template._document_text, sep,
self._document_text)
else:
if self._document_text and not self._document_text.endswith("\n"):
sep = "\n"
self._document_text = '{0}{1}{2}'.format(
self._document_text,
"" if self._document_text.
endswith("\n") else "\n",
self._document_text, sep,
template._document_text)
def __bool__(self):

@ -71,7 +71,7 @@ class Process:
self._process = None
self._iterator = iter([])
# Flags.
# Флаги.
self._opened = False
self._is_read = False
@ -79,12 +79,12 @@ class Process:
self._writable = False
self._readable_errors = False
# I/O handlers.
# I/O обработчики.
self.stdin_handler = None
self.stdout_handler = None
self.stderr_handler = None
# Caches.
# Кэши.
self._output_cache = ''
self._error_cache = ''

@ -87,10 +87,10 @@ class PackageCreator(type):
class Version:
'''Класс объектов представляющих значения версий.'''
_suffix_order = {'alpha': 0, 'beta': 1, 'pre': 2,
'rc': 3, 'no': 4, 'p': 5}
'''Класс для работы со значениями версий.'''
def __init__(self, version_value: Union["Version", None, int,
float, str] = None):
if version_value is None:

@ -1506,7 +1506,7 @@ class TestDirectoryProcessor:
'/etc/dir_61/._cfg0000_file_0'),
'r') as new_file:
new_text = new_file.read()
assert new_text == '\nnew content\n'
assert new_text == 'new content\n'
def test_current_template_variable(self):
datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,
@ -1518,7 +1518,7 @@ class TestDirectoryProcessor:
'# Processed template files:\n' +
f'# {template_path}\n' +
'#' + '-' * 79 +
f'\n\ntemplate = {template_path}\n')
f'\ntemplate = {template_path}\n')
directory_processor = DirectoryProcessor(
'install',
datavars_module=datavars,
@ -1803,7 +1803,7 @@ class TestDirectoryProcessor:
with open(join_paths(CHROOT_PATH,
'/etc/file_23'), 'r') as target_file:
target_text = target_file.read()
assert target_text == "joy division -- new dawn fades"
assert target_text == "joy division -- new dawn fades\n"
mode = os.stat(join_paths(CHROOT_PATH, '/etc/file_23')).st_mode
assert int(mode) == 0o100645

@ -8,6 +8,7 @@ dir /etc/dir_60
obj /etc/dir_60/file_0 c9a9459e4266ea35a612b90dc3653112 1593525253
obj /etc/file_19 3fd436479300b04370b97f4bcfdc90f7 1592574626
obj /etc/file_20 3fd436479300b04370b97f4bcfdc90f7 1592574626
obj /etc/file_23 c18d75dcdbe03b64a461dc708b5b1a80 1592574626
dir /etc/dir_76
obj /etc/dir_76/file_0 3fd436479300b04370b97f4bcfdc90f7 1592574626
dir /etc/dir_77

Loading…
Cancel
Save