Skip to content

Commit

Permalink
Add flake8 config, fix pep8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tobspr committed Apr 28, 2016
1 parent dcc023c commit 8bcecc7
Show file tree
Hide file tree
Showing 142 changed files with 482 additions and 344 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length=100
exclude=rplibs/*,data/*,hosek_wilkie_scattering,bake_gi,_DEV,*_generated.py,resources_rc.py

2 changes: 2 additions & 0 deletions rpcore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"""

# flake8: noqa

# This file includes all classes from the pipeline which are exposed
from rpcore.render_pipeline import RenderPipeline
from rpcore.native import SpotLight, PointLight
3 changes: 2 additions & 1 deletion rpcore/common_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

from rpcore.util.shader_input_blocks import GroupedInputBlock


class CommonResources(RPObject):

""" This class manages the loading and binding of commonly used resources,
Expand Down Expand Up @@ -197,7 +198,7 @@ def update(self):
# Remove jitter and set the new view projection mat
proj_mat.set_cell(1, 0, 0.0)
proj_mat.set_cell(1, 1, 0.0)
update("view_proj_mat_no_jitter", view_mat * proj_mat)
update("view_proj_mat_no_jitter", view_mat * proj_mat)

# Store the frame delta
update("frame_delta", Globals.clock.get_dt())
Expand Down
7 changes: 4 additions & 3 deletions rpcore/effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from rpcore.rpobject import RPObject
from rpcore.loader import RPLoader


class Effect(RPObject):

""" This class represents an instance of a compiled effect. It can be loaded
Expand Down Expand Up @@ -180,7 +181,7 @@ def _parse_shader_template(self, pass_id, stage, data):
shader_path = self._construct_shader_from_data(pass_id, stage, template_src, data)
self._generated_shader_paths[stage + "-" + pass_id] = shader_path

def _construct_shader_from_data(self, pass_id, stage, template_src, data): # pylint: disable=too-many-branches
def _construct_shader_from_data(self, pass_id, stage, template_src, data): # pylint: disable=too-many-branches # noqa
""" Constructs a shader from a given dataset """
injects = {"defines": []}

Expand Down Expand Up @@ -236,7 +237,7 @@ def _process_shader_template(self, template_src, cache_key, injections):
# to properly insert scoped code blocks
in_main = False

for line in shader_lines: # pylint: disable=too-many-nested-blocks
for line in shader_lines: # pylint: disable=too-many-nested-blocks
stripped_line = line.strip().lower()

# Check if we are already in the main function
Expand All @@ -263,7 +264,7 @@ def _process_shader_template(self, template_src, cache_key, injections):
# When we are in the main function, we have to make sure we
# use a seperate scope, so there are no conflicts with variable
# declarations
header = indent + "/* Hook: " + hook_name + " */" + (" {" if in_main else "")
header = indent + "/* Hook: " + hook_name + " */" + (" {" if in_main else "") # noqa
parsed_lines.append(header)

for line_to_insert in insertions:
Expand Down
3 changes: 2 additions & 1 deletion rpcore/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

__all__ = ("Globals",)

class Globals(object): # pylint: disable=too-few-public-methods

class Globals(object): # pylint: disable=too-few-public-methods

""" This class is a singleton to store globals widely used by the application.
This is a wrapper around Panda3D's globals since ShowBase writes to __builtins__
Expand Down
1 change: 1 addition & 0 deletions rpcore/gpu_command_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from rpcore.native import GPUCommand, GPUCommandList


class GPUCommandQueue(RPObject):

""" This class offers an interface to the gpu, allowing commands to be
Expand Down
14 changes: 8 additions & 6 deletions rpcore/gui/buffer_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"""


from __future__ import division
from functools import partial

from panda3d.core import Texture, Vec3

from direct.gui.DirectFrame import DirectFrame
from direct.gui.DirectScrolledFrame import DirectScrolledFrame
from direct.gui.DirectGui import DGG
from direct.gui.DirectScrolledFrame import DirectScrolledFrame

from rplibs.six import itervalues

Expand All @@ -45,6 +45,7 @@
from rpcore.gui.text import Text
from rpcore.gui.draggable_window import DraggableWindow


class BufferViewer(DraggableWindow):

""" This class provides a view into the buffers to inspect them """
Expand Down Expand Up @@ -162,15 +163,15 @@ def _perform_update(self):

self._render_stages()

def _on_texture_hovered(self, hover_frame, evt=None): # pylint: disable=unused-argument
def _on_texture_hovered(self, hover_frame, evt=None): # pylint: disable=unused-argument
""" Internal method when a texture is hovered """
hover_frame["frameColor"] = (0, 0, 0, 0.1)

def _on_texture_blurred(self, hover_frame, evt=None): # pylint: disable=unused-argument
def _on_texture_blurred(self, hover_frame, evt=None): # pylint: disable=unused-argument
""" Internal method when a texture is blurred """
hover_frame["frameColor"] = (0, 0, 0, 0)

def _on_texture_clicked(self, tex_handle, evt=None): # pylint: disable=unused-argument
def _on_texture_clicked(self, tex_handle, evt=None): # pylint: disable=unused-argument
""" Internal method when a texture is blurred """
self._tex_preview.present(tex_handle)

Expand Down Expand Up @@ -244,7 +245,8 @@ def _render_stages(self):
preview.set_shader_input("brightness", 1)
preview.set_shader_input("tonemap", False)

preview_shader = DisplayShaderBuilder.build(stage_tex, scale_factor*w, scale_factor*h)
preview_shader = DisplayShaderBuilder.build(
stage_tex, scale_factor * w, scale_factor * h)
preview.set_shader(preview_shader)

num_rows = (index + entries_per_row) // entries_per_row
Expand Down
1 change: 1 addition & 0 deletions rpcore/gui/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from rpcore.rpobject import RPObject
from rpcore.loader import RPLoader


class Checkbox(RPObject):

""" This is a wrapper around DirectCheckBox, providing a simpler interface
Expand Down
1 change: 1 addition & 0 deletions rpcore/gui/checkbox_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import direct.gui.DirectGuiGlobals as DGG


class CheckboxCollection(RPObject):

""" This is a container for multiple Checkboxes, controlling that
Expand Down
3 changes: 2 additions & 1 deletion rpcore/gui/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from __future__ import division

from rplibs.six.moves import range # pylint: disable=import-error
from rplibs.six.moves import range # pylint: disable=import-error

from panda3d.core import Vec4, Vec3, Vec2, RenderState, TransformState
from panda3d.core import TexturePool, SceneGraphAnalyzer
Expand All @@ -50,6 +50,7 @@
from rpcore.render_target import RenderTarget
from rpcore.image import Image


class Debugger(RPObject):

""" This class manages the onscreen control, and displays statistics. """
Expand Down
13 changes: 7 additions & 6 deletions rpcore/gui/draggable_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from rpcore.globals import Globals
from rpcore.gui.text import Text


class DraggableWindow(RPObject):

""" This is a simple draggable but not resizeable window """
Expand All @@ -55,7 +56,7 @@ def center_on_screen(self):
self._context_width = Globals.native_resolution.x * self._context_scale
self._context_height = Globals.native_resolution.y * self._context_scale
self._set_pos(Vec2((self._context_width - self._width) / 2,
(self._context_height - self._height) / 2))
(self._context_height - self._height) / 2))

def set_title(self, title):
""" Sets the window title """
Expand Down Expand Up @@ -117,7 +118,7 @@ def _create_components(self):
self._title_bar.bind(DGG.B1PRESS, self._start_drag)
self._title_bar.bind(DGG.B1RELEASE, self._stop_drag)

def _start_drag(self, evt=None): # pylint: disable=unused-argument
def _start_drag(self, evt=None): # pylint: disable=unused-argument
""" Gets called when the user starts dragging the window """
self._dragging = True
self._node.detach_node()
Expand All @@ -126,19 +127,19 @@ def _start_drag(self, evt=None): # pylint: disable=unused-argument
uponDeath=self._stop_drag)
self._drag_offset = self._pos - self._get_mouse_pos()

def _on_close_btn_hover(self, evt=None): # pylint: disable=unused-argument
def _on_close_btn_hover(self, evt=None): # pylint: disable=unused-argument
""" Internal method when the close button got hovered """
self._btn_close["image"] = "/$$rp/data/gui/close_window_hover.png"

def _on_close_btn_out(self, evt=None): # pylint: disable=unused-argument
def _on_close_btn_out(self, evt=None): # pylint: disable=unused-argument
""" Internal method when the close button is no longer hovered """
self._btn_close["image"] = "/$$rp/data/gui/close_window.png"

def _request_close(self, evt=None): # pylint: disable=unused-argument
def _request_close(self, evt=None): # pylint: disable=unused-argument
""" This method gets called when the close button gets clicked """
self.hide()

def _stop_drag(self, evt=None): # pylint: disable=unused-argument
def _stop_drag(self, evt=None): # pylint: disable=unused-argument
""" Gets called when the user stops dragging the window """
Globals.base.taskMgr.remove("UIWindowDrag")
self._dragging = False
Expand Down
1 change: 1 addition & 0 deletions rpcore/gui/error_message_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from rpcore.gui.text import Text


class ErrorMessageDisplay(RPObject):

""" This is a gui element which listens to the panda output stream
Expand Down
1 change: 1 addition & 0 deletions rpcore/gui/exposure_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from rpcore.globals import Globals
from rpcore.loader import RPLoader


class ExposureWidget(RPObject):

""" Widget to show the current exposure """
Expand Down
3 changes: 1 addition & 2 deletions rpcore/gui/fps_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from rpcore.globals import Globals
from rpcore.loader import RPLoader


class FPSChart(RPObject):

""" Widget to show the FPS as a chart """
Expand Down Expand Up @@ -83,7 +84,6 @@ def _late_init(self, task):
text="0 ms", parent=self._node, x=20, y=120,
size=13, color=Vec3(1), may_change=True)


# Create the shader which generates the visualization texture
self._cshader_node = ComputeNode("FPSChartUpdateChart")
self._cshader_node.add_dispatch(250 // 10, 120 // 4, 1)
Expand Down Expand Up @@ -114,7 +114,6 @@ def _update(self, task):
self._store_index[0] = (self._store_index[0] + 1) % 250
self._current_ftime[0] = Globals.clock.get_dt() * 1000.0


avg_fps = Globals.clock.get_average_frame_rate()
if avg_fps > 122:
self._chart_ms_max[0] = 10.0
Expand Down
5 changes: 3 additions & 2 deletions rpcore/gui/labeled_checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from rpcore.gui.checkbox import Checkbox
from rpcore.gui.text import Text


class LabeledCheckbox(RPObject):

""" This is a checkbox, combined with a label. The arguments are
Expand Down Expand Up @@ -65,12 +66,12 @@ def __init__(self, parent=None, x=0, y=0, chb_callback=None,
self._checkbox.node.bind(DGG.WITHIN, self._on_node_enter)
self._checkbox.node.bind(DGG.WITHOUT, self._on_node_leave)

def _on_node_enter(self, *args): # pylint: disable=unused-argument
def _on_node_enter(self, *args): # pylint: disable=unused-argument
""" Internal callback when the node gets hovered """
self._text.node["fg"] = (self.text_color.x + 0.1, self.text_color.y + 0.1,
self.text_color.z + 0.1, 1.0)

def _on_node_leave(self, *args): # pylint: disable=unused-argument
def _on_node_leave(self, *args): # pylint: disable=unused-argument
""" Internal callback when the node gets no longer hovered """
self._text.node["fg"] = (self.text_color.x, self.text_color.y, self.text_color.z, 1.0)

Expand Down
7 changes: 4 additions & 3 deletions rpcore/gui/loading_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
"""
from __future__ import division

from rplibs.six.moves import range # pylint: disable=import-error
from rplibs.six.moves import range # pylint: disable=import-error

from rpcore.gui.sprite import Sprite
from rpcore.rpobject import RPObject
from rpcore.globals import Globals


class LoadingScreen(RPObject):

""" This is the default loading screen used by the pipeline. It provides
Expand All @@ -56,8 +57,8 @@ def create(self):
scale = max(scale_w, scale_h)

self.fullscreen_bg = Sprite(
image=self.image_source, x=(screen_w-1920.0*scale)//2,
y=(screen_h-1080.0*scale)//2, w=int(1920 * scale),
image=self.image_source, x=(screen_w - 1920.0 * scale) // 2,
y=(screen_h - 1080.0 * scale) // 2, w=int(1920 * scale),
h=int(1080 * scale), parent=self.fullscreen_node, near_filter=False)

for _ in range(2):
Expand Down
6 changes: 4 additions & 2 deletions rpcore/gui/pipe_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
THE SOFTWARE.
"""

from rplibs.six import iteritems

from panda3d.core import Texture, Vec3
Expand All @@ -39,6 +40,7 @@
from rpcore.gui.text import Text
from rpcore.gui.sprite import Sprite


class PipeViewer(DraggableWindow):

""" Small tool which displays the order of the graphic pipes """
Expand Down Expand Up @@ -81,7 +83,7 @@ def _update_task(self, task=None):
self._pipe_descriptions.set_x(scroll_value * 2759.0)
return task.cont

def _populate_content(self): # pylint: disable=too-many-branches,too-many-statements
def _populate_content(self): # pylint: disable=too-many-branches,too-many-statements
""" Reads the pipes and stages from the stage manager and renders those
into the window """
self._created = True
Expand Down Expand Up @@ -161,7 +163,7 @@ def _populate_content(self): # pylint: disable=too-many-branches,too-many-statem
tex_desc = pipe_tex.format_texture_type(pipe_tex.get_texture_type())
tex_desc += " - " + pipe_tex.format_format(pipe_tex.get_format()).upper()

Text(text=tex_desc, parent=node, x=55 + 48/2,
Text(text=tex_desc, parent=node, x=55 + 48 / 2,
y=130 + pipe_idx * pipe_height, color=Vec3(0.2),
size=12, align="center")

Expand Down
1 change: 1 addition & 0 deletions rpcore/gui/pixel_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from rpcore.globals import Globals
from rpcore.loader import RPLoader


class PixelInspector(RPObject):

""" Widget to analyze the rendered pixels, by zooming in """
Expand Down
1 change: 1 addition & 0 deletions rpcore/gui/render_mode_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from rpcore.gui.labeled_checkbox import LabeledCheckbox
from rpcore.gui.checkbox_collection import CheckboxCollection


class RenderModeSelector(DraggableWindow):

""" Window which offers the user to select a render mode to apply """
Expand Down
1 change: 1 addition & 0 deletions rpcore/gui/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from rpcore.rpobject import RPObject


class Slider(RPObject):

""" This is a simple wrapper around DirectSlider, providing a simpler
Expand Down
1 change: 1 addition & 0 deletions rpcore/gui/sprite.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from rpcore.rpobject import RPObject
from rpcore.loader import RPLoader


class Sprite(RPObject):

""" Simple wrapper arround OnscreenImage, providing a simpler interface """
Expand Down
1 change: 1 addition & 0 deletions rpcore/gui/text_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from rpcore.rpobject import RPObject
from rpcore.loader import RPLoader


class TextNode(RPObject):

""" Interface for the Panda3D TextNode. """
Expand Down
2 changes: 1 addition & 1 deletion rpcore/gui/texture_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

from rpcore.util.display_shader_builder import DisplayShaderBuilder


class TexturePreview(DraggableWindow):

""" Small window which provides a preview of a texture """
Expand Down Expand Up @@ -174,7 +175,6 @@ def _set_brightness(self):
def _set_enable_tonemap(self, enable_tonemap):
self._preview_image.set_shader_input("tonemap", enable_tonemap)


def _create_components(self):
""" Internal method to init the components """
DraggableWindow._create_components(self)
Expand Down
Loading

0 comments on commit 8bcecc7

Please sign in to comment.