async def apply_settings(self): width = None height = None for obj in self.additional_objects: if obj.name == 'text_input_width': width = int(obj.text.text) elif obj.name == 'text_input_height': height = int(obj.text.text) if width != None and height != None: break set_config.set_config(width=width, height=height) pygame.quit() sys.exit()
def fix_spaces(file): #pattern = re.compile(r'\s+') f = open(file, "r") data = f.readlines() f.close() #tokens = dict() config = set_config() print(config) for index, line in enumerate(data): line = list(line) for i, elem in enumerate(line): if elem is "(" and config["SPACES"]["BEFORE_LEFT_BRACKET"] is True: if i > 0 and line[i - 1] != " ": line.insert(i, " ") if elem in ASSIGNMENT_OPS and config["SPACES"][ "AROUND_ASSIGNMENT_IN_NAMED_PARAMS"]: if i > 0 and line[i - 1] != " ": line.insert(i - 1, " ") if line[i + 1] != " ": line.insert(i + 1, " ") data[index] = line #print(line) f = open(file, "w") for line in data: line = "".join(line) f.write(line) f.close()
def format(argv): from set_config import set_config if len(argv) == 2 and argv[1] == "-i": set_config(argv[1]) elif len(argv) == 4 and "-i" in argv and "-f" in argv: set_config("-i", config_to_use=argv[argv.index("-f") + 1]) else: try: file = argv[1] f = open(file, "r") except OSError: print("Error! File not found.") else: args = [] new_config = "" config_to_use = "" if len(argv) > 2 and argv[2] == "-c": if "-n" in argv: args = argv[3:argv.index("-n")] new_config = argv[argv.index("-n") + 1] else: args = argv[3:] new_config = "" elif len(argv) > 2 and argv[2] == "-f": config_to_use = argv[argv.index("-f") + 1] elif len(argv) > 2 and argv[2] == "-i": args = ["-i"] input_data = f.readlines() errors_and_warnings = dict() config = set_config(args, new_config, config_to_use) tokens, indent_levels = tokenize(input_data, config, errors_and_warnings) data = refact(input_data, tokens, indent_levels, config, errors_and_warnings) for key in errors_and_warnings.keys(): print(errors_and_warnings[key], " | line ", key) f.close() f = open(file, "w") f.writelines(data) f.close()
def __init__(self, **kwargs): self.start_str = kwargs.get('start_str') self.path = kwargs.get('path') self.str_date_start = kwargs.get('str_date_start') self.ftp = kwargs.get("ftp") self.remote_path = kwargs.get("remote_path") if not (os.path.exists(self.path)): os.mkdir(self.path) config_path = self.path + "/Config" if not (os.path.exists(config_path)): config = set_config(config_path) config.setup() self.login_path = config_path + "/login.yaml" self.data_path = kwargs.get('data_path') self.path_path = config_path + "/path.yaml"
# You should have received a copy of the GNU General Public License along with NopSCADlib. # If not, see <https://www.gnu.org/licenses/>. # #! Generates all the files for a project by running `bom.py`, `stls.py`, `dxfs.py`, `render.py` and `views.py`. import sys from exports import make_parts from bom import boms from render import render from views import views from plateup import plateup from set_config import set_config def usage(): print("\nusage:\n\tmake_all [target_config] - Make all the manufacturing files and readme for a project.") sys.exit(1) if __name__ == '__main__': if len(sys.argv) > 2: usage() target = None if len(sys.argv) == 1 else sys.argv[1] set_config(target, usage) boms(target) for part in ['stl', 'dxf']: make_parts(target, part) render(target, part) plateup(target, part) views(target)