Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ To install Wikipedia, simply run:

$ pip install wikipedia

After installation to define parameter 'WIKIPEDIA_PROJECT' with the path to the current project in system variables.

Wikipedia is compatible with Python 2.6+ (2.7+ to run unittest discover) and Python 3.3+.

Documentation
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
numpy
beautifulsoup4
requests>=2.0.0,<3.0.0
7 changes: 7 additions & 0 deletions wikipedia/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,10 @@ def __init__(self, query):

def __unicode__(self):
return u"Searching for \"{0}\" resulted in a timeout. Try again in a few seconds, and make sure you have rate limiting set to True.".format(self.query)


class BadParameterException(WikipediaException):
"""Exception raised when an incorrectly set parameter, such as language, query parameter and etc."""

def __unicode__(self):
return "The parameter is set incorrectly. {0}".format(self.error)
24 changes: 24 additions & 0 deletions wikipedia/languages_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import csv
import os

from numpy.core.defchararray import lower

from .exceptions import BadParameterException

project_folder = "WIKIPEDIA_PROJECT"
file_csv = "{0}{1}".format(os.environ.get(project_folder, None), "\\wikipedia\\list_languages.csv")


def init_list_languages():
try:
with open(file_csv, newline='') as file:
reader = csv.reader(file)
return list(reader)
except FileNotFoundError:
raise BadParameterException("Make sure that the system variable '{0}' is set, "
"the value of which must be the path to the current project".format(project_folder))


def find_language(lst, param):
if lower(param) in lst:
return True
310 changes: 310 additions & 0 deletions wikipedia/list_languages.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,310 @@
en
ceb
sv
de
fr
nl
ru
it
es
pl
war
vi
ja
zh
ar
pt
uk
fa
ca
sr
arz
no
id
ko
fi
hu
cs
sh
ro
zh-min-nan
eu
tr
ms
eo
hy
he
bg
da
ce
azb
sk
kk
min
hr
et
lt
be
el
sl
gl
simple
az
ur
nn
hi
th
ka
uz
la
cy
ta
vo
ast
mk
lv
tg
tt
mg
af
bn
oc
zh-yue
bs
sq
ky
new
tl
be-tarask
te
ml
br
nds
pms
su
sw
ht
lb
vec
jv
mr
sco
pnb
ga
szl
ba
is
my
fy
cv
lmo
an
pa
ne
wuu
yo
bar
io
gu
ku
als
ckb
kn
scn
bpy
ia
qu
mn
diq
bat-smg
or
si
cdo
nv
ilo
gd
yi
am
nap
bug
xmf
wa
sd
hsb
mai
map-bms
fo
mzn
li
eml
os
sah
ps
sa
frr
bcl
ace
zh-classical
mrj
mhr
hif
hak
roa-tara
pam
nso
km
hyw
se
rue
crh
bh
vls
mi
shn
nds-nl
nah
as
sc
vep
gan
myv
gor
ab
glk
bo
so
co
tk
fiu-vro
sn
lrc
kv
csb
ha
gv
udm
ie
ay
pcd
zea
kab
nrm
ug
lez
stq
kw
haw
frp
lfn
lij
mwl
gn
gom
rm
mt
lo
lad
koi
fur
olo
sat
dty
dsb
ang
ext
ln
bjn
cbk-zam
dv
ban
ksh
gag
pfl
pag
pi
tyv
av
zu
awa
bxr
xal
krc
pap
za
pdc
kaa
rw
arc
szy
to
nov
jam
tpi
kbp
kbd
ig
na
tet
wo
ki
tcy
inh
jbo
atj
roa-rup
bi
lbe
kg
ty
lg
mdf
srn
xh
gcr
fj
ltg
chr
sm
got
ak
kl
pih
om
cu
tn
tw
st
ts
rmy
bm
chy
nqo
rn
tum
ny
mnw
ss
ch
pnt
iu
ady
ks
ve
ee
ik
sg
ff
ti
dz
din
cr
ng
cho
kj
mh
ho
ii
aa
mus
hz
kr
Loading