Skip to content

Commit

Permalink
lint fixes;
Browse files Browse the repository at this point in the history
  • Loading branch information
twiddli committed Jan 7, 2018
1 parent ee948a4 commit eb1ece0
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 42 deletions.
18 changes: 9 additions & 9 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,15 @@ def deploy(args, unknown=None):
installer_filename = ".installed"
installer_file = os.path.join("deploy", installer_filename)
if not prun(["happypandax.spec", "--noconfirm"]) and not prun(['updater.py',
'--onefile',
'--name',
constants.updater_name,
'--icon',
os.path.join(constants.dir_static,
'favicon.ico'),
'--specpath',
'build'
]):
'--onefile',
'--name',
constants.updater_name,
'--icon',
os.path.join(constants.dir_static,
'favicon.ico'),
'--specpath',
'build'
]):
upd_name = constants.updater_name
if constants.is_win:
upd_name += '.exe'
Expand Down
1 change: 1 addition & 0 deletions happypanda/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class EnumError(ServerError):
"""Enum error."""
pass


@error_code(410)
class ParsingError(ServerError):
""
Expand Down
4 changes: 3 additions & 1 deletion happypanda/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def _handshake(self, data, user=None, password=None, ignore_err=False):
if not ignore_err:
serv_error = data.get('error')
if serv_error:
raise exceptions.AuthError(utils.this_function(), "{}: {}".format(serv_error['code'], serv_error['msg']))
raise exceptions.AuthError(
utils.this_function(), "{}: {}".format(
serv_error['code'], serv_error['msg']))
serv_data = data.get('data')
if serv_data == "Authenticated":
self.session = data.get('session')
Expand Down
2 changes: 1 addition & 1 deletion happypanda/core/commands/gallery_cmd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import subprocess

from happypanda.common import utils, hlogger, config, constants
from happypanda.common import utils, hlogger, config
from happypanda.core.command import (UndoCommand, CommandEvent,
CommandEntry, Command)
from happypanda.core.commands import database_cmd, io_cmd
Expand Down
2 changes: 2 additions & 0 deletions happypanda/interface/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def _contruct_tags_msg(nstags):

return msg


def get_all_tags(limit: int=100):
"""
Get all tags from the db
Expand All @@ -46,6 +47,7 @@ def get_all_tags(limit: int=100):

return message.Identity('tags', msg)


def get_tags(item_type: enums.ItemType = enums.ItemType.Gallery,
item_id: int = 0,
raw: bool = False):
Expand Down
10 changes: 8 additions & 2 deletions templates/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,17 @@ def app_did_mount():
def get_container_ref(ctx):
state['container_ref'] = ctx


__pragma__("kwargs")


def app_menu_contents(el, **kwargs):
this.setState({'menu_nav_contents': el, 'menu_nav_args':kwargs})
this.setState({'menu_nav_contents': el, 'menu_nav_args': kwargs})


__pragma__("nokwargs")


def app_render():
sidebar_args = {
'toggler': this.toggle_sidebar,
Expand Down Expand Up @@ -229,7 +235,7 @@ def app_render():
e(Route, path="/item/gallery", component=this.gallery_page),
e(Route, path="/item/collection", component=this.collection_page),
e(Route, path="/item/page", component=this.page_page),
e(Redirect, js_from="/", exact=True, to={'pathname':"/library"}),
e(Redirect, js_from="/", exact=True, to={'pathname': "/library"}),
),
e(ui.Dimmer, simple=True, onClickOutside=this.toggle_sidebar),
*modal_els,
Expand Down
17 changes: 11 additions & 6 deletions templates/src/pages/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
from src.state import state
from src.single import tagitem


def artistpage_render():
return e(ui.Container,
e(ui.Segment.Group,
e(ui.Segment),
e(ui.Segment, secondary=True, basic=True)
))


ArtistsPage = createReactClass({
'displayName': 'ArtistsPage',

Expand All @@ -27,15 +29,17 @@ def artistpage_render():
'render': artistpage_render
})


def get_db_tags(data=None, error=None):
if data is not None and not error:
this.setState({"data": data, 'data_loading':False})
this.setState({"data": data, 'data_loading': False})
elif error:
state.app.notif("Failed to fetch tags", level="error")
this.setState({'data_loading':False})
this.setState({'data_loading': False})
else:
client.call_func("get_all_tags", this.get_tags, limit=25)
this.setState({'data_loading':True})
this.setState({'data_loading': True})


def tagspage_render():

Expand Down Expand Up @@ -69,19 +73,20 @@ def tagspage_render():
),
e(ui.Divider, hidden=True),
e(ui.Search, placeholder=tr(this, "", "Search tags"), fluid=True,
js_input={'fluid':True})
js_input={'fluid': True})
),
e(ui.Segment, e(ui.Label.Group, *tag_lbl, size="large"), secondary=True, basic=True,
loading=this.state.data_loading)
))


TagsPage = createReactClass({
'displayName': 'TagsPage',

'getInitialState': lambda: {
'data': {},
'data_loading': False,
},
},

'get_tags': get_db_tags,

Expand All @@ -106,7 +111,7 @@ def tagspage_render():
e(Switch,
e(Route, path="/directory/tags", component=TagsPage),
e(Route, path="/directory/artists", component=ArtistsPage),
e(Redirect, js_from="/directory", exact=True, to={'pathname':"/directory/tags"}),
e(Redirect, js_from="/directory", exact=True, to={'pathname': "/directory/tags"}),
),
basic=True,
)
Expand Down
46 changes: 25 additions & 21 deletions templates/src/pages/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,18 @@ def receive_props(n_props):
el = this.props.context or this.state.context or state.container_ref
utils.scroll_to_element(el)


class ReaderDirection:
left_to_right = 1
right_to_left = 2


class ReaderScaling:
default = 1
fit_width = 2
fit_height = 3


def page_render():
number = 0
p_id = this.state.id
Expand Down Expand Up @@ -219,18 +222,18 @@ def page_render():
e(ui.Table.Cell, e(ui.Header, "Hash:", as_="h5"), collapsing=True),
e(ui.Table.Cell, e(ui.Label, hash_id))))

#### config
# config

cfg_direction = [
{'key': 1, 'text':tr(this, "", 'Left to Right'), 'value': ReaderDirection.left_to_right},
{'key': 2, 'text':tr(this, "", 'Right to Left'), 'value': ReaderDirection.right_to_left},
]
{'key': 1, 'text': tr(this, "", 'Left to Right'), 'value': ReaderDirection.left_to_right},
{'key': 2, 'text': tr(this, "", 'Right to Left'), 'value': ReaderDirection.right_to_left},
]

cfg_scaling = [
{'key': 1, 'text':tr(this, "", 'Default'), 'value': ReaderScaling.default},
{'key': 2, 'text':tr(this, "", 'Fit Width'), 'value': ReaderScaling.fit_width},
{'key': 3, 'text':tr(this, "", 'Fit Height'), 'value': ReaderScaling.fit_height},
]
{'key': 1, 'text': tr(this, "", 'Default'), 'value': ReaderScaling.default},
{'key': 2, 'text': tr(this, "", 'Fit Width'), 'value': ReaderScaling.fit_width},
{'key': 3, 'text': tr(this, "", 'Fit Height'), 'value': ReaderScaling.fit_height},
]

thumb_style = {}
thumb_class = ''
Expand All @@ -246,8 +249,8 @@ def page_render():
thumb_class = 'reader-fitheight'

return e(ui.Sidebar.Pushable,
e(ui.Sidebar, # wait for infinite scroll, then a page list can be implemented here
as_=ui.Segment,
e(ui.Sidebar, # wait for infinite scroll, then a page list can be implemented here
as_=ui.Segment,
size="small",
basic=True,
visible=this.state.pages_visible and not this.state.config_visible,
Expand All @@ -267,8 +270,8 @@ def page_render():
defaultChecked=this.state.cfg_invert, onChange=this.set_cfg_invert),
e(ui.Form.Field, "Close", control=ui.Button),
onSubmit=this.toggle_config,
),
as_=ui.Segment,
),
as_=ui.Segment,
size="small",
basic=True,
visible=this.state.config_visible and not this.state.pages_visible,
Expand Down Expand Up @@ -320,7 +323,7 @@ def page_render():
padded=True,
inverted=this.state.cfg_invert,
as_=ui.Grid,
)
)
)


Expand Down Expand Up @@ -355,13 +358,13 @@ def page_render():
'next_page': lambda e: all((utils.go_to(this.props.history, query={'id': this.state.data.id, 'go': "next"}),)),
'back_to_gallery': lambda: utils.go_to(this.props.history, "/item/gallery", query={'id': utils.get_query("gid") or this.state.data.gallery_id}, keep_query=False),

'set_cfg_direction': lambda e, d: all((this.setState({'cfg_direction':d.value}), utils.storage.set("reader_direction", d.value))),
'set_cfg_scaling': lambda e, d: all((this.setState({'cfg_scaling':d.value}), utils.storage.set("reader_scaling", d.value))),
'set_cfg_stretch': lambda e, d: all((this.setState({'cfg_stretch':d.checked}), utils.storage.set("reader_stretch", d.checked))),
'set_cfg_invert': lambda e, d: all((this.setState({'cfg_invert':d.checked}), utils.storage.set("reader_invert", d.checked))),
'set_cfg_direction': lambda e, d: all((this.setState({'cfg_direction': d.value}), utils.storage.set("reader_direction", d.value))),
'set_cfg_scaling': lambda e, d: all((this.setState({'cfg_scaling': d.value}), utils.storage.set("reader_scaling", d.value))),
'set_cfg_stretch': lambda e, d: all((this.setState({'cfg_stretch': d.checked}), utils.storage.set("reader_stretch", d.checked))),
'set_cfg_invert': lambda e, d: all((this.setState({'cfg_invert': d.checked}), utils.storage.set("reader_invert", d.checked))),

'toggle_config': lambda: this.setState({'config_visible':not this.state.config_visible, 'pages_visible':False}),
'toggle_pages': lambda: this.setState({'pages_visible':not this.state.pages_visible, 'config_visible':False}),
'toggle_config': lambda: this.setState({'config_visible': not this.state.config_visible, 'pages_visible': False}),
'toggle_pages': lambda: this.setState({'pages_visible': not this.state.pages_visible, 'config_visible': False}),
'set_context': lambda c: this.setState({'context': c}),
'componentWillReceiveProps': receive_props,
'componentDidMount': lambda: window.addEventListener("keydown", this.on_key, False),
Expand All @@ -370,8 +373,9 @@ def page_render():
'componentWillMount': lambda: all((this.props.menu([
#e(ui.Menu.Item, e(ui.Icon, js_name="sidebar", size="large"), icon=True, onClick=this.toggle_pages, position="left"),
e(ui.Menu.Menu, e(ui.Menu.Item, e(ui.Icon, js_name="arrow up", size="large"), icon=True, onClick=this.back_to_gallery)),
e(ui.Menu.Item, e(ui.Icon, js_name="options", size="large"), icon=True, onClick=this.toggle_config, position="right"),
]),
e(ui.Menu.Item, e(ui.Icon, js_name="options", size="large"),
icon=True, onClick=this.toggle_config, position="right"),
]),
(this.get_item(go=utils.get_query("go")) if not this.state.data else None),
)),

Expand Down
4 changes: 2 additions & 2 deletions templates/src/views/itemview.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def item_view_render():
'render': item_view_render
})

#SimpleItemView = createReactClass({
# SimpleItemView = createReactClass({
# 'displayName': 'SimpleItemView',

# 'getInitialState': lambda: {'page': int(utils.get_query("page", 1)) or 1,
Expand Down Expand Up @@ -432,4 +432,4 @@ def item_view_render():
# 'componentDidUpdate': item_view_on_update,

# 'render': item_view_render
#})
#})

0 comments on commit eb1ece0

Please sign in to comment.