Пример #1
0
def search_for_opening(search_string,
                       look_alphabetical=True,
                       bail_on_misorder=True):
    cur_index = ""
    where_if_nothing = 0
    actual_search_string = re.sub(".*?\?", "", search_string)
    actual_search_string = re.sub("\\b", "", actual_search_string)
    with open(mi) as file:
        for (line_count, line) in enumerate(file, 1):
            if '[start ' in line:
                this_index = re.sub(".*\[start ", "", line.lower().strip())
                print(line.strip())
                print(this_index, "vs", cur_index)
                if this_index < cur_index:
                    if look_alphabetical:
                        print("OUT OF ORDER INDEX {} vs {} at line {}.".format(
                            this_index, cur_index, line_count))
                if look_alphabetical and this_index > actual_search_string and bail_on_misorder:
                    print("Looking alphabetically, we overshot {} with {}.".
                          format(actual_search_string, this_index))
                    i7.npo(mi, line_count - 1)
                    exit()
                cur_index = this_index
            if 'start' in line: print(line.strip())
            if re.search(search_string, line, re.IGNORECASE):
                print("Got", search_string, "in line", line_count)
                i7.npo(mi, line_count)
                exit()
    print("Found nothing to open.")
    i7.npo(mi, where_if_nothing)
    exit()
Пример #2
0
    elif arg == 'e' or arg == 'ec' or arg == 'ce':
        i7.open_source_config()
        exit()
    elif arg == 'es' or arg == 'se':
        i7.open_source()
        exit()
    else:
        usage()
    cmd_count += 1

read_rhymes_table()

read_mistake_file()
check_source_clues()

check_for_cht()

need_adj = 0

for x in sorted(verbs):
    if got_yet[x]: continue
    print("Didn't have any adjustments for {}.".format(x))
    need_adj += 1

if need_adj: print("Total potential adjustments needed = {}.".format(need_adj))

if len(file_open_after):
    for x in file_open_after:
        i7.npo(x, file_open_after[x], bail=False)
    exit()
Пример #3
0
warnings = []
base_out_string = ''

with open("wbase.txt") as file:
    for (line_count, line) in enumerate(file, 1):
        if line.startswith(">"):
            if line[1] != ' ':
                warnings.append(line_count)
                print("WARNING bad spacing line {:d} of wbase.txt: {:s}".format(line_count, line.strip()))
                line = line[0] + ' ' + line[1:]
        if fix_spaces:
            base_out_string += line

lw = len(warnings)

if fix_spaces and lw:
    print("Fixing", len(warnings), "spacing(s)")
    fout = open("wbase.txt", "w")
    fout.write(base_out_string)
    fout.close()

insert_stuff("walkthrough-pre.txt", os.path.join(wri_dir, "walkthrough.txt"), delete_after, core_max)

if my_proj != 'under-they-thunder':
    insert_stuff("walkthrough-full-pre.txt", os.path.join(wri_dir, "walkthrough-full.txt"), delete_after, max_full_score)

if lw and not fix_spaces:
    print("Found {:d} warning{:s}: {:s} (fix with -fs)".format(lw, mt.plur(lw), ", ".join([str(x) for x in warnings])))
    i7.npo("wbase.txt", warnings[-1 if open_last_err else 0])
Пример #4
0
        if not this_dupes: print("{:s} CHECKED OUT.".format(fs))


i7.go_proj("vvff")

count = 1

while count < len(sys.argv):
    arg = sys.argv[count].lower()
    if arg[0] == '-': arg = arg[1:]
    if arg == 'a' or arg == 'ac' or arg == 'ca':
        copy_rejigged = 'c' in arg
        rejig_notes_file()
        exit()
    if arg[0] == 'e':
        if arg == 'e': i7.npo("notes.txt")
        search_token = r'=={:s}'.format(arg[1:])
        with open("notes.txt") as file:
            for (line_count, line) in enumerate(file, 1):
                if re.search(search_token, line):
                    i7.npo("notes.txt", line_count)
        try:
            q = int(arg[1:])
            pluses = 0
            with open("notes.txt") as file:
                for (line_count, line) in enumerate(file, 1):
                    if re.search("==", line):
                        pluses += 1
                        if pluses == q:
                            print("Opening === line #", pluses)
                            i7.npo("notes.txt", line_count)
Пример #5
0
if not write_file and not print_output and not to_clipboard:
    print("You need to write a file or the clipboard or print the output.")
    exit()

if len(added.keys()) == 0:
    x = i7.dir2proj(os.getcwd())
    if x in short.keys():
        print("Going with default", x)
        added[x] = True
    else:
        print("No mistake file in default directory.")

if edit_source:
    for a in added.keys():
        for b in files[a]:
            i7.npo(b, 1, True)
    if not run_check: exit()

for e in sorted(added.keys()):
    mist_file = "c:/Program Files (x86)/Inform 7/Inform7/Extensions/Andrew Schultz/{:s} mistakes.i7x".format(e)
    if e in smallfiles.keys():
        print(e, "smallfile check:", ', '.join(smallfiles[e]))
        mister(e, mist_file, False)
    print(e, "regular file check:", os.path.basename(mist_file))
    mister(e, mist_file, True)

if clipboard_str:
    pyperclip.copy(clipboard_str)
    pyperclip.paste()
    lines = len(clipboard_str.split("\n"))
    print("Rough testing text sent to clipboard,", lines, "lines.")
Пример #6
0
        quiet = False
    elif re.search("^[asdir]+", arg):
        tabs = []
        if 'a' in arg: tabs.append('aftertexts')
        if 's' in arg: tabs.append('spechelp')
        if 'd' in arg: tabs.append('done rejects')
        if 'r' in arg: tabs.append('readables')
        if 'i' in arg: ignore_nudmis = True
    elif arg.lower()[:2] == 'r=': region_wildcard = arg[2:]
    elif arg.lower()[0] == 'e': err_max = int(arg[1:])
    elif arg == '??': standard_usage()
    elif arg == '?': usage()
    else:
        print("Bad command", arg)
        usage()
    count += 1

if out_to_file: hout = open(houtfile, "w")

if not len(projs): sys.exit("No projects defined. Bailing.")
if not len(tabs): sys.exit("No tables defined. Bailing.")

for q in projs:
    for t in tabs:
        sync_check(q, t, region_wildcard)

if out_to_file:
    print("Wrote to", houtfile)
    hout.close()
    if launch_outfile: i7.npo(houtfile)
Пример #7
0
                continue
            l2 = line.rstrip()
            if l2 in caps["generic"].keys():
                print("WARNING", l2, "in generic caps keys as well as", cur_proj, "at line", line_count)
            caps[cur_proj][l2] = True

count = 1
find_caps_bool = False
brute_force_bool = False
sophisticated_bool = True
check_bold_italic_bool = False

while count < len(sys.argv):
    arg = sys.argv[count].lower()
    if arg[0] == '-': arg = arg[1:]
    if arg == 'e': i7.npo(bolds_data)
    elif arg == 'f': find_caps_bool = True
    elif arg == 'nf' or arg == 'fn': find_caps_bool = False
    elif arg == 'ob' or arg == 'bo':
        sophisticated_bool = brute_force_bool = check_bold_italic_bool = False
        find_caps_bool = True
    elif arg == 'b': brute_force_bool = True
    elif arg == 'nb' or arg == 'bn': brute_force_bool = False
    elif arg == 'ob' or arg == 'bo':
        sophisticated_bool = brute_force_bool = find_caps_bool = False
        check_bold_italic_bool = True
    elif arg == 's': sophisticated_bool = True
    elif arg == 'ns' or arg == 'sn': sophisticated_bool = False
    elif arg == 'os' or arg == 'so':
        check_bold_italic_bool = brute_force_bool = find_caps_bool = False
        sophisticated_bool = True
Пример #8
0
    if base_file_noxt.lower().endswith('.i7x'): base_file_noxt = base_file_noxt[-4]
elif len(file_args) != 2:
    print("You need 2 file arguments: 1st the project, 2nd the module description. You have {:d}.".format(len(file_args)))
    print("Though it is okay to use 1 argument if it has a space in it. That space can be at the beginning or end if there is only one word.");
    usage()

if not base_file_noxt:
    my_proj = i7.proj_exp(file_args[0], False)
    if not my_proj: sys.exit("You need to define a valid project or project abbreviation.")
    base_file_noxt = '{:s} {:s}'.format(i7.proj_exp(file_args[0], False), i7.hf_exp(file_args[1])).title().replace('-', ' ')

base_file = base_file_noxt + ".i7x"
x = i7.extdir + "\\" + base_file # can't use os.path.join since the file may not be there

if os.path.exists(x) and not overwrite:
    if not open_post_conversion: sys.exit("With open post conversion set to off, there is nothing to do here. Bailing.")
    print(x, "exists. Opening and not creating.")
    os.system('"' + x + '"')
else:
    if overwrite:
        print(x, "exists but overwriting.")
    else:
        print(x, "does not exist. Creating.")
    now = datetime.datetime.now()
    f = open(x, "w")
    f.write("Version 1/{:02d}{:02d}{:02d} of {:s} by {:s} begins here.\n\n\"This should briefly describe the purpose of {:s}.\"\n\n".format(now.year % 100, now.month, now.day, base_file_noxt, i7.auth, base_file_noxt))
    f.write("{:s} ends here.\n\n---- DOCUMENTATION ----\n".format(base_file_noxt))
    f.close()

if open_post_conversion: i7.npo(x)
Пример #9
0
def launch_it(x, lc):
    print(x)
    if open_file: i7.npo(config_file, lc)
    exit()
Пример #10
0
        projs += i7.i7com[arg].split(",")
    elif not i7.lpro(arg):
        print(arg, "does not map to any project. Showing usage.")
        usage()
    else: projs.append(i7.lpro(arg))
    count = count + 1

my_newline = "\n" if unix_newline else "\r\n"

alpha_on = all_alpha[:alpha_level]
alpha_off = all_alpha[alpha_level:]

read_cfg_file()

if detail_debug:
    print('ON:', ', '.join(alpha_on), '({:d})'.format(len(alpha_on)))
    print('OFF:', ', '.join(alpha_off), '({:d})'.format(len(alpha_off)))

if len(projs) == 0:
    if not super_quiet: print("Using default", default_proj)
    projs = [ default_proj ]

if not super_quiet: print("Okay, processing", ', '.join(projs))

pod = OrderedDict.fromkeys(projs)

for q in pod:
    sort_mistake(q)
    if post_open and post_open_line:
        i7.npo(i7.mifi(q), post_open_line, True, False)
    post_open_line = 0
Пример #11
0
        x = x[1:]
    if x == 'cod': show_code = True
    elif x == 'ncod': show_code = False
    elif x == 'cou': show_count = True
    elif x == 'ncou': show_count = False
    elif x == '?' or x == '-?': usage()
    elif x == 'ed' or x == 'de':
        os.system(data_file)
        exit()
    elif x == 'a' or x == 'oa': open_after = True
    elif x == 'af' or x == 'oaf':
        open_after = True
        open_first = True
    elif x == 'al' or x == 'oal':
        open_after = True
        open_first = False
    else:
        print("Unknown flag", x)
        usage()
    arg_count = arg_count + 1

check_aftertexts()

check_logic_file(need_logic, got_logic, "logic.htm", "<!-- logic for {:s} -->", "old HTML", launch_message = "lh.bat")
check_logic_file(need_logic, got_logic_invis, "c:\\writing\\scripts\\invis\\rl.txt", "# logic for {:s}", "raw InvisiClues", launch_message = "invis.pl rl e")
check_logic_file(need_logic, got_logic_reds, logic_reds, "#qver of {:s}", "reds.txt verification, {:d} question mark{:s} needed".format(qm_needed, i7.plur(qm_needed)), other_test = (qm_needed > 0), launch_message = "reds.txt")

if open_after:
    for q in open_line.keys():
        i7.npo(q, open_line[q])
    if not len(open_line.keys()): print("Nothing to open. Everything worked.")
Пример #12
0
    elif arg == 'gac': get_all_caps = True # detects ALL CAPS at start of a subject e.g. "SEARCH" is flagged along with "Search"
    else:
        if tried_yet: sys.exit("Tried to define a project name -- or a bad flag -- twice. {:s}/{:s}.".format(tried_yet, arg))
        tried_yet = arg
        proj_name = i7.proj_exp(arg, False)
        if not proj_name: print ("WARNING", arg, "not identified as a project.")
    count += 1

if not proj_name:
    if i7.dir2proj(os.getcwd()): proj_name = i7.dir2proj(os.getcwd())
    else: proj_name = default_project
    print("No project name, going with", proj_name)

file_name = i7.src(proj_name)

if open_lang_verb_line: i7.npo(file_name, lang_verb_line(file_name))

read_language_verb(file_name)
read_lanv_config()

ever_ignore_section = ignore_section = False

with open(file_name) as file:
    for (line_count, line) in enumerate(file, 1):
        inl = i7.new_lev(line)
        if inl:
            # print('before', line.strip(), cur_lev, cur_nfr)
            # print(line_count, line.strip())
            cur_lev = inl
            nfr = 'not for release' in line.lower()
            if nfr: cur_nfr = (cur_lev if cur_lev > cur_nfr else cur_nfr)
Пример #13
0
     if not line.startswith("PROJ="): sys.exit("You need to start line {:d} with PROJ= not {:s}.".format(line_count, line[:5]))
     cur_proj = i7.proj_exp(line.lower().strip()[5:])
     print(cur_proj)
     if cur_proj == proj:
         got_proj = True
         in_proj = True
     else:
         in_proj = False
     continue
 if not in_proj: continue
 if '>' in line: # this could get hairy later if I use backchecks in regexes
     ary = line.strip().split(">")
     if len(ary) > 2:
         print("Too many >'s at line", line_count, "in zr.txt:", line.strip())
         if not line_to_open: line_to_open = line_count
         if open_file: i7.npo(zr_data, line_count)
         exit()
     text_change[ary[0].lower()] = ary[1]
 always = False
 if line.startswith('a:'):
     line = re.sub('a:', '', line)
     always = True
 if not line.strip(): continue
 if "\t" in line:
     line_ary = line.strip().split("\t")
     regex_detail[line_ary[0]] = line_ary[1]
     continue
 q = re.split(", *", line.strip())
 for q1 in range(0, len(q)):
     temp = q[q1]
     if temp in cap_search:
Пример #14
0
def rmname(l):
    if ' name=' not in l: return ''
    l2 = re.sub(".* name=.", "", l.strip())
    l2 = re.sub("\".*", "", l2)
    return l2.lower()


count = 1

verbose = False

while count < len(sys.argv):
    arg = sys.argv[count]
    if arg == 'es': i7.open_source()
    elif arg == 'et': i7.npo(rtrizs)
    elif arg == 'ed' or arg == 'e': i7.npo(trizdat, bail=False)
    elif arg == 'v': verbose = True
    elif arg == 'vn' or arg == 'nv': verbose = False
    else: usage()
    count += 1

f2 = open(rtrizt, "w")

with open(trizdat) as file:
    for (line_count, line) in enumerate(file, 1):
        if line.startswith(';'): break
        if line.startswith('#'): continue
        ll = line.strip()
        l2 = ll.split("\t")
        llo = l2[0].lower()
Пример #15
0
                max_process = int(lary[0])
                if max_process < -1:
                    print("Setting default max_process to -1. Maybe fix line", line_count)
                    max_process = -1
            except:
                print("MAXPROC= went wrong at line", line_count)
                cfg_edit_line = line_count
        else:
            print("Unrecognized command line", line_count, line.strip())
            cfg_edit_line = line_count

if cfg_edit_line:
    if not open_on_warn:
        for q in sys.argv:
            if q == 'e' or q == '-e': open_on_warn = True
    if open_on_warn: i7.npo(dg_cfg, cfg_edit_line)
    else: print("Put in an OPENONWARN in {:s} to open the CFG file, or type e/-e on the command line.".format(dg_cfg))

cmd_count = 1
while cmd_count < len(sys.argv):
    arg = sys.argv[cmd_count].lower()
    if arg[0] == '-': arg = arg[1:]
    if arg.isdigit(): max_process = arg
    elif re.search("^d(b)?[0-9]+$", arg):
        temp = re.sub("^d(b)?", "", arg)
        days_before_ignore = int(temp)
    elif arg == 'd' or arg == 'db': days_before_ignore = 0
    elif arg == 'dt' or arg == 't': max_process = -1
    elif arg[:2] == 'g=': my_globs = arg[2:].split(",")
    elif arg == 'e':
        os.system(dg_cfg)
Пример #16
0
        open_files_after = True
    elif arg == 'no' or arg == 'on':
        open_files_after = False
    elif arg == 's':
        show_score = True
    elif arg == 'ns' or arg == 'sn':
        show_score = False
    elif arg == 'r':
        file_filter = sys.argv[count + 1].lower()
        count += 1
    elif arg[0] == 'r':
        file_filter = arg[1:]
    elif arg == '?':
        usage()
    else:
        print("Unrecognized command", arg)
        usage()
    count += 1

for proj in test_ary:
    testproj(proj)

if open_files_after:
    if open_after.keys():
        for f in open_after.keys():
            i7.npo(f, open_after[f], bail=False)
        else:
            print("No error files to open.")
else:
    if open_after.keys(): print("Use -o to open files that flagged errors.")
    else: print("No error files, but if there were any, -o would open them.")