Skip to content

Commit 9ba2b57

Browse files
committed
0.0.1a3
1 parent 671ed94 commit 9ba2b57

File tree

18 files changed

+204
-154
lines changed

18 files changed

+204
-154
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Natural Quantum Script is a special domain programming language that aims to sim
1010

1111
Scripts written in NQS seek to visually resemble quantum circuits as much as possible. For example:
1212

13-
q0 q1
14-
X
15-
H
16-
.--- X
17-
c1
13+
q0 q1<br>
14+
X<br>
15+
H<br>
16+
.--- X<br>
17+
c1<br>
1818

1919
NQS is initially based on Qiskit, but seeks to go mainstream in the future. This is an OS project whose initial goal was to make it easier to write basic scripts in Qiskit and to bridge the gap for people who don't dare to delve into quantum computing.
2020

build/lib/eggdriver/app.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Imports
2-
from eggdriver.resources.console import get, clearConsole
2+
from eggdriver.resources.console import get, clearConsole, pg
33
from eggdriver.resources.constants import *
44
from eggdriver.resources.modules import installFromRequests, upgrade, Repo
55
from eggdriver.resources.help import help
@@ -28,42 +28,38 @@
2828
This is the reason why condition only allows <<bool>> as data type
2929
"""
3030
def eggConsole(condition: bool = True):
31-
print(white+"Egg Console is now running")
31+
"""Display the Egg Console"""
32+
print(white + "Egg Console is now running")
3233
logged=0
3334
while condition:
34-
i=get("egg")
35-
if i=="$nqs":
35+
i = get("egg")
36+
if i == "$nqs":
3637
from eggdriver.nqs import developerConsole
3738
developerConsole()
38-
elif i=="$new":
39+
elif i == "$new":
3940
from eggdriver.news import journalistConsole
4041
journalistConsole()
41-
elif i=="$login":
42+
elif i == "$login":
4243
login()
43-
elif i=="$register":
44+
elif i == "$register":
4445
register()
45-
elif i=="$install":
46-
print(white+"Package:")
47-
name=get("egg")
46+
elif i == "$install":
47+
name = pg("Package:")
4848
installFromRequests([name], False)
49-
elif i=="$upgrade":
50-
print(white+"Package:")
51-
name=get("egg")
49+
elif i == "$upgrade":
50+
name = pg("Package:")
5251
upgrade(name)
53-
elif i=="$pull":
54-
print(white+"Repo:")
55-
name=get("egg")
56-
repo=Repo(name)
57-
print(white+"Package:")
58-
package=get("egg")
59-
last=repo.pull(package)
60-
# *comming soon*
61-
elif i=="$help":
52+
elif i == "$pull":
53+
org = pg("User or Organization:")
54+
name = pg("Repository:")
55+
repo = Repo(org, name)
56+
repo.pull()
57+
elif i == "$help":
6258
help()
63-
elif i=="$clear":
59+
elif i == "$clear":
6460
clearConsole()
65-
elif i=="$end":
66-
print(white+"Egg Console stopped running")
61+
elif i == "$end":
62+
print(white + "Egg Console stopped running")
6763
return "done"
6864
else:
6965
pass

build/lib/eggdriver/driver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
>>> Requirement already satisfied: pip in <root> (21.2.4)
1515
"""
1616
def init():
17+
"""Upgrade pip and install all the packages in requests file"""
1718
install_option_1("$upgrade") # Upgrade pip
1819
sleep(10) # Waits 10 ms
1920
installFromRequests() # Install all the packages in requests file

build/lib/eggdriver/nqs/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from eggdriver.nqs.core import *
22
from eggdriver.nqs.developer import *
33

4-
_author="eanorambuena"
5-
_author_email="[email protected]"
4+
author = "eanorambuena"
5+
author_email = "[email protected]"
66

7-
nqsCommands=[
7+
nqsCommands = [
88
"host",
99
"shots",
1010
"hist",
@@ -15,7 +15,7 @@
1515
"delay"
1616
]
1717

18-
consoleCommands=[
18+
consoleCommands = [
1919
"display",
2020
"compile",
2121
"save",

build/lib/eggdriver/nqs/core/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
from eggdriver.nqs.core.quantum import *
44
from eggdriver.nqs.core.reader import *
55

6-
_author="eanorambuena"
7-
_author_email="[email protected]"
6+
author="eanorambuena"
7+
author_email="[email protected]"
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
from eggdriver.resources.extensions import py
22

33
class Func():
4-
def __init__(self,name: str,params,actions,indexfile: str,definitionsfile: str):
5-
self.name=name
6-
self.params=params
7-
self.actions=actions
8-
self.indexfile=indexfile
9-
self.definitionsfile=definitionsfile
4+
def __init__(self, name: str, params, actions, indexfile: str, definitionsfile: str):
5+
self.name = name
6+
self.params = params
7+
self.actions = actions
8+
self.indexfile = indexfile
9+
self.definitionsfile = definitionsfile
1010
def index(self):
11-
#lines=py.getLines(self.indexfile)
12-
lines=py.read(self.indexfile).split("\n")
11+
# lines = py.getLines(self.indexfile)
12+
lines = py.read(self.indexfile).split("\n")
1313
lines.pop()
14-
newline="\'"+self.name+"\': Definition."+self.name+", "
14+
newline = f"\'{self.name}\': Definition.{self.name}, "
1515
lines.append(newline)
1616
lines.append("}")
17-
text=""
17+
text = ""
1818
for i in lines:
19-
text+=i+"\n"
20-
py.write(text,self.indexfile)
19+
text += i + "\n"
20+
py.write(text, self.indexfile)
2121
def define(self):
22-
T="\tdef "+self.name+"("
23-
last=self.params[-1]
24-
j=self.params
22+
T = "\tdef {self.name}("
23+
last = self.params[-1]
24+
j = self.params
2525
j.pop()
2626
for i in j:
27-
T+=i+","
28-
T+=last+"):\n"
27+
T += i + ","
28+
T += last + "):\n"
2929
for i in self.actions:
30-
T+="\t\t"+i+"\n"
31-
py.append(T,self.definitionsfile)
30+
T += "\t\t{i}\n"
31+
py.append(T, self.definitionsfile)
3232
def add(self):
3333
self.define()
3434
self.index()
3535

3636
def clear(param: str):
37-
if param=="all":
38-
t1="from user.definitions import Definition\n"
39-
t1+="Index = { \n"
40-
t1+="\'__init__\': Definition.__init__, # Do not remove this function, Index must not be void\n"
41-
t1+="}\n"
42-
py.write(t1,"user/index")
43-
t2="class Definition():\n"
44-
t2+="\tdef __init__(): # Do not remove this function, Definition must not be void\n"
45-
t2+="\t\treturn \"done\""
46-
py.write(t2,"user/definitions")
37+
if param == "all":
38+
t1 = "from user.definitions import Definition\n"
39+
t1 += "Index = { \n"
40+
t1 += "\'__init__\': Definition.__init__, # Do not remove this function, Index must not be void\n"
41+
t1 += "}\n"
42+
py.write(t1, "user/index")
43+
t2 = "class Definition():\n"
44+
t2 += "\tdef __init__(): # Do not remove this function, Definition must not be void\n"
45+
t2 += "\t\treturn \"done\""
46+
py.write(t2, "user/definitions")
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
from eggdriver.library import nqsCommands, eggConsoleCommands
2-
from eggdriver.nqs.core.functions import Func,clear
2+
from eggdriver.nqs.core.functions import Func, clear
33
from eggdriver.resources.console import sleep
44

5-
def settings(command: str,param):
6-
t=""
7-
if command=="host":
8-
t="s=1024\nbackend=Aer.get_backend('"+param+"')\n"
9-
t+="job=execute(circuit, backend, shots=s)\n"
10-
t+="result=job.result()\n"
11-
t+="counts=result.get_counts(circuit)\n"
12-
elif command=="shots":
13-
t="s="+param
14-
elif command=="hist":
15-
t="graph=plot_histogram(counts)\n"
16-
t+="display(graph)\n"
17-
elif command=="draw":
18-
t="circuit.draw('mpl')\n"
19-
elif command=="inject":
20-
t=param+"\n"
21-
elif command=="function":
22-
p=Parameter(param)
5+
def settings(command: str, param):
6+
t = ""
7+
if command == "host":
8+
t = "s=1024\nbackend=Aer.get_backend('" + param + "')\n"
9+
t += "job=execute(circuit, backend, shots=s)\n"
10+
t += "result=job.result()\n"
11+
t += "counts=result.get_counts(circuit)\n"
12+
elif command == "shots":
13+
t = "s=" + param
14+
elif command == "hist":
15+
t = "graph=plot_histogram(counts)\n"
16+
t += "display(graph)\n"
17+
elif command == "draw":
18+
t = "circuit.draw('mpl')\n"
19+
elif command == "inject":
20+
t = param+"\n"
21+
elif command == "function":
22+
p = Parameter(param)
2323
if p.name in nqsCommands or p.name in eggConsoleCommands:
24-
print("Error: "+p.name+" is protected.")
24+
print("Error: " + p.name + " is protected.")
2525
return t
26-
f=Func(p.name,p.params,p.actions,"user/index","user/definitions")
26+
f = Func(p.name, p.params, p.actions, "user/index", "user/definitions")
2727
f.add()
28-
elif command=="clear":
28+
elif command == "clear":
2929
clear(param)
30-
elif command=="delay":
30+
elif command == "delay":
3131
sleep(int(param))
3232
else:
33-
params=param.split(",")
34-
t=executeFunction(command,params)
33+
params = param.split(",")
34+
t = executeFunction(command, params)
3535
return t
3636

3737
class Parameter():
38-
def __init__(self,param: str):
39-
arr=param.split("|")
40-
self.name=arr[0]
41-
paramsBeforeSplit=arr[1]
42-
self.params=paramsBeforeSplit.split(",")
43-
actionsBeforeSplit=arr[2]
44-
self.actions=actionsBeforeSplit.split(",")
38+
def __init__(self, param: str):
39+
arr = param.split("|")
40+
self.name = arr[0]
41+
paramsBeforeSplit = arr[1]
42+
self.params = paramsBeforeSplit.split(",")
43+
actionsBeforeSplit = arr[2]
44+
self.actions = actionsBeforeSplit.split(",")
4545

46-
def executeFunction(command,params):
47-
t="try:\n"
48-
t+="\tIndex[\""+command+"\"]("
49-
last=params[-1]
46+
def executeFunction(command, params):
47+
t = "try:\n"
48+
t += "\tIndex[\""+command+"\"]("
49+
last = params[-1]
5050
params.pop()
5151
for i in params:
52-
t+="\""+i+"\""+","
53-
t+="\""+last+"\""+")\n"
54-
t+="except:\n"
55-
t+="\tprint(\"Error: "+command+" is not defined or is inaccessible\")\n"
52+
t += "\"" + i + "\","
53+
t += "\"" + last + "\")\n"
54+
t += "except:\n"
55+
t += "\tprint(\"Error: " + command + " is not defined or is inaccessible\")\n"
5656
return t

build/lib/eggdriver/nqs/developer/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from eggdriver.nqs.developer.run import *
33
from eggdriver.nqs.developer.write import *
44

5-
_author="eanorambuena"
6-
_author_email="[email protected]"
5+
author = "eanorambuena"
6+
author_email = "[email protected]"
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
from eggdriver.nqs.developer.run import run
2-
from eggdriver.nqs.core import compile
2+
from eggdriver.nqs.core.core import compile
33
from eggdriver.resources.extensions import nqa
44
from eggdriver.resources.console import display, get, sleep
55
from eggdriver.resources.constants import *
66

77
def developerDisplay(name: str):
8-
content=nqa.read(name)
8+
content = nqa.read(name)
99
display(content)
1010

1111
def developerConsole(condition: bool = True):
12-
print(white+"Developer Console is now running")
12+
print(white + "Developer Console is now running")
1313
while condition:
14-
i=get("nqs")
15-
name="temp_compile"
16-
if i=="$display":
17-
content=nqa.read(name)
18-
print(white+content)
19-
elif i=="$compile":
14+
i = get("nqs")
15+
name = "temp_compile"
16+
if i == "$display":
17+
content = nqa.read(name)
18+
print(white + content)
19+
elif i == "$compile":
2020
compile(name)
21-
elif i=="$save":
22-
print(white+"Save as:")
23-
adress=get("nqs")
24-
content=nqa.read(name)
25-
nqa.write(content,adress)
26-
elif i=="$run":
21+
elif i == "$save":
22+
print(white + "Save as:")
23+
adress = get("nqs")
24+
content = nqa.read(name)
25+
nqa.write(content, adress)
26+
elif i == "$run":
2727
run(name)
28-
elif i=="$delay":
29-
print(white+"How many milliseconds?")
30-
delta=get("nqs")
28+
elif i == "$delay":
29+
print(white + "How many milliseconds?")
30+
delta = get("nqs")
3131
sleep(int(delta))
32-
elif i=="$end":
32+
elif i == "$end":
3333
try:
3434
nqa.delete(name)
3535
except:
3636
pass
37-
print(white+"Developer Console stopped running")
37+
print(white + "Developer Console stopped running")
3838
return "done"
3939
else:
40-
nqa.append(i+"\n",name)
40+
nqa.append(i + "\n", name)

build/lib/eggdriver/pypi.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
"""
44
FUNCTION build()
5+
Build and upload a pypi package release
56
7+
In Windows is equal to type in the console the following lines:
68
py -m build --sdist
79
py -m build --wheel
810
py -m twine check dist/*
911
py -m twine upload dist/*
1012
"""
1113
def build():
14+
"""Build and upload a pypi package release"""
1215
installFromRequests(["setuptools", "twine", "build"], False)
1316
sysCommand("-m build --sdist")
1417
sysCommand("-m build --wheel")

0 commit comments

Comments
 (0)