2016-09-07 04:04:42 +00:00
|
|
|
from js2py.base import *
|
FIX:(#1358) nzbname error when retrieving nzb and assigning filename from WWT tracker, FIX:(#1372)(#1369) Fix for creating series folder when adding a series when series title contains either double quotation marks, or an asterisk, FIX:(#1373) Filechecker would ignore filenames that had the extension captialized, FIX:(#1366) When Comic Publisher is not provided on CV, would error during add, FIX: Attempted fix for unicode characters when importing (series title, filenames), FIX: Removed str references that would cause an error on weekly pull in some instances, FIX: When checking for watched series, if series title being checked against had only one word, would cause a traceback error, FIX: When attempting to retrieve results/torrents from TPSE and was behind cloudflare, would error out, IMP: file-size check now works for 32p feeds, FIX: When pullist issue was marked as Wanted and issue was populated on series detail page, occassionaly would not have the same status of Wanted, FIX: Fixed incorrect placement of Comic Location title in GUI, IMP: Added short description for Search Delay option within GUI, FIX:(#1370) multiple selection from Manage Comics tab (Refresh/Delete/Pause) would only select one item
2016-09-06 15:06:07 +00:00
|
|
|
import inspect
|
|
|
|
try:
|
2016-09-07 04:04:42 +00:00
|
|
|
from js2py.translators.translator import translate_js
|
FIX:(#1358) nzbname error when retrieving nzb and assigning filename from WWT tracker, FIX:(#1372)(#1369) Fix for creating series folder when adding a series when series title contains either double quotation marks, or an asterisk, FIX:(#1373) Filechecker would ignore filenames that had the extension captialized, FIX:(#1366) When Comic Publisher is not provided on CV, would error during add, FIX: Attempted fix for unicode characters when importing (series title, filenames), FIX: Removed str references that would cause an error on weekly pull in some instances, FIX: When checking for watched series, if series title being checked against had only one word, would cause a traceback error, FIX: When attempting to retrieve results/torrents from TPSE and was behind cloudflare, would error out, IMP: file-size check now works for 32p feeds, FIX: When pullist issue was marked as Wanted and issue was populated on series detail page, occassionaly would not have the same status of Wanted, FIX: Fixed incorrect placement of Comic Location title in GUI, IMP: Added short description for Search Delay option within GUI, FIX:(#1370) multiple selection from Manage Comics tab (Refresh/Delete/Pause) would only select one item
2016-09-06 15:06:07 +00:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@Js
|
|
|
|
def Eval(code):
|
|
|
|
local_scope = inspect.stack()[3][0].f_locals['var']
|
|
|
|
global_scope = this.GlobalObject
|
|
|
|
# todo fix scope - we have to behave differently if called through variable other than eval
|
|
|
|
# we will use local scope (default)
|
|
|
|
globals()['var'] = local_scope
|
|
|
|
try:
|
|
|
|
py_code = translate_js(code.to_string().value, '')
|
|
|
|
except SyntaxError as syn_err:
|
|
|
|
raise MakeError('SyntaxError', str(syn_err))
|
|
|
|
lines = py_code.split('\n')
|
|
|
|
# a simple way to return value from eval. Will not work in complex cases.
|
|
|
|
has_return = False
|
|
|
|
for n in xrange(len(lines)):
|
|
|
|
line = lines[len(lines)-n-1]
|
|
|
|
if line.strip():
|
|
|
|
if line.startswith(' '):
|
|
|
|
break
|
|
|
|
elif line.strip()=='pass':
|
|
|
|
continue
|
|
|
|
elif any(line.startswith(e) for e in ['return ', 'continue ', 'break', 'raise ']):
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
has_return = True
|
|
|
|
cand = 'EVAL_RESULT = (%s)\n'%line
|
|
|
|
try:
|
|
|
|
compile(cand, '', 'exec')
|
|
|
|
except SyntaxError:
|
|
|
|
break
|
|
|
|
lines[len(lines)-n-1] = cand
|
|
|
|
py_code = '\n'.join(lines)
|
|
|
|
break
|
|
|
|
#print py_code
|
|
|
|
executor(py_code)
|
|
|
|
if has_return:
|
|
|
|
return globals()['EVAL_RESULT']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def executor(code):
|
|
|
|
exec(code, globals())
|
|
|
|
|