Spaces:
Build error
Build error
0.0.2
Browse files- .gitignore +2 -1
- open_in_colab_generator.py +28 -116
- requirements.txt +1 -0
- src/abstract.py +0 -5
- src/base.py +6 -0
- src/github_codespace.py +5 -2
- src/is_binder.py +3 -5
- src/is_colab.py +4 -7
- src/is_kaggle.py +3 -9
- src/is_livebook.py +30 -0
- src/utils.py +24 -0
.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
.devcontainer
|
|
|
|
|
|
| 1 |
+
.devcontainer
|
| 2 |
+
src/__pycache__
|
open_in_colab_generator.py
CHANGED
|
@@ -1,135 +1,47 @@
|
|
| 1 |
# streamlit run c:\Users\lenovo\Desktop\VSCode\stramlit.py
|
| 2 |
|
| 3 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
st.title("Open-in Badge Generator")
|
| 6 |
# st.container(overflow='hidden')
|
| 7 |
|
| 8 |
github_link = st.text_input('Github link: ','')
|
| 9 |
is_kaggle_notebook = st.checkbox("Is Kaggle Notebook", help="is this a link to a kaggle notebook?")
|
| 10 |
-
link_splitted = github_link.split('/')
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
-
colab_link = github_link.replace("https:/","") # Removing https:/
|
| 20 |
-
colab_link = colab_link.replace(".com","") # Remving .com
|
| 21 |
|
| 22 |
-
binder_link = '/'.join(colab_link.replace("/github","").replace('/tree','').split('/')[1:3]) + "/" + branch
|
| 23 |
-
|
| 24 |
-
codespace_link = '/'.join(colab_link.replace("/github","").replace('/tree','').split('/')[1:3])
|
| 25 |
-
githubdev_link = github_link.replace('github.com','github.dev')
|
| 26 |
|
|
|
|
|
|
|
| 27 |
|
| 28 |
############
|
| 29 |
st.divider()
|
| 30 |
############
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
# with col2:
|
| 44 |
-
# st.write("**URL**")
|
| 45 |
-
# st.code(colab_url)
|
| 46 |
-
|
| 47 |
-
# st.markdown(colab_markdown)
|
| 48 |
-
|
| 49 |
-
############
|
| 50 |
-
st.divider()
|
| 51 |
-
############
|
| 52 |
-
|
| 53 |
-
# # Kaggle
|
| 54 |
-
# st.write("### Kaggle Notebook")
|
| 55 |
-
# # Showing Markdown
|
| 56 |
-
# kaggle_url = f'<a href="{github_link}" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a>'
|
| 57 |
-
# st.write("**URL**")
|
| 58 |
-
# st.code(kaggle_url)
|
| 59 |
-
# st.markdown(kaggle_url, unsafe_allow_html=True)
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
############
|
| 63 |
-
st.divider()
|
| 64 |
-
############
|
| 65 |
-
|
| 66 |
-
# Binder
|
| 67 |
-
# st.write("### Binder")
|
| 68 |
-
# option_color = st.selectbox("Select Color : " , options = ['579ACA' , 'E66581' , 'F5A252' , "%7Boption_color%7D"] , format_func = lambda option: {'579ACA':'Blue', 'E66581':'Red' , 'F5A252':'Orange' , "%7Boption_color%7D":"Green"}.get(option))
|
| 69 |
-
# is_file = st.checkbox("Is File",help="Is it a File or Repository?")
|
| 70 |
-
|
| 71 |
-
# binder_markdown = f'[](https://mybinder.org/v2/gh/{binder_link}{f"?labpath={file_name}" if is_file else ""})'
|
| 72 |
-
# # binder_url = f'https://img.shields.io/badge/Binder-Launch-{option_color}.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFkAAABZCAMAAABi1XidAAAB8lBMVEX///9XmsrmZYH1olJXmsr1olJXmsrmZYH1olJXmsr1olJXmsrmZYH1olL1olJXmsr1olJXmsrmZYH1olL1olJXmsrmZYH1olJXmsr1olL1olJXmsrmZY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 73 |
-
|
| 74 |
-
# st.write("""
|
| 75 |
-
# **Note**: You can open full github Repositories
|
| 76 |
-
# """)
|
| 77 |
-
|
| 78 |
-
# # Showing Codes
|
| 79 |
-
# st.write("**Markdown**")
|
| 80 |
-
# st.code(binder_markdown)
|
| 81 |
-
|
| 82 |
-
# st.markdown(binder_markdown)
|
| 83 |
-
|
| 84 |
-
############
|
| 85 |
-
st.divider()
|
| 86 |
-
############
|
| 87 |
-
|
| 88 |
-
st.write("### Livebook")
|
| 89 |
-
option_color = st.selectbox("Select Color : " , options = ['blue' , 'black' , 'gray' , 'pink'] , format_func = lambda option: {'blue':'Blue', 'black':'Black' , 'gray':'Gray' , "pink":"Pink"}.get(option))
|
| 90 |
-
|
| 91 |
-
livebook_markdown = f'[](https://livebook.dev/run?url={github_link})'
|
| 92 |
-
livebook_html = f"""
|
| 93 |
-
<a href="https://livebook.dev/run?url={github_link}">
|
| 94 |
-
<img src="https://livebook.dev/badge/v1/{option_color}.svg" alt="Run in Livebook" />
|
| 95 |
-
</a>
|
| 96 |
-
"""
|
| 97 |
-
|
| 98 |
-
st.write("""
|
| 99 |
-
**Note**: Elixir files Only
|
| 100 |
-
""")
|
| 101 |
-
|
| 102 |
-
# Showing Codes
|
| 103 |
-
col1 , col2 = st.columns(2)
|
| 104 |
-
with col1:
|
| 105 |
-
st.write("**Markdown**")
|
| 106 |
-
st.code(livebook_markdown)
|
| 107 |
-
|
| 108 |
-
with col2:
|
| 109 |
-
st.write("**HTML**")
|
| 110 |
-
st.code(livebook_html)
|
| 111 |
-
|
| 112 |
-
st.markdown(livebook_markdown)
|
| 113 |
-
|
| 114 |
-
############
|
| 115 |
-
st.divider()
|
| 116 |
-
############
|
| 117 |
-
|
| 118 |
-
# st.write("### Github Codespace")
|
| 119 |
-
# quickstart = "?quickstart=1" if st.checkbox("Quick Start",help="Automatically create or reuse the most recent matching codespaces") else ""
|
| 120 |
-
# is_file = st.checkbox("Is File",help="Is it File or Repository")
|
| 121 |
-
|
| 122 |
-
# codespace_markdown = f'[]({f"https://codespaces.new/{codespace_link}{quickstart}" if not is_file else githubdev_link})'
|
| 123 |
-
# codespace_html = f'''<a href={f'https://codespaces.new/{codespace_link}{quickstart}' if not is_file else githubdev_link}><img src='https://github.com/codespaces/badge.svg' alt='Open in GitHub Codespaces' style='max-width: 100%;'></a>'''
|
| 124 |
-
|
| 125 |
-
# # Showing Codes
|
| 126 |
-
# col1 , col2 = st.columns(2)
|
| 127 |
-
# with col1:
|
| 128 |
-
# st.write("**Markdown**")
|
| 129 |
-
# st.code(codespace_markdown)
|
| 130 |
-
|
| 131 |
-
# with col2:
|
| 132 |
-
# st.write("**HTML**")
|
| 133 |
-
# st.code(codespace_html)
|
| 134 |
-
|
| 135 |
-
# st.markdown(codespace_markdown)
|
|
|
|
| 1 |
# streamlit run c:\Users\lenovo\Desktop\VSCode\stramlit.py
|
| 2 |
|
| 3 |
import streamlit as st
|
| 4 |
+
from src.is_colab import Colab
|
| 5 |
+
from src.is_kaggle import Kaggle
|
| 6 |
+
from src.is_binder import Binder
|
| 7 |
+
from src.is_livebook import LiveBook
|
| 8 |
+
from src.github_codespace import CodeSpace
|
| 9 |
+
from src.base import types
|
| 10 |
|
| 11 |
st.title("Open-in Badge Generator")
|
| 12 |
# st.container(overflow='hidden')
|
| 13 |
|
| 14 |
github_link = st.text_input('Github link: ','')
|
| 15 |
is_kaggle_notebook = st.checkbox("Is Kaggle Notebook", help="is this a link to a kaggle notebook?")
|
|
|
|
| 16 |
|
| 17 |
+
if not is_kaggle_notebook:
|
| 18 |
+
link_splitted = github_link.split('/')
|
| 19 |
+
branch , file_name = "main" , ""
|
| 20 |
+
if github_link != "" and len(link_splitted) >= 6:
|
| 21 |
+
# repo = "".join(link_splitted[3:5])
|
| 22 |
+
branch = link_splitted[6]
|
| 23 |
+
file_name = "/".join(link_splitted[7:])
|
| 24 |
|
| 25 |
|
| 26 |
+
colab_link = github_link.replace("https:/","") # Removing https:/
|
| 27 |
+
colab_link = colab_link.replace(".com","") # Remving .com
|
| 28 |
|
| 29 |
+
binder_link = '/'.join(colab_link.replace("/github","").replace('/tree','').split('/')[1:3]) + "/" + branch
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
codespace_link = '/'.join(colab_link.replace("/github","").replace('/tree','').split('/')[1:3])
|
| 32 |
+
githubdev_link = github_link.replace('github.com','github.dev')
|
| 33 |
|
| 34 |
############
|
| 35 |
st.divider()
|
| 36 |
############
|
| 37 |
|
| 38 |
+
if not is_kaggle_notebook:
|
| 39 |
+
Colab(colab_link)
|
| 40 |
+
st.divider()
|
| 41 |
+
Binder(binder_link, file_name=file_name)
|
| 42 |
+
st.divider()
|
| 43 |
+
CodeSpace(codespace_link,githubdev_link)
|
| 44 |
+
st.divider()
|
| 45 |
+
LiveBook(github_link)
|
| 46 |
+
else:
|
| 47 |
+
Kaggle(github_link)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
src/abstract.py
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
class Base:
|
| 2 |
-
def __init__(self,url:str):
|
| 3 |
-
raise NotImplementedError("Override init method")
|
| 4 |
-
def _prepare_url(self , url:str):
|
| 5 |
-
raise NotImplementedError("Override this method")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/base.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class types:
|
| 2 |
+
colab = "colab"
|
| 3 |
+
binder = "binder"
|
| 4 |
+
codespace = "codespace"
|
| 5 |
+
livebook = "livebook"
|
| 6 |
+
githubdev = "GithubDev"
|
src/github_codespace.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
-
class
|
| 4 |
-
def __init__(self,
|
|
|
|
|
|
|
|
|
|
| 5 |
st.write("### Github Codespace")
|
| 6 |
|
| 7 |
quickstart = "?quickstart=1" if st.checkbox(
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
+
class CodeSpace:
|
| 4 |
+
def __init__(self,codespace_url:str, githubdev_url:str):
|
| 5 |
+
codespace_link = codespace_url
|
| 6 |
+
githubdev_link = githubdev_url
|
| 7 |
+
|
| 8 |
st.write("### Github Codespace")
|
| 9 |
|
| 10 |
quickstart = "?quickstart=1" if st.checkbox(
|
src/is_binder.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
class Binder:
|
| 4 |
-
def __init__():
|
|
|
|
| 5 |
st.write("### Binder")
|
| 6 |
|
| 7 |
option_color = st.selectbox("Select Color : ", options=['579ACA', 'E66581', 'F5A252', "%7Boption_color%7D"], format_func=lambda option: {
|
|
@@ -19,6 +19,4 @@ class Binder:
|
|
| 19 |
st.write("**Markdown**")
|
| 20 |
st.code(binder_markdown)
|
| 21 |
|
| 22 |
-
st.markdown(binder_markdown)
|
| 23 |
-
def _prepare_url(self,url):
|
| 24 |
-
pass
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
class Binder:
|
| 3 |
+
def __init__(self , url:str,file_name:str):
|
| 4 |
+
binder_link = url
|
| 5 |
st.write("### Binder")
|
| 6 |
|
| 7 |
option_color = st.selectbox("Select Color : ", options=['579ACA', 'E66581', 'F5A252', "%7Boption_color%7D"], format_func=lambda option: {
|
|
|
|
| 19 |
st.write("**Markdown**")
|
| 20 |
st.code(binder_markdown)
|
| 21 |
|
| 22 |
+
st.markdown(binder_markdown)
|
|
|
|
|
|
src/is_colab.py
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
class Colab:
|
| 4 |
def __init__(self,url:str):
|
| 5 |
-
colab_link =
|
|
|
|
| 6 |
|
| 7 |
st.write("### Google Colab")
|
| 8 |
|
| 9 |
colab_markdown = f'[](https://colab.research.google.com{colab_link})'
|
| 10 |
colab_url = f'<a href="https://colab.research.google.com{colab_link}" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>'
|
| 11 |
|
| 12 |
-
# Showing
|
| 13 |
col1, col2 = st.columns(2)
|
| 14 |
with col1:
|
| 15 |
st.write("**Markdown**")
|
|
@@ -19,7 +19,4 @@ class Colab:
|
|
| 19 |
st.write("**URL**")
|
| 20 |
st.code(colab_url)
|
| 21 |
|
| 22 |
-
st.markdown(colab_markdown)
|
| 23 |
-
|
| 24 |
-
def _prepare_url(self , url:str):
|
| 25 |
-
pass
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
class Colab:
|
| 3 |
def __init__(self,url:str):
|
| 4 |
+
# colab_link = link_prepare(url, types.colab)
|
| 5 |
+
colab_link = url
|
| 6 |
|
| 7 |
st.write("### Google Colab")
|
| 8 |
|
| 9 |
colab_markdown = f'[](https://colab.research.google.com{colab_link})'
|
| 10 |
colab_url = f'<a href="https://colab.research.google.com{colab_link}" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>'
|
| 11 |
|
| 12 |
+
# Showing Badges in markdown and url
|
| 13 |
col1, col2 = st.columns(2)
|
| 14 |
with col1:
|
| 15 |
st.write("**Markdown**")
|
|
|
|
| 19 |
st.write("**URL**")
|
| 20 |
st.code(colab_url)
|
| 21 |
|
| 22 |
+
st.markdown(colab_markdown)
|
|
|
|
|
|
|
|
|
src/is_kaggle.py
CHANGED
|
@@ -1,16 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
class Kaggle:
|
| 4 |
def __init__(self,url:str):
|
| 5 |
st.write("### Kaggle Notebook")
|
| 6 |
|
| 7 |
-
# Showing
|
| 8 |
-
kaggle_url = f'<a href="{
|
| 9 |
st.write("**URL**")
|
| 10 |
st.code(kaggle_url)
|
| 11 |
-
st.markdown(kaggle_url, unsafe_allow_html=True)
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
def _prepare_url(self,utl:str):
|
| 15 |
-
pass
|
| 16 |
-
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
class Kaggle:
|
| 3 |
def __init__(self,url:str):
|
| 4 |
st.write("### Kaggle Notebook")
|
| 5 |
|
| 6 |
+
# Showing kaggle badge
|
| 7 |
+
kaggle_url = f'<a href="{url}" target="_blank"><img align="left" alt="Kaggle" title="Open in Kaggle" src="https://kaggle.com/static/images/open-in-kaggle.svg"></a>'
|
| 8 |
st.write("**URL**")
|
| 9 |
st.code(kaggle_url)
|
| 10 |
+
st.markdown(kaggle_url, unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/is_livebook.py
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
class LiveBook:
|
| 3 |
+
def __init__(self,url:str):
|
| 4 |
+
github_link = url
|
| 5 |
+
|
| 6 |
+
st.write("### Livebook")
|
| 7 |
+
option_color = st.selectbox("Select Color : " , options = ['blue' , 'black' , 'gray' , 'pink'] , format_func = lambda option: {'blue':'Blue', 'black':'Black' , 'gray':'Gray' , "pink":"Pink"}.get(option))
|
| 8 |
+
|
| 9 |
+
livebook_markdown = f'[](https://livebook.dev/run?url={github_link})'
|
| 10 |
+
livebook_html = f"""
|
| 11 |
+
<a href="https://livebook.dev/run?url={github_link}">
|
| 12 |
+
<img src="https://livebook.dev/badge/v1/{option_color}.svg" alt="Run in Livebook" />
|
| 13 |
+
</a>
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
st.write("""
|
| 17 |
+
**Note**: Elixir files Only
|
| 18 |
+
""")
|
| 19 |
+
|
| 20 |
+
# Showing Codes
|
| 21 |
+
col1 , col2 = st.columns(2)
|
| 22 |
+
with col1:
|
| 23 |
+
st.write("**Markdown**")
|
| 24 |
+
st.code(livebook_markdown)
|
| 25 |
+
|
| 26 |
+
with col2:
|
| 27 |
+
st.write("**HTML**")
|
| 28 |
+
st.code(livebook_html)
|
| 29 |
+
|
| 30 |
+
st.markdown(livebook_markdown)
|
src/utils.py
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from base import types
|
| 2 |
+
def link_prepare(url:str , type:types) ->str :
|
| 3 |
+
"""Preparing links for badges
|
| 4 |
+
Args:
|
| 5 |
+
url (str): Link of the notebook in github or kaggle
|
| 6 |
+
type (str): Type of the badge (Colab - Codespace - Livebook - Binder - Kaggle)
|
| 7 |
+
Return:
|
| 8 |
+
str: Link of badge type
|
| 9 |
+
"""
|
| 10 |
+
match(type):
|
| 11 |
+
case types.kaggle:
|
| 12 |
+
return url
|
| 13 |
+
case types.binder:
|
| 14 |
+
pass
|
| 15 |
+
case types.colab:
|
| 16 |
+
pass
|
| 17 |
+
case types.codespace:
|
| 18 |
+
pass
|
| 19 |
+
case types.livebook:
|
| 20 |
+
return url
|
| 21 |
+
case types.githubdev:
|
| 22 |
+
pass
|
| 23 |
+
case _:
|
| 24 |
+
raise("Invalid Input")
|