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


Python Logger.warning方法代码示例

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


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

示例1: load

# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import warning [as 别名]
    def load(filename):
        """Load a sound, and return a sound() instance."""
        rfn = resource_find(filename)
        if rfn is not None:
            filename = rfn

        ext = filename.split('.')[-1].lower()
        if '#' in ext:
            tryext = ext.split('#')[-1].lower()
            if len(tryext)<=4:
                ext = tryext
            else:
                ext = ext.split('#')[0]

        if '?' in ext:
            ext = ext.split('?')[0]

        for classobj in SoundLoader._classes:
            if ext in classobj.extensions():
                return classobj(source=filename)
        Logger.warning('Audio: Unable to find a loader for <%s>' %
                       filename)
        return None
开发者ID:talpah,项目名称:pivystation,代码行数:25,代码来源:__init__.py

示例2: calc_mesh_vertices

# 需要导入模块: from kivy import Logger [as 别名]
# 或者: from kivy.Logger import warning [as 别名]
    def calc_mesh_vertices(self, step = None, update_mesh=True, preserve_uv=True):
        """Calculate Mesh.vertices and indices from the ControlPoints
        If step omitted, uses ControlPoints at current position, otherwise
        vertices at that animation step (ControlPoint.positions[step]).
        Central vertice at center is added as first item in list if mesh_mode=='triangle_fan'
        preserve_uv: Do not overwrite the uv coordinates in the current Mesh.vertices
        (only has an effect if update_mesh==True and vertices are already set)

        returns vertices, indices
        """
        if step is not None and not isinstance(step, basestring):
            raise ValueError('step must be a string')

        num = len(self.control_points)
        if num == 0:
            Logger.warning("AnimationConstructor: Called calc_mesh_vertices without any control_points")
            return [], []


        triangle_fan_mode = self.mesh_mode == 'triangle_fan'

        verts = []
        cent_x, cent_y, cent_u, cent_v = 0.0, 0.0, 0.0, 0.0

        # Need to calculate Centroid first, then do pass through to calculate vertices
        for cp in self.control_points:
            tx, ty = cp.get_tex_coords(step)
            cent_x += tx
            cent_y += ty

        cent_x /= num
        cent_y /= num

        # step may be None if moving points
        if triangle_fan_mode and self.animation_step==setup_step:
            # Sort by angle from centroid in case user didn't place around perimeter in order

            cent_vec = Vector(cent_x, cent_y)
            ref = Vector(1, 0) # Reference vector to measure angle from
            for cp in self.control_points:
                cp.centroid_angle = ref.angle(Vector(cp.get_tex_coords(step)) - cent_vec)

            # ListProperty.sort does not exist
            #self.control_points.sort(key = lambda cp: cp.centroid_angle)
            self.control_points = sorted(self.control_points, key = lambda cp: cp.centroid_angle)

        # TODO Need to figure out similar solution if using triangle_strip

        # Create vertices list
        # centroid added as first vertex in triangle-fan mode
        start = 1 if triangle_fan_mode else 0
        # enumerate always goes through all items, start is just where the count starts
        for index, cp in enumerate(self.control_points, start=start):
            coords = cp.calc_vertex_coords(pos_index=step)
            # Need to calculate u, v centroid still
            cent_u += coords[2]
            cent_v += coords[3]

            cp.vertex_index = index
            verts.extend(coords)

        cent_u /= num
        cent_v /= num

        if triangle_fan_mode:
            # Calculate mean centroid and add to beginning of vertices
            verts.insert(0, cent_v)
            verts.insert(0, cent_u)
            verts.insert(0, cent_y)
            verts.insert(0, cent_x)

            # PERF: Technically don't need to recalculate indices except step 0, but not bothering with optimization now
            indices = range(1, num + 1)
            indices.insert(0, 0)
            indices.append(1)

        else:
            indices = range(num)

        if update_mesh:
            mesh_verts = self.mesh.vertices
            num_mesh_verts = len(mesh_verts)

            # preserve_uv: Do not overwrite the uv coordinates in the current Mesh.vertices
            # None: False if self.animation_step == setup_step
            # specified: False if step == setup_step
            # Refactored this way earlier, but went back because Animation uses None and when animating
            # back to setup_step we want preserve_uv false
            # preserve_uv = True
            # if step is None and self.animation_step == setup_step:
            #     preserve_uv = False
            # elif step == setup_step:
            #     preserve_uv = False

            if preserve_uv and num_mesh_verts > 0:
                if num_mesh_verts != len(verts):
                    raise AssertionError('Number of calculated vertices (%d) != number Mesh.vertices (%d) step=%s'
                                         %(len(verts), num_mesh_verts, step))

                # Only overwrite x, y mesh coords
#.........这里部分代码省略.........
开发者ID:arlowhite,项目名称:MyJelly,代码行数:103,代码来源:animation_constructors.py


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