def main(): # defining the: modules_func_tuple mapping modules__func_tuples = ( # TUPLE format: # [module_path_str, ((name_str, function_name_str, list_of_positional_arguments, dictionary_of_keyword_arguments))] [path_abspath('emit_lconf_json1.py'), ( ('do_emit__lconf', 'do_emit__lconf', [], {}), ('do_emit__json_ordered', 'do_emit__json_ordered', [], {}), ('do_emit__json', 'do_emit__json', [], {}), )], [path_abspath('parse_lconf_json1.py'), ( ('do_parse__lconf', 'do_parse__lconf', [], {}), ('do_parse__json_ordered', 'do_parse__json_ordered', [], {}), ('do_parse__json', 'do_parse__json', [], {}), )], ) speed_it( html_output_dir_path=path_abspath('result_output_speed_it_lconf_json'), enable_benchmarkit=True, enable_profileit=False, enable_linememoryprofileit=False, enable_disassembleit=False, modules__func_tuples=modules__func_tuples, output_max_slashes_fileinfo=2, use_func_name=True, output_in_sec=False, profileit__repeat=1, benchmarkit__output_source=False, benchmarkit__with_gc=False, benchmarkit__check_too_fast=True, benchmarkit__rank_by='worst', benchmarkit__run_sec=2.0, benchmarkit__repeat=3 )
def get_versions(default=None, verbose=False): # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have __file__, we can work backwards from there to # the root. Some py2exe/bbfreeze/non-CPython implementations don't do __file__, in which case we can only use expanded # keywords. if not default: default = {'version': 'unknown', 'full': ''} keywords = {'refnames': git_refnames, 'full': git_full} ver = git_versions_from_keywords(keywords, tag_prefix, verbose) if ver: return ver try: root = path_abspath(__file__) # versionfile_source is the relative path from the top of the source tree (where the .git directory might live) to this # file. Invert this to find the root from __file__. for i in range(len(versionfile_source.split(os_sep))): root = path_dirname(root) except NameError: return default return ( git_versions_from_vcs(tag_prefix, root, verbose) or versions_from_parentdir(parentdir_prefix, root, verbose) or default )
def test_jqpc_simple_pie_chart__not_absolute_source_path_expect_failure(): """ Tests: test_jqpc_simple_pie_chart__not_absolute_source_path_expect_failure """ print( '::: TEST: test_jqpc_simple_pie_chart__not_absolute_source_path_expect_failure()' ) scripts_pie_chart_path = 'scripts_pie_chart_test_jqpc_simple_pie_chart__not_absolute_source_path_expect_failure' if path_exists(scripts_pie_chart_path): shutil_rmtree(scripts_pie_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_pie_chart( absolute_source_dir_path=scripts_pie_chart_path, script_src_tag_dir_path=path_abspath(scripts_pie_chart_path), chart_id='example_id', class_str='', chart_title='JqPyCharts simple_pie_chart', chart_data_matrix=[('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '')], highlighter_prefix='', background='#fffdf6', legend_font_px=15, data_label_threshold=9.0, width_px=480, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) if path_exists(scripts_pie_chart_path): shutil_rmtree(scripts_pie_chart_path)
def test_jqpc_simple_bar_chart_ok6(): """ Tests: test_jqpc_simple_bar_chart_ok6: """ print('::: TEST: test_jqpc_simple_bar_chart_ok6()') scripts_bar_chart_path = path_join(SCRIPT_PATH, 'scripts_bar_chart_test_jqpc_simple_bar_chart_ok6') if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_abspath(scripts_bar_chart_path), chart_id='example_id', class_str='', chart_title='JqPyCharts simple_bar_chart', chart_x_label={'fontFamily': 'Helvetica', 'fontSize': 14, 'textColor': '#000000'}, chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)') ], highlighter_prefix='Gram', background='#fffdf6', horizontal=False, draw_grid_lines=False, width_px=550, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) for resource_name in [ 'jquery.min.js', 'jquery.jqplot.min.js', 'jqplot.canvasAxisLabelRenderer.min.js', 'jqplot.categoryAxisRenderer.min.js', 'jqplot.canvasTextRenderer.min.js', 'jqplot.barRenderer.min.js', 'jqplot.pointLabels.min.js', 'jquery.jqplot.min.css']: resource_dir_path__abspath = path_join(scripts_bar_chart_path, resource_name) if resource_dir_path__abspath[-2:] == 'js': check_line = '<script type="text/javascript" src="{}"></script>'.format(resource_dir_path__abspath) ok_(check_line in js_css_resources_header, msg=None) elif resource_dir_path__abspath[-3:] == 'css': check_line = '<link rel="stylesheet" type="text/css" href="{}">'.format(resource_dir_path__abspath) ok_(check_line in js_css_resources_header, msg=None) else: raise Err('test_jqpc_simple_bar_chart_ok6', [ '`resource_name`: <{}> must end with <.js> or <.css>'.format(resource_name) ]) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)
def test_jqpc_simple_bar_horizontal_chart_ok6(): """ Tests: test_jqpc_simple_bar_horizontal_chart_ok6: """ print('::: TEST: test_jqpc_simple_bar_horizontal_chart_ok6()') scripts_bar_chart_path = path_join(SCRIPT_PATH, 'scripts_bar_chart_test_jqpc_simple_bar_horizontal_chart_ok6') if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_abspath(scripts_bar_chart_path), chart_id='example_id', class_str='', chart_title='JqPyCharts simple_bar_chart', chart_x_label={'fontFamily': 'Helvetica', 'fontSize': 14, 'textColor': '#000000'}, chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)') ], highlighter_prefix='Gram', background='#fffdf6', horizontal=True, draw_grid_lines=False, width_px=550, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) for resource_name in [ 'jquery.min.js', 'jquery.jqplot.min.js', 'jqplot.canvasAxisLabelRenderer.min.js', 'jqplot.categoryAxisRenderer.min.js', 'jqplot.canvasTextRenderer.min.js', 'jqplot.barRenderer.min.js', 'jqplot.pointLabels.min.js', 'jquery.jqplot.min.css']: resource_dir_path__abspath = path_join(scripts_bar_chart_path, resource_name) if resource_dir_path__abspath[-2:] == 'js': check_line = '<script type="text/javascript" src="{}"></script>'.format(resource_dir_path__abspath) ok_(check_line in js_css_resources_header, msg=None) elif resource_dir_path__abspath[-3:] == 'css': check_line = '<link rel="stylesheet" type="text/css" href="{}">'.format(resource_dir_path__abspath) ok_(check_line in js_css_resources_header, msg=None) else: raise Err('test_jqpc_simple_bar_horizontal_chart_ok6', [ '`resource_name`: <{}> must end with <.js> or <.css>'.format(resource_name) ]) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)
def test_jqpc_simple_pie_chart_ok5(): """ Tests: test_jqpc_simple_pie_chart_ok5: empty highlighter_prefix """ print('::: TEST: test_jqpc_simple_pie_chart_ok5()') scripts_pie_chart_path = path_join( SCRIPT_PATH, 'scripts_pie_chart_test_jqpc_simple_pie_chart_ok5') if path_exists(scripts_pie_chart_path): shutil_rmtree(scripts_pie_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_pie_chart( absolute_source_dir_path=scripts_pie_chart_path, script_src_tag_dir_path=path_abspath(scripts_pie_chart_path), chart_id='example_id', class_str='', chart_title='JqPyCharts simple_pie_chart', chart_data_matrix=[('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '')], highlighter_prefix='', background='#fffdf6', legend_font_px=15, data_label_threshold=9.0, width_px=480, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) for resource_name in [ 'jquery.min.js', 'jquery.jqplot.min.js', 'jqplot.highlighter.min.js', 'jqplot.canvasTextRenderer.min.js', 'jqplot.pieRenderer.min.js', 'jquery.jqplot.min.css' ]: resource_dir_path__abspath = path_join(scripts_pie_chart_path, resource_name) if resource_dir_path__abspath[-2:] == 'js': check_line = '<script type="text/javascript" src="{}"></script>'.format( resource_dir_path__abspath) ok_(check_line in js_css_resources_header, msg=None) elif resource_dir_path__abspath[-3:] == 'css': check_line = '<link rel="stylesheet" type="text/css" href="{}">'.format( resource_dir_path__abspath) ok_(check_line in js_css_resources_header, msg=None) else: raise Err('test_jqpc_simple_pie_chart_ok5', [ '`resource_name`: <{}> must end with <.js> or <.css>'.format( resource_name) ]) if path_exists(scripts_pie_chart_path): shutil_rmtree(scripts_pie_chart_path)
def main(): # defining the: modules_func_tuple mapping modules__func_tuples = ( # TUPLE format: # [module_path_str, ((name_str, function_name_str, list_of_positional_arguments, dictionary_of_keyword_arguments))] [path_abspath('calculate_pi.py'), ( ('calculate pi', 'approx_pi', [], {'n_': 100000}), )], [path_abspath('dict_sorting.py'), ( ('sorting: pep265', 'example_pep265', [data], {}), ('sorting: stupid', 'example_stupid', [data], {}), ('sorting: list_expansion', 'example_list_expansion', [data], {}), ('sorting: generator', 'example_generator', [data], {}), ('sorting: lambda', 'example_lambda', [data], {}), ('sorting: formal_func_inner', 'example_formal_func_inner', [data], {}), ('sorting: formal_func_outer', 'example_formal_func_outer', [data], {}), )], [path_abspath('memory_example.py'), ( ('memory_example1', 'memory_example1', [27], {'mul': 100}), ('memory_example2', 'memory_example2', [], {}), )], ) speed_it( html_output_dir_path=path_abspath('result_output'), enable_benchmarkit=True, enable_profileit=True, enable_linememoryprofileit=True, enable_disassembleit=True, modules__func_tuples=modules__func_tuples, output_max_slashes_fileinfo=2, use_func_name=True, output_in_sec=False, profileit__repeat=1, benchmarkit__output_source=True, benchmarkit__with_gc=False, benchmarkit__check_too_fast=True, benchmarkit__rank_by='best', benchmarkit__run_sec=0.5, benchmarkit__repeat=3 )
def main(): html_template = ''' <!DOCTYPE html> <html> <head> {js_css_resources_header} {jqplotchart_script1} </head> <body> <br> {html_chart_insert_tag1} <br> </body> </html> ''' js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_bar_chart( absolute_source_dir_path=path_abspath('scripts'), script_src_tag_dir_path='scripts', chart_id='id_1', class_str='', chart_title='JqPyCharts Simple Bar Chart: 1 (with defined legends)', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)') ], highlighter_prefix='Grams', background='#fffdf6', horizontal=False, draw_grid_lines=False, width_px=550, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0 ) example_final_html_code = html_template.format( js_css_resources_header=js_css_resources_header1, jqplotchart_script1=jqplotchart_script1, html_chart_insert_tag1=html_chart_insert_tag1, ) with open('example__simple_bar_chart.html', 'w') as file_: file_.write(example_final_html_code)
def main(): html_template = ''' <!DOCTYPE html> <html> <head> {js_css_resources_header} {jqplotchart_script1} </head> <body> <br> {html_chart_insert_tag1} <br> </body> </html> ''' js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_pie_chart( absolute_source_dir_path=path_abspath('scripts'), script_src_tag_dir_path='scripts', chart_id='id_1', class_str='', chart_title='JqPyCharts Simple Pie Chart', chart_data_matrix=[ ('Fat', 200, '#EAA228', 'Fat: 200 g'), ('Protein', 21, '#4bb2c5', 'Protein: 21 g'), ('Carbohydrate', 10, '#c5b47f', 'Carbohydrate: 10 g') ], highlighter_prefix='Grams', background='#fffdf6', legend_font_px=15, data_label_threshold=9.0, width_px=550, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0 ) example_final_html_code = html_template.format( js_css_resources_header=js_css_resources_header1, jqplotchart_script1=jqplotchart_script1, html_chart_insert_tag1=html_chart_insert_tag1, ) with open('usage_example__simple_pie_chart.html', 'w') as file_: file_.write(example_final_html_code)
def main(): html_template = ''' <!DOCTYPE html> <html> <head> {js_css_resources_header} {jqplotchart_script1} </head> <body> <br> {html_chart_insert_tag1} <br> </body> </html> ''' js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_pie_chart( absolute_source_dir_path=path_abspath('scripts'), script_src_tag_dir_path='scripts', chart_id='id_1', class_str='', chart_title='JqPyCharts Simple Pie Chart', chart_data_matrix=[('Fat', 200, '#EAA228', 'Fat: 200 g'), ('Protein', 21, '#4bb2c5', 'Protein: 21 g'), ('Carbohydrate', 10, '#c5b47f', 'Carbohydrate: 10 g')], highlighter_prefix='Grams', background='#fffdf6', legend_font_px=15, data_label_threshold=9.0, width_px=550, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) example_final_html_code = html_template.format( js_css_resources_header=js_css_resources_header1, jqplotchart_script1=jqplotchart_script1, html_chart_insert_tag1=html_chart_insert_tag1, ) with open('usage_example__simple_pie_chart.html', 'w') as file_: file_.write(example_final_html_code)
def lconf_to_pathexpanduser(path_str, extra_err_info): """ Return a path string if it starts with `~` expanduser else return it unchanged :param path_str: (str) string of a path which must start with `~` or `/` :param extra_err_info: (str) any additional info which will be printed if an error is raised: e.g line number, original line ect.. :return: (str) if input starts with `~` expanduser else return it unchanged :raise Err: """ # must start with ~ or / if path_str[0] == '/' or path_str[0] == '~': return path_abspath(path_expanduser(path_str)) raise Err('lconf_to_pathexpanduser', [ 'path_str must start with <~> or </>. We got: <{}>'.format(lconf_to_pathexpanduser), ' extra_err_info: {}'.format(extra_err_info) ])
def google_compile(dependency_file, output_file, path_to_closure): with open(dependency_file, 'r') as f: file_contents = f.read() dependencies = set([ ]) for dependency_set in file_contents.split('\n\n'): dep_set_split = dependency_set.split(' :') if len(dep_set_split) > 1: deps = dep_set_split[1] file_list = deps.split() for f in file_list: f.strip() if f != ':' and f != '\\': f = path_abspath(f) dependencies.add(f) # Create flag file flag_file_path = 'flagfile.txt' with open(flag_file_path, 'w') as flag_file: flag_file.write(' --js '.join(dependencies)) optimization_level = 'SIMPLE_OPTIMIZATIONS' #optimization_level = 'ADVANCED_OPTIMIZATIONS' args = [ 'java', '-jar', path_to_closure, '--compilation_level', optimization_level, '--flagfile', flag_file_path, '--js_output_file', output_file, '--warning_level', 'DEFAULT' ] _log_stage('RUNNING CLOSURE COMPILER') exec_command(args, console=True, shell=True)
def lconf_to_pathexpanduser(path_str, extra_err_info): """ Return a path string if it starts with `~` expanduser else return it unchanged :param path_str: (str) string of a path which must start with `~` or `/` :param extra_err_info: (str) any additional info which will be printed if an error is raised: e.g line number, original line ect.. :return: (str) if input starts with `~` expanduser else return it unchanged :raise Err: """ # must start with ~ or / if path_str[0] == '/' or path_str[0] == '~': return path_abspath(path_expanduser(path_str)) raise Err('lconf_to_pathexpanduser', [ 'path_str must start with <~> or </>. We got: <{}>'.format( lconf_to_pathexpanduser), ' extra_err_info: {}'.format(extra_err_info) ])
def test_jqpc_get_html_js_css_resources_ok2(): """ Tests: test_jqpc_get_html_js_css_resources_ok2 """ print('::: TEST: test_jqpc_get_html_js_css_resources_ok2()') source_scripts_path = path_join(SCRIPT_PATH, 'source_scripts') # make sure we have the needed resources jqpc_write__resource_dict('jqplot_scripts', source_scripts_path, force=False) needed_resources = [ 'jquery.min.js', 'jquery.jqplot.min.css', 'jqplot.highlighter.min.js', ] out_js_css_resources = jqpc_get_html_js_css_resources( needed_resources, source_scripts_path, path_abspath(source_scripts_path), indent=' ' )
def test_jqpc_get_html_js_css_resources_ok2(): """ Tests: test_jqpc_get_html_js_css_resources_ok2 """ print('::: TEST: test_jqpc_get_html_js_css_resources_ok2()') source_scripts_path = path_join(SCRIPT_PATH, 'source_scripts') # make sure we have the needed resources jqpc_write__resource_dict('jqplot_scripts', source_scripts_path, force=False) needed_resources = [ 'jquery.min.js', 'jquery.jqplot.min.css', 'jqplot.highlighter.min.js', ] out_js_css_resources = jqpc_get_html_js_css_resources( needed_resources, source_scripts_path, path_abspath(source_scripts_path), indent=' ')
def download_files(main_key, dest_path): """ Download files stored in Redis key called `main_key` and extract them into dest_path. """ try: rmtree(dest_path, ignore_errors=True) sub_keys = rs_cli.hkeys(main_key) if not len(sub_keys): logging.error( 'Failed to download files from Redis, key does not exist.') raise KeyError(main_key) for key in sub_keys: key = key.decode('utf-8') m = match(r'^file:(.+)$', key) if m: path = path_join(dest_path, m.group(1)) # in case of directories, if path is eg. foo/bar/code.cpp try: makedirs(path_abspath(path_join(path, '..'))) except FileExistsError: pass with open(path, 'wb') as source_file: source_file.write(rs_cli.hget(main_key, key)) if not rs_cli.hget(main_key, 'options:persistent'): rs_cli.delete(main_key) except ConnectionError as e: err = 'Failed to download files from Redis. Connection problem. {}'.format( e.message) logging.error(err) raise RuntimeError(err)
def main(): # pylint: disable=E1103 options = _check_options() locale.setlocale(locale.LC_ALL, '') verbose = options.verbose if verbose: logging.disable(logging.INFO) else: logging.disable(logging.WARNING) _add_missing_mime_types() try: game = Game(game_list=None, game_path=path_abspath(path_dirname(options.input)), slug=None, games_root=options.cache, deploy_enable=True, manifest_name=path_basename(options.input)) _check_game(game) silent = options.silent if not silent: log('Deploying "%s" to "%s".' % (game.slug, options.hub)) connection = connection_from_url(options.hub, maxsize=8, timeout=8.0) cookie = login(connection, options) (project, projectversion, projectversion_title) = _check_project(connection, options, cookie) result = 0 deploy_info = None deploy_thread = None try: deploy_info = Deployment(game, connection, project, projectversion, projectversion_title, _get_cookie_value(cookie), options.cache) deploy_thread = Thread(target=deploy_info.deploy, args=[options.ultra]) deploy_thread.start() start_time = time() result = _progress(deploy_info, silent, verbose) if (0 == result): result = _postupload_progress(deploy_info, connection, cookie, silent, verbose) if (0 == result): if not silent: log('Deployment time: %s' % _fmt_time( (time() - start_time))) game.set_deployed() except KeyboardInterrupt: warning('Program stopped by user!') if deploy_info: deploy_info.cancel() result = -1 except Exception as e: error(str(e)) if deploy_info: deploy_info.cancel() result = -1 if deploy_info: del deploy_info if deploy_thread: del deploy_thread logout(connection, cookie) return result except GameError: return -1
def get_root(): try: return path_dirname(path_abspath(__file__)) except NameError: return path_dirname(path_abspath(sys_argv[0]))
loads as json_loads ) from os.path import ( abspath as path_abspath, dirname as path_dirname, join as path_join, ) from sys import path as sys_path from nose.tools import ( eq_, ok_ ) 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_classes import ( LconfKVList, LconfRoot, ) from LCONF.lconf_structure_classes import ( KVList, Root, )
find_packages, setup, ) import versioneer versioneer.VCS = 'git' versioneer.versionfile_source = 'PSphinxTheme/_version.py' versioneer.versionfile_build = 'PSphinxTheme/_version.py' versioneer.tag_prefix = '' # tags are like 1.1.0 versioneer.parentdir_prefix = 'PSphinxTheme-' # dirname like 'PSphinxTheme-1.1.0' _version = versioneer.get_version() SCRIPT_PATH = path_dirname(path_abspath(getfile(currentframe()))) PACKAGE_NAME = 'PSphinxTheme' ROOT_PACKAGE_PATH = path_join(path_dirname(SCRIPT_PATH), PACKAGE_NAME) MAIN_PACKAGE_PATH = path_join(ROOT_PACKAGE_PATH, PACKAGE_NAME) from PSphinxTheme import TESTED_HOST_OS if sys_version_info[:2] < (3, 4) or sys_platform == 'win32': print(''' \nPSphinxTheme is only tested with Python 3.4.1 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 for option_temp in {'bdist_dumb', 'bdist_rpm', 'bdist_wininst', 'bdist_egg'}:
def get_psphinxtheme_root_dir(): """ :return: (str) path of the *P-SphinxTheme* root dir """ return path_dirname(path_abspath(inspect_getfile(inspect_currentframe())))
def main(): # common var source_dir_path = path_abspath('scripts') script_src_tag_dir_path = 'scripts' background = '#fffdf6' legend_font_px = 15 data_label_threshold = 9.0 width_px = 550 height_px = 300 margin_top_px = 0 margin_bottom_px = 0 margin_right_px = 0 margin_left_px = 0 js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_pie_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_1', class_str='', chart_title='JqPyCharts Simple Pie Chart: 3 (with defined legends)', chart_data_matrix=[ ('Fat', 200, '#EAA228', 'Fat: 200 g'), ('Protein', 21, '#4bb2c5', 'Protein: 21 g'), ('Carbohydrate', 10, '#c5b47f', 'Carbohydrate: 10 g') ], highlighter_prefix='Grams', background=background, legend_font_px=legend_font_px, data_label_threshold=data_label_threshold, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px ) js_css_resources_header2, jqplotchart_script2, html_chart_insert_tag2 = jqpc_simple_pie_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_2', class_str='', chart_title='JqPyCharts Simple Pie Chart: 2 (with no defined legends)', chart_data_matrix=[ ('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '') ], highlighter_prefix='Grams', background=background, legend_font_px=legend_font_px, data_label_threshold=data_label_threshold, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px ) js_css_resources_header3, jqplotchart_script3, html_chart_insert_tag3 = jqpc_simple_pie_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_3', class_str='', chart_title='JqPyCharts Simple Pie Chart: 3 (with None legends)', chart_data_matrix=[ ('Fat', 200, '#EAA228', None), ('Protein', 21, '#4bb2c5', None), ('Carbohydrate', 10, '#c5b47f', None) ], highlighter_prefix='Grams', background=background, legend_font_px=legend_font_px, data_label_threshold=data_label_threshold, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px ) js_css_resources_header4, jqplotchart_script4, html_chart_insert_tag4 = jqpc_simple_pie_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_4', class_str='', chart_title='JqPyCharts Simple Pie Chart: 4 (no highlighter_prefix)', chart_data_matrix=[ ('Fat', 200, '#EAA228', 'Fat: 200 g'), ('Protein', 21, '#4bb2c5', 'Protein: 21 g'), ('Carbohydrate', 10, '#c5b47f', 'Carbohydrate: 10 g') ], highlighter_prefix='', background=background, legend_font_px=legend_font_px, data_label_threshold=data_label_threshold, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px ) example_final_html_code = html_template.format( js_css_resources_header=js_css_resources_header1, jqplotchart_script1=jqplotchart_script1, jqplotchart_script2=jqplotchart_script2, jqplotchart_script3=jqplotchart_script3, jqplotchart_script4=jqplotchart_script4, html_chart_insert_tag1=html_chart_insert_tag1, html_chart_insert_tag2=html_chart_insert_tag2, html_chart_insert_tag3=html_chart_insert_tag3, html_chart_insert_tag4=html_chart_insert_tag4, ) with open('example__simple_pie_chart.html', 'w') as file_: file_.write(example_final_html_code)
def main(): # common var source_dir_path = path_abspath('scripts') script_src_tag_dir_path = 'scripts' background = '#fffdf6' horizontal = False width_px = 550 height_px = 300 margin_top_px = 0 margin_bottom_px = 0 margin_right_px = 0 margin_left_px = 0 js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_1', class_str='', chart_title='JqPyCharts Simple Bar Chart: 1 (with defined legends)', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)')], highlighter_prefix='', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header2, jqplotchart_script2, html_chart_insert_tag2 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_2', class_str='', chart_title='JqPyCharts Simple Bar Chart: 2 (with no defined legends)', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '')], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header3, jqplotchart_script3, html_chart_insert_tag3 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_3', class_str='', chart_title='JqPyCharts Simple Bar Chart: 3 (with grid_lines)', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)')], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=True, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header4, jqplotchart_script4, html_chart_insert_tag4 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_4', class_str='', chart_title='JqPyCharts Simple Bar Chart: 4 (with x_label)', chart_x_label='Grams', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)')], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header5, jqplotchart_script5, html_chart_insert_tag5 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_5', class_str='', chart_title='JqPyCharts Simple Bar Chart: 5 (with x_label_fontdict)', chart_x_label='Grams', chart_x_label_fontdict={ 'fontFamily': 'Impact', 'fontSize': 20, 'textColor': '#557700' }, chart_ticks_fontdict=None, chart_data_matrix=[('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)')], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header6, jqplotchart_script6, html_chart_insert_tag6 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_6', class_str='', chart_title='JqPyCharts Simple Bar Chart: 6 (with ticks_fontdict)', chart_x_label='Grams', chart_x_label_fontdict=None, chart_ticks_fontdict={ 'fontFamily': 'Impact', 'fontSize': 12, 'textColor': '#557700' }, chart_data_matrix=[('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)')], highlighter_prefix='', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) example_final_html_code = html_template.format( js_css_resources_header=js_css_resources_header1, jqplotchart_script1=jqplotchart_script1, jqplotchart_script2=jqplotchart_script2, jqplotchart_script3=jqplotchart_script3, jqplotchart_script4=jqplotchart_script4, jqplotchart_script5=jqplotchart_script5, jqplotchart_script6=jqplotchart_script6, html_chart_insert_tag1=html_chart_insert_tag1, html_chart_insert_tag2=html_chart_insert_tag2, html_chart_insert_tag3=html_chart_insert_tag3, html_chart_insert_tag4=html_chart_insert_tag4, html_chart_insert_tag5=html_chart_insert_tag5, html_chart_insert_tag6=html_chart_insert_tag6, ) with open('example__simple_bar_chart.html', 'w') as file_: file_.write(example_final_html_code)
Command, find_packages, setup, ) import versioneer versioneer.VCS = 'git' versioneer.versionfile_source = 'PSphinxTheme/_version.py' versioneer.versionfile_build = 'PSphinxTheme/_version.py' versioneer.tag_prefix = '' # tags are like 1.1.0 versioneer.parentdir_prefix = 'PSphinxTheme-' # dirname like 'PSphinxTheme-1.1.0' _version = versioneer.get_version() SCRIPT_PATH = path_dirname(path_abspath(getfile(currentframe()))) PACKAGE_NAME = 'PSphinxTheme' ROOT_PACKAGE_PATH = path_join(path_dirname(SCRIPT_PATH), PACKAGE_NAME) MAIN_PACKAGE_PATH = path_join(ROOT_PACKAGE_PATH, PACKAGE_NAME) from PSphinxTheme import TESTED_HOST_OS if sys_version_info[:2] < (3, 4) or sys_platform == 'win32': print((''' \nPSphinxTheme is only tested with Python 3.4.1 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 for option_temp in {'bdist_dumb', 'bdist_rpm', 'bdist_wininst', 'bdist_egg'}:
def main(): # pylint: disable=E1103 options = _check_options() locale.setlocale(locale.LC_ALL, '') verbose = options.verbose if verbose: logging.disable(logging.INFO) else: logging.disable(logging.WARNING) _add_missing_mime_types() try: game = Game(game_list=None, game_path=path_abspath(path_dirname(options.input)), slug=None, games_root=options.cache, deploy_enable=True, manifest_name=path_basename(options.input)) _check_game(game) silent = options.silent if not silent: log('Deploying "%s" to "%s".' % (game.slug, options.hub)) connection = connection_from_url(options.hub, maxsize=8, timeout=8.0) cookie = login(connection, options) (project, projectversion, projectversion_title) = _check_project(connection, options, cookie) result = 0 deploy_info = None deploy_thread = None try: deploy_info = Deployment(game, connection, project, projectversion, projectversion_title, _get_cookie_value(cookie), options.cache) deploy_thread = Thread(target=deploy_info.deploy, args=[options.ultra]) deploy_thread.start() start_time = clock() result = _progress(deploy_info, silent, verbose) if (0 == result): result = _postupload_progress(deploy_info, connection, cookie, silent, verbose) if (0 == result): if not silent: log('Deployment time: %s' % _fmt_time((clock() - start_time))) game.set_deployed() except KeyboardInterrupt: warning('Program stopped by user!') if deploy_info: deploy_info.cancel() result = -1 except Exception as e: error(str(e)) if deploy_info: deploy_info.cancel() result = -1 if deploy_info: del deploy_info if deploy_thread: del deploy_thread logout(connection, cookie) return result except GameError: return -1
# 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 datetime import datetime 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 from nose.tools import (eq_, ok_) 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_classes import ( LconfBlk, LconfBlkI, LconfKVList, LconfKVMap, LconfRoot, LconfListOT, )
def main(): # common var source_dir_path = path_abspath('scripts') script_src_tag_dir_path = 'scripts' background = '#fffdf6' horizontal = True width_px = 700 height_px = 300 margin_top_px = 0 margin_bottom_px = 0 margin_right_px = 0 margin_left_px = 0 js_css_resources_header1, jqplotchart_script1, html_chart_insert_tag1 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_1', class_str='', chart_title='JqPyCharts Simple Bar Chart: 1 (with defined legends)', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', '57.7 %'), ('Protein', 21, '#4bb2c5', '21.3 %'), ('Carbohydrate', 10, '#c5b47f', '24.0 %') ], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header2, jqplotchart_script2, html_chart_insert_tag2 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_2', class_str='', chart_title='JqPyCharts Simple Bar Chart: 2 (with no defined legends)', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '') ], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header3, jqplotchart_script3, html_chart_insert_tag3 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_3', class_str='', chart_title='JqPyCharts Simple Bar Chart: 3 (with grid_lines)', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)') ], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=True, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header4, jqplotchart_script4, html_chart_insert_tag4 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_4', class_str='', chart_title='JqPyCharts Simple Bar Chart: 4 (with x_label)', chart_x_label='Grams', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)') ], highlighter_prefix='Gram', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header5, jqplotchart_script5, html_chart_insert_tag5 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_5', class_str='', chart_title='JqPyCharts Simple Bar Chart: 5 (with x_label_fontdict)', chart_x_label='Grams', chart_x_label_fontdict={'fontFamily': 'Impact', 'fontSize': 20, 'textColor': '#557700'}, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)') ], highlighter_prefix='', background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) js_css_resources_header6, jqplotchart_script6, html_chart_insert_tag6 = jqpc_simple_bar_chart( absolute_source_dir_path=source_dir_path, script_src_tag_dir_path=script_src_tag_dir_path, chart_id='id_6', class_str='', chart_title='JqPyCharts Simple Bar Chart: 6 (with ticks_fontdict)', chart_x_label='Grams', chart_x_label_fontdict=None, chart_ticks_fontdict={'fontFamily': 'Impact', 'fontSize': 12, 'textColor': '#557700'}, chart_data_matrix=[ ('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)') ], background=background, horizontal=horizontal, draw_grid_lines=False, width_px=width_px, height_px=height_px, margin_top_px=margin_top_px, margin_bottom_px=margin_bottom_px, margin_right_px=margin_right_px, margin_left_px=margin_left_px) example_final_html_code = html_template.format( js_css_resources_header=js_css_resources_header1, jqplotchart_script1=jqplotchart_script1, jqplotchart_script2=jqplotchart_script2, jqplotchart_script3=jqplotchart_script3, jqplotchart_script4=jqplotchart_script4, jqplotchart_script5=jqplotchart_script5, jqplotchart_script6=jqplotchart_script6, html_chart_insert_tag1=html_chart_insert_tag1, html_chart_insert_tag2=html_chart_insert_tag2, html_chart_insert_tag3=html_chart_insert_tag3, html_chart_insert_tag4=html_chart_insert_tag4, html_chart_insert_tag5=html_chart_insert_tag5, html_chart_insert_tag6=html_chart_insert_tag6, ) with open('example__simple_bar_horizontal_chart.html', 'w') as file_: file_.write(example_final_html_code)