""" Example implementation: simple_bar_chart """ from inspect import ( getfile as inspect_getfile, currentframe as inspect_currentframe, ) from os.path import ( abspath as path_abspath, dirname as path_dirname, join as path_join, ) from sys import path as sys_path SCRIPT_PATH = path_dirname( path_abspath(inspect_getfile(inspect_currentframe()))) PROJECT_ROOT = path_dirname(SCRIPT_PATH) ROOT_PACKAGE_NAME = 'JqPyCharts' ROOT_PACKAGE_PATH = path_join(PROJECT_ROOT, ROOT_PACKAGE_NAME) sys_path.insert(0, PROJECT_ROOT) from JqPyCharts.main_code import jqpc_simple_bar_chart html_template = ''' <!DOCTYPE html> <html> <head> {js_css_resources_header} {jqplotchart_script1} {jqplotchart_script2}
# https://github.com/enthought/pyql/blob/master/setup.py from Cython.Build import cythonize from Cython.Compiler.Options import parse_directive_list import versioneer versioneer.VCS = 'git' versioneer.versionfile_source = 'PySpeedIT/_version.py' versioneer.versionfile_build = 'PySpeedIT/_version.py' versioneer.tag_prefix = '' # tags are like 1.1.0 versioneer.parentdir_prefix = 'PySpeedIT-' # path_dirname like 'PySpeedIT-1.1.0' _version = versioneer.get_version() SCRIPT_PATH = path_dirname(path_abspath(inspect_getfile(inspect_currentframe()))) PACKAGE_NAME = 'PySpeedIT' ROOT_PACKAGE_PATH = path_join(path_dirname(SCRIPT_PATH), PACKAGE_NAME) MAIN_PACKAGE_PATH = path_join(ROOT_PACKAGE_PATH, PACKAGE_NAME) from PySpeedIT import TESTED_HOST_OS if sys_version_info[:2] < (3, 4) or 'linux' not in sys_platform: print(''' PySpeedIT is only tested with Python 3.4.2rc1 or higher:\n current python version: {0:d}.{1:d}\n\n TESTED_HOST_OS: {3:} '''.format(sys_version_info[:2][0], sys_version_info[:2][1], TESTED_HOST_OS)) # check some untested options
from inspect import ( getfile as inspect_getfile, currentframe as inspect_currentframe, ) from json import ( dumps as json_dumps ) from os.path import ( abspath as path_abspath, dirname as path_dirname, join as path_join, ) from sys import path as sys_path SCRIPT_PATH = path_dirname(path_abspath(inspect_getfile(inspect_currentframe()))) PROJECT_ROOT = path_dirname(SCRIPT_PATH) ROOT_PACKAGE_NAME = 'LCONF' ROOT_PACKAGE_PATH = path_join(PROJECT_ROOT, ROOT_PACKAGE_NAME) sys_path.insert(0, PROJECT_ROOT) from LCONF.lconf_structure_classes import ( Blk, BlkI, KVList, KVMap, Root, )
def get_psphinxtheme_root_dir(): """ :return: (str) path of the *P-SphinxTheme* root dir """ return path_dirname(path_abspath(inspect_getfile(inspect_currentframe())))
def web_log(output: str, level: int = 1) -> bool: _src = inspect_getfile(inspect_stack()[1][0]) debug = config.SERVER.debug return Log(typ='web', src_file=_src, debug=debug).write(output=output, level=level)
def fns_log(output: str, level: int = 1) -> bool: _src = inspect_getfile(inspect_stack()[1][0]) return Log(src_file=_src).write(output=output, level=level, system=True)
def migration_aerich_tortoise(): """ AERICH TORTOISE ORM FAST API """ print('INIT AERICH CORE') aerich_name = asf('aerich') from aerich.models import Aerich path = inspect_getfile(Aerich) with open(path, 'r+') as file: lines = file.readlines() if lines[-1].find('table') < 0: file.writelines(f"\n table = '{aerich_name}'") from aerich.cli import coro path = inspect_getfile(coro) cfg_import = GeneralConfig.DEFAULT_AERICH_CFG_PATH.replace( '.TORTOISE_ORM', '') first_line = 'sys.path.insert(0, os.getcwd())' line_repair = f"{first_line}\nfrom importlib import import_module\nimport_module('{cfg_import}')\n" repair = False with open(path, 'r') as file: lines = file.readlines() if lines[4].find(first_line) < 0: lines.insert(4, line_repair) repair = True if repair: with open(path, 'w') as file: file.writelines(lines) if GeneralConfig.DEFAULT_AERICH_INI_FILE.is_file(): # Проект уже успешно инициализирован, либо порезан if GeneralConfig.DEFAULT_AERICH_INI_PATH.is_file(): print('AERICH WILL BE INIT EARLY') else: # Проект порезан. Это значит, что кто-то всё стёр на локальной машине print('AERICH REPAIR RUN') _, data_cmd = run( f'aerich init -t {GeneralConfig.DEFAULT_AERICH_CFG_PATH} --location {GeneralConfig.DEFAULT_AERICH_MIGR_PATH.absolute()}' ) print(data_cmd) _, data_cmd = run('aerich init-db') print(data_cmd) # Сохранение конфигурации (для последующего перемещения) shutil_copy(src=GeneralConfig.DEFAULT_AERICH_INI_FILE, dst=GeneralConfig.DEFAULT_AERICH_INI_PATH) else: if GeneralConfig.DEFAULT_AERICH_INI_PATH.is_file(): # Перенос проекта куда-либо print('PROJECT WILL BE MOVE. RECOMBINE AERICH') shutil_copy(src=GeneralConfig.DEFAULT_AERICH_INI_PATH, dst=GeneralConfig.DEFAULT_AERICH_INI_FILE) else: # Первый старт print('AERICH FIRST RUN') _, data_cmd = run( f'aerich init -t {GeneralConfig.DEFAULT_AERICH_CFG_PATH} --location {GeneralConfig.DEFAULT_AERICH_MIGR_PATH.absolute()}' ) print(data_cmd) _, data_cmd = run('aerich init-db') print(data_cmd) # Сохранение конфигурации (для последующего перемещения) shutil_copy(src=GeneralConfig.DEFAULT_AERICH_INI_FILE, dst=GeneralConfig.DEFAULT_AERICH_INI_PATH) # Авто-рендер каждый раз из-за возможных переносов приложения между мирами src_jinja = Path( __file__).parent.parent / 'aerich_proc' / 'pattern_aerich_init.jinja' dict_jinja = { 'tortoise_orm': GeneralConfig.DEFAULT_AERICH_CFG_PATH, 'location': GeneralConfig.DEFAULT_AERICH_MIGR_PATH.absolute() } jinja_render_to_file(src=src_jinja, render=dict_jinja, dst=GeneralConfig.DEFAULT_AERICH_INI_PATH) jinja_render_to_file(src=src_jinja, render=dict_jinja, dst=GeneralConfig.DEFAULT_AERICH_INI_FILE)