Skip to content

Commit d9e3139

Browse files
committed
2.0.3
Solve pfcf bugs
1 parent 6a90b5d commit d9e3139

File tree

7 files changed

+53
-14
lines changed

7 files changed

+53
-14
lines changed

pyforchange/pfcf/code.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
from pyforchange.pfcf.utils import *
22
import pyforchange.pfcf.codel.qiskit as q
3+
import pyforchange.pfcf.codel.wolfram as w
34

45
def codef(codel: str,text: str): #code function
56
form="_compile.py"
67
f=open(codel+form,"w")
78
t=""
89
if codel=="qiskit":
910
t=qiskit(text)
11+
elif codel=="wolfram":
12+
t=wolfram(text)
13+
elif codel=="python":
14+
t=text
1015
f.write(t)
1116
f.close()
1217

@@ -61,3 +66,36 @@ def qiskit(text: str):
6166
Q+=1
6267
return T
6368

69+
def wolfram(text: str):
70+
T=""
71+
T+="from wolframclient.evaluation import WolframLanguageSession\n"
72+
T+="from wolframclient.language import wl, wlexpr\n"
73+
T+="session = WolframLanguageSession()\n"
74+
s=0
75+
command=""
76+
param=""
77+
t=""
78+
for i in text:
79+
if i==",":
80+
pass
81+
elif s==1: #settings mode on
82+
if i!=" ":
83+
command+=i
84+
else:
85+
s=2
86+
elif s==2:
87+
if i!=" " and i!="\n":
88+
param+=i
89+
else:
90+
T+=w.settings(command,param)
91+
command=""
92+
param=""
93+
s=0
94+
elif i=="$":
95+
s=1
96+
elif i=="\n" and t!="":
97+
T+="session.evaluate(wlexpr(\'"+t+"\'))\n"
98+
t=""
99+
elif i!="\n":
100+
t+=i
101+
return T

pyforchange/pfcf/codel/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
from pyforchange.pfcf.codel.qiskit import *

pyforchange/pfcf/codel/qiskit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from pyforchange.pfcf.utils import *
2-
32
def settings(command: str,param):
43
t=""
54
if command=="host":

pyforchange/pfcf/codel/wolfram.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def settings(command: str,param):
2+
t=""
3+
if command=="inject":
4+
t=param+"\n"
5+
return t

pyforchange/pfcf/read.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ def read(name: str,printYesOrNo: int =1,returnText: int =0):
77
t=""
88
code=""
99
codel="" #code language
10-
codel2=""
1110
m=0
1211
codem=0
1312
p=Parser()
@@ -31,16 +30,15 @@ def read(name: str,printYesOrNo: int =1,returnText: int =0):
3130
elif j=="<" or j==">":
3231
codem+=1
3332
elif codem==4:
34-
if codel2==codel:
33+
try:
3534
codef(codel,code)
3635
codem==0
3736
codel=""
38-
codel2=""
39-
else:
37+
code=""
38+
except:
4039
print("Sintax error")
4140
elif codem==3:
42-
if j!="/":
43-
codel2+=j
41+
pass
4442
elif codem==2:
4543
code+=j
4644
elif codem==1: #Code mode on

pyforchange/pfcf/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ def execute(name):
5353
t="/usr/bin/python "+name+".py"
5454
os.system(t)
5555
except:
56-
print("Execute error in: "+"/usr/bin/python "+name+".py")
56+
print("Execute error in: "+"/usr/bin/python "+name+".py")

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
setup(
88
name = 'pyforchange',
9-
packages = ['pyforchange'], # this must be the same as the name above
9+
packages=find_packages(),
1010
include_package_data=True, # muy importante para que se incluyan archivos sin extension .py
11-
version = '2.0.2',
11+
version = '2.0.3',
1212
description ="pythonforchange.github.io",
1313
long_description=README1,
1414
long_description_content_type='text/markdown',
1515
author = 'Python For Change',
1616
author_email = 'pythonforchange@gmail.com',
1717
license="MIT",
1818
url = 'https://github.com/PythonForChange/pyforchange', # use the URL to the github repo
19-
download_url = 'https://github.com/PythonForChange/pyforchange/archive/refs/tags/v2.0.2.tar.gz',
20-
keywords = ['covid', 'logging', 'language', 'plot', 'life'],
21-
classifiers = ['Programming Language :: Python :: 3'],
19+
download_url = 'https://github.com/PythonForChange/pyforchange/archive/refs/tags/v2.0.3.tar.gz',
20+
keywords = ['covid', 'qiskit', 'language', 'plot', 'files'],
21+
classifiers = ['Programming Language :: Python :: 3','Intended Audience :: Developers','License :: OSI Approved :: MIT License','Natural Language :: English','Operating System :: OS Independent','Topic :: Text Processing :: Markup :: PFCF'],
2222
)

0 commit comments

Comments
 (0)