Skip to content

Commit

Permalink
refact(core): Refactor all code according to the standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinci1it2000 committed Nov 19, 2023
1 parent 6d53633 commit badc36e
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 77 deletions.
1 change: 1 addition & 0 deletions schedula/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def __getattr__(name):
)
from .utils.gen import Token, counter
from .utils.graph import DiGraph

try:
from .utils.io import (
load_default_values, load_dispatcher, load_map, save_default_values,
Expand Down
2 changes: 1 addition & 1 deletion schedula/utils/alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import collections
from .gen import counter
from .cst import EMPTY, NONE
from .dsp import SubDispatch, bypass, selector, stlp, parent_func, NoSub, inf
from .dsp import SubDispatch, bypass, stlp, parent_func, NoSub, inf

__author__ = 'Vincenzo Arcidiacono <[email protected]>'

Expand Down
2 changes: 2 additions & 0 deletions schedula/utils/drw/index/css/icon.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 15 additions & 7 deletions schedula/utils/drw/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const alive_url = "{{ alive_url }}";
const alive_period = {{ (alive_period or 600) * 1000 }};
let response, fail = 0;
while (alive_url){
while (alive_url) {
await new Promise(resolve => setTimeout(resolve, alive_period));
response = await fetch(alive_url);
if (response.status == 200) {
Expand All @@ -33,6 +33,7 @@
if (fail === 5) break;
}
}

imAlive();
</script>
{% endif %}
Expand Down Expand Up @@ -70,10 +71,10 @@

let dsp_UID = 0;

function Dispatcher (data, icicle) {
function Dispatcher(data, icicle) {
let self = {};
self.id = '{{pid|safe}}' + dsp_UID;
dsp_UID++;
self.id = '{{pid|safe}}' + dsp_UID;
dsp_UID++;
self.data = data,
setIframe = function (src) {
if (src)
Expand Down Expand Up @@ -345,6 +346,7 @@
document.removeEventListener("mousemove", resize);
});
});

function resize(e) {
e.preventDefault();
e.stopPropagation();
Expand Down Expand Up @@ -390,7 +392,9 @@
.width(el.clientWidth)
.height(el.clientHeight)
.data(json)
.color(function(d, parent) {return color(parent ? parent.data.name : null)})
.color(function (d, parent) {
return color(parent ? parent.data.name : null)
})
.minSliceAngle(.4)
.maxLevels(3)
.showLabels(true)
Expand All @@ -399,10 +403,14 @@
let stack = getNodeStack(node);
return $('<div/>').text(stack
.slice(stack.length > 1 ? 1 : 0)
.map(function(d){return d.data.name})
.map(function (d) {
return d.data.name
})
.join(' → ')).html()
})
.tooltipContent(function(d, node){return 'Time: <i>'+d.duration+'</i> s'})
.tooltipContent(function (d, node) {
return 'Time: <i>' + d.duration + '</i> s'
})
(el)
}

Expand Down
3 changes: 2 additions & 1 deletion schedula/utils/drw/templates/render.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
const alive_url = "{{ alive_url }}";
const alive_period = {{ (alive_period or 600) * 1000 }};
let response, fail = 0;
while (alive_url){
while (alive_url) {
await new Promise(resolve => setTimeout(resolve, alive_period));
response = await fetch(alive_url);
if (response.status == 200) {
Expand All @@ -115,6 +115,7 @@
if (fail === 5) break;
}
}

imAlive();
</script>
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions schedula/utils/form/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def render_form(self, form='index'):
try:
return render_template(template, **context)
except TemplateNotFound:
# noinspection PyUnresolvedReferences
return render_template('schedula/base.html', **context)

def _csrf_token(self):
Expand Down
2 changes: 1 addition & 1 deletion schedula/utils/form/react/scripts/translate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import merge from "lodash/merge";
import merge from "lodash/merge";

let key = process.argv[2], module
if (fs.existsSync(`./src/themes/antd/models/locale/${key}.mjs`)) {
Expand Down
5 changes: 2 additions & 3 deletions schedula/utils/form/react/scripts/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def _compile_po(lang, d, default=None):
def t(text):
if text not in cache:
cache[text] = ts.translate_text(
text, to_language=lang[:2], from_language='en'#, translator='alibaba'
text, to_language=lang[:2], from_language='en'
# , translator='alibaba'
)
return cache[text]

Expand Down Expand Up @@ -130,5 +131,3 @@ def t(text):
for lang, d in sorted(data.items()):
print(lang)
_compile_po(lang, d, default_po)

data
129 changes: 72 additions & 57 deletions schedula/utils/form/react/src/themes/antd/components/Pricing/index.css
Original file line number Diff line number Diff line change
@@ -1,78 +1,93 @@
.pricing-wrapper .pricing {
min-height: 370px;
padding: 0 24px;
display: flex;
align-items: flex-end;
min-height: 370px;
padding: 0 24px;
display: flex;
align-items: flex-end;
}

.pricing-wrapper .pricing-img-wrapper {
height: 100%;
transform-origin: top;
padding: 0 32px;
height: 100%;
transform-origin: top;
padding: 0 32px;
}

.pricing-wrapper .pricing-img-wrapper .pricing-img {
display: block;
width: 100%;
max-width: 560px;
display: block;
width: 100%;
max-width: 560px;
}

.pricing-wrapper .pricing-img-wrapper .pricing-img img {
display: block;
display: block;
}

.pricing-wrapper .pricing-text-wrapper {
min-height: 320px;
padding: 0 40px;
max-width: 560px;
margin-bottom: 32px;
min-height: 320px;
padding: 0 40px;
max-width: 560px;
margin-bottom: 32px;
}

.pricing-wrapper .pricing-text-wrapper .pricing-content,
.pricing-wrapper .pricing-text-wrapper .pricing-title {
position: relative !important;
position: relative !important;
}

.pricing-wrapper .pricing-text-wrapper .pricing-title {
font-size: 24px;
font-weight: normal;
color: #404040;
margin: 72px auto 16px;
font-size: 24px;
font-weight: normal;
color: #404040;
margin: 72px auto 16px;
}

.pricing-wrapper .pricing-text-wrapper .pricing-content {
font-size: 12px;
color: #666;
line-height: 1.5;
font-size: 12px;
color: #666;
line-height: 1.5;
}

.pricing-wrapper .pricing-text-wrapper .pricing-pricing {
font-size: 36px;
color: #404040;
margin: 32px 0 24px;
font-size: 36px;
color: #404040;
margin: 32px 0 24px;
}

@media screen and (max-width: 767px) {
.pricing-wrapper {
min-height: 720px;
}
.pricing-wrapper .pricing {
display: block;
}
.pricing-wrapper .pricing-img-wrapper {
padding: 0;
text-align: center;
margin-top: 24px;
}
.pricing-wrapper .pricing-img-wrapper .pricing-img {
display: inline-block;
width: 80%;
margin: auto;
}
.pricing-wrapper .pricing-text-wrapper {
height: auto;
text-align: center;
padding: 0;
max-width: 100%;
}
.pricing-wrapper .pricing-text-wrapper .pricing-content,
.pricing-wrapper .pricing-text-wrapper .pricing-title {
width: 100%;
top: auto;
}
.pricing-wrapper .pricing-text-wrapper .pricing-title {
margin: 32px auto 16px;
font-size: 24px;
}
.pricing-wrapper {
min-height: 720px;
}

.pricing-wrapper .pricing {
display: block;
}

.pricing-wrapper .pricing-img-wrapper {
padding: 0;
text-align: center;
margin-top: 24px;
}

.pricing-wrapper .pricing-img-wrapper .pricing-img {
display: inline-block;
width: 80%;
margin: auto;
}

.pricing-wrapper .pricing-text-wrapper {
height: auto;
text-align: center;
padding: 0;
max-width: 100%;
}

.pricing-wrapper .pricing-text-wrapper .pricing-content,
.pricing-wrapper .pricing-text-wrapper .pricing-title {
width: 100%;
top: auto;
}

.pricing-wrapper .pricing-text-wrapper .pricing-title {
margin: 32px auto 16px;
font-size: 24px;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import en_US from 'antd/locale/en_US.js';
import merge from "lodash/merge.js";

const en = en_US.default
export const locale = merge({}, en, {
App: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import it_IT from 'antd/locale/it_IT.js';

const it = it_IT.default
export const locale = {
...it,
Expand Down
4 changes: 3 additions & 1 deletion schedula/utils/form/static/schedula/forms/index-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
"title": "output",
"type": "object"
},
"hash": {"type": "string"}
"hash": {
"type": "string"
}
},
"definitions": {
}
Expand Down
1 change: 1 addition & 0 deletions schedula/utils/imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Error:
class Lock:
pass


# noinspection PyUnusedLocal
def finalize(*args, **kwargs):
pass
3 changes: 2 additions & 1 deletion schedula/utils/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def before_request():
if request.headers.get('Content-Encoding') == 'gzip':
request.stream = gzip.GzipFile(fileobj=request.stream)

def after_request(self, response):
@staticmethod
def after_request(response):
from flask import request, current_app, get_flashed_messages
messages = get_flashed_messages(with_categories=True)
if messages:
Expand Down
3 changes: 2 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import logging
logging.disable()

logging.disable()
9 changes: 6 additions & 3 deletions tests/docs/test_autodispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def assert_result(self, items, name, **kw):
assert len(_warnings) == 0, _warnings
assert_equal_items(self, items)

directive.env.ref_context['py:module'] = 'tests.docs.test_autodispatcher'
ref_context = directive.env.ref_context
ref_context['py:module'] = 'tests.docs.test_autodispatcher'

res = [
'',
Expand Down Expand Up @@ -253,12 +254,14 @@ def assert_result(self, items, name, **kw):

res[1] = '.. py:data:: dsp_1'
res[5] = 'Docstring 2'
res[9] = '.. dsp:: _build/_dispatchers/dispatcher-f4a8eeea5aeabee7398423c3e0d2cde1c19667f4/Pippo.gv'
res[
9] = '.. dsp:: _build/_dispatchers/dispatcher-f4a8eeea5aeabee7398423c3e0d2cde1c19667f4/Pippo.gv'
assert_result(self, res, 'dsp_1')

res[1] = '.. py:data:: dsp_2'
res[5] = 'Docstring 3'
res[9] = '.. dsp:: _build/_dispatchers/dispatcher-18bc3d5e4a4c20576cd56e64681c4ca48528ac2e/Pippo.gv'
res[
9] = '.. dsp:: _build/_dispatchers/dispatcher-18bc3d5e4a4c20576cd56e64681c4ca48528ac2e/Pippo.gv'
assert_result(self, res, 'dsp_2')

def test_build(self):
Expand Down
1 change: 0 additions & 1 deletion tests/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
import unittest


EXTRAS = os.environ.get('EXTRAS', 'all')


Expand Down
1 change: 1 addition & 0 deletions tests/utils/test_dsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ def test_function(self):
self.assertEqual(fun({'x': 3}), 3)
self.assertRaises(TypeError, fun, {'x': 2}, x=2)


class TestSubDispatchPipe(unittest.TestCase):
def setUp(self):
dsp_1 = sh.BlueDispatcher()
Expand Down

0 comments on commit badc36e

Please sign in to comment.