Esempio n. 1
0
def build_tex(tex_folder, mod_name):
    base_filepath = tex_folder + mod_name
    extensions = ['tex', 'pdf', 'aux', 'log']
    filepaths = {
        i: io.folder_correct(base_filepath + '.' + i)
        for i in extensions
    }
    remove_filepaths = [
        io.folder_correct(os.getcwd() + '/' + mod_name + '.' + i)
        for i in ['aux', 'log']
    ]
    jnk_filepath = io.folder_correct(base_filepath + '6sfdsafo7re_4adsfsd.tmp')
    sb.call("pdflatex %s > %s" % (filepaths['tex'], jnk_filepath), shell=True)
    os.remove(jnk_filepath)
    for i in remove_filepaths:
        os.remove(i)
    os.rename(io.folder_correct(os.getcwd() + '/' + mod_name + '.pdf'),
              filepaths['pdf'])
    sb.call("xdg-open %s" % filepaths['pdf'], shell=True)
Esempio n. 2
0
 def _garbage_collector(self):
     """
     Deletes temporary files.
     """
     self.all_settings['delete_these'].append(
                                         io.folder_correct('./vmdscene.dat')
                                             )
     # Garbage collection
     #self.all_settings['delete_these'].append(self.all_settings['f.txt'])
     for f in all_settings['delete_these']:
         if os.path.isfile(f):
             os.remove(f)
Esempio n. 3
0
                    type=str,
                    help='an integer for the accumulator')
parser.add_argument("-c",
                    action='store_true',
                    default=False,
                    help="Prints the functions called within functions")
parser.add_argument(
    "-f",
    action='store_true',
    default=False,
    help=
    "Creates a tikz concept map of the subroutines and functions in the file")

args = parser.parse_args()

filepath = io.folder_correct(args.input)
ltxt = io.open_read_close(filepath)

subroutines, sub_beg_indices, _ = txt_lib.splicing(ltxt, "subroutine", "(",
                                                   "end subroutine")
if args.c:
    calls = {
        i: txt_lib.splicing(subroutines[i][1][:], "call", "(", ")",
                            d_on=False)[0]
        for i in subroutines
    }
functions, sub_beg_indices, _ = txt_lib.splicing(
    ltxt, "function", "(", "end function", start_d_index=len(subroutines) + 1)
if args.c:
    for i in functions:
        calls[i] = txt_lib.splicing(functions[i][1][:],
Esempio n. 4
0
#import sympy as sp  # Use this to print things prettyily eventually (maybe to simplify certain bits too)
import sys
#import os


class Transform(object):
    def __init__(self, equation_in):
        steps_taken = ""
        begin_eq = "\n"
        end_eq = "\n"
        math_objs = MO.MATH_OBJECTS(equation_in, steps_taken, begin_eq, end_eq)
        print(math_objs.latex())


transform_path = io.folder_correct("./To_Transform")
transform_txt = io.open_read(transform_path)
transform_txt = txt_lib.clean_eq(transform_txt)

if not len(transform_txt):
    print("Can't find any text")
    sys.exit()

Transform("\sum{_k \delta_{jk}}")

#tex_folderpath = io.folder_correct('./steps')
#tex_filepath = tex_folderpath + "steps.tex"
#
#io.open_write(tex_filepath, MO.steps_taken)
#latex_cmd = "pdflatex --output-directory='%s'"%tex_folderpath
#os.system("%s %s"%(latex_cmd, tex_filepath))
Esempio n. 5
0
        # Don't handle the path variable as it hasn't got a default
        if not path_done and dfl.SequenceMatcher(None, setting, 'path').ratio() > 0.8:
            path_done = True
            all_settings['path'] = clean_settings_dict[setting]
            final_orig_settings_dict['path'] = orig_settings_dict[setting]
            continue

        actual_setting = get_act_setting(setting, all_setting_names)
        if type(orig_settings_dict[setting][0]) == str:
            final_orig_settings_dict[actual_setting] = ["'%s'"%orig_settings_dict[setting][0], orig_settings_dict[setting][1]]
        else:
            final_orig_settings_dict[actual_setting] = orig_settings_dict[setting]
    return final_orig_settings_dict

settings_file = io.folder_correct(consts.settings_filepath)
orig_settings_ltxt = io.open_read(settings_file).split('\n')
settings_ltxt = remove_bad_lines(orig_settings_ltxt)
clean_settings_dict = create_clean_settings(settings_ltxt)
orig_settings_dict = create_orig_settings(orig_settings_ltxt)
all_settings = grab_defaults(clean_settings_dict)
final_orig_settings = find_final_orig_settings(orig_settings_dict, all_settings)
io.write_cleaned_orig_settings(final_orig_settings, settings_file)
if 'path' not in all_settings:
    raise SystemExit("""Sorry I can't find the path variable.... Are you sure you set this?

Use path='...' in the settings.inp file.
""")

if not io.path_leads_somewhere(all_settings['path']):
   raise SystemExit("\nThe specified path doesn't lead anywhere:\n%s\n\n\t Where is my data?! "%all_settings['path'])
Esempio n. 6
0
                    templates.
    * template_filepaths => this specifies where all the template files are
"""
from collections import OrderedDict
import os
import re

from src import IO as io
from src import EXCEPT as EXC

import docstring as docstr
import sys

# Define folders
if __name__ == '__main__':
    docs_folder = io.folder_correct('./Docs')
    templates_folder = io.folder_correct('./Templates/HTML')
    static_folder = io.folder_correct(docs_folder + "Static")
    tables_folder = io.folder_correct(docs_folder + "Tables")
    index_filePath = io.folder_correct('./Documentation.html')


class ParseDefaults(object):
    """
    Will parse the default settings file. Stores all the parsed setting in a
    dictionary called self.params. This is divided up by the section header in
    the defaults dict file.

    This class will also create the filepaths for the table HTML files

    Inputs: