def check_defs(d): # Cache for all the warnings warns = [] # Find all the modules that we have to worry about mods = locate_files(d) mods = list(filter(lambda x: needsPreamble(x), mods)) ret = True for mod in remove_doubles(mods): ret = ret and check_symcomplete(mod["file"], warns) return ret
def check_defs(d): # Cache for all the warnings warns = [] # Find all the modules that we have to worry about mods = locate_files(d) mods = list(filter(lambda x:needsPreamble(x), mods)) ret = True for mod in remove_doubles(mods): ret = ret and check_symcomplete(mod["file"], warns) return ret
def add_symis(text, symis): addtext = [] for sym in symis: if sym[1] == 0: continue addtext.append("\\sym%s{%s}\n" % ("i" * sym[1], "}{".join(sym[2]))) # HACK: Print out the symbols we add std(", ".join(addtext).replace("\n", "")) addtext = remove_doubles(addtext) pattern = r"\\begin{modsig}((.|\n)*)\\end{modsig}" return re.sub(pattern, r"\\begin{modsig}\1" + "".join(addtext) + "\\end{modsig}", text)
def add_symis(text, symis): addtext = [] for sym in symis: if sym[1] == 0: continue addtext.append("\\sym%s{%s}\n" % ("i"*sym[1], "}{".join(sym[2]))) # HACK: Print out the symbols we add std(", ".join(addtext).replace("\n", "")) addtext = remove_doubles(addtext) pattern = r"\\begin{modsig}((.|\n)*)\\end{modsig}" return re.sub(pattern, r"\\begin{modsig}\1"+"".join(addtext)+"\\end{modsig}", text)
def find_all_symdefs(text): # FInd all symdefs pattern = r"\\begin{modsig}((.|\n)*)\\end{modsig}" pattern2 = r"\\symdef(\[([^\]]*,(\s)*)?name=([^],]+)?(,[^\]]*)?\])?\{([^{}]+)?\}" pattern3 = r"\\symdef(\[([^\]]+)\])?\{([^{}]+)?\}" matches = re.findall(pattern, text) if len(matches) == 0: return [] text = matches[0][0] # Find symdefs with seperate names matches = re.findall(pattern2, text) names_1 = [m[3] if m[3] != "" else m[5] for m in matches] # and without seperate names matches2 = re.findall(pattern3, re.sub(pattern2, "", text)) names_2 = [m[2] for m in matches2] # and combine return remove_doubles(names_1 + names_2)
def find_all_symdefs(text): # FInd all symdefs pattern = r"\\begin{modsig}((.|\n)*)\\end{modsig}" pattern2 = r"\\symdef(\[([^\]]*,(\s)*)?name=([^],]+)?(,[^\]]*)?\])?\{([^{}]+)?\}" pattern3 = r"\\symdef(\[([^\]]+)\])?\{([^{}]+)?\}" matches = re.findall(pattern, text) if len(matches) == 0: return [] text = matches[0][0] # Find symdefs with seperate names matches = re.findall(pattern2, text) names_1 = [m[3] if m[3] != "" else m[5] for m in matches] # and without seperate names matches2 = re.findall(pattern3, re.sub(pattern2, "", text)) names_2 = [m[2] for m in matches2] # and combine return remove_doubles(names_1+names_2)
def match_repos(repos, root=os.getcwd(), abs=False): """ Matches a list of specefiers to repositories. @param {string[]} repos - Specefiers to match @param {string} root - Root directory to use @param {boolean} [abs=False] - Should absolute paths be returned? @returns string[] - repository paths """ # For each element do the following: # 1) Check if given directory exists relatively from current root. # 1a) If it is a repository or repository subdir, return that # 1b) If it is inside the data_dir, return all repo subdirectories # 2) If it does not exist, resolve it as glob.glob from install_dir # 3) For each of the found directories, run 1) # If the repositories are just a string, we want an array. if is_string(repos): repos = [repos] # it is already an array, so remove doubles please. else: repos = remove_doubles(repos) # the glob expressions we want to use # and the repo directories we will use. results = set() def match_repo_name(r): # make an absolute path # this will also work with globs names = os.path.abspath(os.path.join(root, r)) # it is not inside the data directory # so try again next time if not is_in_data(names): return True # find the relative path of it to the root. names = os.path.relpath(os.path.abspath(names), lmh_locate("content")) # make sure everything ends with a slash # so that we can count properly if names[-1] != "/": names += "/" # Now figure out which level we are at # by counting slashes num_slashes = 0 for c in names: # count the slashes # by increasing the level. if c == "/": num_slashes += 1 # if we have no slashes # we are toplevel # and can pretty much exit everything if names == "./": names = lmh_locate("content", "*", "*") # if we have 1 slash # we are one level deep elif num_slashes == 1: names = lmh_locate("content", names, "*") else: names = lmh_locate("content", names) # now expand with the help of globs names = glob.glob(names) # and check if they exist names = list(filter(is_repo, names)) # if we found something # we should through the item if len(names) > 0: results.update(names) return False else: return True # now filter the repos repos = list(filter(match_repo_name, repos)) # repeat again with data_dir as root root = lmh_locate("content") repos = list(filter(match_repo_name, repos)) # if we want the relative paths we need to set them properly. if not abs: return [os.path.relpath(d, lmh_locate("content")) for d in results] return list(results)
def match_repos(repos, root=os.getcwd(), abs=False): """ Matches a list of specefiers to repositories. @param {string[]} repos - Specefiers to match @param {string} root - Root directory to use @param {boolean} [abs=False] - Should absolute paths be returned? @returns string[] - repository paths """ # For each element do the following: # 1) Check if given directory exists relatively from current root. # 1a) If it is a repository or repository subdir, return that # 1b) If it is inside the data_dir, return all repo subdirectories # 2) If it does not exist, resolve it as glob.glob from install_dir # 3) For each of the found directories, run 1) # If the repositories are just a string, we want an array. if is_string(repos): repos = [repos] # it is already an array, so remove doubles please. else: repos = remove_doubles(repos) # the glob expressions we want to use # and the repo directories we will use. results = set() def match_repo_name(r): # make an absolute path # this will also work with globs names = os.path.abspath(os.path.join(root, r)) # it is not inside the data directory # so try again next time if not is_in_data(names): return True # find the relative path of it to the root. names = os.path.relpath( os.path.abspath(names), lmh_locate("content") ) # make sure everything ends with a slash # so that we can count properly if names[-1] != "/": names += "/" # Now figure out which level we are at # by counting slashes num_slashes = 0 for c in names: # count the slashes # by increasing the level. if c == "/": num_slashes += 1 # if we have no slashes # we are toplevel # and can pretty much exit everything if names == "./": names = lmh_locate("content", "*", "*") # if we have 1 slash # we are one level deep elif num_slashes == 1: names = lmh_locate("content", names, "*") else: names = lmh_locate("content", names) # now expand with the help of globs names = glob.glob(names) # and check if they exist names = list(filter(is_repo, names)) # if we found something # we should through the item if len(names) > 0: results.update(names) return False else: return True # now filter the repos repos = list(filter(match_repo_name, repos)) # repeat again with data_dir as root root = lmh_locate("content") repos = list(filter(match_repo_name, repos)) # if we want the relative paths we need to set them properly. if not abs: return [os.path.relpath(d, lmh_locate("content")) for d in results] return list(results)