Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions bandit.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Warnings "Use of assert detected" are invalid.
# Please disable this pattern for test code.
skips: .'B101'.
assert_used: skips: ['*_test.py', '*test_*.py']
249 changes: 249 additions & 0 deletions fixtures/ru.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
# Russian translations for PROJECT.
# Copyright (C) 2023 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-03-01 15:29+0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ru\n"
"Language-Team: ru <LL@li.org>\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.11.0\n"

#: pipeline_integrity/method/asme/b31g_1991.py:51
msgid "The relative defect depth == defect depth / pipe wall thickness * 100%."
msgstr "Относительная глубина дефекта == глубина / толщина стенки * 100%."

#: pipeline_integrity/method/asme/b31g_1991.py:60
#, python-format
msgid "The relative defect depth less than {}% from wall thickness."
msgstr "Относительная глубина дефекта меньше {}% толщины стенки."

#: pipeline_integrity/method/asme/b31g_1991.py:63
#: pipeline_integrity/method/asme/b31g_1991.py:86
#: pipeline_integrity/method/asme/b31g_1991.py:108
msgid "The defect is not dangerous."
msgstr "Дефект не опасен."

#: pipeline_integrity/method/asme/b31g_1991.py:70
#, python-format
msgid "The relative defect depth greater than {}% from wall thickness."
msgstr "Относительная глубина дефекта больше {}% толщины стенки."

#: pipeline_integrity/method/asme/b31g_1991.py:73
msgid "The defect needs to be repaired."
msgstr "Дефект нужно ремонтировать."

#: pipeline_integrity/method/asme/b31g_1991.py:83
msgid ""
"The length of the defect {} does not exceed the maximum allowable length "
"{}."
msgstr "Длина дефекта {} не превышает максимально допустимую длину {}."

#: pipeline_integrity/method/asme/b31g_1991.py:95
msgid "The length of the defect {} exceed the maximum allowable length {}."
msgstr "Длина дефекта {} превышает максимально допустимую длину {}."

#: pipeline_integrity/method/asme/b31g_1991.py:98
msgid "It is necessary to calculate the allowable pressure for defect."
msgstr "Необходимо рассчитать допустимое давление для дефекта."

#: pipeline_integrity/method/asme/b31g_1991.py:105
msgid "The working pressure {} does not exceed the allowable pressure {}."
msgstr "Рабочее давление {} не превышает допустимое давление {}."

#: pipeline_integrity/method/asme/b31g_1991.py:114
msgid "Repair or pressure reduction to {} required."
msgstr "Необходим ремонт или снижение давления до {}."

#: pipeline_integrity/method/asme/b31g_1991.py:124
msgid "Parameter B."
msgstr "Параметр B."

#: pipeline_integrity/method/asme/b31g_1991.py:132
msgid "The relative defect depth {} less than {}%."
msgstr "Относительная глубина дефекта {} меньше {}%."

#: pipeline_integrity/method/asme/b31g_1991.py:135
msgid "Set Parameter B value to {}."
msgstr "Параметр B ghbybvftncz hfdysv {}."

#: pipeline_integrity/method/asme/b31g_1991.py:141
msgid "The relative defect depth {} more than {}%."
msgstr "Относительная глубина дефекта {} больше {}%."

#: pipeline_integrity/method/asme/b31g_1991.py:182
msgid "Calculation of the maximum allowable defect length."
msgstr "Расчет максимально допустимой длины дефекта."

#: pipeline_integrity/method/asme/b31g_1991.py:220
msgid "Calculation of the maximum allowable pressure."
msgstr "Расчет максимально допустимого давления."

#: pipeline_integrity/method/asme/b31g_1991.py:221
msgid "Parameter A for defect length {}."
msgstr "Параметр A для дефекта длиной {}."

#: pipeline_integrity/method/asme/b31g_1991.py:226
msgid "Design pressure."
msgstr "Расчетное давление."

#: pipeline_integrity/method/asme/b31g_1991.py:236
msgid "Parameter A more than 4."
msgstr "Параметр A больше 4."

#: pipeline_integrity/method/asme/b31g_1991.py:247
msgid "Parameter A less than 4."
msgstr "Параметр A меньше 4."

#: pipeline_integrity/method/asme/b31g_1991.py:262
msgid "Safe pressure {} more than design pressure {}."
msgstr "Безопасное давление {} превышает расчетное давление {}."

#: pipeline_integrity/method/asme/b31g_1991.py:266
msgid "Use design pressure {} as maximum allowable pressure."
msgstr "Используем расчетное давление как максимально допустимое давление."

#: pipeline_integrity/method/asme/b31g_1991.py:271
msgid "Use safe pressure {} as maximum allowable pressure."
msgstr "Используем безопасное давление как максимально допустимое давление."

#: pipeline_integrity/method/asme/b31g_2012.py:40
msgid "Parameter Z = length^2 / (diameter * wallthickness)."
msgstr "Параметр Z = длина^2 / (диаметр * толщина)."

#: pipeline_integrity/method/asme/b31g_2012.py:56
msgid "Parameter M = sqrt(1 + 0.8 * Z)."
msgstr "Параметр M = sqrt(1 + 0.8 * Z)."

#: pipeline_integrity/method/asme/b31g_2012.py:71
msgid "Parameter Sflow = 1.1 * material_smys."
msgstr "Параметр Sflow = 1.1 * предел_текучести."

#: pipeline_integrity/method/asme/b31g_2012.py:81
msgid "Parameter Sflow > material SMTS."
msgstr "Параметр Sflow > предела прочности при растяжении материала."

#: pipeline_integrity/method/asme/b31g_2012.py:82
msgid "Use material SMTS as Sflow = {}."
msgstr "Используем предел прочности при растяжении материала как параметр Sflow."

#: pipeline_integrity/method/asme/b31g_2012.py:94
msgid "Calculate failure stress level by the classic way."
msgstr "Вычисляем величину напряжения разрыва классическим методом."

#: pipeline_integrity/method/asme/b31g_2012.py:107
msgid "Parameter Z = {} <= 20."
msgstr "Параметр Z = {} <= 20."

#: pipeline_integrity/method/asme/b31g_2012.py:108
msgid ""
"Failure stress level = Sflow * (1 - 2/3 * (depth / wallthickness)) / (1 -"
" 2/3 * (depth / wallthickness) / M)."
msgstr ""
"Напряжение разрыва = Sflow * (1 - 2/3 * (глубина / толщина)) / (1 - 2/3 *"
" (глубина / толщина) / M)."

#: pipeline_integrity/method/asme/b31g_2012.py:130
msgid "Parameter Z = {} > 20."
msgstr "Параметр Z = {} > 20."

#: pipeline_integrity/method/asme/b31g_2012.py:131
msgid "Failure stress level = Sflow * (1 - depth / wallthickness)."
msgstr "Напряжение разрыва = Sflow * (1 - глубина / толщина)."

#: pipeline_integrity/method/asme/b31g_2012.py:145
msgid "Calculate failure stress level by the modified way."
msgstr "Вычисляем величину напряжения разрыва модифицированным методом."

#: pipeline_integrity/method/asme/b31g_2012.py:155
msgid "Parameter Z = {} <= 50."
msgstr "Параметр Z = {} <= 50."

#: pipeline_integrity/method/asme/b31g_2012.py:156
msgid "Parameter M = sqrt(1 + 0.6275 * Z - 0.003375 * Z^2)"
msgstr "Параметр M = sqrt(1 + 0.6275 * Z - 0.003375 * Z^2)"

#: pipeline_integrity/method/asme/b31g_2012.py:166
msgid "Parameter Z = {} > 50."
msgstr "Параметр Z = {} > 50."

#: pipeline_integrity/method/asme/b31g_2012.py:167
msgid "Parameter M = 0.032 * Z + 3.3"
msgstr "Параметр M = 0.032 * Z + 3.3"

#: pipeline_integrity/method/asme/b31g_2012.py:177
msgid ""
"Failure stress level = Sflow * (1 - 0.85 * (depth / wallthickness)) / (1 "
"- 0.85 * (depth / wallthickness) / M)."
msgstr ""
"Напряжение разрыва = Sflow * (1 - 0.85 * (глубина / толщина)) / (1 - 0.85"
" * (глубина / толщина) / M)."

#: pipeline_integrity/method/asme/b31g_2012.py:207
msgid "Failure pressure = 2 * stress_fail * wallthickness / diameter."
msgstr "Давление разрыва = 2 * stress_fail * толщина / диаметр."

#: pipeline_integrity/method/asme/b31g_2012.py:220
msgid "modified"
msgstr "модифицированный"

#: pipeline_integrity/method/asme/b31g_2012.py:220
msgid "classic"
msgstr "классический"

#: pipeline_integrity/method/asme/b31g_2012.py:222
msgid "Calculate ERF by {} {}."
msgstr "Вычисляем КБД по {} {}."

#: pipeline_integrity/method/asme/b31g_2012.py:229
msgid "ERF = pipe_maop / press_fail."
msgstr "КБД = рабочее_давление / давление_разрыва."

#: pipeline_integrity/method/asme/b31g_2012.py:246
msgid "Repair required immediately, years to repair: 0."
msgstr "Необходим ремонт, лет до ремонта: 0."

#: pipeline_integrity/method/asme/b31g_2012.py:257
msgid "Repair is not required at the moment, calculate the time before repair."
msgstr "На данный момент ремонт не требуется, вычисляем время до ремонта."

#: pipeline_integrity/method/asme/b31g_2012.py:259
msgid ""
"With corrosion rate {} mm/year, pipe wall {} and depth {} a through hole "
"is formed after years: {}."
msgstr "При скорости коррозии {} мм/год, толщине стенки {} и глубине дефекта {}, сквозной дефект образуется через лет: {}."

#: pipeline_integrity/method/asme/b31g_2012.py:277
msgid "But even a through defect does not require repair."
msgstr "Но даже сквозной дефект не нуждается в ремонте."

#: pipeline_integrity/method/asme/b31g_2012.py:278
msgid "ERF = {}. Use special value for years: 777."
msgstr "КБД = {}. Используем специальное значение 777 для годов до ремонта."

#: pipeline_integrity/method/asme/b31g_2012.py:288
msgid ""
"Calculating the year in which the corrosion growth of the defect will "
"require repair."
msgstr "Вычисляем через сколько лет дефект потребует ремонта при заданной скорости коррозии."

#: pipeline_integrity/method/asme/b31g_2012.py:307
#: pipeline_integrity/method/asme/b31g_2012.py:308
msgid "Years: {} ERF: {}."
msgstr "Года: {} КБД: {}."

#: pipeline_integrity/method/asme/b31g_2012.py:309
msgid "Defect will require repair after years: {}."
msgstr "Дефект нужно будет отремонтировать через лет: {}."

1 change: 1 addition & 0 deletions pipeline_csv/integrity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Pipeline defects danger calculation."""
50 changes: 50 additions & 0 deletions pipeline_csv/integrity/i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Localization stuff."""


class Lang:
"""Embedded languages for localize explain text."""

Ru = 'ru'


def fake_gettext(text, context):
"""Translate text in given context."""
if isinstance(context.is_explain, dict):
return context.is_explain.get(text, text)

return text


def read_item(sign, line, inp):
"""Read multiline text item from given start line and input.

Return tuple from item and last read line.
"""
item = [line.strip().split(sign)[1].strip('"')]
line = next(inp).strip()
while line.startswith('"'):
item.append(line.strip('"'))
line = next(inp).strip()

return (''.join(item), line)


def read_pair(line, inp):
"""Read and return pair msgid, msgstr from given start line and input."""
msgid, line = read_item('msgid ', line, inp)
msgstr, line = read_item('msgstr ', line, inp)

return (msgid, msgstr)


def load_po(file_name):
"""Load data from given po file and return it as dict."""
data = {}
with open(file_name, 'rt', encoding='utf-8') as inp:
for line in inp:
if line.startswith('msgid '):
msgid, msgstr = read_pair(line, inp)
if msgid and msgstr:
data[msgid] = msgstr

return data
File renamed without changes.
6 changes: 6 additions & 0 deletions tests/test/test_integrity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Root class for testing integrity package."""
from .. import TestIV


class TestIntegrity(TestIV):
"""Base class for Integrity tests."""
35 changes: 35 additions & 0 deletions tests/test/test_integrity/test_i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Tests i18n.py file.

make test T=test_integrity/test_i18n.py
"""
from . import TestIntegrity


class MockContext:
"""Mocked Context class."""

def __init__(self, is_explain=None):
"""Make instance."""
self.is_explain = is_explain


class TestI18n(TestIntegrity):
"""File i18n.py."""

def test_load_po(self):
"""Check load_po function."""
from pipeline_csv.integrity.i18n import load_po

data = load_po(self.fixture('ru.po'))
assert len(data) > 1

def test_fgettext(self):
"""Check fake_gettext function."""
from pipeline_csv.integrity.i18n import fake_gettext

assert fake_gettext('xxx', MockContext()) == 'xxx'

data = {
'xxx': 'yyy'
}
assert fake_gettext('xxx', MockContext(is_explain=data)) == 'yyy'
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Module test_material.py.

make test T=test_material.py
make test T=test_integrity/test_material.py
"""
from . import TestIV
from . import TestIntegrity


class TestMaterial(TestIV):
class TestMaterial(TestIntegrity):
"""Check material.py file."""

@staticmethod
def test_material():
"""Check PipeMaterial class."""
from pipeline_csv.material import PipeMaterial
from pipeline_csv.integrity.material import PipeMaterial

material = PipeMaterial("Сталь3", 250)
assert material.name == "Сталь3"
Expand Down