def get_max_file():
    my_proj = i7.dir2proj()
    if my_proj == 'under-they-thunder':
        return i7.hdr('ut', 'glo')
    return i7.main_src(my_proj)
Esempio n. 2
0
# symlinked from QQNN to VVFF
#
# todo: i7.topx2ary so we can test multiple mistakes
#

from mytools import nohy
import sys
import os
import re
import i7
from collections import defaultdict

debug = False
add_and_verify = True

my_proj = i7.dir2proj(to_abbrev=True)
if my_proj != 'vv' and my_proj != 'qq':
    sys.exit("You need to run this from the VVFF or QQNN source directory.")

os.chdir(i7.sdir(my_proj))
mistake_cfg = os.path.join(i7.sdir(my_proj), my_proj + "m.txt")
source_cfg = os.path.join(i7.sdir(my_proj), my_proj + "s.txt")
my_src = i7.src(my_proj)
mistake_file = i7.hdr(my_proj, "mi")
table_file = i7.hdr(my_proj, "ta")

ignores = defaultdict(bool)
should_be = defaultdict(str)
found_yet = defaultdict(bool)
file_open_after = defaultdict(int)
verbs = defaultdict(bool)
Esempio n. 3
0
                insteads_global += 1
                out_string += "({:d}/{:d}) ".format(insteads, insteads_global) + line
                in_instead = True
                continue
            if in_instead:
                out_string += line
                if not line.strip(): in_instead = False
                continue
    if out_string:
        print("====", q, "====")
        print(out_string)
        print(insteads, "total insteads for", q)
    else: print("No INSTEADS string for", q)

default_project = "ailihphilia"
my_project = i7.dir2proj(os.getcwd())
if not my_project:
    print("Project directory not located. Using default", default_project)
    my_project = default_project

cmd_proj = ""

cmd_count = 1

get_potential_adjusts()

while cmd_count < len(sys.argv):
    arg = mt.nohy(sys.argv[cmd_count])
    if i7.proj_exp(arg, False):
        if cmd_proj: sys.exit("Defined two command line projects. Bailing.")
        cmd_proj = i7.proj_exp(arg)
import os
import re
import i7
import sys
import stat
import mytools as mt
import __main__ as main

max_full_score = 0
# the maximum score is ...
max_score = 0
# vvff specific: if we have optional points
max_bonus = 0
core_max = 0

my_proj = i7.dir2proj()

wri_dir = i7.gh_src(my_proj, give_source = False)
wri_loc = i7.sdir(my_proj)

fix_spaces = False

out_read_only = True
delete_after = False #It's ok to have this, since we don't copy over the pre-files to the source control directory
verbose = True

open_last_err = True
need_core_max = False

show_rbr_warning = not ('-norbrwarn' in sys.argv or 'norbrwarn' in sys.argv)
if show_rbr_warning: print("NOTE do not run wdrop.py on its own--run rbr.py wbase.txt.")
Esempio n. 5
0
    elif arg == 'nc' or arg == 'cn': check_bold_italic_bool = False
    elif arg == 'oc' or arg == 'co':
        sophisticated_bool = brute_force_bool = find_caps_bool = False
        check_bold_italic_bool = True
    elif arg == '?': usage()
    else:
        if cmd_line_proj: sys.exit("You tried to define 2 cmd line projects, {:s} then {:s}.".format(cmd_line_proj, arg))
        cmd_line_proj = i7.proj_exp(arg)
    count += 1

if cmd_line_proj:
    print("Changing dir to", cmd_line_proj)
    try:
        os.chdir(to_proj(cmd_line_project))
    except:
        sys.exit("Can't map", cmd_line_proj, "to a directory.")

my_proj = i7.dir2proj(os.getcwd())

if not os.path.exists("story.ni"): sys.exit("Need a directory with story.ni.")

read_data_file()

caps_par = "|".join(set(caps[my_project].keys()) | set(caps["generic"].keys()))

if find_caps_bool: find_caps()
if brute_force_bool: brute_force()
if sophisticated_bool: line_to_open = sophisticated()
if check_bold_italic_bool: check_bold_italic()

if line_to_open: i7.npo("story.ni", line_to_open)
Esempio n. 6
0
                    added[q] = True
                elif q in i7.i7x.keys() and i7.i7x[q] in short.keys():
                    print("Adding", i7.i7x[q])
                    added[i7.i7x[q]] = True
                else:
                    print(q, "not recognized as a project with a mistake file and/or regex test files.")
                    print('=' * 50)
                    usage()
        count += 1

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():
            if 'ready;' in line:
                if anything_but(my_ary, 'xxx'):
                    print(this_rule, "ready has printing above line",
                          line_count)
                    mt.add_postopen(my_file, line_count)
                    got_one = True
                my_ary = []
    if not got_one:
        print("Everything worked out for", mb)


rhyme_check_array = []

try:
    if len(sys.argv) == 1:
        rhyme_check_array = [i7.dir2proj()]
    elif sys.argv[1] == 'a':
        rhyme_check_array = i7.i7com['pprr'].split(',')
    elif sys.argv[1].isdigit():
        rhyme_check_array = i7.i7com[:int(sys.argv[1])]
    elif sys.argv[1] == 'm':
        rhyme_check_array['vvff', 'lljj']
    elif re.search(r"^[vqlc]+$", sys.argv[1]):
        if 'l' in sys.argv[1]:
            rhyme_check_array.append('lljj')
        if 'v' in sys.argv[1]:
            rhyme_check_array.append('vvff')
        if 'q' in sys.argv[1]:
            rhyme_check_array.append('qqnn')
        if 'c' in sys.argv[1]:
            rhyme_check_array.append('csdd')
def check_rhymes(this_proj=i7.dir2proj()):
    my_file = i7.hdr(this_proj, 'ta')
    print("Checking vc- and vr- rules for the right say-stubs in", my_file)
    in_vc_rule = in_vr_rule = False
    mb = os.path.basename(my_file)
    got_one = False
    with open(my_file) as file:
        for (line_count, line) in enumerate(file, 1):
            l0 = line.strip()
            if not l0:
                if in_vr_rule:
                    if not got_score_variable:
                        print("No", my_score_variable, "in", this_rule, "line",
                              line_count)
                in_vc_rule = in_vr_rule = False
                continue
            if "this is the vr-" in l0:
                in_vr_rule = True
                this_rule = header_to_rule(line.strip())
                my_score_variable = this_rule.replace("vr-", "sco-").replace(
                    " rule", "")
                got_score_variable = False
                continue
            if "this is the vc-" in l0:
                in_vc_rule = True
                this_rule = re.sub("^.*?\(", "", line.strip())
                this_rule = re.sub("\).*", "", this_rule)
                my_ary = []
            if not in_vc_rule and not in_vr_rule:
                continue
            if in_vr_rule:
                if my_score_variable in line:
                    got_score_variable = True
                continue
            for x in addables:
                if l0.startswith(x) and '[oksay]' not in line:
                    my_ary.append(x)
            if 'already-done;' in line:
                if anything_but(my_ary, 'vcal'):
                    print(this_rule,
                          "already-done has non-vcal print above line",
                          line_count)
                    got_one = True
                    mt.add_postopen(my_file, line_count)
                my_ary = []
            if 'not-yet;' in line:
                if anything_but(my_ary, 'vcp'):
                    print(this_rule, "not-yet has non-vcp print above line",
                          line_count)
                    got_one = True
                    mt.add_postopen(my_file, line_count)
                my_ary = []
            if 'ready;' in line:
                if anything_but(my_ary, 'xxx'):
                    print(this_rule, "ready has printing above line",
                          line_count)
                    mt.add_postopen(my_file, line_count)
                    got_one = True
                my_ary = []
    if not got_one:
        print("Everything worked out for", mb)
Esempio n. 9
0
import os
import sys
import i7
import re
from filecmp import cmp
from shutil import copy
from collections import defaultdict
from collections import OrderedDict

malf_cfg = "c:/writing/scripts/malf.txt"

temp_file = "c:\\games\\inform\\mist.i7x"
temp_detail_1 = "c:\\games\\inform\\mist1.i7x"
temp_detail_2 = "c:\\games\\inform\\mist2.i7x"

default_proj = i7.dir2proj()
if not default_proj: default_proj = 'ai'

sort_level = defaultdict(str)

detail_debug = False
copy_not_show = False
track_global_duplicates = True
super_quiet = False

projs = []

count = 1

alpha_level = 2
all_alpha = [ 'section', 'chapter', 'part', 'book', 'volume' ]
Esempio n. 10
0
dupe_without_spaces = 0

this_project = ""

while count < len(sys.argv):
    arg = sys.argv[count].lower()
    if arg[0] == '-': arg = arg[1:]
    if arg == 'ns' or arg == 'sn': check_spaceless = False
    elif arg == 's': check_spaceless = True
    elif arg in i7.i7x.keys(): this_project = i7.i7x[arg]
    elif arg in i7.i7x.values(): this_project = arg
    else:
        print("Bad argument", arg)
        usage()
    count += 1

if not this_project:
    this_project=i7.dir2proj()
    if not this_project: sys.exit("Could not find project for current working directory. Go to a source directory or specify a project or abbreviation.")
    print("Pulling default project {:s} from current directory.".format(this_project))

read_format_strings()

table_hack(i7.src(this_project))
table_hack(i7.tafi(this_project))

if dupes: print(dupes, "total duplicates to fix.")
else: print("DUPLICATE TESTING PASSED")

if dupe_without_spaces: print(dupe_without_spaces, "duplicates without spaces to fix e.g. Not On vs No Ton.")
else: print("DUPLICATE TESTING WITHOUT SPACES PASSED")
Esempio n. 11
0
    print("Use a project directory or its abbreviation.")
    print("-v = verbose output")
    print("-f = format help for roomsync.txt file")
    exit()

def format_help():
    print("ignore: = ignore rooms labeled X")
    print("rename: = rename (source name) to (trizbort name)")
    exit()

def if_rename(x):
    if x in room_renamer.keys():
        return room_renamer[x]
    return x

my_proj_dir = i7.dir2proj(os.getcwd())
if not my_proj_dir: sys.exit("Need to be in a valid project directory.")
read_this = True

def read_ignore_file():
    line_count = 0
    with open(ignore_file) as file:
        for line in file:
            line_count += 1
            if line.startswith(';'): break
            if line.startswith('#'): continue
            if line.startswith('project:'):
                ll = re.sub("^project:", "", line.strip().lower())
                if not ll or i7.proj_exp(ll) == my_proj_dir: read_this = True
                else: read_this = False
            if not read_this: continue
Esempio n. 12
0
while count < len(sys.argv):
    arg = sys.argv[count]
    if arg == 'c': i7.open_source()
    elif arg == 'cl': open_lang_verb_line = True
    elif arg == 'e': i7.open_config()
    elif arg == 't': check_test_file = True
    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)
Esempio n. 13
0
    count += 1

if in_file:
    if not os.path.isfile(in_file): sys.exit(in_file + " not found.")
    os.chdir(os.path.dirname(os.path.abspath(in_file)))
    mydir = os.getcwd()
    if edit_main_branch:
        print("Opening branch file", in_file)
        os.system(in_file)
    else:
        get_file(in_file)
    exit()

if not proj:
    myd = os.getcwd()
    if i7.dir2proj(myd):
        proj = i7.dir2proj(myd)
        print("Going with project from current directory", proj)
    else:
        print("Going with default", def_proj)
        proj = def_proj

if verify_nudges:
    q = glob.glob("reg-*.txt")
    nudge_overall = 0
    for q1 in q:
        if 'nudmis' in q1: continue
        if 'nudges' in q1: continue
        if 'roi-' in q1: continue
        print("Checking nudges for", q1)
        nudge_this = 0
Esempio n. 14
0
# question: search for starting tabs in non-.ni files. What script for that?
#

from shutil import copy
from collections import defaultdict
import i7
import glob
import re
import os
import sys
import time

glob_default = "da"
default_sect = ""
my_sect = ""
default_by_dir = i7.dir2proj(to_abbrev = True)

dg_cfg = "c:/writing/scripts/dgrab.txt"
flat_cfg = os.path.basename(dg_cfg)
dg_temp = "c:/writing/temp/dgrab-temp.txt"
flat_temp = os.path.basename(dg_temp)

mapping = defaultdict(str)
regex_sect = defaultdict(str)
regex_comment = defaultdict(str)
file_regex = defaultdict(str)
notes_to_open = defaultdict(int)
globs = defaultdict(str)

max_process = 0
open_notes = 0
Esempio n. 15
0
            searchables.append(i7.i7x[ll])
        elif ll in i7.i7x.values():
            searchables.append(ll)
        else:
            print("WARNING!", ll, "is not in i7x.keys.")
        count += 1

html_file = "c:/games/inform/qq.htm"

if html_exp:
    fhtml = open(html_file, "w")
    fhtml.write("<html>\n<title>\nQQ.PY all-project results</title>\n<body>\n")

if search_all_qs:
    for x in sorted(i7.i7xr):
        todo_hunt(x)
elif len(searchables) == 0:
    if os.path.exists("story.ni"):
        todo_hunt(i7.dir2proj(os.getcwd()))
    else:
        sys.exit("Didn't find any story.ni to process. Bailing.")
else:
    for x in sorted(searchables):
        todo_hunt(x)

if html_exp:
    fhtml.write("</body>\n</html>\n")
    fhtml.close()
    print("Launching", html_file)
    os.system(html_file)