Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ConfigurationFileReader::ReadLine returns typing.Optional[str]#4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionsrc/implementation/v00/configuration_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3308,7 +3308,7 @@ def Helper__LoadFileContent(
lineData = fileContent.ReadLine()

if not lineData:
#assert lineData is None
assert lineData is None
break

assert type(lineData) == str
Expand Down
3 changes: 2 additions & 1 deletionsrc/os/abstract/configuration_os_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,14 +6,15 @@
from ...core.raise_error import RaiseError

import datetime
import typing


# //////////////////////////////////////////////////////////////////////////////
# class ConfigurationFileReader


class ConfigurationFileReader:
def ReadLine(self) -> str:
def ReadLine(self) ->typing.Optional[str]:
RaiseError.MethodIsNotImplemented(__class__, "ReadLine")


Expand Down
12 changes: 10 additions & 2 deletionssrc/os/local/configuration_os_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@
import os
import io
import datetime
import typing

# //////////////////////////////////////////////////////////////////////////////
# class ConfigurationOsFile
Expand DownExpand Up@@ -49,9 +50,16 @@ def IsClosed(self) -> bool:
return self.m_file is None

# --------------------------------------------------------------------
def ReadLine(self) -> str:
def ReadLine(self) ->typing.Optional[str]:
assert isinstance(self.m_file, io.TextIOWrapper)
return self.m_file.readline()
r = self.m_file.readline()
assert type(r) == str # noqa: E721
if not r:
assert r == ""
return None

assert r != ""
return r

# --------------------------------------------------------------------
def Overwrite(self, text: str) -> None:
Expand Down
13 changes: 11 additions & 2 deletionstests/CfgFileReader.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
from src.os.abstract.configuration_os_ops import ConfigurationFileReader

import io
import typing

# //////////////////////////////////////////////////////////////////////////////
# class CfgFileReader
Expand All@@ -19,9 +20,17 @@ def __init__(self, text: str):
self.m_file = io.StringIO(text)

# --------------------------------------------------------------------
def ReadLine(self) -> str:
def ReadLine(self) ->typing.Optional[str]:
assert type(self.m_file) == io.StringIO
return self.m_file.readline()

r = self.m_file.readline()
assert type(r) == str # noqa: E721
if not r:
assert r == ""
return None

assert r != ""
return r


# //////////////////////////////////////////////////////////////////////////////

[8]ページ先頭

©2009-2025 Movatter.jp