Procházet zdrojové kódy

url2Sketch to read a YAML Sketch from Internet

Gilbert Brault před 5 roky
rodič
revize
6675579f3f
3 změnil soubory, kde provedl 211 přidání a 29 odebrání
  1. 199 29
      notebooks/DryFriction.ipynb
  2. 11 0
      pysketcher/shapes.py
  3. 1 0
      requirements.txt

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 199 - 29
notebooks/DryFriction.ipynb


+ 11 - 0
pysketcher/shapes.py

@@ -18,6 +18,7 @@ from ruamel.yaml import YAML
 from PIL import Image
 import ast
 from collections import *
+import requests
 
 from .MatplotlibDraw import MatplotlibDraw
 drawing_tool = MatplotlibDraw()
@@ -68,6 +69,16 @@ class Sketch():
                 return f"{sketch}/{key}: {name} in {expression} is not defined"
         return 1
 
+    def url2Sketch(self, url):
+        """
+        get a sketch given an url
+        """      
+        r = requests.get(url)  #, auth=('user', 'pass'))
+        if r.status_code == 200:
+            sketchstring = r.text
+            return self.string2Sketch(sketchstring)
+        return False
+
     def sketch2File(self, filePath):
         """
         dump a sketch to file

+ 1 - 0
requirements.txt

@@ -4,3 +4,4 @@ Pillow
 matplotlib
 ipympl
 scipy
+requests