Skip to content

Commit 54a564d

Browse files
committed
Format files in order 2 pull them into pyforchange
1 parent 54c8f54 commit 54a564d

File tree

124 files changed

+1087
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+1087
-4
lines changed

.vscode/launch.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Docker: Python - General",
5+
"type": "docker",
6+
"request": "launch",
7+
"preLaunchTask": "docker-run: debug",
8+
"python": {
9+
"pathMappings": [
10+
{
11+
"localRoot": "${workspaceFolder}",
12+
"remoteRoot": "/app"
13+
}
14+
],
15+
"projectType": "general"
16+
}
17+
}
18+
]
19+
}

.vscode/tasks.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "docker-build",
6+
"label": "docker-build",
7+
"platform": "python",
8+
"dockerBuild": {
9+
"tag": "egg:latest",
10+
"dockerfile": "${workspaceFolder}/Dockerfile",
11+
"context": "${workspaceFolder}",
12+
"pull": true
13+
}
14+
},
15+
{
16+
"type": "docker-run",
17+
"label": "docker-run: debug",
18+
"dependsOn": [
19+
"docker-build"
20+
],
21+
"python": {
22+
"file": "egg\\app.py"
23+
}
24+
}
25+
]
26+
}

LICENCE.txt renamed to LICENSE

File renamed without changes.

MANIFEST.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
include README.md
2-
include LICENSE.txt
2+
include LICENSE
33
include examples/*
4+
include .vscode/*
5+
include github_com/*

examples/index.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<body>
3+
<h1>Hi</h1>
4+
<p>
5+
xd
6+
</p>
7+
</body>
8+
</html>

examples/main.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from pyforchange.egg import eggConsole
2+
3+
eggConsole()
4+
5+
"""
6+
document=Document("template")
7+
document.addTag("h1","Hi","aqui")
8+
document.write("xd","2")
9+
10+
covid=Repo("CovidPlot")
11+
cp=covid.pull("covidplot","CovidData")
12+
#pull("CovidPlot")
13+
covidata=cp.CovidData
14+
c=covidata()
15+
c.plot
16+
"""

examples/template.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<body>
3+
$egg aqui
4+
<p>
5+
$egg 2
6+
</p>
7+
</body>
8+
</html>

github_com/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Vladimir Iakovlev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

github_com/README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Import from `github_com` (Please don't use it)
2+
3+
Experimental Python module finder/loader from github, like in golang.
4+
5+
So, in golang we can import like:
6+
7+
```go
8+
import "github.com/parnurzeal/gorequest"
9+
```
10+
11+
But in python we should install package by our hands:
12+
13+
```bash
14+
pip install requests
15+
```
16+
17+
And import it like:
18+
19+
```python
20+
import requests
21+
```
22+
23+
But with this magic package and power of [PEP-0302](https://www.python.org/dev/peps/pep-0302/) we can
24+
do it automatically:
25+
26+
```python
27+
from github_com.kennethreitz import requests
28+
29+
assert requests.get('https://github.com/nvbn/import_from_github_com').status_code == 200
30+
```
31+
32+
## Installation
33+
34+
You should have git, Python 3.2+ and pip:
35+
36+
```bash
37+
pip install import_from_github_com
38+
```
39+
40+
## License MIT
41+
Project License can be found [here](LICENSE).

github_com/__init__.py

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import sys
2+
import pip
3+
4+
5+
class IntermediateModule:
6+
"""Module for paths like `github_com.nvbn`."""
7+
8+
def __init__(self, fullname):
9+
self.__package__ = fullname
10+
self.__path__ = fullname.split('.')
11+
self.__name__ = fullname
12+
13+
14+
class GithubComFinder:
15+
"""Handles `github_com....` modules."""
16+
17+
def find_module(self, module_name, package_path):
18+
if module_name.startswith('github_com'):
19+
return GithubComLoader()
20+
21+
22+
class GithubComLoader:
23+
"""Installs and imports modules from github."""
24+
25+
def _is_installed(self, fullname):
26+
try:
27+
self._import_module(fullname)
28+
return True
29+
except ImportError:
30+
return False
31+
32+
def _import_module(self, fullname):
33+
actual_name = '.'.join(fullname.split('.')[2:])
34+
return __import__(actual_name)
35+
36+
def _install_module(self, fullname):
37+
if not self._is_installed(fullname):
38+
url = fullname.replace('.', '/') \
39+
.replace('github_com', 'git+https://github.com', 1)
40+
pip.main(['install', url])
41+
42+
def _is_repository_path(self, fullname):
43+
return fullname.count('.') == 2
44+
45+
def _is_intermediate_path(self, fullname):
46+
return fullname.count('.') < 2
47+
48+
def load_module(self, fullname):
49+
if self._is_repository_path(fullname):
50+
self._install_module(fullname)
51+
52+
if self._is_intermediate_path(fullname):
53+
module = IntermediateModule(fullname)
54+
else:
55+
module = self._import_module(fullname)
56+
57+
sys.modules[fullname] = module
58+
59+
60+
sys.meta_path.append(GithubComFinder())
2.41 KB
Binary file not shown.

pyforchange/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_author="eanorambuena"
2+
_author_email="[email protected]"
207 Bytes
Binary file not shown.

pyforchange/egg/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 PythonForChange
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

pyforchange/egg/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from pyforchange.egg.resources.modules import *
2+
from pyforchange.egg.resources.console import *
3+
from pyforchange.egg.resources.constants import *
4+
from pyforchange.egg.resources.extensions import *
5+
from pyforchange.egg.app import *
367 Bytes
Binary file not shown.
1.46 KB
Binary file not shown.

pyforchange/egg/app.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#Imports
2+
from pyforchange.egg.resources.console import get, clearConsole
3+
from pyforchange.egg.resources.extensions import py
4+
from pyforchange.egg.resources.constants import *
5+
from pyforchange.egg.resources.modules import install, upgrade, Repo
6+
from pyforchange.egg.resources.help import help
7+
from pyforchange.egg.resources.auth import login, register
8+
# BEWARE: There are imports in lines: ~17 & ~21
9+
10+
def eggConsole(condition: bool = True):
11+
print(white+"Egg Console is now running")
12+
logged=0
13+
while condition:
14+
i=get("egg")
15+
if i=="$nqs":
16+
# BEWARE: There is an import here
17+
from pyforchange.nqs.developer.app import developerConsole
18+
developerConsole()
19+
elif i=="$new":
20+
# BEWARE: There is an import here
21+
from pyforchange.news.app import journalistConsole
22+
journalistConsole()
23+
elif i=="$login":
24+
login()
25+
elif i=="$register":
26+
register()
27+
elif i=="$install":
28+
print(white+"Package:")
29+
name=get("egg")
30+
install(name)
31+
elif i=="$upgrade":
32+
print(white+"Package:")
33+
name=get("egg")
34+
upgrade(name)
35+
elif i=="$pull":
36+
print(white+"Repo:")
37+
name=get("egg")
38+
repo=Repo(name)
39+
print(white+"Package:")
40+
package=get("egg")
41+
last=repo.pull(package)
42+
elif i=="$help":
43+
help()
44+
elif i=="$clear":
45+
clearConsole()
46+
elif i=="$end":
47+
print(white+"Egg Console stopped running")
48+
return "done"
49+
else:
50+
pass

pyforchange/egg/library/__init__.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
_author="eanorambuena"
2+
_author_email="[email protected]"
3+
4+
eggConsoleCommands=[
5+
"nqs",
6+
"new",
7+
"end",
8+
]
9+
10+
developerConsoleCommands=[
11+
"display",
12+
"compile",
13+
"save",
14+
"run",
15+
"end",
16+
"delay"
17+
]
18+
19+
nqsCommands=[
20+
"host",
21+
"shots",
22+
"hist",
23+
"draw",
24+
"inject",
25+
"function",
26+
"clear",
27+
"delay"
28+
]
29+
30+
journalistConsoleCommands=[
31+
"save",
32+
"end",
33+
]
Binary file not shown.
Binary file not shown.

pyforchange/egg/library/commands.nqa

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
~
2+
_author="eanorambuena"
3+
_author_email="[email protected]"
4+
5+
eggConsoleCommands=[
6+
"nqs",
7+
"new",
8+
"end",
9+
]
10+
11+
developerConsoleCommands=[
12+
"display",
13+
"compile",
14+
"save",
15+
"run",
16+
"end",
17+
"delay"
18+
]
19+
20+
nqsCommands=[
21+
"host",
22+
"shots",
23+
"hist",
24+
"draw",
25+
"inject",
26+
"function",
27+
"clear",
28+
"delay"
29+
]
30+
31+
journalistConsoleCommands=[
32+
"save",
33+
"end",
34+
]
35+
~

0 commit comments

Comments
 (0)