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


Python path.path方法代码示例

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


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

示例1: execute

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def execute(self):
        dist_min = np.array([self.wt_dist[i] for i in range(self.wt_dist.shape[0]) ]).min()
        dist_mean = np.array([self.wt_dist[i] for i in range(self.wt_dist.shape[0]) ]).mean()

        if self.inc==0:
            try:
                pa(self.result_file+'.results').remove()
            except:
                pass
            self.iterations = [self.inc]
            self.targvalue = [[self.foundation_length, self.elnet_length, dist_mean, dist_min, self.net_aep]]
        else:
            self.iterations.append(self.inc)
            self.targvalue.append([self.foundation_length, self.elnet_length, dist_mean, dist_min, self.net_aep])
        self.targname = ['Foundation length', 'El net length', 'Mean WT Dist', 'Min WT Dist', 'AEP']

        targarr = np.array(self.targvalue)
        output =  '%d:'%(self.inc) + ', '.join(['%s=%6.2f'%(self.targname[i], targarr[-1,i]) for i in range(len(self.targname))]) + '\n' # + str(self.wt_positions)
        print output
        with open(self.result_file+'.results','a') as f:
            f.write(output)

        self.inc += 1 
开发者ID:DTUWindEnergy,项目名称:TOPFARM,代码行数:25,代码来源:plot.py

示例2: __init__

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def __init__(self, add_inputs, title='', **kwargs):
        super(OffshorePlot, self).__init__(**kwargs)
        self.fig = plt.figure(num=None, facecolor='w', edgecolor='k') #figsize=(13, 8), dpi=1000
        self.shape_plot = self.fig.add_subplot(121)
        self.objf_plot = self.fig.add_subplot(122)

        self.targname = add_inputs
        self.title = title

        # Adding automatically the inputs
        for i in add_inputs:
            self.add(i, Float(0.0, iotype='in'))

        #sns.set(style="darkgrid")
        #self.pal = sns.dark_palette("skyblue", as_cmap=True)
        plt.rc('lines', linewidth=1)
        plt.ion()
        self.force_execute = True
        if not pa('fig').exists():
            pa('fig').mkdir() 
开发者ID:DTUWindEnergy,项目名称:TOPFARM,代码行数:22,代码来源:plot.py

示例3: setUpClass

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def setUpClass(cls):
        if 'libclang' in autowig.parser:
            autowig.parser.plugin = 'libclang'
        cls.srcdir = Path('fp17')
        if not cls.srcdir.exists():
            Repo.clone_from('https://github.com/StatisKit/FP17.git', cls.srcdir.relpath('.'), recursive=True)
        cls.srcdir = cls.srcdir/'share'/'git'/'ClangLite'
        cls.incdir = Path(sys.prefix).abspath()
        if any(platform.win32_ver()):
            cls.incdir = cls.incdir/'Library'
        subprocess.check_output(['scons', 'cpp', '--prefix=' + str(cls.incdir)],
                                cwd=cls.srcdir)
        if any(platform.win32_ver()):
            cls.scons = subprocess.check_output(['where', 'scons.bat']).strip()
        else:
            cls.scons = subprocess.check_output(['which', 'scons']).strip()
        cls.incdir = cls.incdir/'include'/'clanglite' 
开发者ID:StatisKit,项目名称:AutoWIG,代码行数:19,代码来源:test_subset.py

示例4: pathitems

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def pathitems(self):
        """return list of pathitems"""
        if not self.normsubpathitems:
            return []

        # remove trailing normline_pt of closed subpaths
        if self.closed and isinstance(self.normsubpathitems[-1], normline_pt):
            normsubpathitems = self.normsubpathitems[:-1]
        else:
            normsubpathitems = self.normsubpathitems

        result = [path.moveto_pt(*self.atbegin_pt())]
        for normsubpathitem in normsubpathitems:
            result.append(normsubpathitem.pathitem())
        if self.closed:
            result.append(path.closepath())
        return result 
开发者ID:VLSIDA,项目名称:OpenRAM,代码行数:19,代码来源:normpath.py

示例5: intersect

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def intersect(self, other):
        """intersect self with other path

        Returns a tuple of lists consisting of the parameter values
        of the intersection points of the corresponding normpath.
        """
        other = other.normpath()

        # here we build up the result
        intersections = ([], [])

        # Intersect all normsubpaths of self with the normsubpaths of
        # other.
        for ia, normsubpath_a in enumerate(self.normsubpaths):
            for ib, normsubpath_b in enumerate(other.normsubpaths):
                for intersection in zip(*normsubpath_a.intersect(normsubpath_b)):
                    intersections[0].append(normpathparam(self, ia, intersection[0]))
                    intersections[1].append(normpathparam(other, ib, intersection[1]))
        return intersections 
开发者ID:VLSIDA,项目名称:OpenRAM,代码行数:21,代码来源:normpath.py

示例6: _tangent

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def _tangent(self, params, length_pt):
        """return tangent vector of path at params

        If length_pt in pts is not None, the tangent vector will be scaled to
        the desired length.
        """

        result = [None] * len(params)
        tangenttemplate = path.line_pt(0, 0, length_pt, 0).normpath()
        for normsubpathindex, (indices, params) in self._distributeparams(params).items():
            for index, atrafo in zip(indices, self.normsubpaths[normsubpathindex].trafo(params)):
                if atrafo is invalid:
                    result[index] = invalid
                else:
                    result[index] = tangenttemplate.transformed(atrafo)
        return result 
开发者ID:VLSIDA,项目名称:OpenRAM,代码行数:18,代码来源:normpath.py

示例7: i18n_validate_transifex_config

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def i18n_validate_transifex_config():
    """
    Make sure config file with username/password exists
    """
    home = path('~').expanduser()
    config = home / '.transifexrc'

    if not config.isfile or config.getsize == 0:
        msg = colorize(
            'red',
            "Cannot connect to Transifex, config file is missing"
            " or empty: {config} \nSee "
            "http://help.transifex.com/features/client/#transifexrc \n".format(
                config=config,
            )
        )

        sys.stderr.write(msg)
        sys.exit(1) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:21,代码来源:i18n.py

示例8: test_no_coursexml

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def test_no_coursexml(self):
        """
        Check that the response for a tar.gz import without a course.xml is
        correct.
        """
        with open(self.bad_tar) as btar:
            resp = self.client.post(
                self.url,
                {
                    "name": self.bad_tar,
                    "course-data": [btar]
                })
        self.assertEquals(resp.status_code, 415)
        # Check that `import_status` returns the appropriate stage (i.e., the
        # stage at which import failed).
        resp_status = self.client.get(
            reverse_course_url(
                'import_status_handler',
                self.course.id,
                kwargs={'filename': os.path.split(self.bad_tar)[1]}
            )
        )

        self.assertEquals(json.loads(resp_status.content)["ImportStatus"], -2) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:26,代码来源:test_import_export.py

示例9: setUp

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def setUp(self):
        """
        Build course XML for importing
        """
        super(TestImport, self).setUp()
        self.content_dir = path(tempfile.mkdtemp())
        self.addCleanup(shutil.rmtree, self.content_dir)

        # Create good course xml
        self.good_dir = self.create_course_xml(self.content_dir, self.BASE_COURSE_KEY)

        # Create run changed course xml
        self.dupe_dir = self.create_course_xml(self.content_dir, self.DIFF_KEY)

        # Create course XML where TRUNCATED_COURSE.org == BASE_COURSE_ID.org
        # and BASE_COURSE_ID.startswith(TRUNCATED_COURSE.course)
        self.course_dir = self.create_course_xml(self.content_dir, self.TRUNCATED_KEY) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:19,代码来源:test_import.py

示例10: test_export_course_with_metadata_only_video

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def test_export_course_with_metadata_only_video(self):
        content_store = contentstore()

        import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'])
        course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')

        # create a new video module and add it as a child to a vertical
        # this re-creates a bug whereby since the video template doesn't have
        # anything in 'data' field, the export was blowing up
        verticals = self.store.get_items(course_id, qualifiers={'category': 'vertical'})

        self.assertGreater(len(verticals), 0)

        parent = verticals[0]

        ItemFactory.create(parent_location=parent.location, category="video", display_name="untitled")

        root_dir = path(mkdtemp_clean())

        print 'Exporting to tempdir = {0}'.format(root_dir)

        # export out to a tempdir
        export_to_xml(self.store, content_store, course_id, root_dir, 'test_export')

        shutil.rmtree(root_dir) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:27,代码来源:test_contentstore.py

示例11: test_export_course_with_metadata_only_word_cloud

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def test_export_course_with_metadata_only_word_cloud(self):
        """
        Similar to `test_export_course_with_metadata_only_video`.
        """
        content_store = contentstore()

        import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['word_cloud'])
        course_id = SlashSeparatedCourseKey('HarvardX', 'ER22x', '2013_Spring')

        verticals = self.store.get_items(course_id, qualifiers={'category': 'vertical'})

        self.assertGreater(len(verticals), 0)

        parent = verticals[0]

        ItemFactory.create(parent_location=parent.location, category="word_cloud", display_name="untitled")

        root_dir = path(mkdtemp_clean())

        print 'Exporting to tempdir = {0}'.format(root_dir)

        # export out to a tempdir
        export_to_xml(self.store, content_store, course_id, root_dir, 'test_export')

        shutil.rmtree(root_dir) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:27,代码来源:test_contentstore.py

示例12: test_html_export_roundtrip

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def test_html_export_roundtrip(self):
        """
        Test that a course which has HTML that has style formatting is preserved in export/import
        """
        content_store = contentstore()

        import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'])

        course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')

        # Export the course
        root_dir = path(mkdtemp_clean())
        export_to_xml(self.store, content_store, course_id, root_dir, 'test_roundtrip')

        # Reimport and get the video back
        import_from_xml(self.store, self.user.id, root_dir)

        # get the sample HTML with styling information
        html_module = self.store.get_item(course_id.make_usage_key('html', 'with_styling'))
        self.assertIn('<p style="font:italic bold 72px/30px Georgia, serif; color: red; ">', html_module.data)

        # get the sample HTML with just a simple <img> tag information
        html_module = self.store.get_item(course_id.make_usage_key('html', 'just_img'))
        self.assertIn('<img src="/static/foo_bar.jpg" />', html_module.data) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:26,代码来源:test_contentstore.py

示例13: test_course_handouts_rewrites

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def test_course_handouts_rewrites(self):
        """
        Test that the xblock_handler rewrites static handout links
        """
        handouts = self.store.create_item(
            self.user.id, self.course.id, 'course_info', 'handouts', fields={
                "data": "<a href='/static/handouts/sample_handout.txt'>Sample</a>",
            }
        )

        # get module info (json)
        resp = self.client.get(get_url('xblock_handler', handouts.location))

        # make sure we got a successful response
        self.assertEqual(resp.status_code, 200)
        # check that /static/ has been converted to the full path
        # note, we know the link it should be because that's what in the 'toy' course in the test data
        asset_key = self.course.id.make_asset_key('asset', 'handouts_sample_handout.txt')
        self.assertContains(resp, unicode(asset_key)) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:21,代码来源:test_contentstore.py

示例14: read_docs

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def read_docs(dirname="wiki_sample"):
    for fname in path.path(dirname).walkfiles("*.bz2"):
        f = bz2.BZ2File(fname)
        text = None
        for line in f:
            if six.PY3:
                line = line.decode()
            if text is None:
                r = head_re.match(line)
                if r:
                    docid, url, title = r.groups()
                    text = []
            else:
                if line == tail:
                    yield {"id": docid,
                           "url": url,
                           "title": title,
                           "text": "".join(text)}
                    text = None
                else:
                    text.append(line)
        f.close() 
开发者ID:zerodb,项目名称:zerodb,代码行数:24,代码来源:wiki.py

示例15: virtualenv

# 需要导入模块: import path [as 别名]
# 或者: from path import path [as 别名]
def virtualenv():
    """ Function-scoped virtualenv in a temporary workspace.

        Methods
        -------
        run()                : run a command using this virtualenv's shell environment
        run_with_coverage()  : run a command in this virtualenv, collecting coverage
        install_package()    : install a package in this virtualenv
        installed_packages() : return a dict of installed packages

        Attributes
        ----------
        virtualenv (`path.path`)    : Path to this virtualenv's base directory
        python (`path.path`)        : Path to this virtualenv's Python executable
        easy_install (`path.path`)  : Path to this virtualenv's easy_install executable
        .. also inherits all attributes from the `workspace` fixture
    """
    venv = VirtualEnv()
    yield venv
    venv.teardown() 
开发者ID:man-group,项目名称:pytest-plugins,代码行数:22,代码来源:pytest_virtualenv.py


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