当前位置: 首页>>代码示例>>Python>>正文


Python Dive.do_dive_without_exceptions方法代码示例

本文整理汇总了Python中dipplanner.dive.Dive.do_dive_without_exceptions方法的典型用法代码示例。如果您正苦于以下问题:Python Dive.do_dive_without_exceptions方法的具体用法?Python Dive.do_dive_without_exceptions怎么用?Python Dive.do_dive_without_exceptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dipplanner.dive.Dive的用法示例。


在下文中一共展示了Dive.do_dive_without_exceptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestDiveAirDiveOutput_woExc

# 需要导入模块: from dipplanner.dive import Dive [as 别名]
# 或者: from dipplanner.dive.Dive import do_dive_without_exceptions [as 别名]
class TestDiveAirDiveOutput_woExc(TestDive):
    """Test segments output for air dive 1 without exc."""

    expected_result = [
        " DESCENT: at  30m for   1:30 [RT:  1:30], on Air,  SP:0.0, END:29m",
        "   CONST: at  30m for  28:30 [RT: 30:00], on Air,  SP:0.0, END:29m",
        "  ASCENT: at  15m for   1:30 [RT: 31:30], on Air,  SP:0.0, END:14m",
        "    DECO: at  15m for   0:01 [RT: 31:31], on Air,  SP:0.0, END:14m",
        "  ASCENT: at  12m for   1:00 [RT: 32:31], on Air,  SP:0.0, END:11m",
        "    DECO: at  12m for   0:20 [RT: 32:51], on Air,  SP:0.0, END:11m",
        "  ASCENT: at   9m for   1:00 [RT: 33:51], on Air,  SP:0.0, END:8m",
        "    DECO: at   9m for   2:39 [RT: 36:30], on Air,  SP:0.0, END:8m",
        "  ASCENT: at   6m for   1:00 [RT: 37:30], on Air,  SP:0.0, END:5m",
        "    DECO: at   6m for   4:59 [RT: 42:29], on Air,  SP:0.0, END:5m",
        "  ASCENT: at   3m for   1:00 [RT: 43:29], on Air,  SP:0.0, END:2m",
        "    DECO: at   3m for  12:42 [RT: 56:11], on Air,  SP:0.0, END:2m",
        "  ASCENT: at   0m for   1:00 [RT: 57:11], on Air,  SP:0.0, END:0m", ]


    def setUp(self):
        """Init of the tests."""
        super().setUp()
        diveseg1 = SegmentDive(30, 30 * 60, self.airtank, 0)
        self.profile1 = Dive([diveseg1], [self.airtank])
        self.profile1.do_dive_without_exceptions()

    def test_segments(self):
        """Check all segments."""
        for idx in range(len(self.expected_result)):
            self.assertEqual(
                str(self.profile1.output_segments[idx]),
                self.expected_result[idx],
                'bad segment n°%s (%s)' % (
                    idx, self.profile1.output_segments[idx]))
开发者ID:ThomasChiroux,项目名称:dipplanner,代码行数:36,代码来源:dive_test.py

示例2: main

# 需要导入模块: from dipplanner.dive import Dive [as 别名]
# 或者: from dipplanner.dive.Dive import do_dive_without_exceptions [as 别名]
def main(cli_arguments=None):
    """Main entry point.

    main uses the parameters, tanks and dives given in config file(s)
    and/or command line, calculates the dives and return the output in stdout.

    :param list cli_arguments: list of arguments, like sys.argv
    """
    if sys.version_info < (3, 4):
        raise SystemExit("ERROR: This programm needs python 3.4 or greater")

    if cli_arguments is None:
        cli_arguments = sys.argv

    activate_debug()

    # get the version
    try:
        version_file = open("RELEASE-VERSION", "r")
        try:
            version = version_file.readlines()[0]
            settings.__VERSION__ = version.strip()
        finally:
            version_file.close()
    except IOError:
        settings.__VERSION__ = "unknown"

    dipplanner_arguments = DipplannerCliArguments(cli_arguments)
    dives = dipplanner_arguments.dives

    profiles = []
    current_dive = None
    previous_dive = None
    for dive in dives:
        if previous_dive is None:
            current_dive = Dive(
                dives[dive]['segments'].values(),
                dives[dive]['tanks'].values())
        else:
            current_dive = Dive(
                dives[dive]['segments'].values(),
                dives[dive]['tanks'].values(),
                previous_dive
            )
        if dives[dive]['surface_interval']:
            current_dive.do_surface_interval(dives[dive]['surface_interval'])

        current_dive.do_dive_without_exceptions()
        profiles.append(current_dive)
        previous_dive = current_dive
        # now, dive exceptins do not stop the program anymore, but can be
        # displayed in the output template instead. The used MUST take care of
        # the result.

    # now calculate no flight time based on the last dive
    ######current_dive.no_flight_time_wo_exception()

    # now Prepare the output
    env = Environment(loader=PackageLoader('dipplanner', 'templates'))
    tpl = env.get_template(settings.TEMPLATE)
    # pylint: disable=no-member
    text = tpl.render(settings=settings, dives=profiles)
    # pylint: enable=no-member
    print(text)
开发者ID:ThomasChiroux,项目名称:dipplanner,代码行数:66,代码来源:main.py

示例3: TestDiveAirDiveOutput_woExc

# 需要导入模块: from dipplanner.dive import Dive [as 别名]
# 或者: from dipplanner.dive.Dive import do_dive_without_exceptions [as 别名]
class TestDiveAirDiveOutput_woExc(TestDive):

    def setUp(self):
        TestDive.setUp(self)
        diveseg1 = SegmentDive(30, 30 * 60, self.airtank, 0)
        self.profile1 = Dive([diveseg1], [self.airtank])
        self.profile1.do_dive_without_exceptions()

    def test_segment1(self):
        self.assertEqual(str(self.profile1.output_segments[0]),
                         ' DESCENT: at  30m for   1:30 [RT:  1:30], '
                         'on Air,  SP:0.0, END:29m',
                         'bad segment (%s)'
                         % self.profile1.output_segments[0])

    def test_segment2(self):
        self.assertEqual(str(self.profile1.output_segments[1]),
                         '   CONST: at  30m for  28:30 [RT: 30:00], '
                         'on Air,  SP:0.0, END:29m',
                         'bad segment (%s)'
                         % self.profile1.output_segments[1])

    def test_segment3(self):
        self.assertEqual(str(self.profile1.output_segments[2]),
                         '  ASCENT: at  15m for   1:30 [RT: 31:30], '
                         'on Air,  SP:0.0, END:14m',
                         'bad segment (%s)'
                         % self.profile1.output_segments[2])

    def test_segment4(self):
        self.assertEqual(str(self.profile1.output_segments[3]),
                         '    DECO: at  15m for   0:01 [RT: 31:31], '
                         'on Air,  SP:0.0, END:14m',
                         'bad segment (%s)'
                         % self.profile1.output_segments[3])

    def test_segment5(self):
        self.assertEqual(str(self.profile1.output_segments[4]),
                         '    DECO: at  12m for   0:25 [RT: 31:56], '
                         'on Air,  SP:0.0, END:11m',
                         'bad segment (%s)'
                         % self.profile1.output_segments[4])

    def test_segment6(self):
        self.assertEqual(str(self.profile1.output_segments[5]),
                         '    DECO: at   9m for   2:42 [RT: 34:38], '
                         'on Air,  SP:0.0, END:8m',
                         'bad segment (%s)'
                         % self.profile1.output_segments[5])

    def test_segment7(self):
        self.assertEqual(str(self.profile1.output_segments[6]),
                         '    DECO: at   6m for   5:02 [RT: 39:40], '
                         'on Air,  SP:0.0, END:5m',
                         'bad segment (%s)'
                         % self.profile1.output_segments[6])

    def test_segment8(self):
        self.assertEqual(str(self.profile1.output_segments[7]),
                         '    DECO: at   3m for   8:44 [RT: 48:24], '
                         'on Air,  SP:0.0, END:2m',
                         'bad segment (%s)'
                         % self.profile1.output_segments[7])
开发者ID:hordurk,项目名称:dipplanner,代码行数:65,代码来源:dive_test.py


注:本文中的dipplanner.dive.Dive.do_dive_without_exceptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。