소스 검색

url2Sketch to read a YAML Sketch from Internet

Gilbert Brault 5 년 전
부모
커밋
6675579f3f
3개의 변경된 파일211개의 추가작업 그리고 29개의 파일을 삭제
  1. 199 29
      notebooks/DryFriction.ipynb
  2. 11 0
      pysketcher/shapes.py
  3. 1 0
      requirements.txt

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 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