chore(formatting): ran black to format sources
This commit is contained in:
		
							parent
							
								
									45c11da77d
								
							
						
					
					
						commit
						6f2940947e
					
				
					 6 changed files with 1172 additions and 166 deletions
				
			
		|  | @ -11,8 +11,18 @@ config_file.touch() | |||
| 
 | ||||
| cfg = profig.Config(str(config_file), strict=True) | ||||
| 
 | ||||
| cfg.init("history.bodies_url", ["https://www.edsm.net/dump/bodies.json"], "path_list", comment="history of bodies.json urls") | ||||
| cfg.init("history.systems_url", ["https://www.edsm.net/dump/systemsWithCoordinates.json"], "path_list", comment="history of systems.json urls") | ||||
| cfg.init( | ||||
|     "history.bodies_url", | ||||
|     ["https://www.edsm.net/dump/bodies.json"], | ||||
|     "path_list", | ||||
|     comment="history of bodies.json urls", | ||||
| ) | ||||
| cfg.init( | ||||
|     "history.systems_url", | ||||
|     ["https://www.edsm.net/dump/systemsWithCoordinates.json"], | ||||
|     "path_list", | ||||
|     comment="history of systems.json urls", | ||||
| ) | ||||
| cfg.init( | ||||
|     "history.bodies_path", | ||||
|     [os.path.join(config_dir, "data", "bodies.json")], | ||||
|  | @ -26,7 +36,10 @@ cfg.init( | |||
|     comment="history of systems.json download paths", | ||||
| ) | ||||
| cfg.init( | ||||
|     "history.stars_csv_path", [os.path.join(config_dir, "data","stars.csv")], "path_list", comment="history of paths for stars.csv" | ||||
|     "history.stars_csv_path", | ||||
|     [os.path.join(config_dir, "data", "stars.csv")], | ||||
|     "path_list", | ||||
|     comment="history of paths for stars.csv", | ||||
| ) | ||||
| cfg.init("route.range", 7.56, comment="jump range") | ||||
| cfg.init("route.primary", False, comment="only route through primary stars") | ||||
|  | @ -40,7 +53,7 @@ cfg.init("route.prune.steps", 5, comment="number of steps before path gets prune | |||
| cfg.init("route.greediness", 0.5, comment="A* greediness") | ||||
| cfg.init("folders.data_dir", os.path.join(config_dir, "data"), comment="Data directory") | ||||
| 
 | ||||
| cfg.init("GUI.theme", 'dark', comment="GUI theme to use") | ||||
| cfg.init("GUI.theme", "dark", comment="GUI theme to use") | ||||
| 
 | ||||
| 
 | ||||
| cfg.sync() | ||||
|  |  | |||
|  | @ -147,7 +147,7 @@ class RouterJob(Job): | |||
|     def handle_progess(self, state): | ||||
|         sent = object() | ||||
|         if state.get("return", sent) != sent: | ||||
|             print(state['return']) | ||||
|             print(state["return"]) | ||||
|             self.progress_dialog.close() | ||||
|             route_win = WRoute(self.main_window, state["return"]) | ||||
|             return | ||||
|  |  | |||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -10,11 +10,12 @@ from sqlalchemy.orm import scoped_session, sessionmaker, relationship, backref | |||
| from sqlalchemy.types import Float, String, Boolean | ||||
| 
 | ||||
| app = Flask(__name__) | ||||
| app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///jobs.db' | ||||
| app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | ||||
| app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///jobs.db" | ||||
| app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False | ||||
| 
 | ||||
| db = SQLAlchemy(app) | ||||
| 
 | ||||
| 
 | ||||
| @generic_repr | ||||
| class Job(db.Model, Timestamp): | ||||
|     id = db.Column(db.String, default=lambda: str(uuid.uuid4()), primary_key=True) | ||||
|  | @ -43,16 +44,18 @@ class Job(db.Model,Timestamp): | |||
|         ret = {} | ||||
|         for col in self.__table__.columns: | ||||
|             ret[col.name] = getattr(self, col.name) | ||||
|         ret['systems']=json.loads(ret['systems']) | ||||
|         ret["systems"] = json.loads(ret["systems"]) | ||||
|         return ret | ||||
| 
 | ||||
|     @dict.setter | ||||
|     def set_dict(self, *args, **kwargs): | ||||
|         raise NotImplementedError | ||||
| 
 | ||||
| 
 | ||||
| db.create_all() | ||||
| db.session.commit() | ||||
| 
 | ||||
| 
 | ||||
| @app.errorhandler(422) | ||||
| @app.errorhandler(400) | ||||
| def handle_error(err): | ||||
|  | @ -63,25 +66,35 @@ def handle_error(err): | |||
|     else: | ||||
|         return jsonify({"errors": messages}), err.code | ||||
| 
 | ||||
| 
 | ||||
| @app.route("/route", methods=["GET", "POST"]) | ||||
| @use_args({ | ||||
| @use_args( | ||||
|     { | ||||
|         "jump_range": fields.Float(required=True), | ||||
|     "mode": fields.String(missing="bfs",validate=validate.OneOf(["bfs","greedy","a-star"])), | ||||
|         "mode": fields.String( | ||||
|             missing="bfs", validate=validate.OneOf(["bfs", "greedy", "a-star"]) | ||||
|         ), | ||||
|         "systems": fields.DelimitedList(fields.String, required=True), | ||||
|     "permute": fields.String(missing=None,validate=validate.OneOf(["all", "keep_first", "keep_last", "keep_both"])), | ||||
|         "permute": fields.String( | ||||
|             missing=None, | ||||
|             validate=validate.OneOf(["all", "keep_first", "keep_last", "keep_both"]), | ||||
|         ), | ||||
|         "primary": fields.Boolean(missing=False), | ||||
|     "factor": fields.Float(missing=0.5) | ||||
| }) | ||||
|         "factor": fields.Float(missing=0.5), | ||||
|     } | ||||
| ) | ||||
| def route(args): | ||||
|     args['systems']=json.dumps(args['systems']) | ||||
|     args["systems"] = json.dumps(args["systems"]) | ||||
|     for k, v in args.items(): | ||||
|         print(k, v) | ||||
|     return jsonify({'id':Job.new(**args).id}) | ||||
|     return jsonify({"id": Job.new(**args).id}) | ||||
| 
 | ||||
| 
 | ||||
| @app.route("/status/<uuid:job_id>") | ||||
| def status(job_id): | ||||
|     job = db.session.query(Job).get_or_404(str(job_id)) | ||||
|     return jsonify(job.dict) | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|     app.run(host="0.0.0.0", port=3777, debug=True) | ||||
							
								
								
									
										32
									
								
								icon/make.py
									
										
									
									
									
								
							
							
						
						
									
										32
									
								
								icon/make.py
									
										
									
									
									
								
							|  | @ -5,6 +5,7 @@ from math import factorial,sin,cos,pi | |||
| from itertools import permutations | ||||
| import tsp as m_tsp | ||||
| 
 | ||||
| 
 | ||||
| def dist(p1, p2): | ||||
|     return dist2(p1, p2) ** 0.5 | ||||
| 
 | ||||
|  | @ -41,6 +42,8 @@ def make_points(n,size,min_dist=0): | |||
|             points.append((px, py)) | ||||
|             print("{}/{}".format(len(points), n)) | ||||
|     return points | ||||
| 
 | ||||
| 
 | ||||
| def generate(seed, name=None, small=False): | ||||
|     sd = 1 | ||||
|     if small: | ||||
|  | @ -57,7 +60,7 @@ def generate(seed,name=None,small=False): | |||
|         name = seed | ||||
|     dwg = svgwrite.Drawing(filename="out/{}.svg".format(name)) | ||||
|     dwg.defs.add(dwg.style(".background { fill: #222; }")) | ||||
|     dwg.add(dwg.rect(size=('100%','100%'), class_='background')) | ||||
|     dwg.add(dwg.rect(size=("100%", "100%"), class_="background")) | ||||
|     print("Generating points...") | ||||
|     color = "#eee" | ||||
|     pos = make_points(num_points, size, min_dist=min_dist) | ||||
|  | @ -78,9 +81,23 @@ def generate(seed,name=None,small=False): | |||
|             px /= sd | ||||
|             py /= sd | ||||
|         if random.random() > 0.8: | ||||
|             dwg.add(dwg.circle((px,py),r=base_r+random.random()*base_r,stroke_width=w,stroke='#0ae')).fill('#0ae') | ||||
|             dwg.add( | ||||
|                 dwg.circle( | ||||
|                     (px, py), | ||||
|                     r=base_r + random.random() * base_r, | ||||
|                     stroke_width=w, | ||||
|                     stroke="#0ae", | ||||
|                 ) | ||||
|             ).fill("#0ae") | ||||
|         else: | ||||
|             dwg.add(dwg.circle((px,py),r=base_r+random.random()*base_r,stroke_width=w,stroke=color)).fill(color) | ||||
|             dwg.add( | ||||
|                 dwg.circle( | ||||
|                     (px, py), | ||||
|                     r=base_r + random.random() * base_r, | ||||
|                     stroke_width=w, | ||||
|                     stroke=color, | ||||
|                 ) | ||||
|             ).fill(color) | ||||
|         r = base_r | ||||
|         for _ in range(random.randint(1, max_rings)): | ||||
|             if small: | ||||
|  | @ -98,7 +115,14 @@ def generate(seed,name=None,small=False): | |||
|             dx = cos(d) | ||||
|             dy = sin(d) | ||||
|             m = random.random() | ||||
|             moon=dwg.add(dwg.circle((px+dx*r,py+dy*r),r=2+2*m,stroke_width=w,stroke=ring_col)) | ||||
|             moon = dwg.add( | ||||
|                 dwg.circle( | ||||
|                     (px + dx * r, py + dy * r), | ||||
|                     r=2 + 2 * m, | ||||
|                     stroke_width=w, | ||||
|                     stroke=ring_col, | ||||
|                 ) | ||||
|             ) | ||||
|             moon.fill(ring_col) | ||||
| 
 | ||||
|     dwg.save() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue